From 4846328dac14028d58e7dad7193640eb6f4ce412 Mon Sep 17 00:00:00 2001 From: kenta-elys Date: Mon, 27 Nov 2023 16:46:23 +0000 Subject: [PATCH] chore: fix unit test failure in tokenomics module --- x/incentive/keeper/abci.go | 4 ++-- x/incentive/types/params.go | 4 ++-- x/tokenomics/client/cli/query_time_based_inflation_test.go | 7 +++++++ 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/x/incentive/keeper/abci.go b/x/incentive/keeper/abci.go index d75454073..4c00810c0 100644 --- a/x/incentive/keeper/abci.go +++ b/x/incentive/keeper/abci.go @@ -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) @@ -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) diff --git a/x/incentive/types/params.go b/x/incentive/types/params.go index 8966d5510..906ad8beb 100644 --- a/x/incentive/types/params.go +++ b/x/incentive/types/params.go @@ -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) } @@ -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) } diff --git a/x/tokenomics/client/cli/query_time_based_inflation_test.go b/x/tokenomics/client/cli/query_time_based_inflation_test.go index a060e9d37..42c539bf0 100644 --- a/x/tokenomics/client/cli/query_time_based_inflation_test.go +++ b/x/tokenomics/client/cli/query_time_based_inflation_test.go @@ -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)