mirror of
https://github.com/0glabs/0g-chain.git
synced 2024-12-24 15:25:18 +00:00
initialize claim period ids if they don't exist (#620)
This commit is contained in:
parent
e9e038a2c4
commit
928ce5f064
@ -90,6 +90,10 @@ func (k Keeper) GetAllRewardPeriods(ctx sdk.Context) types.RewardPeriods {
|
||||
func (k Keeper) GetNextClaimPeriodID(ctx sdk.Context, denom string) uint64 {
|
||||
store := prefix.NewStore(ctx.KVStore(k.key), types.NextClaimPeriodIDPrefix)
|
||||
bz := store.Get([]byte(denom))
|
||||
if bz == nil {
|
||||
k.SetNextClaimPeriodID(ctx, denom, 1)
|
||||
return uint64(1)
|
||||
}
|
||||
return types.BytesToUint64(bz)
|
||||
}
|
||||
|
||||
|
@ -86,14 +86,16 @@ func (suite *KeeperTestSuite) TestGetSetDeleteClaimPeriod() {
|
||||
}
|
||||
|
||||
func (suite *KeeperTestSuite) TestGetSetClaimPeriodID() {
|
||||
suite.Panics(func() {
|
||||
suite.keeper.GetNextClaimPeriodID(suite.ctx, "bnb")
|
||||
suite.NotPanics(func() {
|
||||
suite.keeper.GetNextClaimPeriodID(suite.ctx, "yolo")
|
||||
})
|
||||
suite.NotPanics(func() {
|
||||
suite.keeper.SetNextClaimPeriodID(suite.ctx, "bnb", 1)
|
||||
})
|
||||
testID := suite.keeper.GetNextClaimPeriodID(suite.ctx, "bnb")
|
||||
suite.Equal(uint64(1), testID)
|
||||
testID = suite.keeper.GetNextClaimPeriodID(suite.ctx, "yolo")
|
||||
suite.Equal(uint64(1), testID)
|
||||
}
|
||||
|
||||
func (suite *KeeperTestSuite) TestGetSetDeleteClaim() {
|
||||
|
Loading…
Reference in New Issue
Block a user