From 866c741440eb39ded935acae91a30f65a2450862 Mon Sep 17 00:00:00 2001 From: mmsqe Date: Tue, 12 Nov 2024 22:35:19 +0800 Subject: [PATCH] fix test --- rpc/backend/evm_query_client_test.go | 14 ++++++++++++++ rpc/backend/tracing_test.go | 5 +++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/rpc/backend/evm_query_client_test.go b/rpc/backend/evm_query_client_test.go index f2e8b6b4c0..4163b09c89 100644 --- a/rpc/backend/evm_query_client_test.go +++ b/rpc/backend/evm_query_client_test.go @@ -7,6 +7,7 @@ import ( "strconv" "testing" + "cosmossdk.io/math" sdk "github.com/cosmos/cosmos-sdk/types" errortypes "github.com/cosmos/cosmos-sdk/types/errors" grpctypes "github.com/cosmos/cosmos-sdk/types/grpc" @@ -31,6 +32,13 @@ import ( var _ evmtypes.QueryClient = &mocks.EVMQueryClient{} // TraceTransaction +func RegisterTraceTransactionWithPredecessorsAndBaseFee(queryClient *mocks.EVMQueryClient, msgEthTx *evmtypes.MsgEthereumTx, predecessors []*evmtypes.MsgEthereumTx, baseFee math.Int) { + data := []byte{0x7b, 0x22, 0x74, 0x65, 0x73, 0x74, 0x22, 0x3a, 0x20, 0x22, 0x68, 0x65, 0x6c, 0x6c, 0x6f, 0x22, 0x7d} + queryClient.On("TraceTx", rpc.ContextWithHeight(1), + &evmtypes.QueryTraceTxRequest{Msg: msgEthTx, BlockNumber: 1, Predecessors: predecessors, ChainId: 9000, BaseFee: &baseFee}). + Return(&evmtypes.QueryTraceTxResponse{Data: data}, nil) +} + func RegisterTraceTransactionWithPredecessors(queryClient *mocks.EVMQueryClient, msgEthTx *evmtypes.MsgEthereumTx, predecessors []*evmtypes.MsgEthereumTx) { data := []byte{0x7b, 0x22, 0x74, 0x65, 0x73, 0x74, 0x22, 0x3a, 0x20, 0x22, 0x68, 0x65, 0x6c, 0x6c, 0x6f, 0x22, 0x7d} queryClient.On("TraceTx", rpc.ContextWithHeight(1), @@ -38,6 +46,12 @@ func RegisterTraceTransactionWithPredecessors(queryClient *mocks.EVMQueryClient, Return(&evmtypes.QueryTraceTxResponse{Data: data}, nil) } +func RegisterTraceTransactionAndBaseFee(queryClient *mocks.EVMQueryClient, msgEthTx *evmtypes.MsgEthereumTx, baseFee math.Int) { + data := []byte{0x7b, 0x22, 0x74, 0x65, 0x73, 0x74, 0x22, 0x3a, 0x20, 0x22, 0x68, 0x65, 0x6c, 0x6c, 0x6f, 0x22, 0x7d} + queryClient.On("TraceTx", rpc.ContextWithHeight(1), &evmtypes.QueryTraceTxRequest{Msg: msgEthTx, BlockNumber: 1, ChainId: 9000, BaseFee: &baseFee}). + Return(&evmtypes.QueryTraceTxResponse{Data: data}, nil) +} + func RegisterTraceTransaction(queryClient *mocks.EVMQueryClient, msgEthTx *evmtypes.MsgEthereumTx) { data := []byte{0x7b, 0x22, 0x74, 0x65, 0x73, 0x74, 0x22, 0x3a, 0x20, 0x22, 0x68, 0x65, 0x6c, 0x6c, 0x6f, 0x22, 0x7d} queryClient.On("TraceTx", rpc.ContextWithHeight(1), &evmtypes.QueryTraceTxRequest{Msg: msgEthTx, BlockNumber: 1, ChainId: 9000}). diff --git a/rpc/backend/tracing_test.go b/rpc/backend/tracing_test.go index c783bdf98e..3cfa3438ce 100644 --- a/rpc/backend/tracing_test.go +++ b/rpc/backend/tracing_test.go @@ -21,6 +21,7 @@ import ( rpctypes "github.com/evmos/ethermint/rpc/types" "github.com/evmos/ethermint/tests" evmtypes "github.com/evmos/ethermint/x/evm/types" + feemarkettypes "github.com/evmos/ethermint/x/feemarket/types" ) func (suite *BackendTestSuite) TestTraceTransaction() { @@ -116,7 +117,7 @@ func (suite *BackendTestSuite) TestTraceTransaction() { RegisterBlockMultipleTxs(client, 1, []types.Tx{txBz, txBz2}) feeMarketClient := suite.backend.queryClient.FeeMarket.(*mocks.FeeMarketQueryClient) RegisterFeeMarketParams(feeMarketClient, 1) - RegisterTraceTransactionWithPredecessors(queryClient, msgEthereumTx, []*evmtypes.MsgEthereumTx{msgEthereumTx}) + RegisterTraceTransactionWithPredecessorsAndBaseFee(queryClient, msgEthereumTx, []*evmtypes.MsgEthereumTx{msgEthereumTx}, feemarkettypes.DefaultParams().BaseFee) }, &types.Block{Header: types.Header{Height: 1, ChainID: ChainID}, Data: types.Data{Txs: []types.Tx{txBz, txBz2}}}, []*abci.ResponseDeliverTx{ @@ -158,7 +159,7 @@ func (suite *BackendTestSuite) TestTraceTransaction() { RegisterBlock(client, 1, txBz) feeMarketClient := suite.backend.queryClient.FeeMarket.(*mocks.FeeMarketQueryClient) RegisterFeeMarketParams(feeMarketClient, 1) - RegisterTraceTransaction(queryClient, msgEthereumTx) + RegisterTraceTransactionAndBaseFee(queryClient, msgEthereumTx, feemarkettypes.DefaultParams().BaseFee) }, &types.Block{Header: types.Header{Height: 1}, Data: types.Data{Txs: []types.Tx{txBz}}}, []*abci.ResponseDeliverTx{