Skip to content

Commit f8a0af0

Browse files
committed
fix test and lint
1 parent c2be47a commit f8a0af0

File tree

4 files changed

+9
-9
lines changed

4 files changed

+9
-9
lines changed

x/restake/keeper/hooks.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package keeper
22

33
import (
4-
"cosmossdk.io/math"
4+
sdkmath "cosmossdk.io/math"
55
sdk "github.com/cosmos/cosmos-sdk/types"
66
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
77

@@ -84,7 +84,7 @@ func (h Hooks) AfterUnbondingInitiated(_ sdk.Context, _ uint64) error {
8484
return nil
8585
}
8686

87-
func (h Hooks) isAbleToUnbond(ctx sdk.Context, addr sdk.AccAddress, delegated math.Int) error {
87+
func (h Hooks) isAbleToUnbond(ctx sdk.Context, addr sdk.AccAddress, delegated sdkmath.Int) error {
8888
iterator := sdk.KVStoreReversePrefixIterator(ctx.KVStore(h.k.storeKey), types.LocksByAmountIndexKey(addr))
8989
defer iterator.Close()
9090

x/restake/keeper/keeper_lock.go

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package keeper
22

33
import (
4-
"cosmossdk.io/math"
54
sdkmath "cosmossdk.io/math"
65
sdk "github.com/cosmos/cosmos-sdk/types"
76

@@ -10,7 +9,7 @@ import (
109

1110
// SetLockedPower sets the new locked power amount of the address to the key
1211
// This function will override the previous locked amount.
13-
func (k Keeper) SetLockedPower(ctx sdk.Context, lockerAddr sdk.AccAddress, keyName string, amount math.Int) error {
12+
func (k Keeper) SetLockedPower(ctx sdk.Context, lockerAddr sdk.AccAddress, keyName string, amount sdkmath.Int) error {
1413
if !amount.IsUint64() {
1514
return types.ErrInvalidAmount
1615
}
@@ -69,19 +68,19 @@ func (k Keeper) SetLockedPower(ctx sdk.Context, lockerAddr sdk.AccAddress, keyNa
6968
}
7069

7170
// GetLockedPower returns locked power of the address to the key.
72-
func (k Keeper) GetLockedPower(ctx sdk.Context, lockerAddr sdk.AccAddress, keyName string) (math.Int, error) {
71+
func (k Keeper) GetLockedPower(ctx sdk.Context, lockerAddr sdk.AccAddress, keyName string) (sdkmath.Int, error) {
7372
key, err := k.GetKey(ctx, keyName)
7473
if err != nil {
75-
return math.Int{}, types.ErrKeyNotFound
74+
return sdkmath.Int{}, types.ErrKeyNotFound
7675
}
7776

7877
if !key.IsActive {
79-
return math.Int{}, types.ErrKeyNotActive
78+
return sdkmath.Int{}, types.ErrKeyNotActive
8079
}
8180

8281
lock, err := k.GetLock(ctx, lockerAddr, keyName)
8382
if err != nil {
84-
return math.Int{}, types.ErrLockNotFound
83+
return sdkmath.Int{}, types.ErrLockNotFound
8584
}
8685

8786
return lock.Amount, nil

x/restake/keeper/msg_server.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ func (k msgServer) ClaimRewards(
4646
finalRewards, remainders := reward.Rewards.TruncateDecimal()
4747

4848
if !finalRewards.IsZero() {
49-
lock.PosRewardDebts = sdk.NewDecCoins()
49+
lock.PosRewardDebts = k.getTotalRewards(ctx, lock)
5050
lock.NegRewardDebts = remainders
5151
k.SetLock(ctx, lock)
5252

x/restake/keeper/msg_server_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ func (suite *KeeperTestSuite) TestMsgClaimRewards() {
5050
lock, err := suite.restakeKeeper.GetLock(ctx, ValidAddress1, ValidKey1)
5151
suite.Require().NoError(err)
5252
suite.Require().Equal(sdk.NewDecCoins(sdk.NewDecCoin("uband", sdkmath.NewInt(1))), lock.PosRewardDebts)
53+
suite.Require().Equal(sdk.DecCoins(nil), lock.NegRewardDebts)
5354
},
5455
},
5556
}

0 commit comments

Comments
 (0)