Skip to content

Commit

Permalink
update reward test
Browse files Browse the repository at this point in the history
  • Loading branch information
notJoon committed Jan 16, 2025
1 parent 26acf7c commit cc10169
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions launchpad/reward_test.gno
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
package launchpad

import (
"std"
"testing"

"gno.land/p/demo/testutils"
"gno.land/p/demo/uassert"
"gno.land/p/demo/ufmt"
u256 "gno.land/p/gnoswap/uint256"
Expand Down Expand Up @@ -225,3 +227,39 @@ func TestCalculateTierRewards(t *testing.T) {
})
}
}

func TestCollectRewardByDepositId_FailCases(t *testing.T) {
setup := func() {
projects = make(map[string]Project)
deposits = make(map[string]Deposit)
depositsByUserByProject = make(map[std.Address]map[string][]string)
}

t.Run("ID not found", func(t *testing.T) {
setup()

defer func() {
if r := recover(); r == nil {
t.Error("expected panic but not")
}
}()

CollectRewardByDepositId("non_existent_id")
})

t.Run("Claimable height before", func(t *testing.T) {
setup()

projectId := "test_project"
depositId := "test_deposit"

deposits[depositId] = Deposit{
id: depositId,
projectId: projectId,
claimableHeight: uint64(std.GetHeight()) + 1000,
}

reward := CollectRewardByDepositId(depositId)
uassert.Equal(t, reward, uint64(0))
})
}

0 comments on commit cc10169

Please sign in to comment.