From f7c9d3854d5e4371f1d0e7d7177bb2476f0a5feb Mon Sep 17 00:00:00 2001 From: MalteHerrmann Date: Mon, 23 Sep 2024 21:27:27 +0200 Subject: [PATCH] fix mainnet vs. testnet wevmos contracts used in tests --- precompiles/erc20/integration_test.go | 26 +----------------------- testutil/integration/os/network/setup.go | 1 - testutil/integration/os/utils/genesis.go | 12 ++++------- 3 files changed, 5 insertions(+), 34 deletions(-) diff --git a/precompiles/erc20/integration_test.go b/precompiles/erc20/integration_test.go index 72f4fdab..31994ba7 100644 --- a/precompiles/erc20/integration_test.go +++ b/precompiles/erc20/integration_test.go @@ -245,7 +245,7 @@ var _ = Describe("ERC20 Extension -", func() { erc20Params := is.network.App.Erc20Keeper.GetParams(is.network.GetContext()) Expect(len(erc20Params.NativePrecompiles)).To(Equal(1)) - Expect(common.HexToAddress(erc20Params.NativePrecompiles[0])).To(Equal(common.HexToAddress(testconstants.WEVMOSContractTestnet))) + Expect(common.HexToAddress(erc20Params.NativePrecompiles[0])).To(Equal(common.HexToAddress(testconstants.WEVMOSContractMainnet))) revertContractAddr, err = is.factory.DeployContract( sender.Priv, @@ -436,30 +436,6 @@ var _ = Describe("ERC20 Extension -", func() { receiver := is.keyring.GetKey(1) amountToSend := big.NewInt(100) - fmt.Println("testnet contract: ", testconstants.WEVMOSContractTestnet) - evmParams := is.network.App.EVMKeeper.GetParams(is.network.GetContext()) - fmt.Println("evmParams: ", evmParams.ActiveStaticPrecompiles) - erc20Params := is.network.App.Erc20Keeper.GetParams(is.network.GetContext()) - fmt.Println("erc20Params: ", erc20Params.NativePrecompiles) - - // Check if token pair is actually registered - tokenPair := is.network.App.Erc20Keeper.GetTokenPairs(is.network.GetContext()) - Expect(tokenPair).ToNot(BeNil()) - fmt.Println("got token pairs: ", tokenPair) - for _, pair := range tokenPair { - fmt.Println(" denom: ", pair.Denom) - fmt.Println(" addr: ", pair.Erc20Address) - } - - // Get ERC20 balance of user - erc20Balance, err := integrationutils.GetERC20Balance( - is.network, - common.HexToAddress(testconstants.WEVMOSContractTestnet), - sender.Addr, - ) - Expect(err).ToNot(HaveOccurred(), "failed to get ERC20 balance") - Expect(erc20Balance).ToNot(BeZero(), "expected non-zero balance of sender") - balRes, err := is.handler.GetBalance(receiver.AccAddr, is.bondDenom) Expect(err).To(BeNil()) denomInitialBalance := balRes.Balance diff --git a/testutil/integration/os/network/setup.go b/testutil/integration/os/network/setup.go index e6f53133..f2c2679b 100644 --- a/testutil/integration/os/network/setup.go +++ b/testutil/integration/os/network/setup.go @@ -459,7 +459,6 @@ func setDefaultMintGenesisState(evmosApp *exampleapp.ExampleChain, genesisState return genesisState } -// TODO: why is this being set here? This was imported from the Evmos repo and is maybe not necessary with the corresponding setup from the example chain repo (incl. moving the default Mint and Gov states there instead of here) func setDefaultErc20GenesisState(evmosApp *exampleapp.ExampleChain, genesisState evmostypes.GenesisState) evmostypes.GenesisState { // NOTE: here we are using the setup from the example chain erc20Gen := exampleapp.NewErc20GenesisState() diff --git a/testutil/integration/os/utils/genesis.go b/testutil/integration/os/utils/genesis.go index bfe9ca49..6d73196d 100644 --- a/testutil/integration/os/utils/genesis.go +++ b/testutil/integration/os/utils/genesis.go @@ -52,12 +52,8 @@ func CreateGenesisWithTokenPairs(keyring testkeyring.Keyring, denoms ...string) // Add token pairs to genesis tokenPairs := make([]erc20types.TokenPair, 0, len(denoms)+1) tokenPairs = append(tokenPairs, - erc20types.TokenPair{ - Erc20Address: constants.WEVMOSContractTestnet, - Denom: constants.ExampleAttoDenom, - Enabled: true, - ContractOwner: erc20types.OWNER_MODULE, // NOTE: Owner is the module account since it's a native token and was registered through governance - }, + // NOTE: the example token pairs are being added in the integration test utils + exampleapp.ExampleTokenPairs..., ) dynPrecAddr := make([]string, 0, len(denoms)) @@ -74,10 +70,10 @@ func CreateGenesisWithTokenPairs(keyring testkeyring.Keyring, denoms ...string) } // STR v2: update the NativePrecompiles and DynamicPrecompiles - // with the WEVMOS (default is testnet) and 'xmpl' tokens in the erc20 params + // with the WEVMOS (default is mainnet) and 'xmpl' tokens in the erc20 params erc20GenesisState := exampleapp.NewErc20GenesisState() erc20GenesisState.TokenPairs = tokenPairs - erc20GenesisState.Params.NativePrecompiles = []string{constants.WEVMOSContractTestnet} + erc20GenesisState.Params.NativePrecompiles = []string{constants.WEVMOSContractMainnet} erc20GenesisState.Params.DynamicPrecompiles = dynPrecAddr // Combine module genesis states