Skip to content

Commit

Permalink
fix mainnet vs. testnet wevmos contracts used in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
MalteHerrmann committed Sep 23, 2024
1 parent c3cd1a1 commit f7c9d38
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 34 deletions.
26 changes: 1 addition & 25 deletions precompiles/erc20/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion testutil/integration/os/network/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
12 changes: 4 additions & 8 deletions testutil/integration/os/utils/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand All @@ -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
Expand Down

0 comments on commit f7c9d38

Please sign in to comment.