From f0c22bfdc9855ed472473405b2e375bbec81ef22 Mon Sep 17 00:00:00 2001 From: Mateusz Sekara Date: Thu, 17 Aug 2023 20:17:31 +0200 Subject: [PATCH] Use chain selectors in Integration Tests (#49) --- integration-tests/actions/ccip_helpers.go | 22 +++++++++---------- .../contracts/ccip/contract_models.go | 7 ++++-- integration-tests/load/ccip_loadgen.go | 2 +- 3 files changed, 16 insertions(+), 15 deletions(-) diff --git a/integration-tests/actions/ccip_helpers.go b/integration-tests/actions/ccip_helpers.go index bdbb5e4071..d35f5f69ac 100644 --- a/integration-tests/actions/ccip_helpers.go +++ b/integration-tests/actions/ccip_helpers.go @@ -69,14 +69,12 @@ type CCIPTOMLEnv struct { Networks []blockchain.EVMNetwork } -var EvmChainIdToChainSelector = func(chainId uint64, simulated bool) (uint64, error) { - if simulated { - return chainId, nil - } +var EvmChainIdToChainSelector = func(chainId uint64) (uint64, error) { mapSelector := map[uint64]uint64{ // Testnets 420: 2664363617261496610, // Optimism Goerli - 1337: 3379446385462418246, // Quorem + 1337: 3379446385462418246, // Tests + 2337: 12922642891491394802, // Tests 43113: 14767482510784806043, // Avax Fuji 80001: 12532609583862916517, // Polygon Mumbai 421613: 6101244977088475029, // Arbitrum Goerli @@ -519,11 +517,11 @@ func (sourceCCIP *SourceCCIPModule) DeployContracts(lane *laneconfig.LaneConfig) if len(sourceCCIP.TransferAmount) != len(sourceCCIP.Common.BridgeTokens) { sourceCCIP.TransferAmount = sourceCCIP.TransferAmount[:len(sourceCCIP.Common.BridgeTokens)] } - sourceChainSelector, err := EvmChainIdToChainSelector(sourceCCIP.Common.ChainClient.GetChainID().Uint64(), sourceCCIP.Common.ChainClient.NetworkSimulated()) + sourceChainSelector, err := EvmChainIdToChainSelector(sourceCCIP.Common.ChainClient.GetChainID().Uint64()) if err != nil { return errors.WithStack(err) } - destChainSelector, err := EvmChainIdToChainSelector(sourceCCIP.DestinationChainId, sourceCCIP.Common.ChainClient.NetworkSimulated()) + destChainSelector, err := EvmChainIdToChainSelector(sourceCCIP.DestinationChainId) if err != nil { return errors.WithStack(err) } @@ -635,7 +633,7 @@ func (sourceCCIP *SourceCCIPModule) DeployContracts(lane *laneconfig.LaneConfig) } // update source Router with OnRamp address - err = sourceCCIP.Common.Router.SetOnRamp(sourceCCIP.DestinationChainId, sourceCCIP.OnRamp.EthAddress) + err = sourceCCIP.Common.Router.SetOnRamp(destChainSelector, sourceCCIP.OnRamp.EthAddress) if err != nil { return fmt.Errorf("setting onramp on the router shouldn't fail %+v", err) } @@ -849,7 +847,7 @@ func (sourceCCIP *SourceCCIPModule) SendRequest( if err != nil { return common.Hash{}, d, nil, fmt.Errorf("failed encoding the options field: %+v", err) } - destChainSelector, err := EvmChainIdToChainSelector(sourceCCIP.DestinationChainId, sourceCCIP.Common.ChainClient.NetworkSimulated()) + destChainSelector, err := EvmChainIdToChainSelector(sourceCCIP.DestinationChainId) if err != nil { return common.Hash{}, d, nil, fmt.Errorf("failed getting the chain selector: %+v", err) } @@ -966,11 +964,11 @@ func (destCCIP *DestCCIPModule) DeployContracts( } destCCIP.LoadContracts(lane) - sourceChainSelector, err := EvmChainIdToChainSelector(destCCIP.SourceChainId, sourceCCIP.Common.ChainClient.NetworkSimulated()) + sourceChainSelector, err := EvmChainIdToChainSelector(destCCIP.SourceChainId) if err != nil { return errors.WithStack(err) } - destChainSelector, err := EvmChainIdToChainSelector(destCCIP.Common.ChainClient.GetChainID().Uint64(), destCCIP.Common.ChainClient.NetworkSimulated()) + destChainSelector, err := EvmChainIdToChainSelector(destCCIP.Common.ChainClient.GetChainID().Uint64()) if err != nil { return errors.WithStack(err) } @@ -1098,7 +1096,7 @@ func (destCCIP *DestCCIPModule) DeployContracts( } // apply offramp updates - _, err = destCCIP.Common.Router.AddOffRamp(destCCIP.OffRamp.EthAddress, destCCIP.SourceChainId) + _, err = destCCIP.Common.Router.AddOffRamp(destCCIP.OffRamp.EthAddress, sourceChainSelector) if err != nil { return fmt.Errorf("setting offramp as fee updater shouldn't fail %+v", err) } diff --git a/integration-tests/contracts/ccip/contract_models.go b/integration-tests/contracts/ccip/contract_models.go index a7e9e4a893..1cfcbb0f11 100644 --- a/integration-tests/contracts/ccip/contract_models.go +++ b/integration-tests/contracts/ccip/contract_models.go @@ -3,6 +3,7 @@ package ccip import ( "context" "math/big" + "strconv" "github.com/ethereum/go-ethereum/accounts/abi/bind" "github.com/ethereum/go-ethereum/common" @@ -427,16 +428,17 @@ func (r *Router) Address() string { return r.EthAddress.Hex() } -func (r *Router) SetOnRamp(chainID uint64, onRamp common.Address) error { +func (r *Router) SetOnRamp(chainSelector uint64, onRamp common.Address) error { opts, err := r.client.TransactionOpts(r.client.GetDefaultWallet()) if err != nil { return err } log.Info(). Str("Router", r.Address()). + Str("ChainSelector", strconv.FormatUint(chainSelector, 10)). Msg("Setting on ramp for r") - tx, err := r.Instance.ApplyRampUpdates(opts, []router.RouterOnRamp{{DestChainSelector: chainID, OnRamp: onRamp}}, nil, nil) + tx, err := r.Instance.ApplyRampUpdates(opts, []router.RouterOnRamp{{DestChainSelector: chainSelector, OnRamp: onRamp}}, nil, nil) if err != nil { return err } @@ -464,6 +466,7 @@ func (r *Router) CCIPSend(destChainSelector uint64, msg router.ClientEVM2AnyMess Str("router", r.Address()). Str("txHash", tx.Hash().Hex()). Str("Network Name", r.client.GetNetworkConfig().Name). + Str("chain selector", strconv.FormatUint(destChainSelector, 10)). Msg("msg is sent") return tx, r.client.ProcessTransaction(tx) } diff --git a/integration-tests/load/ccip_loadgen.go b/integration-tests/load/ccip_loadgen.go index ad959eccbf..a3ceb3be9b 100644 --- a/integration-tests/load/ccip_loadgen.go +++ b/integration-tests/load/ccip_loadgen.go @@ -161,7 +161,7 @@ func (c *CCIPE2ELoad) Call(_ *wasp.Generator) *wasp.CallResult { var sendTx *types.Transaction var err error - destChainSelector, err := actions.EvmChainIdToChainSelector(sourceCCIP.DestinationChainId, c.Lane.Dest.Common.ChainClient.NetworkSimulated()) + destChainSelector, err := actions.EvmChainIdToChainSelector(sourceCCIP.DestinationChainId) if err != nil { res.Error = err.Error() res.Failed = true