Skip to content

Commit 8dcb6c5

Browse files
committed
adding unit test cases
1 parent b905be6 commit 8dcb6c5

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

x/stablestake/keeper/debt.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ func (k Keeper) DeleteInterestForPool(ctx sdk.Context, delBlock int64, poolId ui
9898
store := prefix.NewStore(runtime.KVStoreAdapter(k.storeService.OpenKVStore(ctx)), types.GetInterestKey(poolId))
9999
key := sdk.Uint64ToBigEndian(uint64(delBlock))
100100
if store.Has(key) {
101-
store.Delete([]byte(key))
101+
store.Delete(key)
102102
}
103103
}
104104

x/stablestake/keeper/debt_test.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,24 @@ func (suite *KeeperTestSuite) TestGetInterestAtHeight() {
176176
suite.Equal(i.PoolId, interestBlock.PoolId)
177177
}
178178

179+
func (suite *KeeperTestSuite) TestDeleteInterestBlock() {
180+
i := types.InterestBlock{
181+
InterestRate: math.LegacyNewDec(2),
182+
BlockTime: 100,
183+
BlockHeight: 1,
184+
PoolId: 1,
185+
}
186+
suite.app.StablestakeKeeper.SetInterestForPool(suite.ctx, 1, 1, i)
187+
interestBlock := suite.app.StablestakeKeeper.GetInterestAtHeight(suite.ctx, 1, 1)
188+
suite.Equal(i.InterestRate, interestBlock.InterestRate)
189+
suite.Equal(i.BlockTime, interestBlock.BlockTime)
190+
suite.Equal(i.BlockHeight, interestBlock.BlockHeight)
191+
suite.Equal(i.PoolId, interestBlock.PoolId)
192+
suite.app.StablestakeKeeper.DeleteInterestForPool(suite.ctx, 1, 1)
193+
interestBlock = suite.app.StablestakeKeeper.GetInterestAtHeight(suite.ctx, 1, 1)
194+
suite.Equal(interestBlock, types.InterestBlock{})
195+
}
196+
179197
func (suite *KeeperTestSuite) TestTestnetMigrate() {
180198
suite.app.StablestakeKeeper.TestnetMigrate(suite.ctx)
181199
}

0 commit comments

Comments
 (0)