Skip to content

Commit

Permalink
test: fix base fee test
Browse files Browse the repository at this point in the history
  • Loading branch information
dudong2 committed Jan 8, 2024
1 parent ad3c976 commit 915ed04
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 21 deletions.
8 changes: 7 additions & 1 deletion app/ante/eth_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,13 @@ func (suite AnteTestSuite) TestEthGasConsumeDecorator() {
ethCfg := suite.app.EvmKeeper.GetParams(suite.ctx).
ChainConfig.EthereumConfig(suite.app.EvmKeeper.ChainID())
baseFee := suite.app.EvmKeeper.GetBaseFee(suite.ctx, ethCfg)
suite.Require().Equal(int64(1000000000), baseFee.Int64())

// The ctx returned by testutil.Commit() is pointing to finalizeBlockState.ms corresponding
// to the previous height. The BeginBlock, DeliverTx, and EndBlock logics have been combined
// into a single FinalizeBlock logic. So, the base fee is modified before the commit,
// in contrast to the previous logic(https://github.com/evmos/ethermint/blob/eb3cc87c9b24fa7f63c156ad6fb1d071a6f80176/testutil/abci.go#L19-L46).
// Therefore, the comparison value was changed from 1000000000 to 875000000.
suite.Require().Equal(int64(875000000), baseFee.Int64())

gasPrice := new(big.Int).Add(baseFee, evmtypes.DefaultPriorityReduction.BigInt())

Expand Down
7 changes: 0 additions & 7 deletions app/ante/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import (

"github.com/ethereum/go-ethereum/common"
ethtypes "github.com/ethereum/go-ethereum/core/types"
ethparams "github.com/ethereum/go-ethereum/params"

signingv1beta1 "cosmossdk.io/api/cosmos/tx/signing/v1beta1"
sdkmath "cosmossdk.io/math"
Expand Down Expand Up @@ -180,12 +179,6 @@ func (suite *AnteTestSuite) SetupTest() {
suite.ctx, err = testutil.Commit(suite.ctx, suite.app, time.Second*0, nil)
suite.Require().NoError(err)

// The BeginBlock, DeliverTx, and EndBlock logic has been combined into one FinalizeBlock logic.
// Compared to the old logic, the BaseFee has changed because testutil.commit() returns a
// ctx in the state in which BeginBlock was called, so we force it to be set to the
// initial state and proceed with the test.
suite.app.FeeMarketKeeper.SetBaseFee(suite.ctx, sdkmath.NewInt(ethparams.InitialBaseFee).BigInt())

legacytx.RegressionTestingAminoCodec = encodingConfig.Amino
}

Expand Down
15 changes: 2 additions & 13 deletions testutil/abci.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,8 @@ import (

// Commit commits a block at a given time. Reminder: At the end of each
// Tendermint Consensus round the following methods are run
// 1. BeginBlock
// 2. DeliverTx
// 3. EndBlock
// 4. Commit
// 1. FinalizeBlock
// 2. Commit
func Commit(ctx sdk.Context, app *app.EthermintApp, t time.Duration, vs *tmtypes.ValidatorSet) (sdk.Context, error) {
header := ctx.BlockHeader()

Expand Down Expand Up @@ -51,15 +49,6 @@ func Commit(ctx sdk.Context, app *app.EthermintApp, t time.Duration, vs *tmtypes
header.Time = header.Time.Add(t)
header.AppHash = app.LastCommitID().Hash

_, err = app.FinalizeBlock(&abci.RequestFinalizeBlock{
Height: header.Height,
Time: header.Time,
Hash: header.AppHash,
})
if err != nil {
return ctx, err
}

return ctx.WithBlockHeader(header), nil
}

Expand Down

0 comments on commit 915ed04

Please sign in to comment.