From 513c4ee7c7624ddea70c2f854f7d5d9c5808e506 Mon Sep 17 00:00:00 2001 From: skosito Date: Thu, 28 Mar 2024 00:33:25 +0100 Subject: [PATCH] Add more block rewards components tests --- .../keeper/block_rewards_components_test.go | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/x/emissions/keeper/block_rewards_components_test.go b/x/emissions/keeper/block_rewards_components_test.go index eb43408d2c..e2a0ad9d68 100644 --- a/x/emissions/keeper/block_rewards_components_test.go +++ b/x/emissions/keeper/block_rewards_components_test.go @@ -168,3 +168,21 @@ func TestKeeper_GetBondFactor(t *testing.T) { require.Equal(t, sdk.OneDec(), bondFactor) }) } + +func TestKeeper_GetDurationFactor(t *testing.T) { + t.Run("should return duration factor 0 if duration factor constant is 0", func(t *testing.T) { + k, ctx, _, _ := keepertest.EmissionsKeeper(t) + params := emissionstypes.DefaultParams() + params.DurationFactorConstant = "0" + k.SetParams(ctx, params) + duractionFactor := k.GetDurationFactor(ctx) + require.Equal(t, sdk.ZeroDec(), duractionFactor) + }) + + t.Run("should return duration factor for default params", func(t *testing.T) { + k, ctx, _, _ := keepertest.EmissionsKeeper(t) + duractionFactor := k.GetDurationFactor(ctx) + // hardcoding actual expected value for default params, it will change if logic changes + require.Equal(t, sdk.MustNewDecFromStr("0.000000004346937374"), duractionFactor) + }) +}