From 5742e69816f49df027d346a48cad6efc2b6780de Mon Sep 17 00:00:00 2001 From: blindchaser Date: Sun, 8 Dec 2024 23:12:34 -0500 Subject: [PATCH] unit test --- x/evm/keeper/fee_test.go | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/x/evm/keeper/fee_test.go b/x/evm/keeper/fee_test.go index 78e0595422..a4088fbed0 100644 --- a/x/evm/keeper/fee_test.go +++ b/x/evm/keeper/fee_test.go @@ -5,6 +5,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" testkeeper "github.com/sei-protocol/sei-chain/testutil/keeper" + "github.com/sei-protocol/sei-chain/x/evm/types" "github.com/stretchr/testify/require" tmproto "github.com/tendermint/tendermint/proto/tendermint/types" ) @@ -177,3 +178,24 @@ func TestAdjustBaseFeePerGas(t *testing.T) { }) } } + +func TestGetDynamicBaseFeePerGasWithNilMinFee(t *testing.T) { + k, ctx := testkeeper.MockEVMKeeper() + + // Test case 1: When dynamic base fee doesn't exist and minimum fee is nil + store := ctx.KVStore(k.GetStoreKey()) + store.Delete(types.BaseFeePerGasPrefix) + + // Clear the dynamic base fee from store + fee := k.GetDynamicBaseFeePerGas(ctx) + require.Equal(t, types.DefaultParams().MinimumFeePerGas, fee) + require.False(t, fee.IsNil()) + + // Test case 2: When dynamic base fee exists + expectedFee := sdk.NewDec(100) + k.SetDynamicBaseFeePerGas(ctx, expectedFee) + + fee = k.GetDynamicBaseFeePerGas(ctx) + require.Equal(t, expectedFee, fee) + require.False(t, fee.IsNil()) +}