Skip to content

Commit

Permalink
fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
beer-1 committed Aug 21, 2024
1 parent 52581df commit 35ad142
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 7 deletions.
21 changes: 14 additions & 7 deletions app/ante/fee_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,28 +36,35 @@ func (suite *AnteTestSuite) Test_NotSpendingGasForTxWithFeeDenom() {
tx, err := suite.CreateTestTx(privs, accNums, accSeqs, suite.ctx.ChainID())
suite.Require().NoError(err)

gasMeter := storetypes.NewGasMeter(250000)
gasMeter := storetypes.NewGasMeter(500000)
feeAnte.AnteHandle(suite.ctx.WithGasMeter(gasMeter), tx, false, nil)
suite.Require().Zero(gasMeter.GasConsumed(), "should not consume gas for fee deduction")

// Case 2. fee denom and other denom
suite.txBuilder.SetFeeAmount(feeAmount.Add(atomFeeAmount...))

gasMeter = storetypes.NewGasMeter(250000)
gasMeter = storetypes.NewGasMeter(500000)
feeAnte.AnteHandle(suite.ctx.WithGasMeter(gasMeter), tx, false, nil)
suite.Require().NotZero(uint64(1039), "should consume gas for fee deduction")
suite.Require().NotZero(gasMeter.GasConsumed(), "should consume gas for fee deduction")

// Case 3. other denom
suite.txBuilder.SetFeeAmount(feeAmount.Add(atomFeeAmount...))

gasMeter = storetypes.NewGasMeter(250000)
gasMeter = storetypes.NewGasMeter(500000)
feeAnte.AnteHandle(suite.ctx.WithGasMeter(gasMeter), tx, false, nil)
suite.Require().NotZero(uint64(1039), "should consume gas for fee deduction")
suite.Require().NotZero(gasMeter.GasConsumed(), "should consume gas for fee deduction")

// Case 4. no fee
suite.txBuilder.SetFeeAmount(sdk.NewCoins())

gasMeter = storetypes.NewGasMeter(250000)
gasMeter = storetypes.NewGasMeter(500000)
feeAnte.AnteHandle(suite.ctx.WithGasMeter(gasMeter), tx, false, nil)
suite.Require().NotZero(uint64(1039), "should consume gas for fee deduction")
suite.Require().NotZero(gasMeter.GasConsumed(), "should consume gas for fee deduction")

// Case 5. simulate gas consumption
suite.txBuilder.SetFeeAmount(sdk.NewCoins())

gasMeter = storetypes.NewGasMeter(500000)
feeAnte.AnteHandle(suite.ctx.WithGasMeter(gasMeter), tx, true, nil)
suite.Require().Greater(gasMeter.GasConsumed(), uint64(250000), "should consume gas for fee deduction")
}
26 changes: 26 additions & 0 deletions x/evm/keeper/params_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package keeper_test

import (
"testing"

"github.com/stretchr/testify/require"

evmtypes "github.com/initia-labs/minievm/x/evm/types"
)

func Test_GetFeeDenom(t *testing.T) {
ctx, input := createDefaultTestInput(t)

denom, err := input.EVMKeeper.GetFeeDenom(ctx)
require.NoError(t, err)
require.Equal(t, evmtypes.DefaultParams().FeeDenom, denom)

err = input.EVMKeeper.Params.Set(ctx, evmtypes.Params{
FeeDenom: "eth",
})
require.NoError(t, err)

denom, err = input.EVMKeeper.GetFeeDenom(ctx)
require.NoError(t, err)
require.Equal(t, "eth", denom)
}

0 comments on commit 35ad142

Please sign in to comment.