Skip to content

Commit cc10169

Browse files
committed
update reward test
1 parent 26acf7c commit cc10169

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

launchpad/reward_test.gno

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
package launchpad
22

33
import (
4+
"std"
45
"testing"
56

7+
"gno.land/p/demo/testutils"
68
"gno.land/p/demo/uassert"
79
"gno.land/p/demo/ufmt"
810
u256 "gno.land/p/gnoswap/uint256"
@@ -225,3 +227,39 @@ func TestCalculateTierRewards(t *testing.T) {
225227
})
226228
}
227229
}
230+
231+
func TestCollectRewardByDepositId_FailCases(t *testing.T) {
232+
setup := func() {
233+
projects = make(map[string]Project)
234+
deposits = make(map[string]Deposit)
235+
depositsByUserByProject = make(map[std.Address]map[string][]string)
236+
}
237+
238+
t.Run("ID not found", func(t *testing.T) {
239+
setup()
240+
241+
defer func() {
242+
if r := recover(); r == nil {
243+
t.Error("expected panic but not")
244+
}
245+
}()
246+
247+
CollectRewardByDepositId("non_existent_id")
248+
})
249+
250+
t.Run("Claimable height before", func(t *testing.T) {
251+
setup()
252+
253+
projectId := "test_project"
254+
depositId := "test_deposit"
255+
256+
deposits[depositId] = Deposit{
257+
id: depositId,
258+
projectId: projectId,
259+
claimableHeight: uint64(std.GetHeight()) + 1000,
260+
}
261+
262+
reward := CollectRewardByDepositId(depositId)
263+
uassert.Equal(t, reward, uint64(0))
264+
})
265+
}

0 commit comments

Comments
 (0)