Skip to content

Commit

Permalink
Use latest ethermint change and fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
skosito committed Apr 20, 2024
1 parent 28abd7c commit eb76373
Show file tree
Hide file tree
Showing 3 changed files with 94 additions and 94 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down
182 changes: 91 additions & 91 deletions x/fungible/keeper/evm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit eb76373

Please sign in to comment.