Skip to content

Commit

Permalink
chore: fix unit test failure in tokenomics module
Browse files Browse the repository at this point in the history
  • Loading branch information
kenta-elys committed Nov 27, 2023
1 parent a4fd29f commit 4846328
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
4 changes: 2 additions & 2 deletions x/incentive/keeper/abci.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ func (k Keeper) ProcessUpdateIncentiveParams(ctx sdk.Context) bool {

totalBlocksPerYear := sdk.NewInt(int64(inflation.EndBlockHeight - inflation.StartBlockHeight + 1))
allocationEpochInblocks := totalBlocksPerYear.Quo(sdk.NewInt(ptypes.DaysPerYear))
if len(params.LpIncentives) < 1 {
if len(params.LpIncentives) == 0 {
totalDistributionEpochPerYear := totalBlocksPerYear.Quo(sdk.NewInt(params.DistributionEpochForLpsInBlocks))
currentEpochInBlocks := sdk.NewInt(ctx.BlockHeight() - int64(inflation.StartBlockHeight)).Mul(totalDistributionEpochPerYear).Quo(totalBlocksPerYear)
maxEdenPerAllocation := sdk.NewInt(int64(inflation.Inflation.LmRewards)).Mul(allocationEpochInblocks).Quo(totalBlocksPerYear)
Expand All @@ -138,7 +138,7 @@ func (k Keeper) ProcessUpdateIncentiveParams(ctx sdk.Context) bool {
})
}

if len(params.StakeIncentives) < 1 {
if len(params.StakeIncentives) == 0 {
totalDistributionEpochPerYear := totalBlocksPerYear.Quo(sdk.NewInt(params.DistributionEpochForStakersInBlocks))
currentEpochInBlocks := sdk.NewInt(ctx.BlockHeight() - int64(inflation.StartBlockHeight)).Mul(totalDistributionEpochPerYear).Quo(totalBlocksPerYear)
maxEdenPerAllocation := sdk.NewInt(int64(inflation.Inflation.IcsStakingRewards)).Mul(allocationEpochInblocks).Quo(totalBlocksPerYear)
Expand Down
4 changes: 2 additions & 2 deletions x/incentive/types/params.go
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ func validateDistributionEpochLps(i interface{}) error {
return fmt.Errorf("invalid parameter type: %T", i)
}

if v < 1 {
if v == 0 {
return fmt.Errorf("invalid parameter type: %T", i)
}

Expand All @@ -352,7 +352,7 @@ func validateDistributionEpochStakers(i interface{}) error {
return fmt.Errorf("invalid parameter type: %T", i)
}

if v < 1 {
if v == 0 {
return fmt.Errorf("invalid parameter type: %T", i)
}

Expand Down
7 changes: 7 additions & 0 deletions x/tokenomics/client/cli/query_time_based_inflation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,13 @@ func networkWithTimeBasedInflationObjects(t *testing.T, n int) (*network.Network
timeBasedInflation := types.TimeBasedInflation{
StartBlockHeight: uint64(i),
EndBlockHeight: uint64(i),
Inflation: &types.InflationEntry{
LmRewards: 9999999,
IcsStakingRewards: 9999999,
CommunityFund: 9999999,
StrategicReserve: 9999999,
TeamTokensVested: 9999999,
},
}
nullify.Fill(&timeBasedInflation)
state.TimeBasedInflationList = append(state.TimeBasedInflationList, timeBasedInflation)
Expand Down

0 comments on commit 4846328

Please sign in to comment.