diff --git a/x/evm/keeper/grpc_query_test.go b/x/evm/keeper/grpc_query_test.go index e770115949..582c8f74bd 100644 --- a/x/evm/keeper/grpc_query_test.go +++ b/x/evm/keeper/grpc_query_test.go @@ -11,6 +11,8 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/tharsis/ethermint/crypto/ethsecp256k1" + "github.com/tharsis/ethermint/server/config" ethermint "github.com/tharsis/ethermint/types" "github.com/tharsis/ethermint/x/evm/types" ) @@ -859,3 +861,36 @@ func (suite *KeeperTestSuite) TestTraceBlock() { suite.enableFeemarket = false // reset flag } + +func (suite *KeeperTestSuite) TestNonceInQuery() { + suite.SetupTest() + priv, err := ethsecp256k1.GenerateKey() + suite.Require().NoError(err) + address := common.BytesToAddress(priv.PubKey().Address().Bytes()) + suite.Require().Equal(uint64(0), suite.app.EvmKeeper.GetNonce(address)) + supply := sdk.NewIntWithDecimal(1000, 18).BigInt() + + // accupy nonce 0 + _ = suite.DeployTestContract(suite.T(), address, supply) + + // do an EthCall/EstimateGas with nonce 0 + ctorArgs, err := types.ERC20Contract.ABI.Pack("", address, supply) + data := append(types.ERC20Contract.Bin, ctorArgs...) + args, err := json.Marshal(&types.TransactionArgs{ + From: &address, + Data: (*hexutil.Bytes)(&data), + }) + suite.Require().NoError(err) + + _, err = suite.queryClient.EstimateGas(sdk.WrapSDKContext(suite.ctx), &types.EthCallRequest{ + Args: args, + GasCap: uint64(config.DefaultGasCap), + }) + suite.Require().NoError(err) + + _, err = suite.queryClient.EthCall(sdk.WrapSDKContext(suite.ctx), &types.EthCallRequest{ + Args: args, + GasCap: uint64(config.DefaultGasCap), + }) + suite.Require().NoError(err) +} diff --git a/x/evm/keeper/keeper_test.go b/x/evm/keeper/keeper_test.go index d29e73d18d..105016326b 100644 --- a/x/evm/keeper/keeper_test.go +++ b/x/evm/keeper/keeper_test.go @@ -220,9 +220,8 @@ func (suite *KeeperTestSuite) DeployTestContract(t require.TestingT, owner commo data := append(types.ERC20Contract.Bin, ctorArgs...) args, err := json.Marshal(&types.TransactionArgs{ - From: &suite.address, - Data: (*hexutil.Bytes)(&data), - Nonce: (*hexutil.Uint64)(&nonce), + From: &suite.address, + Data: (*hexutil.Bytes)(&data), }) require.NoError(t, err)