From 4f44dce692fd0ecd0343a6a32ae5c4d2e085e562 Mon Sep 17 00:00:00 2001 From: Balamurali Gopalswami Date: Fri, 6 Dec 2024 10:04:46 -0500 Subject: [PATCH] Adopting mock lbtc token pool contract in the test --- .../ccip-tests/actions/ccip_helpers.go | 9 +- .../ccip-tests/contracts/contract_deployer.go | 121 +----------------- .../ccip-tests/contracts/contract_models.go | 10 +- 3 files changed, 14 insertions(+), 126 deletions(-) diff --git a/integration-tests/ccip-tests/actions/ccip_helpers.go b/integration-tests/ccip-tests/actions/ccip_helpers.go index 45e24d5fa9..e45cf27ea4 100644 --- a/integration-tests/ccip-tests/actions/ccip_helpers.go +++ b/integration-tests/ccip-tests/actions/ccip_helpers.go @@ -150,7 +150,6 @@ func GetUSDCDomain(networkName string, simulated bool) (uint32, error) { if val, ok := lookup[networkName]; ok { return val, nil } - return 0, fmt.Errorf("USDC domain not found for chain %s", networkName) } @@ -931,7 +930,7 @@ func (ccipModule *CCIPCommon) DeployContracts( if err != nil { return fmt.Errorf("granting minter role to token transmitter shouldn't fail %w", err) } - } else if ccipModule.IsLBTCDeployment() && i == 1 { + } else if ccipModule.IsLBTCDeployment() && i == 0 { // if it's LBTC deployment, we deploy the burn mint token 677 with decimal 8 and cast it to ERC20Token lbtcToken, err := ccipModule.tokenDeployer.DeployCustomBurnMintERC677Token("Lombard LBTC", "LBTC", uint8(18), new(big.Int).Mul(big.NewInt(1e6), big.NewInt(1e18))) if err != nil { @@ -1005,10 +1004,10 @@ func (ccipModule *CCIPCommon) DeployContracts( } ccipModule.BridgeTokenPools = append(ccipModule.BridgeTokenPools, usdcPool) - } else if ccipModule.IsLBTCDeployment() && i == 1 { - lbtcPool, err := ccipModule.tokenDeployer.DeployBurnAndMintTokenPoolContract(token.Address(), *ccipModule.RMNContract, ccipModule.Router.Instance.Address()) + } else if ccipModule.IsLBTCDeployment() && i == 0 { + lbtcPool, err := ccipModule.tokenDeployer.DeployLBTCTokenPoolContract(token.Address(), *ccipModule.RMNContract, ccipModule.Router.Instance.Address()) if err != nil { - return fmt.Errorf("deploying burn and mint bridge Token pool(lbtc) shouldn't fail %w", err) + return fmt.Errorf("deploying mock lbtc bridge token pool shouldn't fail %w", err) } ccipModule.BridgeTokenPools = append(ccipModule.BridgeTokenPools, lbtcPool) diff --git a/integration-tests/ccip-tests/contracts/contract_deployer.go b/integration-tests/ccip-tests/contracts/contract_deployer.go index 7636f778ba..a39f7b5c93 100644 --- a/integration-tests/ccip-tests/contracts/contract_deployer.go +++ b/integration-tests/ccip-tests/contracts/contract_deployer.go @@ -23,7 +23,7 @@ import ( "github.com/smartcontractkit/chainlink-common/pkg/config" "github.com/smartcontractkit/chainlink-testing-framework/lib/blockchain" - burn_mint_token_pool "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/ccip/generated/burn_mint_token_pool_1_4_0" + "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/ccip/generated/mock_lbtc_token_pool" "github.com/smartcontractkit/chainlink/integration-tests/client" "github.com/smartcontractkit/chainlink/integration-tests/contracts" @@ -526,7 +526,6 @@ func (e *CCIPContractsDeployer) DeployUSDCTokenPoolContract(tokenAddr string, to } } -// TODO: finish converting from USDC to LBTC func (e *CCIPContractsDeployer) NewLBTCTokenPoolContract(addr common.Address) ( *TokenPool, error, @@ -535,7 +534,7 @@ func (e *CCIPContractsDeployer) NewLBTCTokenPoolContract(addr common.Address) ( e.logger.Info().Str("Version", version.String()).Msg("New LBTC Token Pool") switch version { case Latest: - pool, err := usdc_token_pool.NewUSDCTokenPool(addr, wrappers.MustNewWrappedContractBackend(e.evmClient, nil)) + pool, err := mock_lbtc_token_pool.NewMockLBTCTokenPool(addr, wrappers.MustNewWrappedContractBackend(e.evmClient, nil)) if err != nil { return nil, err @@ -556,36 +555,7 @@ func (e *CCIPContractsDeployer) NewLBTCTokenPoolContract(addr common.Address) ( Instance: &TokenPoolWrapper{ Latest: &LatestPool{ PoolInterface: poolInterface, - USDCPool: pool, - }, - }, - EthAddress: addr, - OwnerAddress: common.HexToAddress(e.evmClient.GetDefaultWallet().Address()), - OwnerWallet: e.evmClient.GetDefaultWallet(), - }, err - case V1_4_0: - pool, err := usdc_token_pool_1_4_0.NewUSDCTokenPool(addr, wrappers.MustNewWrappedContractBackend(e.evmClient, nil)) - - if err != nil { - return nil, err - } - e.logger.Info(). - Str("Contract Address", addr.Hex()). - Str("Contract Name", "USDC Token Pool"). - Str("From", e.evmClient.GetDefaultWallet().Address()). - Str("Network Name", e.evmClient.GetNetworkConfig().Name). - Msg("New contract") - poolInterface, err := token_pool_1_4_0.NewTokenPool(addr, wrappers.MustNewWrappedContractBackend(e.evmClient, nil)) - if err != nil { - return nil, err - } - return &TokenPool{ - client: e.evmClient, - logger: e.logger, - Instance: &TokenPoolWrapper{ - V1_4_0: &V1_4_0Pool{ - PoolInterface: poolInterface, - USDCPool: pool, + MockLBTCPool: pool, }, }, EthAddress: addr, @@ -598,8 +568,7 @@ func (e *CCIPContractsDeployer) NewLBTCTokenPoolContract(addr common.Address) ( } -// TODO: finish converting from USDC to LBTC -func (e *CCIPContractsDeployer) DeployLBTCTokenPoolContract(tokenAddr string, tokenMessenger, rmnProxy common.Address, router common.Address) ( +func (e *CCIPContractsDeployer) DeployLBTCTokenPoolContract(tokenAddr string, rmnProxy common.Address, router common.Address) ( *TokenPool, error, ) { @@ -612,30 +581,9 @@ func (e *CCIPContractsDeployer) DeployLBTCTokenPoolContract(tokenAddr string, to auth *bind.TransactOpts, _ bind.ContractBackend, ) (common.Address, *types.Transaction, interface{}, error) { - return usdc_token_pool.DeployUSDCTokenPool( - auth, - wrappers.MustNewWrappedContractBackend(e.evmClient, nil), - tokenMessenger, - token, - []common.Address{}, - rmnProxy, - router, - ) - }) - - if err != nil { - return nil, err - } - return e.NewUSDCTokenPoolContract(*address) - case V1_4_0: - address, _, _, err := e.evmClient.DeployContract("USDC Token Pool", func( - auth *bind.TransactOpts, - _ bind.ContractBackend, - ) (common.Address, *types.Transaction, interface{}, error) { - return usdc_token_pool_1_4_0.DeployUSDCTokenPool( + return mock_lbtc_token_pool.DeployMockLBTCTokenPool( auth, wrappers.MustNewWrappedContractBackend(e.evmClient, nil), - tokenMessenger, token, []common.Address{}, rmnProxy, @@ -652,65 +600,6 @@ func (e *CCIPContractsDeployer) DeployLBTCTokenPoolContract(tokenAddr string, to } } -func (e *CCIPContractsDeployer) DeployBurnAndMintTokenPoolContract(tokenAddr string, rmnProxy common.Address, router common.Address) ( - *TokenPool, - error, -) { - version := VersionMap[TokenPoolContract] - e.logger.Debug().Str("Token", tokenAddr).Msg("Deploying Burn and Mint token pool") - token := common.HexToAddress(tokenAddr) - switch version { - case Latest: - address, _, _, err := e.evmClient.DeployContract("Burn and Mint Token Pool", func( - auth *bind.TransactOpts, - _ bind.ContractBackend, - ) (common.Address, *types.Transaction, interface{}, error) { - return burn_mint_token_pool.DeployBurnMintTokenPool( - auth, - wrappers.MustNewWrappedContractBackend(e.evmClient, nil), - token, - []common.Address{}, - rmnProxy, - router, - ) - }) - - if err != nil { - return nil, err - } - pool, err := burn_mint_token_pool.NewBurnMintTokenPool(*address, wrappers.MustNewWrappedContractBackend(e.evmClient, nil)) - - if err != nil { - return nil, err - } - e.logger.Info(). - Str("Contract Address", address.Hex()). - Str("Contract Name", "USDC Token Pool"). - Str("From", e.evmClient.GetDefaultWallet().Address()). - Str("Network Name", e.evmClient.GetNetworkConfig().Name). - Msg("New contract") - poolInterface, err := token_pool.NewTokenPool(*address, wrappers.MustNewWrappedContractBackend(e.evmClient, nil)) - if err != nil { - return nil, err - } - return &TokenPool{ - client: e.evmClient, - logger: e.logger, - Instance: &TokenPoolWrapper{ - Latest: &LatestPool{ - PoolInterface: poolInterface, - BurnAndMintTokenPool: pool, - }, - }, - EthAddress: *address, - OwnerAddress: common.HexToAddress(e.evmClient.GetDefaultWallet().Address()), - OwnerWallet: e.evmClient.GetDefaultWallet(), - }, err - default: - return nil, fmt.Errorf("version not supported: %s", version) - } -} - func (e *CCIPContractsDeployer) DeployLockReleaseTokenPoolContract(tokenAddr string, rmnProxy common.Address, router common.Address) ( *TokenPool, error, diff --git a/integration-tests/ccip-tests/contracts/contract_models.go b/integration-tests/ccip-tests/contracts/contract_models.go index caeaca1956..6d54117fd7 100644 --- a/integration-tests/ccip-tests/contracts/contract_models.go +++ b/integration-tests/ccip-tests/contracts/contract_models.go @@ -18,7 +18,7 @@ import ( "golang.org/x/exp/rand" "github.com/smartcontractkit/chainlink-testing-framework/lib/blockchain" - burn_mint_token_pool "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/ccip/generated/burn_mint_token_pool_1_4_0" + "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/ccip/generated/mock_lbtc_token_pool" "github.com/smartcontractkit/chainlink/integration-tests/wrappers" @@ -402,10 +402,10 @@ func (l *LinkToken) Transfer(to string, amount *big.Int) error { } type LatestPool struct { - PoolInterface *token_pool.TokenPool - BurnAndMintTokenPool *burn_mint_token_pool.BurnMintTokenPool - LockReleasePool *lock_release_token_pool.LockReleaseTokenPool - USDCPool *usdc_token_pool.USDCTokenPool + PoolInterface *token_pool.TokenPool + LockReleasePool *lock_release_token_pool.LockReleaseTokenPool + USDCPool *usdc_token_pool.USDCTokenPool + MockLBTCPool *mock_lbtc_token_pool.MockLBTCTokenPool } type V1_4_0Pool struct {