Skip to content

Commit 2f83ac9

Browse files
author
0xTopaz
committed
fix: test case modified and bug fix
- bug: When receiving a reward, check if the amount of GNS held by the GOV STAKER is more than the amount of reward that should be paid.
1 parent 942d2bd commit 2f83ac9

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

gov/staker/staker.gno

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,7 @@ func collectEmissionReward(addr std.Address) uint64 {
370370
return 0
371371
}
372372

373-
govStakerGnsBalance := xgns.BalanceOf(a2u(consts.GOV_STAKER_ADDR))
373+
govStakerGnsBalance := gns.BalanceOf(a2u(consts.GOV_STAKER_ADDR))
374374
if govStakerGnsBalance < emissionReward {
375375
panic(addDetailToError(
376376
errNotEnoughBalance,

gov/staker/staker_test.gno

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -382,19 +382,25 @@ func TestProtocolFee(t *testing.T) {
382382
}
383383

384384
func TestRedelegate(t *testing.T) {
385-
// assume realm user
386-
std.TestSetRealm(userRealm)
385+
std.TestSetRealm(std.NewCodeRealm(consts.EMISSION_PATH))
386+
std.TestSkipHeights(100)
387+
gns.MintGns(a2u(userRealm.Addr())) // 2M gns
387388

388389
// user has xGNS from previous test (some minted)
389390
// try re-delegating
390391
std.TestSetRealm(userRealm)
391392
from := userRealm.Addr()
392393
to := makeFakeAddress("validator_1")
393-
println("to", to)
394394
amount := uint64(1_000_000)
395395

396396
std.TestSetOrigCaller(userRealm.Addr())
397+
gns.Approve(a2u(consts.GOV_STAKER_ADDR), amount)
398+
Delegate(to, amount)
399+
400+
std.TestSetOrigCaller(userRealm.Addr())
401+
gns.Approve(a2u(consts.GOV_STAKER_ADDR), amount)
397402
Redelegate(from, to, amount)
403+
398404
// check data: user xGNS must remain the same, but from-> to shift in staker structure?
399405

400406
// not enough xGNS => panic

0 commit comments

Comments
 (0)