Skip to content

Commit

Permalink
unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
blindchaser committed Dec 9, 2024
1 parent bfbc7f1 commit 5742e69
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions x/evm/keeper/fee_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down Expand Up @@ -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())
}

0 comments on commit 5742e69

Please sign in to comment.