diff --git a/go.mod b/go.mod index 7ae890de01..1fcb050fca 100644 --- a/go.mod +++ b/go.mod @@ -356,4 +356,4 @@ replace ( replace github.com/cometbft/cometbft-db => github.com/notional-labs/cometbft-db v0.0.0-20230321185329-6dc7c0ca6345 -replace github.com/evmos/ethermint => github.com/zeta-chain/ethermint v0.6.1-0.20240416184712-d8c69a42b319 +replace github.com/evmos/ethermint => github.com/zeta-chain/ethermint v0.6.1-0.20240420031246-f99cf16f246b diff --git a/go.sum b/go.sum index 3c9ddfa97a..28be5dcca3 100644 --- a/go.sum +++ b/go.sum @@ -1700,8 +1700,8 @@ github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9de github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= -github.com/zeta-chain/ethermint v0.6.1-0.20240416184712-d8c69a42b319 h1:cC9ZiNTcDJhW2032kpe/rZqrCF1iXElG+VceaJWFZm8= -github.com/zeta-chain/ethermint v0.6.1-0.20240416184712-d8c69a42b319/go.mod h1:Vvr3Ku1ny6nVfemqUbYfFUsj50Gy7B6fWi1cUVCuMsg= +github.com/zeta-chain/ethermint v0.6.1-0.20240420031246-f99cf16f246b h1:CGgMFPq6L0oZRMQYcLWsDtci1N1jDtJbD5B0Sg4eTNE= +github.com/zeta-chain/ethermint v0.6.1-0.20240420031246-f99cf16f246b/go.mod h1:Vvr3Ku1ny6nVfemqUbYfFUsj50Gy7B6fWi1cUVCuMsg= github.com/zeta-chain/go-tss v0.1.1-0.20240208222330-f3be0d4a0d98 h1:GCSRgszQbAR7h/qK0YKjlm1mcnZOaGMbztRLaAfoOx0= github.com/zeta-chain/go-tss v0.1.1-0.20240208222330-f3be0d4a0d98/go.mod h1:+lJfk/qqt+oxXeVuJV+PzpUoxftUfoTRf2eF3qlbyFI= github.com/zeta-chain/keystone/keys v0.0.0-20231105174229-903bc9405da2 h1:gd2uE0X+ZbdFJ8DubxNqLbOVlCB12EgWdzSNRAR82tM= diff --git a/x/fungible/keeper/evm_test.go b/x/fungible/keeper/evm_test.go index 15f7385e91..a79f91ffd2 100644 --- a/x/fungible/keeper/evm_test.go +++ b/x/fungible/keeper/evm_test.go @@ -537,97 +537,97 @@ func TestKeeper_DepositZRC20AndCallContract(t *testing.T) { } func TestKeeper_CallEVMWithData(t *testing.T) { - // t.Run("should return a revert error when the contract call revert", func(t *testing.T) { - // k, ctx, sdkk, _ := keepertest.FungibleKeeper(t) - // _ = k.GetAuthKeeper().GetModuleAccount(ctx, types.ModuleName) - - // // Deploy example - // contract, err := k.DeployContract(ctx, contracts.ExampleMetaData) - // require.NoError(t, err) - // assertContractDeployment(t, sdkk.EvmKeeper, ctx, contract) - // abi, err := contracts.ExampleMetaData.GetAbi() - // require.NoError(t, err) - - // // doRevert make contract reverted - // res, err := k.CallEVM( - // ctx, - // *abi, - // types.ModuleAddressEVM, - // contract, - // big.NewInt(0), - // nil, - // true, - // false, - // "doRevert", - // ) - // require.Nil(t, res) - // require.True(t, types.IsContractReverted(res, err)) - - // // check reason is included for revert error - // // 0xbfb4ebcf is the hash of "Foo()" - // require.Contains(t, err.Error(), "reason: 0xbfb4ebcf") - - // res, err = k.CallEVM( - // ctx, - // *abi, - // types.ModuleAddressEVM, - // contract, - // big.NewInt(0), - // nil, - // true, - // false, - // "doRevertWithMessage", - // ) - // require.Nil(t, res) - // require.True(t, types.IsContractReverted(res, err)) - - // res, err = k.CallEVM( - // ctx, - // *abi, - // types.ModuleAddressEVM, - // contract, - // big.NewInt(0), - // nil, - // true, - // false, - // "doRevertWithRequire", - // ) - // require.Nil(t, res) - // require.True(t, types.IsContractReverted(res, err)) - - // // Not a revert error if another type of error - // res, err = k.CallEVM( - // ctx, - // *abi, - // types.ModuleAddressEVM, - // contract, - // big.NewInt(0), - // nil, - // true, - // false, - // "doNotExist", - // ) - // require.Nil(t, res) - // require.Error(t, err) - // require.False(t, types.IsContractReverted(res, err)) - // require.NotContains(t, err.Error(), "reason:") - - // // No revert with successfull call - // res, err = k.CallEVM( - // ctx, - // *abi, - // types.ModuleAddressEVM, - // contract, - // big.NewInt(0), - // nil, - // true, - // false, - // "doSucceed", - // ) - // require.NotNil(t, res) - // require.NoError(t, err) - // require.False(t, types.IsContractReverted(res, err)) - // }) + t.Run("should return a revert error when the contract call revert", func(t *testing.T) { + k, ctx, sdkk, _ := keepertest.FungibleKeeper(t) + _ = k.GetAuthKeeper().GetModuleAccount(ctx, types.ModuleName) + + // Deploy example + contract, err := k.DeployContract(ctx, contracts.ExampleMetaData) + require.NoError(t, err) + assertContractDeployment(t, sdkk.EvmKeeper, ctx, contract) + abi, err := contracts.ExampleMetaData.GetAbi() + require.NoError(t, err) + + // doRevert make contract reverted + res, err := k.CallEVM( + ctx, + *abi, + types.ModuleAddressEVM, + contract, + big.NewInt(0), + nil, + true, + false, + "doRevert", + ) + require.Nil(t, res) + require.True(t, types.IsContractReverted(res, err)) + + // check reason is included for revert error + // 0xbfb4ebcf is the hash of "Foo()" + require.Contains(t, err.Error(), "reason: 0xbfb4ebcf") + + res, err = k.CallEVM( + ctx, + *abi, + types.ModuleAddressEVM, + contract, + big.NewInt(0), + nil, + true, + false, + "doRevertWithMessage", + ) + require.Nil(t, res) + require.True(t, types.IsContractReverted(res, err)) + + res, err = k.CallEVM( + ctx, + *abi, + types.ModuleAddressEVM, + contract, + big.NewInt(0), + nil, + true, + false, + "doRevertWithRequire", + ) + require.Nil(t, res) + require.True(t, types.IsContractReverted(res, err)) + + // Not a revert error if another type of error + res, err = k.CallEVM( + ctx, + *abi, + types.ModuleAddressEVM, + contract, + big.NewInt(0), + nil, + true, + false, + "doNotExist", + ) + require.Nil(t, res) + require.Error(t, err) + require.False(t, types.IsContractReverted(res, err)) + require.NotContains(t, err.Error(), "reason:") + + // No revert with successfull call + res, err = k.CallEVM( + ctx, + *abi, + types.ModuleAddressEVM, + contract, + big.NewInt(0), + nil, + true, + false, + "doSucceed", + ) + require.NotNil(t, res) + require.NoError(t, err) + require.False(t, types.IsContractReverted(res, err)) + }) t.Run("apply new message without gas limit estimates gas", func(t *testing.T) { k, ctx := keepertest.FungibleKeeperAllMocks(t)