Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
MalteHerrmann committed Aug 21, 2024
1 parent 7642c13 commit c167e7e
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 10 deletions.
1 change: 1 addition & 0 deletions x/evm/keeper/config.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// Copyright Tharsis Labs Ltd.(Evmos)
// SPDX-License-Identifier:ENCL-1.0(https://github.com/evmos/evmos/blob/main/LICENSE)

package keeper

import (
Expand Down
12 changes: 8 additions & 4 deletions x/evm/keeper/grpc_query_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package keeper_test
import (
"encoding/json"
"fmt"
example_app "github.com/evmos/os/example_chain"
"math/big"

sdkmath "cosmossdk.io/math"
Expand All @@ -28,10 +29,10 @@ import (
const invalidAddress = "0x0000"

// expGasConsumed is the gas consumed in traceTx setup (GetProposerAddr + CalculateBaseFee)
const expGasConsumed = 6422
const expGasConsumed = 7346

// expGasConsumedWithFeeMkt is the gas consumed in traceTx setup (GetProposerAddr + CalculateBaseFee) with enabled feemarket
const expGasConsumedWithFeeMkt = 6416
const expGasConsumedWithFeeMkt = 7340

func (suite *KeeperTestSuite) TestQueryAccount() {
var (
Expand Down Expand Up @@ -411,7 +412,10 @@ func (suite *KeeperTestSuite) TestQueryTxLogs() {

func (suite *KeeperTestSuite) TestQueryParams() {
ctx := sdk.WrapSDKContext(suite.ctx)
expParams := types.DefaultParamsWithEVMDenom(testutil.ExampleAttoDenom)

// NOTE: we are using the EVM genesis state for the example app here, because
// we have different assumptions for the evmOS offering and the example chain.
expParams := example_app.NewEVMGenesisState().Params

res, err := suite.queryClient.Params(ctx, &types.QueryParamsRequest{})
suite.Require().NoError(err)
Expand Down Expand Up @@ -955,7 +959,7 @@ func (suite *KeeperTestSuite) TestTraceTx() {
},
expPass: true,
traceResponse: "{\"gas\":34828,\"failed\":false,\"returnValue\":\"0000000000000000000000000000000000000000000000000000000000000001\",\"structLogs\":[{\"pc\":0,\"op\":\"PUSH1\",\"gas\":",
expFinalGas: 14735, // gas consumed in traceTx setup (GetProposerAddr + CalculateBaseFee) + gas consumed in malleate func
expFinalGas: 25823, // gas consumed in traceTx setup (GetProposerAddr + CalculateBaseFee) + gas consumed in malleate func
},
{
msg: "invalid chain id",
Expand Down
5 changes: 4 additions & 1 deletion x/evm/keeper/params_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package keeper_test

import (
example_app "github.com/evmos/os/example_chain"
"reflect"

"github.com/evmos/os/testutil"
Expand All @@ -19,7 +20,9 @@ func (suite *KeeperTestSuite) TestParams() {
{
"success - Checks if the default params are set correctly",
func() interface{} {
return types.DefaultParamsWithEVMDenom(testutil.ExampleAttoDenom)
// NOTE: we are using the EVM genesis state for the example app here, because
// we have different assumptions for the evmOS offering and the example chain.
return example_app.NewEVMGenesisState().Params
},
func() interface{} {
return suite.app.EVMKeeper.GetParams(suite.ctx)
Expand Down
15 changes: 10 additions & 5 deletions x/evm/keeper/state_transition_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package keeper_test

import (
"fmt"
example_app "github.com/evmos/os/example_chain"
"math"
"math/big"

Expand Down Expand Up @@ -521,14 +522,18 @@ func (suite *KeeperTestSuite) TestResetGasMeterAndConsumeGas() {

func (suite *KeeperTestSuite) TestEVMConfig() {
proposerAddress := suite.ctx.BlockHeader().ProposerAddress
cfg, err := suite.app.EVMKeeper.EVMConfig(suite.ctx, proposerAddress, big.NewInt(9000))
cfg, err := suite.app.EVMKeeper.EVMConfig(suite.ctx, proposerAddress, big.NewInt(testutil.ExampleEIP155ChainID))
suite.Require().NoError(err)
defaultParams := evmtypes.DefaultParamsWithEVMDenom(testutil.ExampleAttoDenom)

// NOTE: since we are using different defaults for the app and the evmOS in general, we are getting the
// default parameters from the EVM genesis state for the example app here.
defaultParams := example_app.NewEVMGenesisState().Params
suite.Require().Equal(defaultParams, cfg.Params)

// london hardfork is enabled by default
suite.Require().Equal(big.NewInt(0), cfg.BaseFee)
suite.Require().Equal(suite.address, cfg.CoinBase)
suite.Require().Equal(defaultParams.ChainConfig.EthereumConfig(big.NewInt(9000)), cfg.ChainConfig)
suite.Require().Equal(defaultParams.ChainConfig.EthereumConfig(big.NewInt(testutil.ExampleEIP155ChainID)), cfg.ChainConfig)
}

func (suite *KeeperTestSuite) TestContractDeployment() {
Expand All @@ -542,7 +547,7 @@ func (suite *KeeperTestSuite) TestApplyMessage() {
var msg core.Message

proposerAddress := suite.ctx.BlockHeader().ProposerAddress
config, err := suite.app.EVMKeeper.EVMConfig(suite.ctx, proposerAddress, big.NewInt(9000))
config, err := suite.app.EVMKeeper.EVMConfig(suite.ctx, proposerAddress, big.NewInt(testutil.ExampleEIP155ChainID))
suite.Require().NoError(err)

keeperParams := suite.app.EVMKeeper.GetParams(suite.ctx)
Expand Down Expand Up @@ -678,7 +683,7 @@ func (suite *KeeperTestSuite) TestApplyMessageWithConfig() {
expectedGasUsed = params.TxGas

proposerAddress := suite.ctx.BlockHeader().ProposerAddress
config, err = suite.app.EVMKeeper.EVMConfig(suite.ctx, proposerAddress, big.NewInt(9000))
config, err = suite.app.EVMKeeper.EVMConfig(suite.ctx, proposerAddress, big.NewInt(testutil.ExampleEIP155ChainID))
suite.Require().NoError(err)

keeperParams = suite.app.EVMKeeper.GetParams(suite.ctx)
Expand Down

0 comments on commit c167e7e

Please sign in to comment.