From 726df15350ece4f6edcba9620215c5635945b33d Mon Sep 17 00:00:00 2001 From: Christophe Date: Mon, 9 Sep 2024 15:15:56 +0000 Subject: [PATCH 01/16] test: Add claim step for CCTP --- .../tests/e2e/specs/withdrawCctp.cy.ts | 6 ++++++ packages/arb-token-bridge-ui/tests/support/commands.ts | 8 +++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/packages/arb-token-bridge-ui/tests/e2e/specs/withdrawCctp.cy.ts b/packages/arb-token-bridge-ui/tests/e2e/specs/withdrawCctp.cy.ts index f2efd4c2c4..ff5faa958b 100644 --- a/packages/arb-token-bridge-ui/tests/e2e/specs/withdrawCctp.cy.ts +++ b/packages/arb-token-bridge-ui/tests/e2e/specs/withdrawCctp.cy.ts @@ -86,6 +86,9 @@ describe('Withdraw USDC through CCTP', () => { amount: USDCAmountToSend, symbol: 'USDC' }) + cy.findClaimButton(USDCAmountToSend.toString(), { timeout: 60_000 }).click() + cy.allowMetamaskToSwitchNetwork() + cy.rejectMetamaskTransaction() }) it('should initiate withdrawing USDC to custom destination address through CCTP successfully', () => { @@ -110,5 +113,8 @@ describe('Withdraw USDC through CCTP', () => { cy.findTransactionDetailsCustomDestinationAddress( Cypress.env('CUSTOM_DESTINATION_ADDRESS') ) + cy.findClaimButton(USDCAmountToSend.toString(), { timeout: 60_000 }).click() + cy.allowMetamaskToSwitchNetwork() + cy.rejectMetamaskTransaction() }) }) diff --git a/packages/arb-token-bridge-ui/tests/support/commands.ts b/packages/arb-token-bridge-ui/tests/support/commands.ts index ca7c54442d..59328ccc9e 100644 --- a/packages/arb-token-bridge-ui/tests/support/commands.ts +++ b/packages/arb-token-bridge-ui/tests/support/commands.ts @@ -8,6 +8,7 @@ // *********************************************** import '@testing-library/cypress/add-commands' +import { SelectorMatcherOptions } from '@testing-library/cypress' import { NetworkType, NetworkName, @@ -296,8 +297,13 @@ export function findTransactionInTransactionHistory({ } export function findClaimButton( - amountToClaim: string + amountToClaim: string, + options?: SelectorMatcherOptions ): Cypress.Chainable> { + if (options) { + return cy.findByLabelText(`Claim ${amountToClaim}`, options) + } + return cy.findByLabelText(`Claim ${amountToClaim}`) } From 6e794a0f4e4abf93c394517d50071435fd26c2db Mon Sep 17 00:00:00 2001 From: Christophe Date: Mon, 9 Sep 2024 15:38:04 +0000 Subject: [PATCH 02/16] Fix findClaimButton label --- .../tests/e2e/specs/withdrawCctp.cy.ts | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/packages/arb-token-bridge-ui/tests/e2e/specs/withdrawCctp.cy.ts b/packages/arb-token-bridge-ui/tests/e2e/specs/withdrawCctp.cy.ts index ff5faa958b..101d47e11f 100644 --- a/packages/arb-token-bridge-ui/tests/e2e/specs/withdrawCctp.cy.ts +++ b/packages/arb-token-bridge-ui/tests/e2e/specs/withdrawCctp.cy.ts @@ -3,6 +3,7 @@ */ import { CommonAddress } from 'packages/arb-token-bridge-ui/src/util/CommonAddressUtils' +import { formatAmount } from 'packages/arb-token-bridge-ui/src/util/NumberUtils' // common function for this cctp withdrawal export const confirmAndApproveCctpWithdrawal = () => { @@ -86,7 +87,12 @@ describe('Withdraw USDC through CCTP', () => { amount: USDCAmountToSend, symbol: 'USDC' }) - cy.findClaimButton(USDCAmountToSend.toString(), { timeout: 60_000 }).click() + cy.findClaimButton( + formatAmount(USDCAmountToSend, { + symbol: 'USDC' + }), + { timeout: 60_000 } + ).click() cy.allowMetamaskToSwitchNetwork() cy.rejectMetamaskTransaction() }) @@ -113,7 +119,12 @@ describe('Withdraw USDC through CCTP', () => { cy.findTransactionDetailsCustomDestinationAddress( Cypress.env('CUSTOM_DESTINATION_ADDRESS') ) - cy.findClaimButton(USDCAmountToSend.toString(), { timeout: 60_000 }).click() + cy.findClaimButton( + formatAmount(USDCAmountToSend, { + symbol: 'USDC' + }), + { timeout: 60_000 } + ).click() cy.allowMetamaskToSwitchNetwork() cy.rejectMetamaskTransaction() }) From 2a252e5ee571a455ad6f8e4b62e74f20a130f0cd Mon Sep 17 00:00:00 2001 From: Christophe Date: Mon, 9 Sep 2024 16:40:19 +0000 Subject: [PATCH 03/16] Create deposit before running tests --- .../synpress.cctp.config.ts | 74 +++++++++++++++---- .../tests/e2e/specs/depositCctp.cy.ts | 15 ++++ 2 files changed, 74 insertions(+), 15 deletions(-) diff --git a/packages/arb-token-bridge-ui/synpress.cctp.config.ts b/packages/arb-token-bridge-ui/synpress.cctp.config.ts index 27b4b10552..15e8109c9d 100644 --- a/packages/arb-token-bridge-ui/synpress.cctp.config.ts +++ b/packages/arb-token-bridge-ui/synpress.cctp.config.ts @@ -1,4 +1,4 @@ -import { BigNumber, Wallet, utils } from 'ethers' +import { BigNumber, Contract, ContractFactory, Wallet, utils } from 'ethers' import { defineConfig } from 'cypress' import { Provider, StaticJsonRpcProvider } from '@ethersproject/providers' import synpressPlugins from '@synthetixio/synpress/plugins' @@ -13,6 +13,9 @@ import { import specFiles from './tests/e2e/cctp.json' import { CommonAddress } from './src/util/CommonAddressUtils' import { ERC20__factory } from '@arbitrum/sdk/dist/lib/abi/factories/ERC20__factory' +import { TokenMessengerAbi } from './src/util/cctp/TokenMessengerAbi' +import { ChainDomain } from './src/pages/api/cctp/[type]' +import { Address } from 'wagmi' export async function fundUsdc({ address, // wallet address where funding is required @@ -119,21 +122,53 @@ async function fundWallets() { const usdcAmount = utils.parseUnits('0.0006', 6) const ethAmountSepolia = utils.parseEther('0.01') const ethAmountArbSepolia = utils.parseEther('0.002') - const ethPromises: (() => Promise)[] = [] - const usdcPromises: (() => Promise)[] = [] + // const ethPromises: (() => Promise)[] = [] + // const usdcPromises: (() => Promise)[] = [] + + // if (tests.some(testFile => testFile.includes('deposit'))) { + // ethPromises.push(fundEthHelper('sepolia')) + // usdcPromises.push(fundUsdcHelper('sepolia')) + // } + + // if (tests.some(testFile => testFile.includes('withdraw'))) { + // ethPromises.push(fundEthHelper('arbSepolia')) + // usdcPromises.push(fundUsdcHelper('arbSepolia')) + // } + + // await Promise.all(ethPromises.map(fn => fn())) + // await Promise.all(usdcPromises.map(fn => fn())) + await fundEthHelper('sepolia')() + await fundUsdcHelper('sepolia')() +} - if (tests.some(testFile => testFile.includes('deposit'))) { - ethPromises.push(fundEthHelper('sepolia')) - usdcPromises.push(fundUsdcHelper('sepolia')) - } +async function createDepositTx(destinationAddress: Address) { + const signer = userWallet.connect(sepoliaProvider) + const usdcContract = ERC20__factory.connect( + CommonAddress.Sepolia.USDC, + signer + ) - if (tests.some(testFile => testFile.includes('withdraw'))) { - ethPromises.push(fundEthHelper('arbSepolia')) - usdcPromises.push(fundUsdcHelper('arbSepolia')) - } + const tx = await usdcContract.functions.approve( + CommonAddress.Sepolia.tokenMessengerContractAddress, + utils.parseUnits('0.00011', 6) + ) + + await tx.wait() + + const tokenMessenger = new Contract( + CommonAddress.Sepolia.tokenMessengerContractAddress, + TokenMessengerAbi, + signer + ) + + await tokenMessenger.deployed() - await Promise.all(ethPromises.map(fn => fn())) - await Promise.all(usdcPromises.map(fn => fn())) + return await tokenMessenger.depositForBurn( + utils.parseUnits('0.00011', 6), + ChainDomain.ArbitrumOne, + utils.hexlify(utils.zeroPad(destinationAddress, 32)), + CommonAddress.Sepolia.USDC + ) } export default defineConfig({ @@ -144,12 +179,21 @@ export default defineConfig({ await fundWallets() + const customAddress = await getCustomDestinationAddress() config.env.PRIVATE_KEY = userWallet.privateKey config.env.PRIVATE_KEY_CCTP = process.env.PRIVATE_KEY_CCTP config.env.SEPOLIA_INFURA_RPC_URL = sepoliaRpcUrl config.env.ARB_SEPOLIA_INFURA_RPC_URL = arbSepoliaRpcUrl - config.env.CUSTOM_DESTINATION_ADDRESS = - await getCustomDestinationAddress() + config.env.CUSTOM_DESTINATION_ADDRESS = customAddress + + /** + * Currently, we can't confirm transaction on Sepolia, we need to programmatically deposit on Sepolia + * And claim on ArbSepolia + */ + await Promise.all([ + createDepositTx(userWallet.address as Address), + createDepositTx(customAddress as Address) + ]) setupCypressTasks(on, { requiresNetworkSetup: false }) synpressPlugins(on, config) diff --git a/packages/arb-token-bridge-ui/tests/e2e/specs/depositCctp.cy.ts b/packages/arb-token-bridge-ui/tests/e2e/specs/depositCctp.cy.ts index 777ceafc74..416c190e23 100644 --- a/packages/arb-token-bridge-ui/tests/e2e/specs/depositCctp.cy.ts +++ b/packages/arb-token-bridge-ui/tests/e2e/specs/depositCctp.cy.ts @@ -4,6 +4,7 @@ import { zeroToLessThanOneETH } from '../../support/common' import { CommonAddress } from '../../../src/util/CommonAddressUtils' +import { formatAmount } from 'packages/arb-token-bridge-ui/src/util/NumberUtils' // common function for this cctp deposit const confirmAndApproveCctpDeposit = () => { @@ -104,6 +105,20 @@ describe('Deposit USDC through CCTP', () => { // timeout: 60_000 // } // }) + + // We have setup deposit transactions before running tests + cy.wait(40_000) + cy.rejectMetamaskTransaction() + + cy.openTransactionsPanel('pending') + cy.findClaimButton( + formatAmount(USDCAmountToSend, { + symbol: 'USDC' + }), + { timeout: 80_000 } + ).click() + cy.allowMetamaskToSwitchNetwork() + cy.confirmMetamaskTransaction(undefined) }) /** From bbb1e10b000839017046b9c29d068cf18326c695 Mon Sep 17 00:00:00 2001 From: Christophe Date: Wed, 18 Sep 2024 08:58:51 +0000 Subject: [PATCH 04/16] WIP --- packages/arb-token-bridge-ui/synpress.cctp.config.ts | 11 ++++++----- .../tests/e2e/specs/depositCctp.cy.ts | 1 + 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/packages/arb-token-bridge-ui/synpress.cctp.config.ts b/packages/arb-token-bridge-ui/synpress.cctp.config.ts index 67547f8ddd..33bdb98b4a 100644 --- a/packages/arb-token-bridge-ui/synpress.cctp.config.ts +++ b/packages/arb-token-bridge-ui/synpress.cctp.config.ts @@ -139,6 +139,7 @@ async function fundWallets() { // await Promise.all(usdcPromises.map(fn => fn())) await fundEthHelper('sepolia')() await fundUsdcHelper('sepolia')() + await fundEthHelper('arbSepolia')() } async function createDepositTx(destinationAddress: Address) { @@ -163,12 +164,14 @@ async function createDepositTx(destinationAddress: Address) { await tokenMessenger.deployed() - return await tokenMessenger.depositForBurn( + const depositForBurnTx = await tokenMessenger.functions.depositForBurn( utils.parseUnits('0.00011', 6), ChainDomain.ArbitrumOne, utils.hexlify(utils.zeroPad(destinationAddress, 32)), CommonAddress.Sepolia.USDC ) + + await depositForBurnTx.wait() } export default defineConfig({ @@ -190,10 +193,8 @@ export default defineConfig({ * Currently, we can't confirm transaction on Sepolia, we need to programmatically deposit on Sepolia * And claim on ArbSepolia */ - await Promise.all([ - createDepositTx(userWallet.address as Address), - createDepositTx(customAddress as Address) - ]) + await createDepositTx(userWallet.address as Address) + await createDepositTx(customAddress as Address) setupCypressTasks(on, { requiresNetworkSetup: false }) synpressPlugins(on, config) diff --git a/packages/arb-token-bridge-ui/tests/e2e/specs/depositCctp.cy.ts b/packages/arb-token-bridge-ui/tests/e2e/specs/depositCctp.cy.ts index 416c190e23..42de9e54cf 100644 --- a/packages/arb-token-bridge-ui/tests/e2e/specs/depositCctp.cy.ts +++ b/packages/arb-token-bridge-ui/tests/e2e/specs/depositCctp.cy.ts @@ -110,6 +110,7 @@ describe('Deposit USDC through CCTP', () => { cy.wait(40_000) cy.rejectMetamaskTransaction() + cy.pause() cy.openTransactionsPanel('pending') cy.findClaimButton( formatAmount(USDCAmountToSend, { From 1b91eb9260be2a123aea402997d5b10473bde1ff Mon Sep 17 00:00:00 2001 From: Christophe Date: Wed, 18 Sep 2024 13:59:01 +0000 Subject: [PATCH 05/16] Add claim step in withdrawal --- .../synpress.cctp.config.ts | 51 ++++++++++--------- .../tests/e2e/specs/depositCctp.cy.ts | 8 +-- .../tests/e2e/specs/withdrawCctp.cy.ts | 21 +++++++- 3 files changed, 52 insertions(+), 28 deletions(-) diff --git a/packages/arb-token-bridge-ui/synpress.cctp.config.ts b/packages/arb-token-bridge-ui/synpress.cctp.config.ts index 33bdb98b4a..2304695ce4 100644 --- a/packages/arb-token-bridge-ui/synpress.cctp.config.ts +++ b/packages/arb-token-bridge-ui/synpress.cctp.config.ts @@ -79,7 +79,10 @@ async function fundWallets() { const userWalletAddress = userWallet.address console.log(`Funding wallet ${userWalletAddress}`) - const fundEthHelper = (network: 'sepolia' | 'arbSepolia') => { + const fundEthHelper = ( + network: 'sepolia' | 'arbSepolia', + amount: BigNumber + ) => { return () => fundEth({ address: userWalletAddress, @@ -87,12 +90,12 @@ async function fundWallets() { ...(network === 'sepolia' ? { provider: sepoliaProvider, - amount: ethAmountSepolia, + amount, networkType: 'parentChain' } : { provider: arbSepoliaProvider, - amount: ethAmountArbSepolia, + amount, networkType: 'childChain' }) }) @@ -125,24 +128,26 @@ async function fundWallets() { const ethPromises: (() => Promise)[] = [] const usdcPromises: (() => Promise)[] = [] - // if (tests.some(testFile => testFile.includes('deposit'))) { - // ethPromises.push(fundEthHelper('sepolia')) - // usdcPromises.push(fundUsdcHelper('sepolia')) - // } - - // if (tests.some(testFile => testFile.includes('withdraw'))) { - // ethPromises.push(fundEthHelper('arbSepolia')) - // usdcPromises.push(fundUsdcHelper('arbSepolia')) - // } - - // await Promise.all(ethPromises.map(fn => fn())) - // await Promise.all(usdcPromises.map(fn => fn())) - await fundEthHelper('sepolia')() - await fundUsdcHelper('sepolia')() - await fundEthHelper('arbSepolia')() + if (tests.some(testFile => testFile.includes('deposit'))) { + ethPromises.push(fundEthHelper('sepolia', ethAmountSepolia)) + usdcPromises.push(fundUsdcHelper('sepolia')) + } + + if (tests.some(testFile => testFile.includes('withdraw'))) { + // Add ETH and USDC on Sepolia, to generate deposit tx on Sepolia + ethPromises.push( + fundEthHelper('arbSepolia', ethAmountArbSepolia), + fundEthHelper('sepolia', utils.parseEther('0.01')) + ) + usdcPromises.push(fundUsdcHelper('arbSepolia'), fundUsdcHelper('sepolia')) + } + + await Promise.all(ethPromises.map(fn => fn())) + await Promise.all(usdcPromises.map(fn => fn())) } -async function createDepositTx(destinationAddress: Address) { +async function createDepositTx(destinationAddress: Address, amount: string) { + console.log(`Creating CCTP deposit transaction for ${destinationAddress}`) const signer = userWallet.connect(sepoliaProvider) const usdcContract = ERC20__factory.connect( CommonAddress.Sepolia.USDC, @@ -151,7 +156,7 @@ async function createDepositTx(destinationAddress: Address) { const tx = await usdcContract.functions.approve( CommonAddress.Sepolia.tokenMessengerContractAddress, - utils.parseUnits('0.00011', 6) + utils.parseUnits(amount, 6) ) await tx.wait() @@ -165,7 +170,7 @@ async function createDepositTx(destinationAddress: Address) { await tokenMessenger.deployed() const depositForBurnTx = await tokenMessenger.functions.depositForBurn( - utils.parseUnits('0.00011', 6), + utils.parseUnits(amount, 6), ChainDomain.ArbitrumOne, utils.hexlify(utils.zeroPad(destinationAddress, 32)), CommonAddress.Sepolia.USDC @@ -193,8 +198,8 @@ export default defineConfig({ * Currently, we can't confirm transaction on Sepolia, we need to programmatically deposit on Sepolia * And claim on ArbSepolia */ - await createDepositTx(userWallet.address as Address) - await createDepositTx(customAddress as Address) + await createDepositTx(userWallet.address as Address, '0.00011') + // await createDepositTx(customAddress as Address, '0.00012') setupCypressTasks(on, { requiresNetworkSetup: false }) synpressPlugins(on, config) diff --git a/packages/arb-token-bridge-ui/tests/e2e/specs/depositCctp.cy.ts b/packages/arb-token-bridge-ui/tests/e2e/specs/depositCctp.cy.ts index 42de9e54cf..57326a948b 100644 --- a/packages/arb-token-bridge-ui/tests/e2e/specs/depositCctp.cy.ts +++ b/packages/arb-token-bridge-ui/tests/e2e/specs/depositCctp.cy.ts @@ -110,15 +110,17 @@ describe('Deposit USDC through CCTP', () => { cy.wait(40_000) cy.rejectMetamaskTransaction() - cy.pause() cy.openTransactionsPanel('pending') cy.findClaimButton( - formatAmount(USDCAmountToSend, { + formatAmount(0.00011, { symbol: 'USDC' }), { timeout: 80_000 } ).click() - cy.allowMetamaskToSwitchNetwork() + cy.allowMetamaskToSwitchNetwork().then(approved => { + expect(approved).to.be.true + }) + cy.wait(15_000) cy.confirmMetamaskTransaction(undefined) }) diff --git a/packages/arb-token-bridge-ui/tests/e2e/specs/withdrawCctp.cy.ts b/packages/arb-token-bridge-ui/tests/e2e/specs/withdrawCctp.cy.ts index 03d79910d8..cd3d48161a 100644 --- a/packages/arb-token-bridge-ui/tests/e2e/specs/withdrawCctp.cy.ts +++ b/packages/arb-token-bridge-ui/tests/e2e/specs/withdrawCctp.cy.ts @@ -78,7 +78,7 @@ describe('Withdraw USDC through CCTP', () => { cy.confirmSpending(USDCAmountToSend.toString()) // eslint-disable-next-line cy.wait(40_000) - cy.confirmMetamaskTransaction(undefined) + cy.confirmMetamaskTransaction({ gasConfig: 'aggressive' }) cy.findTransactionInTransactionHistory({ amount: USDCAmountToSend, symbol: 'USDC' @@ -87,12 +87,29 @@ describe('Withdraw USDC through CCTP', () => { formatAmount(USDCAmountToSend, { symbol: 'USDC' }), - { timeout: 60_000 } + { timeout: 120_000 } ).click() cy.allowMetamaskToSwitchNetwork() + // We can't confirm transaction on Sepolia for the moment cy.rejectMetamaskTransaction() }) + it('should claim deposit', () => { + const amount = 0.00011 + const formattedAmount = formatAmount(0.00011, { + symbol: 'USDC' + }) + cy.openTransactionsPanel('pending') + cy.findTransactionInTransactionHistory({ + amount, + symbol: 'USDC' + }) + cy.findClaimButton(formattedAmount, { timeout: 80_000 }).click() + cy.confirmMetamaskTransaction(undefined) + cy.findByLabelText('show settled transactions').should('be.visible').click() + cy.findByText(formattedAmount).should('be.visible') + }) + it('should initiate withdrawing USDC to custom destination address through CCTP successfully', () => { const USDCAmountToSend = 0.00011 cy.typeAmount(USDCAmountToSend) From c4184650f610b9694ec2b91061b7656d4dc319a8 Mon Sep 17 00:00:00 2001 From: Christophe Date: Wed, 18 Sep 2024 14:23:06 +0000 Subject: [PATCH 06/16] Refine --- .../synpress.cctp.config.ts | 59 ++++++++++++++----- .../tests/e2e/specs/depositCctp.cy.ts | 19 +++++- .../tests/e2e/specs/withdrawCctp.cy.ts | 20 ++++++- 3 files changed, 81 insertions(+), 17 deletions(-) diff --git a/packages/arb-token-bridge-ui/synpress.cctp.config.ts b/packages/arb-token-bridge-ui/synpress.cctp.config.ts index 2304695ce4..5b55b8dbec 100644 --- a/packages/arb-token-bridge-ui/synpress.cctp.config.ts +++ b/packages/arb-token-bridge-ui/synpress.cctp.config.ts @@ -129,7 +129,11 @@ async function fundWallets() { const usdcPromises: (() => Promise)[] = [] if (tests.some(testFile => testFile.includes('deposit'))) { - ethPromises.push(fundEthHelper('sepolia', ethAmountSepolia)) + // Add ETH and USDC on Sepolia, to generate deposit tx on Sepolia + ethPromises.push( + fundEthHelper('sepolia', ethAmountSepolia), + fundEthHelper('arbSepolia', utils.parseEther('0.01')) + ) usdcPromises.push(fundUsdcHelper('sepolia')) } @@ -146,23 +150,34 @@ async function fundWallets() { await Promise.all(usdcPromises.map(fn => fn())) } -async function createDepositTx(destinationAddress: Address, amount: string) { - console.log(`Creating CCTP deposit transaction for ${destinationAddress}`) - const signer = userWallet.connect(sepoliaProvider) - const usdcContract = ERC20__factory.connect( - CommonAddress.Sepolia.USDC, - signer - ) +async function createCctpTx( + type: 'deposit' | 'withdrawal', + destinationAddress: Address, + amount: string +) { + console.log(`Creating CCTP transaction for ${destinationAddress}`) + const provider = type === 'deposit' ? sepoliaProvider : arbSepoliaProvider + const usdcAddress = + type === 'deposit' + ? CommonAddress.Sepolia.USDC + : CommonAddress.ArbitrumSepolia.USDC + const tokenMessengerContractAddress = + type === 'deposit' + ? CommonAddress.Sepolia.tokenMessengerContractAddress + : CommonAddress.ArbitrumSepolia.tokenMessengerContractAddress + + const signer = userWallet.connect(provider) + const usdcContract = ERC20__factory.connect(usdcAddress, signer) const tx = await usdcContract.functions.approve( - CommonAddress.Sepolia.tokenMessengerContractAddress, + tokenMessengerContractAddress, utils.parseUnits(amount, 6) ) await tx.wait() const tokenMessenger = new Contract( - CommonAddress.Sepolia.tokenMessengerContractAddress, + tokenMessengerContractAddress, TokenMessengerAbi, signer ) @@ -171,9 +186,9 @@ async function createDepositTx(destinationAddress: Address, amount: string) { const depositForBurnTx = await tokenMessenger.functions.depositForBurn( utils.parseUnits(amount, 6), - ChainDomain.ArbitrumOne, + type === 'deposit' ? ChainDomain.ArbitrumOne : ChainDomain.Ethereum, utils.hexlify(utils.zeroPad(destinationAddress, 32)), - CommonAddress.Sepolia.USDC + usdcAddress ) await depositForBurnTx.wait() @@ -197,9 +212,25 @@ export default defineConfig({ /** * Currently, we can't confirm transaction on Sepolia, we need to programmatically deposit on Sepolia * And claim on ArbSepolia + * + * - Create one deposit transaction, claimed in withdrawCctp + * - Create one deposit transaction to custom address, claimed in withdrawCctp + * - Create one withdraw transaction, rejected in depositCctp + * - Create one withdraw transaction to custom address, rejected in depositCctp */ - await createDepositTx(userWallet.address as Address, '0.00011') - // await createDepositTx(customAddress as Address, '0.00012') + if (tests.some(testFile => testFile.includes('deposit'))) { + await createCctpTx( + 'withdrawal', + userWallet.address as Address, + '0.00014' + ) + await createCctpTx('withdrawal', customAddress as Address, '0.00015') + } + + if (tests.some(testFile => testFile.includes('withdraw'))) { + await createCctpTx('deposit', userWallet.address as Address, '0.00012') + await createCctpTx('deposit', customAddress as Address, '0.00013') + } setupCypressTasks(on, { requiresNetworkSetup: false }) synpressPlugins(on, config) diff --git a/packages/arb-token-bridge-ui/tests/e2e/specs/depositCctp.cy.ts b/packages/arb-token-bridge-ui/tests/e2e/specs/depositCctp.cy.ts index 57326a948b..10af4bfd80 100644 --- a/packages/arb-token-bridge-ui/tests/e2e/specs/depositCctp.cy.ts +++ b/packages/arb-token-bridge-ui/tests/e2e/specs/depositCctp.cy.ts @@ -109,10 +109,27 @@ describe('Deposit USDC through CCTP', () => { // We have setup deposit transactions before running tests cy.wait(40_000) cy.rejectMetamaskTransaction() + }) + + it('should claim withdrawal', () => { + cy.openTransactionsPanel('pending') + cy.findClaimButton( + formatAmount(0.00014, { + symbol: 'USDC' + }), + { timeout: 80_000 } + ).click() + cy.allowMetamaskToSwitchNetwork().then(approved => { + expect(approved).to.be.true + }) + cy.wait(15_000) + cy.confirmMetamaskTransaction(undefined) + }) + it('should claim withdrawal to a custom address', () => { cy.openTransactionsPanel('pending') cy.findClaimButton( - formatAmount(0.00011, { + formatAmount(0.00015, { symbol: 'USDC' }), { timeout: 80_000 } diff --git a/packages/arb-token-bridge-ui/tests/e2e/specs/withdrawCctp.cy.ts b/packages/arb-token-bridge-ui/tests/e2e/specs/withdrawCctp.cy.ts index cd3d48161a..9faa609ecf 100644 --- a/packages/arb-token-bridge-ui/tests/e2e/specs/withdrawCctp.cy.ts +++ b/packages/arb-token-bridge-ui/tests/e2e/specs/withdrawCctp.cy.ts @@ -95,8 +95,24 @@ describe('Withdraw USDC through CCTP', () => { }) it('should claim deposit', () => { - const amount = 0.00011 - const formattedAmount = formatAmount(0.00011, { + const amount = 0.00012 + const formattedAmount = formatAmount(amount, { + symbol: 'USDC' + }) + cy.openTransactionsPanel('pending') + cy.findTransactionInTransactionHistory({ + amount, + symbol: 'USDC' + }) + cy.findClaimButton(formattedAmount, { timeout: 80_000 }).click() + cy.confirmMetamaskTransaction(undefined) + cy.findByLabelText('show settled transactions').should('be.visible').click() + cy.findByText(formattedAmount).should('be.visible') + }) + + it('should claim deposit to a custom address', () => { + const amount = 0.00013 + const formattedAmount = formatAmount(amount, { symbol: 'USDC' }) cy.openTransactionsPanel('pending') From 4df70f283a14de6c5101bba9164c20b9d6130d9a Mon Sep 17 00:00:00 2001 From: Christophe Date: Wed, 18 Sep 2024 14:50:35 +0000 Subject: [PATCH 07/16] Refine --- .../synpress.cctp.config.ts | 92 ++++++++++--------- 1 file changed, 47 insertions(+), 45 deletions(-) diff --git a/packages/arb-token-bridge-ui/synpress.cctp.config.ts b/packages/arb-token-bridge-ui/synpress.cctp.config.ts index 5b55b8dbec..2af32a16a5 100644 --- a/packages/arb-token-bridge-ui/synpress.cctp.config.ts +++ b/packages/arb-token-bridge-ui/synpress.cctp.config.ts @@ -83,39 +83,40 @@ async function fundWallets() { network: 'sepolia' | 'arbSepolia', amount: BigNumber ) => { - return () => - fundEth({ - address: userWalletAddress, - sourceWallet: localWallet, - ...(network === 'sepolia' - ? { - provider: sepoliaProvider, - amount, - networkType: 'parentChain' - } - : { - provider: arbSepoliaProvider, - amount, - networkType: 'childChain' - }) - }) + return fundEth({ + address: userWalletAddress, + sourceWallet: localWallet, + ...(network === 'sepolia' + ? { + provider: sepoliaProvider, + amount, + networkType: 'parentChain' + } + : { + provider: arbSepoliaProvider, + amount, + networkType: 'childChain' + }) + }) } - const fundUsdcHelper = (network: 'sepolia' | 'arbSepolia') => { - return () => - fundUsdc({ - address: userWalletAddress, - sourceWallet: localWallet, - amount: usdcAmount, - ...(network === 'sepolia' - ? { - provider: sepoliaProvider, - networkType: 'parentChain' - } - : { - provider: arbSepoliaProvider, - networkType: 'childChain' - }) - }) + const fundUsdcHelper = ( + network: 'sepolia' | 'arbSepolia', + amount: BigNumber = usdcAmount + ) => { + return fundUsdc({ + address: userWalletAddress, + sourceWallet: localWallet, + amount, + ...(network === 'sepolia' + ? { + provider: sepoliaProvider, + networkType: 'parentChain' + } + : { + provider: arbSepoliaProvider, + networkType: 'childChain' + }) + }) } /** @@ -125,29 +126,30 @@ async function fundWallets() { const usdcAmount = utils.parseUnits('0.00063', 6) const ethAmountSepolia = utils.parseEther('0.025') const ethAmountArbSepolia = utils.parseEther('0.006') - const ethPromises: (() => Promise)[] = [] - const usdcPromises: (() => Promise)[] = [] if (tests.some(testFile => testFile.includes('deposit'))) { - // Add ETH and USDC on Sepolia, to generate deposit tx on Sepolia - ethPromises.push( + // Add ETH and USDC on ArbSepolia, to generate tx on ArbSepolia + await Promise.all([ fundEthHelper('sepolia', ethAmountSepolia), fundEthHelper('arbSepolia', utils.parseEther('0.01')) - ) - usdcPromises.push(fundUsdcHelper('sepolia')) + ]) + await Promise.all([ + fundUsdcHelper('sepolia'), + fundUsdcHelper('arbSepolia', utils.parseUnits('0.00029', 6)) + ]) } if (tests.some(testFile => testFile.includes('withdraw'))) { - // Add ETH and USDC on Sepolia, to generate deposit tx on Sepolia - ethPromises.push( + // Add ETH and USDC on Sepolia, to generate tx on Sepolia + await Promise.all([ fundEthHelper('arbSepolia', ethAmountArbSepolia), fundEthHelper('sepolia', utils.parseEther('0.01')) - ) - usdcPromises.push(fundUsdcHelper('arbSepolia'), fundUsdcHelper('sepolia')) + ]) + await Promise.all([ + fundUsdcHelper('arbSepolia'), + fundUsdcHelper('sepolia', utils.parseUnits('0.00025', 6)) + ]) } - - await Promise.all(ethPromises.map(fn => fn())) - await Promise.all(usdcPromises.map(fn => fn())) } async function createCctpTx( From 4d497e46d9b10d956cb18b172fed60e81faee708 Mon Sep 17 00:00:00 2001 From: Christophe Date: Wed, 18 Sep 2024 15:05:43 +0000 Subject: [PATCH 08/16] Refine --- .../tests/e2e/cypress.d.ts | 4 ++- .../tests/e2e/specs/depositCctp.cy.ts | 32 +++---------------- .../tests/e2e/specs/withdrawCctp.cy.ts | 32 ++----------------- .../tests/support/commands.ts | 19 ++++++++++- 4 files changed, 28 insertions(+), 59 deletions(-) diff --git a/packages/arb-token-bridge-ui/tests/e2e/cypress.d.ts b/packages/arb-token-bridge-ui/tests/e2e/cypress.d.ts index c3ce4b3cc3..77586173f1 100644 --- a/packages/arb-token-bridge-ui/tests/e2e/cypress.d.ts +++ b/packages/arb-token-bridge-ui/tests/e2e/cypress.d.ts @@ -22,7 +22,8 @@ import { findClaimButton, selectTransactionsPanelTab, confirmSpending, - closeTransactionHistoryPanel + closeTransactionHistoryPanel, + claimCctp } from '../support/commands' import { NetworkType, NetworkName } from '../support/common' @@ -67,6 +68,7 @@ declare global { findTransactionInTransactionHistory: typeof findTransactionInTransactionHistory findClaimButton: typeof findClaimButton confirmSpending: typeof confirmSpending + claimCctp: typeof claimCctp } } } diff --git a/packages/arb-token-bridge-ui/tests/e2e/specs/depositCctp.cy.ts b/packages/arb-token-bridge-ui/tests/e2e/specs/depositCctp.cy.ts index 10af4bfd80..b2706a3de8 100644 --- a/packages/arb-token-bridge-ui/tests/e2e/specs/depositCctp.cy.ts +++ b/packages/arb-token-bridge-ui/tests/e2e/specs/depositCctp.cy.ts @@ -111,34 +111,10 @@ describe('Deposit USDC through CCTP', () => { cy.rejectMetamaskTransaction() }) - it('should claim withdrawal', () => { - cy.openTransactionsPanel('pending') - cy.findClaimButton( - formatAmount(0.00014, { - symbol: 'USDC' - }), - { timeout: 80_000 } - ).click() - cy.allowMetamaskToSwitchNetwork().then(approved => { - expect(approved).to.be.true - }) - cy.wait(15_000) - cy.confirmMetamaskTransaction(undefined) - }) - - it('should claim withdrawal to a custom address', () => { - cy.openTransactionsPanel('pending') - cy.findClaimButton( - formatAmount(0.00015, { - symbol: 'USDC' - }), - { timeout: 80_000 } - ).click() - cy.allowMetamaskToSwitchNetwork().then(approved => { - expect(approved).to.be.true - }) - cy.wait(15_000) - cy.confirmMetamaskTransaction(undefined) + it('should claim deposit', () => { + cy.claimCctp(0.00014) + cy.closeTransactionHistoryPanel() + cy.claimCctp(0.00015) }) /** diff --git a/packages/arb-token-bridge-ui/tests/e2e/specs/withdrawCctp.cy.ts b/packages/arb-token-bridge-ui/tests/e2e/specs/withdrawCctp.cy.ts index 9faa609ecf..e6ebe276af 100644 --- a/packages/arb-token-bridge-ui/tests/e2e/specs/withdrawCctp.cy.ts +++ b/packages/arb-token-bridge-ui/tests/e2e/specs/withdrawCctp.cy.ts @@ -95,35 +95,9 @@ describe('Withdraw USDC through CCTP', () => { }) it('should claim deposit', () => { - const amount = 0.00012 - const formattedAmount = formatAmount(amount, { - symbol: 'USDC' - }) - cy.openTransactionsPanel('pending') - cy.findTransactionInTransactionHistory({ - amount, - symbol: 'USDC' - }) - cy.findClaimButton(formattedAmount, { timeout: 80_000 }).click() - cy.confirmMetamaskTransaction(undefined) - cy.findByLabelText('show settled transactions').should('be.visible').click() - cy.findByText(formattedAmount).should('be.visible') - }) - - it('should claim deposit to a custom address', () => { - const amount = 0.00013 - const formattedAmount = formatAmount(amount, { - symbol: 'USDC' - }) - cy.openTransactionsPanel('pending') - cy.findTransactionInTransactionHistory({ - amount, - symbol: 'USDC' - }) - cy.findClaimButton(formattedAmount, { timeout: 80_000 }).click() - cy.confirmMetamaskTransaction(undefined) - cy.findByLabelText('show settled transactions').should('be.visible').click() - cy.findByText(formattedAmount).should('be.visible') + cy.claimCctp(0.00012) + cy.closeTransactionHistoryPanel() + cy.claimCctp(0.00013) }) it('should initiate withdrawing USDC to custom destination address through CCTP successfully', () => { diff --git a/packages/arb-token-bridge-ui/tests/support/commands.ts b/packages/arb-token-bridge-ui/tests/support/commands.ts index 00a430a362..6c59c60f04 100644 --- a/packages/arb-token-bridge-ui/tests/support/commands.ts +++ b/packages/arb-token-bridge-ui/tests/support/commands.ts @@ -17,6 +17,7 @@ import { getL2NetworkConfig } from './common' import { shortenAddress } from '../../src/util/CommonUtils' +import { formatAmount } from 'packages/arb-token-bridge-ui/src/util/NumberUtils' function shouldChangeNetwork(networkName: NetworkName) { // synpress throws if trying to connect to a network we are already connected to @@ -333,6 +334,21 @@ export function confirmSpending( }) } +export function claimCctp(amount: number) { + const formattedAmount = formatAmount(amount, { + symbol: 'USDC' + }) + cy.openTransactionsPanel('pending') + cy.findTransactionInTransactionHistory({ + amount, + symbol: 'USDC' + }) + cy.findClaimButton(formattedAmount, { timeout: 80_000 }).click() + cy.confirmMetamaskTransaction(undefined) + cy.findByLabelText('show settled transactions').should('be.visible').click() + cy.findByText(formattedAmount).should('be.visible') +} + Cypress.Commands.addAll({ connectToApp, login, @@ -355,5 +371,6 @@ Cypress.Commands.addAll({ findTransactionInTransactionHistory, findClaimButton, findTransactionDetailsCustomDestinationAddress, - confirmSpending + confirmSpending, + claimCctp }) From 6621991aa40210beac2531afb49b11ce7c377d9f Mon Sep 17 00:00:00 2001 From: Christophe Date: Wed, 18 Sep 2024 15:19:43 +0000 Subject: [PATCH 09/16] Refine --- .../arb-token-bridge-ui/tests/e2e/specs/depositCctp.cy.ts | 5 +++-- .../tests/e2e/specs/withdrawCctp.cy.ts | 7 ++++--- packages/arb-token-bridge-ui/tests/support/commands.ts | 8 ++++++-- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/packages/arb-token-bridge-ui/tests/e2e/specs/depositCctp.cy.ts b/packages/arb-token-bridge-ui/tests/e2e/specs/depositCctp.cy.ts index b2706a3de8..430f40141b 100644 --- a/packages/arb-token-bridge-ui/tests/e2e/specs/depositCctp.cy.ts +++ b/packages/arb-token-bridge-ui/tests/e2e/specs/depositCctp.cy.ts @@ -112,9 +112,10 @@ describe('Deposit USDC through CCTP', () => { }) it('should claim deposit', () => { - cy.claimCctp(0.00014) + cy.changeMetamaskNetwork('sepolia') + cy.claimCctp(0.00014, { accept: false }) cy.closeTransactionHistoryPanel() - cy.claimCctp(0.00015) + cy.claimCctp(0.00015, { accept: false }) }) /** diff --git a/packages/arb-token-bridge-ui/tests/e2e/specs/withdrawCctp.cy.ts b/packages/arb-token-bridge-ui/tests/e2e/specs/withdrawCctp.cy.ts index e6ebe276af..4fac65dc69 100644 --- a/packages/arb-token-bridge-ui/tests/e2e/specs/withdrawCctp.cy.ts +++ b/packages/arb-token-bridge-ui/tests/e2e/specs/withdrawCctp.cy.ts @@ -95,9 +95,10 @@ describe('Withdraw USDC through CCTP', () => { }) it('should claim deposit', () => { - cy.claimCctp(0.00012) + cy.changeMetamaskNetwork('arbitrum sepolia') + cy.claimCctp(0.00012, { accept: true }) cy.closeTransactionHistoryPanel() - cy.claimCctp(0.00013) + cy.claimCctp(0.00013, { accept: true }) }) it('should initiate withdrawing USDC to custom destination address through CCTP successfully', () => { @@ -133,7 +134,7 @@ describe('Withdraw USDC through CCTP', () => { formatAmount(USDCAmountToSend, { symbol: 'USDC' }), - { timeout: 60_000 } + { timeout: 80_000 } ).click() cy.allowMetamaskToSwitchNetwork() cy.rejectMetamaskTransaction() diff --git a/packages/arb-token-bridge-ui/tests/support/commands.ts b/packages/arb-token-bridge-ui/tests/support/commands.ts index 6c59c60f04..c0f1198b76 100644 --- a/packages/arb-token-bridge-ui/tests/support/commands.ts +++ b/packages/arb-token-bridge-ui/tests/support/commands.ts @@ -334,7 +334,7 @@ export function confirmSpending( }) } -export function claimCctp(amount: number) { +export function claimCctp(amount: number, options: { accept: boolean }) { const formattedAmount = formatAmount(amount, { symbol: 'USDC' }) @@ -344,7 +344,11 @@ export function claimCctp(amount: number) { symbol: 'USDC' }) cy.findClaimButton(formattedAmount, { timeout: 80_000 }).click() - cy.confirmMetamaskTransaction(undefined) + if (options.accept) { + cy.confirmMetamaskTransaction(undefined) + } else { + cy.rejectMetamaskTransaction() + } cy.findByLabelText('show settled transactions').should('be.visible').click() cy.findByText(formattedAmount).should('be.visible') } From 6aaf4382ea3d6463efdb284fe18509686791f59d Mon Sep 17 00:00:00 2001 From: Christophe Date: Wed, 18 Sep 2024 15:24:37 +0000 Subject: [PATCH 10/16] Dont check settled tabs if we rejected --- packages/arb-token-bridge-ui/tests/support/commands.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/arb-token-bridge-ui/tests/support/commands.ts b/packages/arb-token-bridge-ui/tests/support/commands.ts index c0f1198b76..d236530dfb 100644 --- a/packages/arb-token-bridge-ui/tests/support/commands.ts +++ b/packages/arb-token-bridge-ui/tests/support/commands.ts @@ -346,11 +346,11 @@ export function claimCctp(amount: number, options: { accept: boolean }) { cy.findClaimButton(formattedAmount, { timeout: 80_000 }).click() if (options.accept) { cy.confirmMetamaskTransaction(undefined) + cy.findByLabelText('show settled transactions').should('be.visible').click() + cy.findByText(formattedAmount).should('be.visible') } else { cy.rejectMetamaskTransaction() } - cy.findByLabelText('show settled transactions').should('be.visible').click() - cy.findByText(formattedAmount).should('be.visible') } Cypress.Commands.addAll({ From 472b164f380b2af18f4146ea67409ae544469e15 Mon Sep 17 00:00:00 2001 From: Christophe Date: Wed, 18 Sep 2024 15:53:18 +0000 Subject: [PATCH 11/16] Final --- packages/arb-token-bridge-ui/tests/e2e/cctp.json | 5 ----- .../arb-token-bridge-ui/tests/e2e/specs/depositCctp.cy.ts | 1 - .../arb-token-bridge-ui/tests/e2e/specs/withdrawCctp.cy.ts | 4 ---- 3 files changed, 10 deletions(-) diff --git a/packages/arb-token-bridge-ui/tests/e2e/cctp.json b/packages/arb-token-bridge-ui/tests/e2e/cctp.json index daa7e8636c..f1d3f6857d 100644 --- a/packages/arb-token-bridge-ui/tests/e2e/cctp.json +++ b/packages/arb-token-bridge-ui/tests/e2e/cctp.json @@ -1,9 +1,4 @@ [ - { - "name": "Deposit Cctp", - "file": "tests/e2e/specs/**/depositCctp.cy.{js,jsx,ts,tsx}", - "recordVideo": false - }, { "name": "Withdraw Cctp", "file": "tests/e2e/specs/**/withdrawCctp.cy.{js,jsx,ts,tsx}", diff --git a/packages/arb-token-bridge-ui/tests/e2e/specs/depositCctp.cy.ts b/packages/arb-token-bridge-ui/tests/e2e/specs/depositCctp.cy.ts index 430f40141b..f1d39bbf2d 100644 --- a/packages/arb-token-bridge-ui/tests/e2e/specs/depositCctp.cy.ts +++ b/packages/arb-token-bridge-ui/tests/e2e/specs/depositCctp.cy.ts @@ -112,7 +112,6 @@ describe('Deposit USDC through CCTP', () => { }) it('should claim deposit', () => { - cy.changeMetamaskNetwork('sepolia') cy.claimCctp(0.00014, { accept: false }) cy.closeTransactionHistoryPanel() cy.claimCctp(0.00015, { accept: false }) diff --git a/packages/arb-token-bridge-ui/tests/e2e/specs/withdrawCctp.cy.ts b/packages/arb-token-bridge-ui/tests/e2e/specs/withdrawCctp.cy.ts index 4fac65dc69..a89c8eb91c 100644 --- a/packages/arb-token-bridge-ui/tests/e2e/specs/withdrawCctp.cy.ts +++ b/packages/arb-token-bridge-ui/tests/e2e/specs/withdrawCctp.cy.ts @@ -89,13 +89,9 @@ describe('Withdraw USDC through CCTP', () => { }), { timeout: 120_000 } ).click() - cy.allowMetamaskToSwitchNetwork() - // We can't confirm transaction on Sepolia for the moment - cy.rejectMetamaskTransaction() }) it('should claim deposit', () => { - cy.changeMetamaskNetwork('arbitrum sepolia') cy.claimCctp(0.00012, { accept: true }) cy.closeTransactionHistoryPanel() cy.claimCctp(0.00013, { accept: true }) From 67d0425d2b50dfb9904bf3a6a334ea9e3f5c04be Mon Sep 17 00:00:00 2001 From: Christophe Date: Wed, 18 Sep 2024 15:54:42 +0000 Subject: [PATCH 12/16] Add all spec files --- packages/arb-token-bridge-ui/tests/e2e/cctp.json | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/packages/arb-token-bridge-ui/tests/e2e/cctp.json b/packages/arb-token-bridge-ui/tests/e2e/cctp.json index f1d3f6857d..daa7e8636c 100644 --- a/packages/arb-token-bridge-ui/tests/e2e/cctp.json +++ b/packages/arb-token-bridge-ui/tests/e2e/cctp.json @@ -1,4 +1,9 @@ [ + { + "name": "Deposit Cctp", + "file": "tests/e2e/specs/**/depositCctp.cy.{js,jsx,ts,tsx}", + "recordVideo": false + }, { "name": "Withdraw Cctp", "file": "tests/e2e/specs/**/withdrawCctp.cy.{js,jsx,ts,tsx}", From 5870b56e883617c628cfe3aa276cf2e79512ad79 Mon Sep 17 00:00:00 2001 From: Christophe Date: Wed, 18 Sep 2024 18:47:20 +0000 Subject: [PATCH 13/16] Fix tests --- packages/arb-token-bridge-ui/tests/e2e/cctp.json | 5 ----- .../tests/e2e/specs/withdrawCctp.cy.ts | 8 ++------ 2 files changed, 2 insertions(+), 11 deletions(-) diff --git a/packages/arb-token-bridge-ui/tests/e2e/cctp.json b/packages/arb-token-bridge-ui/tests/e2e/cctp.json index daa7e8636c..f1d3f6857d 100644 --- a/packages/arb-token-bridge-ui/tests/e2e/cctp.json +++ b/packages/arb-token-bridge-ui/tests/e2e/cctp.json @@ -1,9 +1,4 @@ [ - { - "name": "Deposit Cctp", - "file": "tests/e2e/specs/**/depositCctp.cy.{js,jsx,ts,tsx}", - "recordVideo": false - }, { "name": "Withdraw Cctp", "file": "tests/e2e/specs/**/withdrawCctp.cy.{js,jsx,ts,tsx}", diff --git a/packages/arb-token-bridge-ui/tests/e2e/specs/withdrawCctp.cy.ts b/packages/arb-token-bridge-ui/tests/e2e/specs/withdrawCctp.cy.ts index a89c8eb91c..90be5da404 100644 --- a/packages/arb-token-bridge-ui/tests/e2e/specs/withdrawCctp.cy.ts +++ b/packages/arb-token-bridge-ui/tests/e2e/specs/withdrawCctp.cy.ts @@ -83,15 +83,10 @@ describe('Withdraw USDC through CCTP', () => { amount: USDCAmountToSend, symbol: 'USDC' }) - cy.findClaimButton( - formatAmount(USDCAmountToSend, { - symbol: 'USDC' - }), - { timeout: 120_000 } - ).click() }) it('should claim deposit', () => { + cy.changeMetamaskNetwork('sepolia') cy.claimCctp(0.00012, { accept: true }) cy.closeTransactionHistoryPanel() cy.claimCctp(0.00013, { accept: true }) @@ -126,6 +121,7 @@ describe('Withdraw USDC through CCTP', () => { cy.findTransactionDetailsCustomDestinationAddress( Cypress.env('CUSTOM_DESTINATION_ADDRESS') ) + cy.closeTransactionDetails() cy.findClaimButton( formatAmount(USDCAmountToSend, { symbol: 'USDC' From 6d7b7c3a9c0b12ecaea23e30135c8347e60eaa92 Mon Sep 17 00:00:00 2001 From: Christophe Date: Wed, 18 Sep 2024 19:16:31 +0000 Subject: [PATCH 14/16] Cleanup --- packages/arb-token-bridge-ui/tests/e2e/cctp.json | 5 +++++ .../tests/e2e/specs/withdrawCctp.cy.ts | 11 ++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/packages/arb-token-bridge-ui/tests/e2e/cctp.json b/packages/arb-token-bridge-ui/tests/e2e/cctp.json index f1d3f6857d..daa7e8636c 100644 --- a/packages/arb-token-bridge-ui/tests/e2e/cctp.json +++ b/packages/arb-token-bridge-ui/tests/e2e/cctp.json @@ -1,4 +1,9 @@ [ + { + "name": "Deposit Cctp", + "file": "tests/e2e/specs/**/depositCctp.cy.{js,jsx,ts,tsx}", + "recordVideo": false + }, { "name": "Withdraw Cctp", "file": "tests/e2e/specs/**/withdrawCctp.cy.{js,jsx,ts,tsx}", diff --git a/packages/arb-token-bridge-ui/tests/e2e/specs/withdrawCctp.cy.ts b/packages/arb-token-bridge-ui/tests/e2e/specs/withdrawCctp.cy.ts index 90be5da404..e1e062f1c4 100644 --- a/packages/arb-token-bridge-ui/tests/e2e/specs/withdrawCctp.cy.ts +++ b/packages/arb-token-bridge-ui/tests/e2e/specs/withdrawCctp.cy.ts @@ -83,6 +83,15 @@ describe('Withdraw USDC through CCTP', () => { amount: USDCAmountToSend, symbol: 'USDC' }) + cy.findClaimButton( + formatAmount(USDCAmountToSend, { + symbol: 'USDC' + }), + { timeout: 120_000 } + ).click() + cy.allowMetamaskToSwitchNetwork() + cy.rejectMetamaskTransaction() + cy.changeMetamaskNetwork('arbitrum-sepolia') }) it('should claim deposit', () => { @@ -126,7 +135,7 @@ describe('Withdraw USDC through CCTP', () => { formatAmount(USDCAmountToSend, { symbol: 'USDC' }), - { timeout: 80_000 } + { timeout: 120_000 } ).click() cy.allowMetamaskToSwitchNetwork() cy.rejectMetamaskTransaction() From e37e0980aed490b9acfa7773c53b5715dc222440 Mon Sep 17 00:00:00 2001 From: Christophe Date: Wed, 18 Sep 2024 19:31:34 +0000 Subject: [PATCH 15/16] Bump timeout --- packages/arb-token-bridge-ui/tests/support/commands.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/arb-token-bridge-ui/tests/support/commands.ts b/packages/arb-token-bridge-ui/tests/support/commands.ts index d236530dfb..2c7ad3513a 100644 --- a/packages/arb-token-bridge-ui/tests/support/commands.ts +++ b/packages/arb-token-bridge-ui/tests/support/commands.ts @@ -343,7 +343,7 @@ export function claimCctp(amount: number, options: { accept: boolean }) { amount, symbol: 'USDC' }) - cy.findClaimButton(formattedAmount, { timeout: 80_000 }).click() + cy.findClaimButton(formattedAmount, { timeout: 120_000 }).click() if (options.accept) { cy.confirmMetamaskTransaction(undefined) cy.findByLabelText('show settled transactions').should('be.visible').click() From 9abd6a7fd6eb4cc0535e13355c38325e3f839afb Mon Sep 17 00:00:00 2001 From: Christophe Date: Thu, 19 Sep 2024 16:17:29 +0000 Subject: [PATCH 16/16] Cleanup --- .github/workflows/e2e-tests.yml | 1 + .github/workflows/formatSpecfiles.js | 13 +++++++------ .github/workflows/run-cctp-tests.yml | 10 +++++++++- .../arb-token-bridge-ui/synpress.cctp.config.ts | 8 +++++--- 4 files changed, 22 insertions(+), 10 deletions(-) diff --git a/.github/workflows/e2e-tests.yml b/.github/workflows/e2e-tests.yml index 18c1e0c855..00e68cc1d5 100644 --- a/.github/workflows/e2e-tests.yml +++ b/.github/workflows/e2e-tests.yml @@ -16,6 +16,7 @@ env: jobs: load-e2e-files: name: "Load e2e files" + if: inputs.test_type.type != 'cctp' runs-on: ubuntu-latest outputs: matrix: ${{ steps.set-matrix.outputs.e2eFiles }} diff --git a/.github/workflows/formatSpecfiles.js b/.github/workflows/formatSpecfiles.js index cb7e382bbd..9600e29497 100644 --- a/.github/workflows/formatSpecfiles.js +++ b/.github/workflows/formatSpecfiles.js @@ -20,12 +20,13 @@ switch (testType) { break; } case "cctp": { - cctpFiles.forEach((spec) => { - tests.push({ - ...spec, - type: 'cctp', - }) - }) + // Running CCTP tests in parallel cause nonce issues, we're running the two tests sequentially + test.push({ + name: "cctp", + file: "tests/e2e/specs/**/*Cctp.cy.{js,jsx,ts,tsx}", + recordVideo: false, + type: "cctp", + }); break; } } diff --git a/.github/workflows/run-cctp-tests.yml b/.github/workflows/run-cctp-tests.yml index d0be8d5b0f..5365751467 100644 --- a/.github/workflows/run-cctp-tests.yml +++ b/.github/workflows/run-cctp-tests.yml @@ -33,11 +33,19 @@ jobs: - uses: ./.github/actions/check-files id: check-files + anything: + name: "debug test" + runs-on: ubuntu-latest + steps: + - name: "step" + run: | + echo ${{ github.event.comment.body }} + build: name: "Build" runs-on: ubuntu-latest needs: [check-files] - if: | + if: > (needs.check-files.outputs.run_tests == 'true' && ${{ !contains(github.event.pull_request.title, 'hotfix') }}) || (contains(github.event.comment.html_url, '/pull/') && github.event.comment.body == '/run-cctp-tests') steps: diff --git a/packages/arb-token-bridge-ui/synpress.cctp.config.ts b/packages/arb-token-bridge-ui/synpress.cctp.config.ts index 2af32a16a5..bc6679e52f 100644 --- a/packages/arb-token-bridge-ui/synpress.cctp.config.ts +++ b/packages/arb-token-bridge-ui/synpress.cctp.config.ts @@ -45,9 +45,11 @@ export async function fundUsdc({ const shouldRecordVideo = process.env.CYPRESS_RECORD_VIDEO === 'true' -const tests = process.env.TEST_FILE - ? [process.env.TEST_FILE] - : specFiles.map(file => file.file) +const tests = + process.env.TEST_FILE && + specFiles.find(file => file.name === process.env.TEST_FILE) + ? [process.env.TEST_FILE] + : specFiles.map(file => file.file) const INFURA_KEY = process.env.NEXT_PUBLIC_INFURA_KEY if (typeof INFURA_KEY === 'undefined') {