From a10e1811ca2827cd6f150f5f970168a30d42d639 Mon Sep 17 00:00:00 2001 From: Christophe Date: Wed, 14 Aug 2024 10:46:44 +0000 Subject: [PATCH 01/82] test: Add CCTP E2E tests to CI Closes fs-729 --- .github/workflows/build-test.yml | 116 +++++++++++++++ package.json | 2 +- packages/arb-token-bridge-ui/.e2e.env.sample | 2 + .../synpress.cctp.config.ts | 83 +++++++++++ .../arb-token-bridge-ui/synpress.config.ts | 81 ++--------- .../tests/e2e/cypress.d.ts | 6 - .../tests/e2e/getCommonSynpressConfig.ts | 21 +++ .../tests/e2e/specs/depositCctp.cy.ts | 126 +++++++--------- .../tests/e2e/specs/withdrawCctp.cy.ts | 134 +++++++----------- .../tests/support/commands.ts | 82 +---------- .../tests/support/common.ts | 88 +++++++++--- 11 files changed, 411 insertions(+), 330 deletions(-) create mode 100644 packages/arb-token-bridge-ui/synpress.cctp.config.ts create mode 100644 packages/arb-token-bridge-ui/tests/e2e/getCommonSynpressConfig.ts diff --git a/.github/workflows/build-test.yml b/.github/workflows/build-test.yml index 59e14837e6..3b527802cf 100644 --- a/.github/workflows/build-test.yml +++ b/.github/workflows/build-test.yml @@ -269,6 +269,122 @@ jobs: if: needs.test-e2e.result != 'success' && needs.test-e2e.result != 'skipped' run: exit 1 + load-e2e-cctp-files: + name: "Load e2e CCTP files" + runs-on: ubuntu-latest + needs: [check-is-hotfix] + if: needs.check-is-hotfix.outputs.is_hotfix == 'false' + outputs: + matrix: ${{ steps.set-matrix.outputs.e2eCctpFiles }} + steps: + - name: Checkout + uses: actions/checkout@v4 + + - id: set-matrix + run: | + content=`cat packages/arb-token-bridge-ui/tests/e2e/cctp.json | jq --compact-output .` + echo "e2eCctpFiles=$content" >> $GITHUB_OUTPUT + + # test-e2e-cctp: + # name: "Test E2E - ${{ matrix.tests.name }}" + # runs-on: ubuntu-latest + # needs: [build, check-files, check-is-hotfix, load-e2e-cctp-files] + # if: needs.check-files.outputs.run_tests == 'true' && needs.check-is-hotfix.outputs.is_hotfix == 'false' + # strategy: + # fail-fast: false # If one test fails, let the other tests run + # matrix: + # tests: + # ${{ fromJson(needs.load-e2e-cctp-files.outputs.matrix) }} + + # steps: + # - name: Free Disk Space (Ubuntu) + # uses: jlumbroso/free-disk-space@main + # with: + # # this might remove tools that are actually needed, + # # if set to "true" but frees about 6 GB + # tool-cache: false + + # # all of these default to true, but feel free to set to + # # "false" if necessary for your workflow + # android: true + # dotnet: true + # haskell: true + # large-packages: true + # docker-images: false + # swap-storage: true + + # - name: Checkout + # uses: actions/checkout@v4 + + # - name: Install node_modules + # uses: OffchainLabs/actions/node-modules/install@main + + # - name: Restore build artifacts + # uses: ./.github/actions/build-artifacts/restore + + # - name: Install cypress + # run: yarn cypress install + + # - name: Install linux dependencies + # run: | + # sudo apt-get install --no-install-recommends -y \ + # fluxbox \ + # xvfb + + # - name: Run xvfb and fluxbox + # run: | + # Xvfb :0 -screen 0 1366x768x24 -listen tcp -ac & + # fluxbox & + # env: + # DISPLAY: :0.0 + + # - name: Run e2e tests via cypress-io/github-action + # uses: cypress-io/github-action@8d3918616d8ac34caa2b49afc8b408b6a872a6f5 # pin@v6.7.1 + # with: + # start: yarn start + # command: 'yarn test:e2e:cctp --browser chromium' + # wait-on: http://127.0.0.1:3000 + # wait-on-timeout: 120 + # spec: ./packages/arb-token-bridge-ui/tests/e2e/specs/* + # env: + # DISPLAY: :0.0 + # TEST_FILE: ${{ matrix.tests.file }} + # SKIP_METAMASK_SETUP: true + # CYPRESS_RECORD_VIDEO: ${{ matrix.tests.recordVideo }} + # PRIVATE_KEY_CCTP: ${{ secrets.E2E_PRIVATE_KEY_CCTP }} + # LOCAL_CCTP_WALLET_PRIVATE_KEY: + # PRIVATE_KEY_USER: ${{ secrets.E2E_PRIVATE_KEY_USER }} + # NEXT_PUBLIC_IS_E2E_TEST: true + # NEXT_PUBLIC_INFURA_KEY: ${{ secrets.NEXT_PUBLIC_INFURA_KEY }} + + # - name: Archive e2e artifacts + # uses: actions/upload-artifact@v4 + # if: always() + # with: + # name: e2e-artifacts-pull-request-${{ github.event.pull_request.number }}-commit-${{ github.sha }}-cctp + # path: | + # ./packages/arb-token-bridge-ui/cypress/videos + # ./packages/arb-token-bridge-ui/cypress/screenshots + # continue-on-error: true + + # - name: Throw error if tests failed + # if: steps.e2e-cctp-run.outputs.status == 'failed' + # run: exit 1 + + # test-e2e-cctp-success: + name: "Test E2E CCTP Success" + runs-on: ubuntu-latest + needs: [test-e2e-cctp] + if: always() + steps: + - name: E2E Succeeded + if: needs.test-e2e-cctp.result == 'success' || needs.test-e2e-cctp.result == 'skipped' + run: echo "nice" + + - name: E2E Failed + if: needs.test-e2e-cctp.result != 'success' && needs.test-e2e-cctp.result != 'skipped' + run: exit 1 + clean-up: name: "Clean Up" runs-on: ubuntu-latest diff --git a/package.json b/package.json index b826dc8d2c..82ce10cda4 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,7 @@ "lint": "yarn workspace arb-token-bridge-ui lint", "lint:fix": "yarn workspace arb-token-bridge-ui lint:fix", "test:e2e": "yarn workspace arb-token-bridge-ui env-cmd --silent --file .e2e.env yarn synpress run --configFile synpress.config.ts", - "test:e2e:cctp": "E2E_CCTP=true yarn test:e2e", + "test:e2e:cctp": "yarn test:e2e --configFile synpress.cctp.config.ts", "test:e2e:orbit": "E2E_ORBIT=true yarn test:e2e" }, "resolutions": { diff --git a/packages/arb-token-bridge-ui/.e2e.env.sample b/packages/arb-token-bridge-ui/.e2e.env.sample index 573ce3d690..28ca742afc 100644 --- a/packages/arb-token-bridge-ui/.e2e.env.sample +++ b/packages/arb-token-bridge-ui/.e2e.env.sample @@ -12,6 +12,8 @@ CYPRESS_RECORD_VIDEO=false # Below key is only used to fund the newly created wallet PRIVATE_KEY_CUSTOM=b6b15c8cb491557369f3c7d2c287b053eb229daa9c22138887752191c9520659 +PRIVATE_KEY_CCTP= + # We set up MetaMask ourselves SKIP_METAMASK_SETUP=true diff --git a/packages/arb-token-bridge-ui/synpress.cctp.config.ts b/packages/arb-token-bridge-ui/synpress.cctp.config.ts new file mode 100644 index 0000000000..60ab0dd1fe --- /dev/null +++ b/packages/arb-token-bridge-ui/synpress.cctp.config.ts @@ -0,0 +1,83 @@ +import { Wallet, utils } from 'ethers' +import { defineConfig } from 'cypress' +import { StaticJsonRpcProvider } from '@ethersproject/providers' +import synpressPlugins from '@synthetixio/synpress/plugins' +import { getCommonSynpressConfig } from './tests/e2e/getCommonSynpressConfig' + +import { fundEth, fundUsdc, setupCypressTasks } from './tests/support/common' + +const shouldRecordVideo = process.env.CYPRESS_RECORD_VIDEO === 'true' + +const INFURA_KEY = process.env.NEXT_PUBLIC_INFURA_KEY +if (typeof INFURA_KEY === 'undefined') { + throw new Error('Infura API key not provided') +} + +const SEPOLIA_INFURA_RPC_URL = `https://sepolia.infura.io/v3/${INFURA_KEY}` +const ARB_SEPOLIA_INFURA_RPC_URL = `https://arbitrum-sepolia.infura.io/v3/${INFURA_KEY}` + +const sepoliaProvider = new StaticJsonRpcProvider(SEPOLIA_INFURA_RPC_URL) +const arbSepoliaProvider = new StaticJsonRpcProvider(ARB_SEPOLIA_INFURA_RPC_URL) + +if (!process.env.PRIVATE_KEY_CCTP) { + throw new Error('PRIVATE_KEY_CCTP variable missing.') +} + +if (!process.env.TEST_FILE) { + throw new Error('process.env.TEST_FILE is missing.') +} + +// Wallet funded on Sepolia and ArbSepolia with ETH and USDC +const localWallet = new Wallet(process.env.PRIVATE_KEY_CCTP) +// Generate a new wallet every time +const userWallet = Wallet.createRandom() + +export default defineConfig({ + ...getCommonSynpressConfig(shouldRecordVideo), + e2e: { + async setupNodeEvents(on, config) { + require('cypress-terminal-report/src/installLogsPrinter')(on) + + const userWalletAddress = await userWallet.getAddress() + config.env.ADDRESS = userWalletAddress + config.env.LOCAL_CCTP_WALLET_PRIVATE_KEY = localWallet.privateKey + + // Fund wallet + await Promise.all([ + // Sepolia + fundEth({ + address: userWalletAddress, + provider: sepoliaProvider, + sourceWallet: localWallet, + amount: utils.parseEther('0.01') + }), + fundUsdc({ + address: userWalletAddress, + provider: sepoliaProvider, + networkType: 'parentChain', + amount: utils.parseUnits('0.0001', 6) + }), + // ArbSepolia + fundEth({ + address: userWalletAddress, + provider: arbSepoliaProvider, + sourceWallet: localWallet, + amount: utils.parseEther('0.01') + }), + fundUsdc({ + address: userWalletAddress, + provider: arbSepoliaProvider, + networkType: 'childChain', + amount: utils.parseUnits('0.0001', 6) + }) + ]) + + synpressPlugins(on, config) + setupCypressTasks(on, { requiresNetworkSetup: false }) + return config + }, + baseUrl: 'http://localhost:3000', + specPattern: [process.env.TEST_FILE], + supportFile: 'tests/support/index.ts' + } +}) diff --git a/packages/arb-token-bridge-ui/synpress.config.ts b/packages/arb-token-bridge-ui/synpress.config.ts index 0d6e6d1fb2..cdfcf2ff73 100644 --- a/packages/arb-token-bridge-ui/synpress.config.ts +++ b/packages/arb-token-bridge-ui/synpress.config.ts @@ -7,14 +7,14 @@ import { TestERC20__factory } from '@arbitrum/sdk/dist/lib/abi/factories/TestERC import { Erc20Bridger } from '@arbitrum/sdk' import { getL2ERC20Address } from './src/util/TokenUtils' import specFiles from './tests/e2e/specfiles.json' -import cctpFiles from './tests/e2e/cctp.json' import { NetworkName, checkForAssertions, generateActivityOnChains, NetworkType, - fundEth + fundEth, + setupCypressTasks } from './tests/support/common' import { @@ -22,15 +22,11 @@ import { defaultL3Network, registerLocalNetwork } from './src/util/networks' +import { getCommonSynpressConfig } from './tests/e2e/getCommonSynpressConfig' -let tests: string[] -if (process.env.TEST_FILE) { - tests = [process.env.TEST_FILE] -} else if (process.env.E2E_CCTP) { - tests = cctpFiles.map(file => file.file) -} else { - tests = specFiles.map(file => file.file) -} +const tests = process.env.TEST_FILE + ? [process.env.TEST_FILE] + : specFiles.map(file => file.file) const isOrbitTest = process.env.E2E_ORBIT == 'true' const shouldRecordVideo = process.env.CYPRESS_RECORD_VIDEO === 'true' @@ -48,25 +44,8 @@ const l2WethAddress = isOrbitTest : defaultL2Network.tokenBridge!.childWeth export default defineConfig({ - userAgent: 'synpress', - retries: shouldRecordVideo ? 0 : 2, - screenshotsFolder: 'cypress/screenshots', - videosFolder: 'cypress/videos', - video: shouldRecordVideo, - screenshotOnRunFailure: true, - chromeWebSecurity: true, - modifyObstructiveCode: false, - scrollBehavior: false, - viewportWidth: 1366, - viewportHeight: 850, - env: { - coverage: false - }, - defaultCommandTimeout: 30000, - pageLoadTimeout: 30000, - requestTimeout: 30000, + ...getCommonSynpressConfig(shouldRecordVideo), e2e: { - // @ts-ignore async setupNodeEvents(on, config) { require('cypress-terminal-report/src/installLogsPrinter')(on) registerLocalNetwork() @@ -108,18 +87,16 @@ export default defineConfig({ // Fund the userWallet. We do this to run tests on a small amount of ETH. await Promise.all([ fundEth({ - networkType: 'parentChain', address: userWalletAddress, - parentProvider, - childProvider, - sourceWallet: localWallet + provider: parentProvider, + sourceWallet: localWallet, + amount: utils.parseEther('2') }), fundEth({ - networkType: 'childChain', address: userWalletAddress, - parentProvider, - childProvider, - sourceWallet: localWallet + provider: childProvider, + sourceWallet: localWallet, + amount: utils.parseEther('2') }) ]) @@ -165,7 +142,7 @@ export default defineConfig({ await generateTestTxForRedeemRetryable() synpressPlugins(on, config) - setupCypressTasks(on) + setupCypressTasks(on, { requiresNetworkSetup: true }) return config }, baseUrl: 'http://localhost:3000', @@ -311,33 +288,3 @@ async function generateTestTxForRedeemRetryable() { const receipt = await tx.wait() return receipt.transactionHash } - -function setupCypressTasks(on: Cypress.PluginEvents) { - let currentNetworkName: NetworkName | null = null - let networkSetupComplete = false - let walletConnectedToDapp = false - - on('task', { - setCurrentNetworkName: (networkName: NetworkName) => { - currentNetworkName = networkName - return null - }, - getCurrentNetworkName: () => { - return currentNetworkName - }, - setNetworkSetupComplete: () => { - networkSetupComplete = true - return null - }, - getNetworkSetupComplete: () => { - return networkSetupComplete - }, - setWalletConnectedToDapp: () => { - walletConnectedToDapp = true - return null - }, - getWalletConnectedToDapp: () => { - return walletConnectedToDapp - } - }) -} 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 8669de0cad..5c596b1f97 100644 --- a/packages/arb-token-bridge-ui/tests/e2e/cypress.d.ts +++ b/packages/arb-token-bridge-ui/tests/e2e/cypress.d.ts @@ -5,9 +5,6 @@ import { login, logout, openTransactionsPanel, - resetCctpAllowance, - fundUserUsdcTestnet, - fundUserWalletEth, searchAndSelectToken, fillCustomDestinationAddress, typeAmount, @@ -44,9 +41,6 @@ declare global { logout(): typeof logout selectTransactionsPanelTab: typeof selectTransactionsPanelTab openTransactionsPanel: typeof openTransactionsPanel - resetCctpAllowance: typeof resetCctpAllowance - fundUserUsdcTestnet: typeof fundUserUsdcTestnet - fundUserWalletEth: typeof fundUserWalletEth typeRecursively(text: string): Chainable> searchAndSelectToken({ tokenName, diff --git a/packages/arb-token-bridge-ui/tests/e2e/getCommonSynpressConfig.ts b/packages/arb-token-bridge-ui/tests/e2e/getCommonSynpressConfig.ts new file mode 100644 index 0000000000..b74879e34a --- /dev/null +++ b/packages/arb-token-bridge-ui/tests/e2e/getCommonSynpressConfig.ts @@ -0,0 +1,21 @@ +export function getCommonSynpressConfig(shouldRecordVideo: boolean) { + return { + userAgent: 'synpress', + retries: shouldRecordVideo ? 0 : 2, + screenshotsFolder: 'cypress/screenshots', + videosFolder: 'cypress/videos', + video: shouldRecordVideo, + screenshotOnRunFailure: true, + chromeWebSecurity: true, + modifyObstructiveCode: false, + scrollBehavior: false, + viewportWidth: 1366, + viewportHeight: 850, + env: { + coverage: false + }, + defaultCommandTimeout: 30000, + pageLoadTimeout: 30000, + requestTimeout: 30000 + } as const satisfies Cypress.ConfigOptions +} 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 70b6d28bf0..708821b8b1 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 @@ -61,86 +61,60 @@ const confirmAndApproveCctpDeposit = () => { describe('Deposit USDC through CCTP', () => { // Happy Path - context('User has some USDC and is on L1', () => { - let USDCAmountToSend: number = 0 - - // log in to metamask before deposit - beforeEach(() => { - USDCAmountToSend = Number((Math.random() * 0.001).toFixed(6)) // randomize the amount to be sure that previous transactions are not checked in e2e - - cy.fundUserWalletEth('parentChain') - cy.fundUserUsdcTestnet('parentChain') - cy.resetCctpAllowance('parentChain') - - /// common code before all tests - cy.login({ networkType: 'parentChain', networkName: 'sepolia' }) - context('should show L1 and L2 chains, and USD correctly', () => { - cy.findSourceChainButton('Sepolia') - cy.findDestinationChainButton('Arbitrum Sepolia') - cy.findSelectTokenButton('ETH') - }) - - cy.searchAndSelectToken({ - tokenName: 'USDC', - tokenAddress: CommonAddress.Sepolia.USDC - }) - - context('should show summary', () => { - cy.typeAmount(USDCAmountToSend) - cy.findGasFeeSummary(zeroToLessThanOneETH) - cy.findGasFeeForChain('Sepolia', zeroToLessThanOneETH) - cy.findGasFeeForChain( - /You'll have to pay Arbitrum Sepolia gas fee upon claiming./i - ) - }) + let USDCAmountToSend = 0.0001 + + beforeEach(() => { + cy.login({ networkType: 'parentChain', networkName: 'sepolia' }) + cy.findSourceChainButton('Sepolia') + cy.findDestinationChainButton('Arbitrum Sepolia') + cy.findSelectTokenButton('ETH') + + cy.searchAndSelectToken({ + tokenName: 'USDC', + tokenAddress: CommonAddress.Sepolia.USDC }) - it('should initiate depositing USDC to the same address through CCTP successfully', () => { - context('should show clickable deposit button', () => { - cy.findMoveFundsButton().click() - }) - - context('Should display CCTP modal', () => { - confirmAndApproveCctpDeposit() - cy.confirmMetamaskPermissionToSpend(USDCAmountToSend.toString()) - - // eslint-disable-next-line - cy.wait(40_000) - cy.confirmMetamaskTransaction() - cy.findTransactionInTransactionHistory({ - duration: 'a minute', - amount: USDCAmountToSend, - symbol: 'USDC' - }) - }) + cy.typeAmount(USDCAmountToSend) + cy.findGasFeeSummary(zeroToLessThanOneETH) + cy.findGasFeeForChain('Sepolia', zeroToLessThanOneETH) + cy.findGasFeeForChain( + /You'll have to pay Arbitrum Sepolia gas fee upon claiming./i + ) + }) + + it('should initiate depositing USDC to the same address through CCTP successfully', () => { + cy.findMoveFundsButton().click() + + confirmAndApproveCctpDeposit() + cy.confirmMetamaskPermissionToSpend(USDCAmountToSend.toString()) + + // eslint-disable-next-line + cy.wait(40_000) + cy.confirmMetamaskTransaction() + cy.findTransactionInTransactionHistory({ + duration: 'a minute', + amount: USDCAmountToSend, + symbol: 'USDC' }) + }) - it('should initiate depositing USDC to custom destination address through CCTP successfully', () => { - context('should fill custom destination address successfully', () => { - cy.fillCustomDestinationAddress() - }) - - context('should click deposit successfully', () => { - cy.findMoveFundsButton().click() - }) - - context('Should display CCTP modal', () => { - confirmAndApproveCctpDeposit() - cy.confirmMetamaskPermissionToSpend(USDCAmountToSend.toString()) - - // eslint-disable-next-line - cy.wait(40_000) - cy.confirmMetamaskTransaction() - const txData = { amount: USDCAmountToSend, symbol: 'USDC' } - cy.findTransactionInTransactionHistory({ - duration: 'a minute', - ...txData - }) - cy.openTransactionDetails(txData) - cy.findTransactionDetailsCustomDestinationAddress( - Cypress.env('CUSTOM_DESTINATION_ADDRESS') - ) - }) + it('should initiate depositing USDC to custom destination address through CCTP successfully', () => { + cy.fillCustomDestinationAddress() + cy.findMoveFundsButton().click() + confirmAndApproveCctpDeposit() + cy.confirmMetamaskPermissionToSpend(USDCAmountToSend.toString()) + + // eslint-disable-next-line + cy.wait(40_000) + cy.confirmMetamaskTransaction() + const txData = { amount: USDCAmountToSend, symbol: 'USDC' } + cy.findTransactionInTransactionHistory({ + duration: 'a minute', + ...txData }) + cy.openTransactionDetails(txData) + cy.findTransactionDetailsCustomDestinationAddress( + Cypress.env('CUSTOM_DESTINATION_ADDRESS') + ) }) }) 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 b7b772e4ad..84ce90c1ca 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 @@ -51,91 +51,63 @@ export const confirmAndApproveCctpWithdrawal = () => { describe('Withdraw USDC through CCTP', () => { // Happy Path - context('User is on L2 and imports USDC', () => { - let USDCAmountToSend: number - - // log in to metamask before withdrawal - beforeEach(() => { - cy.fundUserWalletEth('childChain') - cy.fundUserUsdcTestnet('childChain') - cy.resetCctpAllowance('childChain') - USDCAmountToSend = Number((Math.random() * 0.001).toFixed(6)) // randomize the amount to be sure that previous transactions are not checked in e2e - - cy.login({ networkType: 'childChain', networkName: 'arbitrum-sepolia' }) - context('should show L1 and L2 chains, and ETH correctly', () => { - cy.findSourceChainButton('Arbitrum Sepolia') - cy.findDestinationChainButton('Sepolia') - cy.findSelectTokenButton('ETH') - }) - - context('should add USDC token', () => { - cy.searchAndSelectToken({ - tokenName: 'USDC', - tokenAddress: CommonAddress.ArbitrumSepolia.USDC - }) - }) + const USDCAmountToSend = 0.0001 + + // log in to metamask before withdrawal + beforeEach(() => { + cy.login({ networkType: 'childChain', networkName: 'arbitrum-sepolia' }) + cy.findSourceChainButton('Arbitrum Sepolia') + cy.findDestinationChainButton('Sepolia') + cy.findSelectTokenButton('ETH') + + cy.searchAndSelectToken({ + tokenName: 'USDC', + tokenAddress: CommonAddress.ArbitrumSepolia.USDC }) + }) - it('should initiate withdrawing USDC to the same address through CCTP successfully', () => { - context('should show clickable withdraw button', () => { - cy.typeAmount(USDCAmountToSend) - cy.findByText( - 'Gas estimates are not available for this action.' - ).should('be.visible') - cy.findGasFeeForChain('Arbitrum Sepolia', zeroToLessThanOneETH) - cy.findGasFeeForChain( - /You'll have to pay Sepolia gas fee upon claiming./i - ) - cy.findMoveFundsButton().click() - }) - - context('Should display CCTP modal', () => { - confirmAndApproveCctpWithdrawal() - cy.confirmMetamaskPermissionToSpend(USDCAmountToSend.toString()) - // eslint-disable-next-line - cy.wait(40_000) - cy.confirmMetamaskTransaction() - cy.findTransactionInTransactionHistory({ - duration: 'a minute', - amount: USDCAmountToSend, - symbol: 'USDC' - }) - }) + it('should initiate withdrawing USDC to the same address through CCTP successfully', () => { + cy.typeAmount(USDCAmountToSend) + cy.findByText('Gas estimates are not available for this action.').should( + 'be.visible' + ) + cy.findGasFeeForChain('Arbitrum Sepolia', zeroToLessThanOneETH) + cy.findGasFeeForChain(/You'll have to pay Sepolia gas fee upon claiming./i) + cy.findMoveFundsButton().click() + + confirmAndApproveCctpWithdrawal() + cy.confirmMetamaskPermissionToSpend(USDCAmountToSend.toString()) + // eslint-disable-next-line + cy.wait(40_000) + cy.confirmMetamaskTransaction() + cy.findTransactionInTransactionHistory({ + duration: 'a minute', + amount: USDCAmountToSend, + symbol: 'USDC' }) + }) - it('should initiate withdrawing USDC to custom destination address through CCTP successfully', () => { - context('should show clickable withdraw button', () => { - cy.typeAmount(USDCAmountToSend) - }) - - context('should fill custom destination address successfully', () => { - cy.fillCustomDestinationAddress() - }) - - context('should click withdraw successfully', () => { - cy.findMoveFundsButton().click() - }) - - context('Should display CCTP modal', () => { - confirmAndApproveCctpWithdrawal() - cy.confirmMetamaskPermissionToSpend(USDCAmountToSend.toString()) - - // eslint-disable-next-line - cy.wait(40_000) - cy.confirmMetamaskTransaction() - const txData = { - amount: USDCAmountToSend, - symbol: 'USDC' - } - cy.findTransactionInTransactionHistory({ - duration: 'a minute', - ...txData - }) - cy.openTransactionDetails(txData) - cy.findTransactionDetailsCustomDestinationAddress( - Cypress.env('CUSTOM_DESTINATION_ADDRESS') - ) - }) + it('should initiate withdrawing USDC to custom destination address through CCTP successfully', () => { + cy.typeAmount(USDCAmountToSend) + cy.fillCustomDestinationAddress() + cy.findMoveFundsButton().click() + confirmAndApproveCctpWithdrawal() + cy.confirmMetamaskPermissionToSpend(USDCAmountToSend.toString()) + + // eslint-disable-next-line + cy.wait(40_000) + cy.confirmMetamaskTransaction() + const txData = { + amount: USDCAmountToSend, + symbol: 'USDC' + } + cy.findTransactionInTransactionHistory({ + duration: 'a minute', + ...txData }) + cy.openTransactionDetails(txData) + cy.findTransactionDetailsCustomDestinationAddress( + Cypress.env('CUSTOM_DESTINATION_ADDRESS') + ) }) }) diff --git a/packages/arb-token-bridge-ui/tests/support/commands.ts b/packages/arb-token-bridge-ui/tests/support/commands.ts index 4d4a7d0666..31c661cd8c 100644 --- a/packages/arb-token-bridge-ui/tests/support/commands.ts +++ b/packages/arb-token-bridge-ui/tests/support/commands.ts @@ -14,14 +14,8 @@ import { NetworkName, startWebApp, getL1NetworkConfig, - getL2NetworkConfig, - getInitialERC20Balance + getL2NetworkConfig } from './common' -import { Wallet, utils } from 'ethers' -import { CommonAddress } from '../../src/util/CommonAddressUtils' -import { StaticJsonRpcProvider } from '@ethersproject/providers' -import { ERC20__factory } from '@arbitrum/sdk/dist/lib/abi/factories/ERC20__factory' -import { MULTICALL_TESTNET_ADDRESS } from '../../src/constants' import { shortenAddress } from '../../src/util/CommonUtils' function shouldChangeNetwork(networkName: NetworkName) { @@ -159,77 +153,6 @@ export const openTransactionsPanel = (tab: 'pending' | 'settled') => { ) } -const l1RpcUrl = Cypress.env('ETH_SEPOLIA_RPC_URL') -const l2RpcUrl = Cypress.env('ARB_SEPOLIA_RPC_URL') -const l1Provider = new StaticJsonRpcProvider(l1RpcUrl) -const l2Provider = new StaticJsonRpcProvider(l2RpcUrl) -const userWallet = new Wallet(Cypress.env('PRIVATE_KEY')) -const localWallet = new Wallet(Cypress.env('LOCAL_WALLET_PRIVATE_KEY')) - -export async function resetCctpAllowance(networkType: NetworkType) { - const provider = networkType === 'parentChain' ? l1Provider : l2Provider - const { USDC, tokenMessengerContractAddress } = - networkType === 'parentChain' - ? CommonAddress.Sepolia - : CommonAddress.ArbitrumSepolia - - const contract = ERC20__factory.connect(USDC, userWallet.connect(provider)) - const allowance = await contract.allowance( - userWallet.address, - tokenMessengerContractAddress - ) - if (allowance.gt(0)) { - await contract.decreaseAllowance(tokenMessengerContractAddress, allowance) - } -} - -export async function fundUserUsdcTestnet(networkType: NetworkType) { - console.log(`Funding USDC to user wallet (testnet): ${networkType}...`) - const usdcContractAddress = - networkType === 'parentChain' - ? CommonAddress.Sepolia.USDC - : CommonAddress.ArbitrumSepolia.USDC - - const usdcBalance = await getInitialERC20Balance({ - address: userWallet.address, - rpcURL: networkType === 'parentChain' ? l1RpcUrl : l2RpcUrl, - tokenAddress: usdcContractAddress, - multiCallerAddress: MULTICALL_TESTNET_ADDRESS - }) - - // Fund only if the balance is less than 0.0001 USDC - if (usdcBalance && usdcBalance.lt(utils.parseUnits('0.0001', 6))) { - console.log(`Adding USDC to user wallet (testnet): ${networkType}...`) - const l1Provider = new StaticJsonRpcProvider(l1RpcUrl) - const l2Provider = new StaticJsonRpcProvider(l2RpcUrl) - const provider = networkType === 'parentChain' ? l1Provider : l2Provider - const contract = new ERC20__factory().connect(localWallet.connect(provider)) - const token = contract.attach(usdcContractAddress) - await token.deployed() - const tx = await token.transfer( - userWallet.address, - utils.parseUnits('1', 6) - ) - await tx.wait() - } -} - -export async function fundUserWalletEth(networkType: NetworkType) { - console.log(`Funding ETH to user wallet (testnet): ${networkType}...`) - const address = await userWallet.getAddress() - const provider = networkType === 'parentChain' ? l1Provider : l2Provider - const balance = await provider.getBalance(address) - // Fund only if the balance is less than 0.005 eth - const amountToTransfer = '0.005' - if (balance.lt(utils.parseEther(amountToTransfer))) { - const tx = await localWallet.connect(provider).sendTransaction({ - to: address, - value: utils.parseEther(amountToTransfer) - }) - await tx.wait() - } -} - export const searchAndSelectToken = ({ tokenName, tokenAddress @@ -404,9 +327,6 @@ Cypress.Commands.addAll({ logout, openTransactionsPanel, selectTransactionsPanelTab, - resetCctpAllowance, - fundUserUsdcTestnet, - fundUserWalletEth, searchAndSelectToken, fillCustomDestinationAddress, typeAmount, diff --git a/packages/arb-token-bridge-ui/tests/support/common.ts b/packages/arb-token-bridge-ui/tests/support/common.ts index 18f38bff36..63ff8948b6 100644 --- a/packages/arb-token-bridge-ui/tests/support/common.ts +++ b/packages/arb-token-bridge-ui/tests/support/common.ts @@ -8,6 +8,8 @@ import { MultiCaller } from '@arbitrum/sdk' import { MULTICALL_TESTNET_ADDRESS } from '../../src/constants' import { defaultL2Network, defaultL3Network } from '../../src/util/networks' import { getChainIdFromProvider } from '../../src/token-bridge-sdk/utils' +import { CommonAddress } from '../../src/util/CommonAddressUtils' +import { ERC20__factory } from '@arbitrum/sdk/dist/lib/abi/factories/ERC20__factory' export type NetworkType = 'parentChain' | 'childChain' export type NetworkName = @@ -183,31 +185,52 @@ export const wait = (ms = 0): Promise => { export async function fundEth({ address, // wallet address where funding is required - networkType, // parentChain or childChain - parentProvider, - childProvider, - sourceWallet // source wallet that will fund the `address` + provider, + sourceWallet, // source wallet that will fund the `address`, + amount = utils.parseEther('2') }: { address: string - parentProvider: Provider - childProvider: Provider + provider: Provider sourceWallet: Wallet - networkType: NetworkType + amount?: BigNumber }) { - console.log(`Funding ETH to user wallet: ${networkType}...`) - const provider = - networkType === 'parentChain' ? parentProvider : childProvider + console.log(`Funding ETH to user wallet...`) const balance = await provider.getBalance(address) // Fund only if the balance is less than 2 eth - if (balance.lt(utils.parseEther('2'))) { + if (balance.lt(amount)) { const tx = await sourceWallet.connect(provider).sendTransaction({ to: address, - value: utils.parseEther('2') + value: amount }) await tx.wait() } } +export async function fundUsdc({ + address, // wallet address where funding is required + provider, + amount, + networkType +}: { + address: string + provider: Provider + amount: BigNumber + networkType: NetworkType +}) { + console.log(`Funding USDC to user wallet...`) + const usdcContractAddress = + networkType === 'parentChain' + ? CommonAddress.Sepolia.USDC + : CommonAddress.ArbitrumSepolia.USDC + + const localWallet = new Wallet(Cypress.env('LOCAL_CCTP_WALLET_PRIVATE_KEY')) + const contract = new ERC20__factory().connect(localWallet.connect(provider)) + const token = contract.attach(usdcContractAddress) + await token.deployed() + const tx = await token.transfer(address, amount) + await tx.wait() +} + export async function generateActivityOnChains({ parentProvider, childProvider, @@ -236,9 +259,7 @@ export async function generateActivityOnChains({ const minerParent = Wallet.createRandom().connect(parentProvider) await fundEth({ address: await minerParent.getAddress(), - networkType: 'parentChain', - parentProvider, - childProvider, + provider: parentProvider, sourceWallet: wallet }) @@ -246,9 +267,7 @@ export async function generateActivityOnChains({ const minerChild = Wallet.createRandom().connect(childProvider) await fundEth({ address: await minerChild.getAddress(), - networkType: 'childChain', - parentProvider, - childProvider, + provider: childProvider, sourceWallet: wallet }) @@ -293,3 +312,36 @@ export async function checkForAssertions({ ) } } + +export function setupCypressTasks( + on: Cypress.PluginEvents, + { requiresNetworkSetup }: { requiresNetworkSetup: boolean } +) { + let currentNetworkName: NetworkName | null = null + let networkSetupComplete = requiresNetworkSetup + let walletConnectedToDapp = false + + on('task', { + setCurrentNetworkName: (networkName: NetworkName) => { + currentNetworkName = networkName + return null + }, + getCurrentNetworkName: () => { + return currentNetworkName + }, + setNetworkSetupComplete: () => { + networkSetupComplete = true + return null + }, + getNetworkSetupComplete: () => { + return networkSetupComplete + }, + setWalletConnectedToDapp: () => { + walletConnectedToDapp = true + return null + }, + getWalletConnectedToDapp: () => { + return walletConnectedToDapp + } + }) +} From b69c8754b527faec29e60acb54a47e53ec66d6c2 Mon Sep 17 00:00:00 2001 From: Christophe Date: Wed, 14 Aug 2024 10:54:41 +0000 Subject: [PATCH 02/82] Cleanup --- .github/workflows/build-test.yml | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/.github/workflows/build-test.yml b/.github/workflows/build-test.yml index 3b527802cf..eb506357c6 100644 --- a/.github/workflows/build-test.yml +++ b/.github/workflows/build-test.yml @@ -372,18 +372,18 @@ jobs: # run: exit 1 # test-e2e-cctp-success: - name: "Test E2E CCTP Success" - runs-on: ubuntu-latest - needs: [test-e2e-cctp] - if: always() - steps: - - name: E2E Succeeded - if: needs.test-e2e-cctp.result == 'success' || needs.test-e2e-cctp.result == 'skipped' - run: echo "nice" + # name: "Test E2E CCTP Success" + # runs-on: ubuntu-latest + # needs: [test-e2e-cctp] + # if: always() + # steps: + # - name: E2E Succeeded + # if: needs.test-e2e-cctp.result == 'success' || needs.test-e2e-cctp.result == 'skipped' + # run: echo "nice" - - name: E2E Failed - if: needs.test-e2e-cctp.result != 'success' && needs.test-e2e-cctp.result != 'skipped' - run: exit 1 + # - name: E2E Failed + # if: needs.test-e2e-cctp.result != 'success' && needs.test-e2e-cctp.result != 'skipped' + # run: exit 1 clean-up: name: "Clean Up" From 98f820dc05c28aebfbb139b372108a9e39d652e6 Mon Sep 17 00:00:00 2001 From: Christophe Date: Wed, 14 Aug 2024 11:50:19 +0000 Subject: [PATCH 03/82] Set proper flag in synpress task --- packages/arb-token-bridge-ui/synpress.cctp.config.ts | 1 + packages/arb-token-bridge-ui/synpress.config.ts | 1 - packages/arb-token-bridge-ui/tests/support/common.ts | 2 +- 3 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/arb-token-bridge-ui/synpress.cctp.config.ts b/packages/arb-token-bridge-ui/synpress.cctp.config.ts index 60ab0dd1fe..2e371178d1 100644 --- a/packages/arb-token-bridge-ui/synpress.cctp.config.ts +++ b/packages/arb-token-bridge-ui/synpress.cctp.config.ts @@ -5,6 +5,7 @@ import synpressPlugins from '@synthetixio/synpress/plugins' import { getCommonSynpressConfig } from './tests/e2e/getCommonSynpressConfig' import { fundEth, fundUsdc, setupCypressTasks } from './tests/support/common' +import { log } from 'console' const shouldRecordVideo = process.env.CYPRESS_RECORD_VIDEO === 'true' diff --git a/packages/arb-token-bridge-ui/synpress.config.ts b/packages/arb-token-bridge-ui/synpress.config.ts index cdfcf2ff73..6405014a3d 100644 --- a/packages/arb-token-bridge-ui/synpress.config.ts +++ b/packages/arb-token-bridge-ui/synpress.config.ts @@ -9,7 +9,6 @@ import { getL2ERC20Address } from './src/util/TokenUtils' import specFiles from './tests/e2e/specfiles.json' import { - NetworkName, checkForAssertions, generateActivityOnChains, NetworkType, diff --git a/packages/arb-token-bridge-ui/tests/support/common.ts b/packages/arb-token-bridge-ui/tests/support/common.ts index 63ff8948b6..ecd24a2f03 100644 --- a/packages/arb-token-bridge-ui/tests/support/common.ts +++ b/packages/arb-token-bridge-ui/tests/support/common.ts @@ -318,7 +318,7 @@ export function setupCypressTasks( { requiresNetworkSetup }: { requiresNetworkSetup: boolean } ) { let currentNetworkName: NetworkName | null = null - let networkSetupComplete = requiresNetworkSetup + let networkSetupComplete = !requiresNetworkSetup let walletConnectedToDapp = false on('task', { From 068647a50ff96381da832a14db4be6e464cc6cad Mon Sep 17 00:00:00 2001 From: Christophe Date: Wed, 14 Aug 2024 13:42:49 +0000 Subject: [PATCH 04/82] Cleanup --- .github/workflows/build-test.yml | 1 - packages/arb-token-bridge-ui/synpress.cctp.config.ts | 5 ++--- packages/arb-token-bridge-ui/synpress.config.ts | 4 ++-- tsconfig.eslint.json | 3 ++- 4 files changed, 6 insertions(+), 7 deletions(-) diff --git a/.github/workflows/build-test.yml b/.github/workflows/build-test.yml index eb506357c6..bffcb554d1 100644 --- a/.github/workflows/build-test.yml +++ b/.github/workflows/build-test.yml @@ -352,7 +352,6 @@ jobs: # SKIP_METAMASK_SETUP: true # CYPRESS_RECORD_VIDEO: ${{ matrix.tests.recordVideo }} # PRIVATE_KEY_CCTP: ${{ secrets.E2E_PRIVATE_KEY_CCTP }} - # LOCAL_CCTP_WALLET_PRIVATE_KEY: # PRIVATE_KEY_USER: ${{ secrets.E2E_PRIVATE_KEY_USER }} # NEXT_PUBLIC_IS_E2E_TEST: true # NEXT_PUBLIC_INFURA_KEY: ${{ secrets.NEXT_PUBLIC_INFURA_KEY }} diff --git a/packages/arb-token-bridge-ui/synpress.cctp.config.ts b/packages/arb-token-bridge-ui/synpress.cctp.config.ts index 2e371178d1..16175ee72d 100644 --- a/packages/arb-token-bridge-ui/synpress.cctp.config.ts +++ b/packages/arb-token-bridge-ui/synpress.cctp.config.ts @@ -2,10 +2,9 @@ import { Wallet, utils } from 'ethers' import { defineConfig } from 'cypress' import { StaticJsonRpcProvider } from '@ethersproject/providers' import synpressPlugins from '@synthetixio/synpress/plugins' +import logsPrinter from 'cypress-terminal-report/src/installLogsPrinter' import { getCommonSynpressConfig } from './tests/e2e/getCommonSynpressConfig' - import { fundEth, fundUsdc, setupCypressTasks } from './tests/support/common' -import { log } from 'console' const shouldRecordVideo = process.env.CYPRESS_RECORD_VIDEO === 'true' @@ -37,7 +36,7 @@ export default defineConfig({ ...getCommonSynpressConfig(shouldRecordVideo), e2e: { async setupNodeEvents(on, config) { - require('cypress-terminal-report/src/installLogsPrinter')(on) + logsPrinter(on) const userWalletAddress = await userWallet.getAddress() config.env.ADDRESS = userWalletAddress diff --git a/packages/arb-token-bridge-ui/synpress.config.ts b/packages/arb-token-bridge-ui/synpress.config.ts index 6405014a3d..7875da4dab 100644 --- a/packages/arb-token-bridge-ui/synpress.config.ts +++ b/packages/arb-token-bridge-ui/synpress.config.ts @@ -5,9 +5,9 @@ import synpressPlugins from '@synthetixio/synpress/plugins' import { TestWETH9__factory } from '@arbitrum/sdk/dist/lib/abi/factories/TestWETH9__factory' import { TestERC20__factory } from '@arbitrum/sdk/dist/lib/abi/factories/TestERC20__factory' import { Erc20Bridger } from '@arbitrum/sdk' +import logsPrinter from 'cypress-terminal-report/src/installLogsPrinter' import { getL2ERC20Address } from './src/util/TokenUtils' import specFiles from './tests/e2e/specfiles.json' - import { checkForAssertions, generateActivityOnChains, @@ -46,7 +46,7 @@ export default defineConfig({ ...getCommonSynpressConfig(shouldRecordVideo), e2e: { async setupNodeEvents(on, config) { - require('cypress-terminal-report/src/installLogsPrinter')(on) + logsPrinter(on) registerLocalNetwork() if (!ethRpcUrl && !isOrbitTest) { diff --git a/tsconfig.eslint.json b/tsconfig.eslint.json index 456b61d6a1..d0a591b7ca 100644 --- a/tsconfig.eslint.json +++ b/tsconfig.eslint.json @@ -10,6 +10,7 @@ // adding eslintrc here fixes eslint from throwing an error // https://stackoverflow.com/questions/63118405/how-to-fix-eslintrc-the-file-does-not-match-your-project-config ".eslintrc.js", - "./packages/arb-token-bridge-ui/tests/**/*.ts" + "./packages/arb-token-bridge-ui/tests/**/*.ts", + "./packages/arb-token-bridge-ui/synpress*.ts" ] } From 87d5076daf998fa1ae15497eef052e1fb95eb590 Mon Sep 17 00:00:00 2001 From: Christophe Date: Wed, 14 Aug 2024 17:25:41 +0000 Subject: [PATCH 05/82] Enable tests --- .github/workflows/build-test.yml | 194 +++++++++++++++---------------- 1 file changed, 97 insertions(+), 97 deletions(-) diff --git a/.github/workflows/build-test.yml b/.github/workflows/build-test.yml index bffcb554d1..3acc03a1f5 100644 --- a/.github/workflows/build-test.yml +++ b/.github/workflows/build-test.yml @@ -285,104 +285,104 @@ jobs: content=`cat packages/arb-token-bridge-ui/tests/e2e/cctp.json | jq --compact-output .` echo "e2eCctpFiles=$content" >> $GITHUB_OUTPUT - # test-e2e-cctp: - # name: "Test E2E - ${{ matrix.tests.name }}" - # runs-on: ubuntu-latest - # needs: [build, check-files, check-is-hotfix, load-e2e-cctp-files] - # if: needs.check-files.outputs.run_tests == 'true' && needs.check-is-hotfix.outputs.is_hotfix == 'false' - # strategy: - # fail-fast: false # If one test fails, let the other tests run - # matrix: - # tests: - # ${{ fromJson(needs.load-e2e-cctp-files.outputs.matrix) }} - - # steps: - # - name: Free Disk Space (Ubuntu) - # uses: jlumbroso/free-disk-space@main - # with: - # # this might remove tools that are actually needed, - # # if set to "true" but frees about 6 GB - # tool-cache: false + test-e2e-cctp: + name: "Test E2E - ${{ matrix.tests.name }}" + runs-on: ubuntu-latest + needs: [build, check-files, check-is-hotfix, load-e2e-cctp-files] + if: needs.check-files.outputs.run_tests == 'true' && needs.check-is-hotfix.outputs.is_hotfix == 'false' + strategy: + fail-fast: false # If one test fails, let the other tests run + matrix: + tests: + ${{ fromJson(needs.load-e2e-cctp-files.outputs.matrix) }} + + steps: + - name: Free Disk Space (Ubuntu) + uses: jlumbroso/free-disk-space@main + with: + # this might remove tools that are actually needed, + # if set to "true" but frees about 6 GB + tool-cache: false - # # all of these default to true, but feel free to set to - # # "false" if necessary for your workflow - # android: true - # dotnet: true - # haskell: true - # large-packages: true - # docker-images: false - # swap-storage: true - - # - name: Checkout - # uses: actions/checkout@v4 - - # - name: Install node_modules - # uses: OffchainLabs/actions/node-modules/install@main - - # - name: Restore build artifacts - # uses: ./.github/actions/build-artifacts/restore - - # - name: Install cypress - # run: yarn cypress install - - # - name: Install linux dependencies - # run: | - # sudo apt-get install --no-install-recommends -y \ - # fluxbox \ - # xvfb - - # - name: Run xvfb and fluxbox - # run: | - # Xvfb :0 -screen 0 1366x768x24 -listen tcp -ac & - # fluxbox & - # env: - # DISPLAY: :0.0 - - # - name: Run e2e tests via cypress-io/github-action - # uses: cypress-io/github-action@8d3918616d8ac34caa2b49afc8b408b6a872a6f5 # pin@v6.7.1 - # with: - # start: yarn start - # command: 'yarn test:e2e:cctp --browser chromium' - # wait-on: http://127.0.0.1:3000 - # wait-on-timeout: 120 - # spec: ./packages/arb-token-bridge-ui/tests/e2e/specs/* - # env: - # DISPLAY: :0.0 - # TEST_FILE: ${{ matrix.tests.file }} - # SKIP_METAMASK_SETUP: true - # CYPRESS_RECORD_VIDEO: ${{ matrix.tests.recordVideo }} - # PRIVATE_KEY_CCTP: ${{ secrets.E2E_PRIVATE_KEY_CCTP }} - # PRIVATE_KEY_USER: ${{ secrets.E2E_PRIVATE_KEY_USER }} - # NEXT_PUBLIC_IS_E2E_TEST: true - # NEXT_PUBLIC_INFURA_KEY: ${{ secrets.NEXT_PUBLIC_INFURA_KEY }} - - # - name: Archive e2e artifacts - # uses: actions/upload-artifact@v4 - # if: always() - # with: - # name: e2e-artifacts-pull-request-${{ github.event.pull_request.number }}-commit-${{ github.sha }}-cctp - # path: | - # ./packages/arb-token-bridge-ui/cypress/videos - # ./packages/arb-token-bridge-ui/cypress/screenshots - # continue-on-error: true - - # - name: Throw error if tests failed - # if: steps.e2e-cctp-run.outputs.status == 'failed' - # run: exit 1 - - # test-e2e-cctp-success: - # name: "Test E2E CCTP Success" - # runs-on: ubuntu-latest - # needs: [test-e2e-cctp] - # if: always() - # steps: - # - name: E2E Succeeded - # if: needs.test-e2e-cctp.result == 'success' || needs.test-e2e-cctp.result == 'skipped' - # run: echo "nice" - - # - name: E2E Failed - # if: needs.test-e2e-cctp.result != 'success' && needs.test-e2e-cctp.result != 'skipped' - # run: exit 1 + # all of these default to true, but feel free to set to + # "false" if necessary for your workflow + android: true + dotnet: true + haskell: true + large-packages: true + docker-images: false + swap-storage: true + + - name: Checkout + uses: actions/checkout@v4 + + - name: Install node_modules + uses: OffchainLabs/actions/node-modules/install@main + + - name: Restore build artifacts + uses: ./.github/actions/build-artifacts/restore + + - name: Install cypress + run: yarn cypress install + + - name: Install linux dependencies + run: | + sudo apt-get install --no-install-recommends -y \ + fluxbox \ + xvfb + + - name: Run xvfb and fluxbox + run: | + Xvfb :0 -screen 0 1366x768x24 -listen tcp -ac & + fluxbox & + env: + DISPLAY: :0.0 + + - name: Run e2e tests via cypress-io/github-action + uses: cypress-io/github-action@8d3918616d8ac34caa2b49afc8b408b6a872a6f5 # pin@v6.7.1 + with: + start: yarn start + command: 'yarn test:e2e:cctp --browser chromium' + wait-on: http://127.0.0.1:3000 + wait-on-timeout: 120 + spec: ./packages/arb-token-bridge-ui/tests/e2e/specs/* + env: + DISPLAY: :0.0 + TEST_FILE: ${{ matrix.tests.file }} + SKIP_METAMASK_SETUP: true + CYPRESS_RECORD_VIDEO: ${{ matrix.tests.recordVideo }} + PRIVATE_KEY_CCTP: ${{ secrets.E2E_PRIVATE_KEY_CCTP }} + PRIVATE_KEY_USER: ${{ secrets.E2E_PRIVATE_KEY_USER }} + NEXT_PUBLIC_IS_E2E_TEST: true + NEXT_PUBLIC_INFURA_KEY: ${{ secrets.NEXT_PUBLIC_INFURA_KEY }} + + - name: Archive e2e artifacts + uses: actions/upload-artifact@v4 + if: always() + with: + name: e2e-artifacts-pull-request-${{ github.event.pull_request.number }}-commit-${{ github.sha }}-cctp + path: | + ./packages/arb-token-bridge-ui/cypress/videos + ./packages/arb-token-bridge-ui/cypress/screenshots + continue-on-error: true + + - name: Throw error if tests failed + if: steps.e2e-cctp-run.outputs.status == 'failed' + run: exit 1 + + test-e2e-cctp-success: + name: "Test E2E CCTP Success" + runs-on: ubuntu-latest + needs: [test-e2e-cctp] + if: always() + steps: + - name: E2E Succeeded + if: needs.test-e2e-cctp.result == 'success' || needs.test-e2e-cctp.result == 'skipped' + run: echo "nice" + + - name: E2E Failed + if: needs.test-e2e-cctp.result != 'success' && needs.test-e2e-cctp.result != 'skipped' + run: exit 1 clean-up: name: "Clean Up" From d25098a23d7582b391c620f51ba464187358dd15 Mon Sep 17 00:00:00 2001 From: Christophe Date: Wed, 14 Aug 2024 17:53:35 +0000 Subject: [PATCH 06/82] WIP --- package.json | 2 +- .../synpress.cctp.config.ts | 1 + .../tests/support/common.ts | 25 ++++++++++--------- 3 files changed, 15 insertions(+), 13 deletions(-) diff --git a/package.json b/package.json index c60ae31523..498ec9f8ea 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,7 @@ "lint": "yarn workspace arb-token-bridge-ui lint", "lint:fix": "yarn workspace arb-token-bridge-ui lint:fix", "test:e2e": "yarn workspace arb-token-bridge-ui env-cmd --silent --file .e2e.env yarn synpress run --configFile synpress.config.ts", - "test:e2e:cctp": "yarn test:e2e --configFile synpress.cctp.config.ts", + "test:e2e:cctp": "yarn workspace arb-token-bridge-ui env-cmd --silent --file .e2e.env yarn synpress run --configFile synpress.cctp.config.ts", "test:e2e:orbit": "E2E_ORBIT=true yarn test:e2e" }, "resolutions": { diff --git a/packages/arb-token-bridge-ui/synpress.cctp.config.ts b/packages/arb-token-bridge-ui/synpress.cctp.config.ts index 16175ee72d..372fdb0bbf 100644 --- a/packages/arb-token-bridge-ui/synpress.cctp.config.ts +++ b/packages/arb-token-bridge-ui/synpress.cctp.config.ts @@ -43,6 +43,7 @@ export default defineConfig({ config.env.LOCAL_CCTP_WALLET_PRIVATE_KEY = localWallet.privateKey // Fund wallet + console.log(`Funding user wallet: ${userWalletAddress}`) await Promise.all([ // Sepolia fundEth({ diff --git a/packages/arb-token-bridge-ui/tests/support/common.ts b/packages/arb-token-bridge-ui/tests/support/common.ts index ecd24a2f03..b922e0623d 100644 --- a/packages/arb-token-bridge-ui/tests/support/common.ts +++ b/packages/arb-token-bridge-ui/tests/support/common.ts @@ -217,18 +217,19 @@ export async function fundUsdc({ amount: BigNumber networkType: NetworkType }) { - console.log(`Funding USDC to user wallet...`) - const usdcContractAddress = - networkType === 'parentChain' - ? CommonAddress.Sepolia.USDC - : CommonAddress.ArbitrumSepolia.USDC - - const localWallet = new Wallet(Cypress.env('LOCAL_CCTP_WALLET_PRIVATE_KEY')) - const contract = new ERC20__factory().connect(localWallet.connect(provider)) - const token = contract.attach(usdcContractAddress) - await token.deployed() - const tx = await token.transfer(address, amount) - await tx.wait() + console.log('Funding USDC to user wallet...') + console.log('Cypress', Cypress) + // const usdcContractAddress = + // networkType === 'parentChain' + // ? CommonAddress.Sepolia.USDC + // : CommonAddress.ArbitrumSepolia.USDC + + // const localWallet = new Wallet(Cypress.env('LOCAL_CCTP_WALLET_PRIVATE_KEY')) + // const contract = new ERC20__factory().connect(localWallet.connect(provider)) + // const token = contract.attach(usdcContractAddress) + // await token.deployed() + // const tx = await token.transfer(address, amount) + // await tx.wait() } export async function generateActivityOnChains({ From aa1a6581e4e06beaca5cb8504b0df8309ade3701 Mon Sep 17 00:00:00 2001 From: Christophe Date: Wed, 14 Aug 2024 18:13:27 +0000 Subject: [PATCH 07/82] WIP --- .github/workflows/build-test.yml | 216 +++++++++++++++---------------- 1 file changed, 108 insertions(+), 108 deletions(-) diff --git a/.github/workflows/build-test.yml b/.github/workflows/build-test.yml index 3acc03a1f5..f4375b291f 100644 --- a/.github/workflows/build-test.yml +++ b/.github/workflows/build-test.yml @@ -159,115 +159,115 @@ jobs: echo "e2eFiles=$content" >> $GITHUB_OUTPUT # based on https://github.com/Synthetixio/synpress/blob/dev/.github/workflows/e2e_cypress-action.yml - test-e2e: - name: "Test E2E${{ matrix.orbit-test == '1' && ' with L3' || '' }} - ${{ matrix.tests.name }}" - runs-on: ubuntu-latest - needs: [build, check-files, check-is-hotfix, load-e2e-files] - if: needs.check-files.outputs.run_tests == 'true' && needs.check-is-hotfix.outputs.is_hotfix == 'false' - strategy: - fail-fast: false # If one test fails, let the other tests run - matrix: - tests: - ${{ fromJson(needs.load-e2e-files.outputs.matrix) }} - orbit-test: ['0', '1'] - - steps: - - name: Free Disk Space (Ubuntu) - uses: jlumbroso/free-disk-space@main - with: - # this might remove tools that are actually needed, - # if set to "true" but frees about 6 GB - tool-cache: false + # test-e2e: + # name: "Test E2E${{ matrix.orbit-test == '1' && ' with L3' || '' }} - ${{ matrix.tests.name }}" + # runs-on: ubuntu-latest + # needs: [build, check-files, check-is-hotfix, load-e2e-files] + # if: needs.check-files.outputs.run_tests == 'true' && needs.check-is-hotfix.outputs.is_hotfix == 'false' + # strategy: + # fail-fast: false # If one test fails, let the other tests run + # matrix: + # tests: + # ${{ fromJson(needs.load-e2e-files.outputs.matrix) }} + # orbit-test: ['0', '1'] + + # steps: + # - name: Free Disk Space (Ubuntu) + # uses: jlumbroso/free-disk-space@main + # with: + # # this might remove tools that are actually needed, + # # if set to "true" but frees about 6 GB + # tool-cache: false - # all of these default to true, but feel free to set to - # "false" if necessary for your workflow - android: true - dotnet: true - haskell: true - large-packages: true - docker-images: false - swap-storage: true - - - name: Checkout - uses: actions/checkout@v4 - - - name: Install node_modules - uses: OffchainLabs/actions/node-modules/install@main - - - name: Restore build artifacts - uses: ./.github/actions/build-artifacts/restore - - - name: Install cypress - run: yarn cypress install - - - name: Install linux dependencies - run: | - sudo apt-get install --no-install-recommends -y \ - fluxbox \ - xvfb - - - name: Run xvfb and fluxbox - run: | - Xvfb :0 -screen 0 1366x768x24 -listen tcp -ac & - fluxbox & - env: - DISPLAY: :0.0 - - - name: Run nitro testnode - uses: OffchainLabs/actions/run-nitro-test-node@a20a76172ce524832ac897bef2fa10a62ed81c29 - with: - nitro-testnode-ref: aab133aceadec2e622f15fa438f6327e3165392d - l3-node: ${{ matrix.orbit-test == '1' }} - no-l3-token-bridge: ${{ matrix.orbit-test == '0' }} - - - name: Run e2e tests via cypress-io/github-action - uses: cypress-io/github-action@8d3918616d8ac34caa2b49afc8b408b6a872a6f5 # pin@v6.7.1 - with: - start: yarn start - command: ${{ matrix.orbit-test == '1' && 'yarn test:e2e:orbit --browser chromium' || 'yarn test:e2e --browser chromium' }} - wait-on: http://127.0.0.1:3000 - wait-on-timeout: 120 - spec: ./packages/arb-token-bridge-ui/tests/e2e/specs/* - env: - DISPLAY: :0.0 - TEST_FILE: ${{ matrix.tests.file }} - SKIP_METAMASK_SETUP: true - CYPRESS_RECORD_VIDEO: ${{ matrix.tests.recordVideo }} - PRIVATE_KEY_CUSTOM: ${{ secrets.E2E_PRIVATE_KEY }} - PRIVATE_KEY_USER: ${{ secrets.E2E_PRIVATE_KEY_USER }} - NEXT_PUBLIC_IS_E2E_TEST: true - NEXT_PUBLIC_INFURA_KEY: ${{ secrets.NEXT_PUBLIC_INFURA_KEY }} - NEXT_PUBLIC_LOCAL_ETHEREUM_RPC_URL: http://127.0.0.1:8545 - NEXT_PUBLIC_LOCAL_ARBITRUM_RPC_URL: http://127.0.0.1:8547 - NEXT_PUBLIC_LOCAL_L3_RPC_URL: http://127.0.0.1:3347 - - - name: Archive e2e artifacts - uses: actions/upload-artifact@v4 - if: always() - with: - name: e2e-artifacts-pull-request-${{ github.event.pull_request.number }}-commit-${{ github.sha }} - path: | - ./packages/arb-token-bridge-ui/cypress/videos - ./packages/arb-token-bridge-ui/cypress/screenshots - continue-on-error: true - - - name: Throw error if tests failed - if: steps.e2e-run.outputs.status == 'failed' - run: exit 1 - - test-e2e-success: - name: "Test E2E Success" - runs-on: ubuntu-latest - needs: [test-e2e] - if: always() - steps: - - name: E2E Succeeded - if: needs.test-e2e.result == 'success' || needs.test-e2e.result == 'skipped' - run: echo "nice" - - - name: E2E Failed - if: needs.test-e2e.result != 'success' && needs.test-e2e.result != 'skipped' - run: exit 1 + # # all of these default to true, but feel free to set to + # # "false" if necessary for your workflow + # android: true + # dotnet: true + # haskell: true + # large-packages: true + # docker-images: false + # swap-storage: true + + # - name: Checkout + # uses: actions/checkout@v4 + + # - name: Install node_modules + # uses: OffchainLabs/actions/node-modules/install@main + + # - name: Restore build artifacts + # uses: ./.github/actions/build-artifacts/restore + + # - name: Install cypress + # run: yarn cypress install + + # - name: Install linux dependencies + # run: | + # sudo apt-get install --no-install-recommends -y \ + # fluxbox \ + # xvfb + + # - name: Run xvfb and fluxbox + # run: | + # Xvfb :0 -screen 0 1366x768x24 -listen tcp -ac & + # fluxbox & + # env: + # DISPLAY: :0.0 + + # - name: Run nitro testnode + # uses: OffchainLabs/actions/run-nitro-test-node@a20a76172ce524832ac897bef2fa10a62ed81c29 + # with: + # nitro-testnode-ref: aab133aceadec2e622f15fa438f6327e3165392d + # l3-node: ${{ matrix.orbit-test == '1' }} + # no-l3-token-bridge: ${{ matrix.orbit-test == '0' }} + + # - name: Run e2e tests via cypress-io/github-action + # uses: cypress-io/github-action@8d3918616d8ac34caa2b49afc8b408b6a872a6f5 # pin@v6.7.1 + # with: + # start: yarn start + # command: ${{ matrix.orbit-test == '1' && 'yarn test:e2e:orbit --browser chromium' || 'yarn test:e2e --browser chromium' }} + # wait-on: http://127.0.0.1:3000 + # wait-on-timeout: 120 + # spec: ./packages/arb-token-bridge-ui/tests/e2e/specs/* + # env: + # DISPLAY: :0.0 + # TEST_FILE: ${{ matrix.tests.file }} + # SKIP_METAMASK_SETUP: true + # CYPRESS_RECORD_VIDEO: ${{ matrix.tests.recordVideo }} + # PRIVATE_KEY_CUSTOM: ${{ secrets.E2E_PRIVATE_KEY }} + # PRIVATE_KEY_USER: ${{ secrets.E2E_PRIVATE_KEY_USER }} + # NEXT_PUBLIC_IS_E2E_TEST: true + # NEXT_PUBLIC_INFURA_KEY: ${{ secrets.NEXT_PUBLIC_INFURA_KEY }} + # NEXT_PUBLIC_LOCAL_ETHEREUM_RPC_URL: http://127.0.0.1:8545 + # NEXT_PUBLIC_LOCAL_ARBITRUM_RPC_URL: http://127.0.0.1:8547 + # NEXT_PUBLIC_LOCAL_L3_RPC_URL: http://127.0.0.1:3347 + + # - name: Archive e2e artifacts + # uses: actions/upload-artifact@v4 + # if: always() + # with: + # name: e2e-artifacts-pull-request-${{ github.event.pull_request.number }}-commit-${{ github.sha }} + # path: | + # ./packages/arb-token-bridge-ui/cypress/videos + # ./packages/arb-token-bridge-ui/cypress/screenshots + # continue-on-error: true + + # - name: Throw error if tests failed + # if: steps.e2e-run.outputs.status == 'failed' + # run: exit 1 + + # test-e2e-success: + # name: "Test E2E Success" + # runs-on: ubuntu-latest + # needs: [test-e2e] + # if: always() + # steps: + # - name: E2E Succeeded + # if: needs.test-e2e.result == 'success' || needs.test-e2e.result == 'skipped' + # run: echo "nice" + + # - name: E2E Failed + # if: needs.test-e2e.result != 'success' && needs.test-e2e.result != 'skipped' + # run: exit 1 load-e2e-cctp-files: name: "Load e2e CCTP files" From c800534729a9ed4abbc26f82707173575b927c12 Mon Sep 17 00:00:00 2001 From: Christophe Date: Thu, 15 Aug 2024 12:57:51 +0000 Subject: [PATCH 08/82] WIP --- .../synpress.cctp.config.ts | 10 ++-- .../tests/e2e/cypress.d.ts | 6 +- .../tests/support/commands.ts | 56 ++++++++++++++++++- .../tests/support/common.ts | 54 +----------------- 4 files changed, 67 insertions(+), 59 deletions(-) diff --git a/packages/arb-token-bridge-ui/synpress.cctp.config.ts b/packages/arb-token-bridge-ui/synpress.cctp.config.ts index 372fdb0bbf..edf83eccc4 100644 --- a/packages/arb-token-bridge-ui/synpress.cctp.config.ts +++ b/packages/arb-token-bridge-ui/synpress.cctp.config.ts @@ -3,8 +3,8 @@ import { defineConfig } from 'cypress' import { StaticJsonRpcProvider } from '@ethersproject/providers' import synpressPlugins from '@synthetixio/synpress/plugins' import logsPrinter from 'cypress-terminal-report/src/installLogsPrinter' +import { setupCypressTasks } from './tests/support/common' import { getCommonSynpressConfig } from './tests/e2e/getCommonSynpressConfig' -import { fundEth, fundUsdc, setupCypressTasks } from './tests/support/common' const shouldRecordVideo = process.env.CYPRESS_RECORD_VIDEO === 'true' @@ -46,26 +46,26 @@ export default defineConfig({ console.log(`Funding user wallet: ${userWalletAddress}`) await Promise.all([ // Sepolia - fundEth({ + cy.fundEth({ address: userWalletAddress, provider: sepoliaProvider, sourceWallet: localWallet, amount: utils.parseEther('0.01') }), - fundUsdc({ + cy.fundUsdc({ address: userWalletAddress, provider: sepoliaProvider, networkType: 'parentChain', amount: utils.parseUnits('0.0001', 6) }), // ArbSepolia - fundEth({ + cy.fundEth({ address: userWalletAddress, provider: arbSepoliaProvider, sourceWallet: localWallet, amount: utils.parseEther('0.01') }), - fundUsdc({ + cy.fundUsdc({ address: userWalletAddress, provider: arbSepoliaProvider, networkType: 'childChain', 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 5c596b1f97..29389fc5c3 100644 --- a/packages/arb-token-bridge-ui/tests/e2e/cypress.d.ts +++ b/packages/arb-token-bridge-ui/tests/e2e/cypress.d.ts @@ -19,7 +19,9 @@ import { findTransactionDetailsCustomDestinationAddress, findTransactionInTransactionHistory, findClaimButton, - selectTransactionsPanelTab + selectTransactionsPanelTab, + fundUsdc, + fundEth } from '../support/commands' import { NetworkType, NetworkName } from '../support/common' @@ -62,6 +64,8 @@ declare global { findTransactionDetailsCustomDestinationAddress: typeof findTransactionDetailsCustomDestinationAddress findTransactionInTransactionHistory: typeof findTransactionInTransactionHistory findClaimButton: typeof findClaimButton + fundUsdc: typeof fundUsdc + fundEth: typeof fundEth } } } diff --git a/packages/arb-token-bridge-ui/tests/support/commands.ts b/packages/arb-token-bridge-ui/tests/support/commands.ts index 31c661cd8c..34c1aeb05e 100644 --- a/packages/arb-token-bridge-ui/tests/support/commands.ts +++ b/packages/arb-token-bridge-ui/tests/support/commands.ts @@ -17,6 +17,10 @@ import { getL2NetworkConfig } from './common' import { shortenAddress } from '../../src/util/CommonUtils' +import { Provider } from '@ethersproject/providers' +import { BigNumber, Wallet, ethers, utils } from 'ethers' +import { CommonAddress } from '../../src/util/CommonAddressUtils' +import { ERC20__factory } from '@arbitrum/sdk/dist/lib/abi/factories/ERC20__factory' function shouldChangeNetwork(networkName: NetworkName) { // synpress throws if trying to connect to a network we are already connected to @@ -321,6 +325,54 @@ export function findClaimButton( return cy.findByLabelText(`Claim ${amountToClaim}`) } +export async function fundUsdc({ + address, // wallet address where funding is required + provider, + amount, + networkType +}: { + address: string + provider: Provider + amount: BigNumber + networkType: NetworkType +}) { + console.log('Funding USDC to user wallet...') + const usdcContractAddress = + networkType === 'parentChain' + ? CommonAddress.Sepolia.USDC + : CommonAddress.ArbitrumSepolia.USDC + + const localWallet = new Wallet(Cypress.env('LOCAL_CCTP_WALLET_PRIVATE_KEY')) + const contract = new ERC20__factory().connect(localWallet.connect(provider)) + const token = contract.attach(usdcContractAddress) + await token.deployed() + const tx = await token.transfer(address, amount) + await tx.wait() +} + +export async function fundEth({ + address, // wallet address where funding is required + provider, + sourceWallet, // source wallet that will fund the `address`, + amount = utils.parseEther('2') +}: { + address: string + provider: Provider + sourceWallet: Wallet + amount?: BigNumber +}) { + console.log(`Funding ETH to user wallet...`) + const balance = await provider.getBalance(address) + // Fund only if the balance is less than 2 eth + if (balance.lt(amount)) { + const tx = await sourceWallet.connect(provider).sendTransaction({ + to: address, + value: amount + }) + await tx.wait() + } +} + Cypress.Commands.addAll({ connectToApp, login, @@ -340,5 +392,7 @@ Cypress.Commands.addAll({ closeTransactionDetails, findTransactionInTransactionHistory, findClaimButton, - findTransactionDetailsCustomDestinationAddress + findTransactionDetailsCustomDestinationAddress, + fundUsdc, + fundEth }) diff --git a/packages/arb-token-bridge-ui/tests/support/common.ts b/packages/arb-token-bridge-ui/tests/support/common.ts index b922e0623d..d8cafe02a8 100644 --- a/packages/arb-token-bridge-ui/tests/support/common.ts +++ b/packages/arb-token-bridge-ui/tests/support/common.ts @@ -3,13 +3,12 @@ */ import { Provider, StaticJsonRpcProvider } from '@ethersproject/providers' -import { BigNumber, Signer, Wallet, ethers, utils } from 'ethers' +import { BigNumber, Signer, Wallet, ethers } from 'ethers' import { MultiCaller } from '@arbitrum/sdk' import { MULTICALL_TESTNET_ADDRESS } from '../../src/constants' import { defaultL2Network, defaultL3Network } from '../../src/util/networks' import { getChainIdFromProvider } from '../../src/token-bridge-sdk/utils' -import { CommonAddress } from '../../src/util/CommonAddressUtils' -import { ERC20__factory } from '@arbitrum/sdk/dist/lib/abi/factories/ERC20__factory' +import { fundEth } from './commands' export type NetworkType = 'parentChain' | 'childChain' export type NetworkName = @@ -183,55 +182,6 @@ export const wait = (ms = 0): Promise => { return new Promise(res => setTimeout(res, ms)) } -export async function fundEth({ - address, // wallet address where funding is required - provider, - sourceWallet, // source wallet that will fund the `address`, - amount = utils.parseEther('2') -}: { - address: string - provider: Provider - sourceWallet: Wallet - amount?: BigNumber -}) { - console.log(`Funding ETH to user wallet...`) - const balance = await provider.getBalance(address) - // Fund only if the balance is less than 2 eth - if (balance.lt(amount)) { - const tx = await sourceWallet.connect(provider).sendTransaction({ - to: address, - value: amount - }) - await tx.wait() - } -} - -export async function fundUsdc({ - address, // wallet address where funding is required - provider, - amount, - networkType -}: { - address: string - provider: Provider - amount: BigNumber - networkType: NetworkType -}) { - console.log('Funding USDC to user wallet...') - console.log('Cypress', Cypress) - // const usdcContractAddress = - // networkType === 'parentChain' - // ? CommonAddress.Sepolia.USDC - // : CommonAddress.ArbitrumSepolia.USDC - - // const localWallet = new Wallet(Cypress.env('LOCAL_CCTP_WALLET_PRIVATE_KEY')) - // const contract = new ERC20__factory().connect(localWallet.connect(provider)) - // const token = contract.attach(usdcContractAddress) - // await token.deployed() - // const tx = await token.transfer(address, amount) - // await tx.wait() -} - export async function generateActivityOnChains({ parentProvider, childProvider, From ebd0fe7ef918ce49fe1835ea57f7daa989d0e004 Mon Sep 17 00:00:00 2001 From: Christophe Date: Thu, 15 Aug 2024 13:13:48 +0000 Subject: [PATCH 09/82] WIP --- .../synpress.cctp.config.ts | 66 +++++++++---------- 1 file changed, 33 insertions(+), 33 deletions(-) diff --git a/packages/arb-token-bridge-ui/synpress.cctp.config.ts b/packages/arb-token-bridge-ui/synpress.cctp.config.ts index edf83eccc4..8923b7f4d7 100644 --- a/packages/arb-token-bridge-ui/synpress.cctp.config.ts +++ b/packages/arb-token-bridge-ui/synpress.cctp.config.ts @@ -38,40 +38,40 @@ export default defineConfig({ async setupNodeEvents(on, config) { logsPrinter(on) - const userWalletAddress = await userWallet.getAddress() - config.env.ADDRESS = userWalletAddress - config.env.LOCAL_CCTP_WALLET_PRIVATE_KEY = localWallet.privateKey + // const userWalletAddress = await userWallet.getAddress() + // config.env.ADDRESS = userWalletAddress + // config.env.LOCAL_CCTP_WALLET_PRIVATE_KEY = localWallet.privateKey - // Fund wallet - console.log(`Funding user wallet: ${userWalletAddress}`) - await Promise.all([ - // Sepolia - cy.fundEth({ - address: userWalletAddress, - provider: sepoliaProvider, - sourceWallet: localWallet, - amount: utils.parseEther('0.01') - }), - cy.fundUsdc({ - address: userWalletAddress, - provider: sepoliaProvider, - networkType: 'parentChain', - amount: utils.parseUnits('0.0001', 6) - }), - // ArbSepolia - cy.fundEth({ - address: userWalletAddress, - provider: arbSepoliaProvider, - sourceWallet: localWallet, - amount: utils.parseEther('0.01') - }), - cy.fundUsdc({ - address: userWalletAddress, - provider: arbSepoliaProvider, - networkType: 'childChain', - amount: utils.parseUnits('0.0001', 6) - }) - ]) + // // Fund wallet + // console.log(`Funding user wallet: ${userWalletAddress}`) + // await Promise.all([ + // // Sepolia + // cy.fundEth({ + // address: userWalletAddress, + // provider: sepoliaProvider, + // sourceWallet: localWallet, + // amount: utils.parseEther('0.01') + // }), + // cy.fundUsdc({ + // address: userWalletAddress, + // provider: sepoliaProvider, + // networkType: 'parentChain', + // amount: utils.parseUnits('0.0001', 6) + // }), + // // ArbSepolia + // cy.fundEth({ + // address: userWalletAddress, + // provider: arbSepoliaProvider, + // sourceWallet: localWallet, + // amount: utils.parseEther('0.01') + // }), + // cy.fundUsdc({ + // address: userWalletAddress, + // provider: arbSepoliaProvider, + // networkType: 'childChain', + // amount: utils.parseUnits('0.0001', 6) + // }) + // ]) synpressPlugins(on, config) setupCypressTasks(on, { requiresNetworkSetup: false }) From 2fd494f507997d79eebec68fd68840f9f52bbae3 Mon Sep 17 00:00:00 2001 From: Christophe Date: Thu, 15 Aug 2024 13:25:04 +0000 Subject: [PATCH 10/82] WIP --- .../synpress.cctp.config.ts | 37 ++++++++++++++++++- 1 file changed, 35 insertions(+), 2 deletions(-) diff --git a/packages/arb-token-bridge-ui/synpress.cctp.config.ts b/packages/arb-token-bridge-ui/synpress.cctp.config.ts index 8923b7f4d7..2660bc62d0 100644 --- a/packages/arb-token-bridge-ui/synpress.cctp.config.ts +++ b/packages/arb-token-bridge-ui/synpress.cctp.config.ts @@ -1,9 +1,9 @@ -import { Wallet, utils } from 'ethers' +import { Wallet } from 'ethers' import { defineConfig } from 'cypress' import { StaticJsonRpcProvider } from '@ethersproject/providers' import synpressPlugins from '@synthetixio/synpress/plugins' import logsPrinter from 'cypress-terminal-report/src/installLogsPrinter' -import { setupCypressTasks } from './tests/support/common' +import { NetworkName } from './tests/support/common' import { getCommonSynpressConfig } from './tests/e2e/getCommonSynpressConfig' const shouldRecordVideo = process.env.CYPRESS_RECORD_VIDEO === 'true' @@ -82,3 +82,36 @@ export default defineConfig({ supportFile: 'tests/support/index.ts' } }) + +function setupCypressTasks( + on: Cypress.PluginEvents, + { requiresNetworkSetup }: { requiresNetworkSetup: boolean } +) { + let currentNetworkName: NetworkName | null = null + let networkSetupComplete = !requiresNetworkSetup + let walletConnectedToDapp = false + + on('task', { + setCurrentNetworkName: (networkName: NetworkName) => { + currentNetworkName = networkName + return null + }, + getCurrentNetworkName: () => { + return currentNetworkName + }, + setNetworkSetupComplete: () => { + networkSetupComplete = true + return null + }, + getNetworkSetupComplete: () => { + return networkSetupComplete + }, + setWalletConnectedToDapp: () => { + walletConnectedToDapp = true + return null + }, + getWalletConnectedToDapp: () => { + return walletConnectedToDapp + } + }) +} From 2dfa7f9e4ad3bb902ee27527725cecc6eb3c7c4c Mon Sep 17 00:00:00 2001 From: Christophe Date: Thu, 15 Aug 2024 13:28:56 +0000 Subject: [PATCH 11/82] WIP --- packages/arb-token-bridge-ui/synpress.cctp.config.ts | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/packages/arb-token-bridge-ui/synpress.cctp.config.ts b/packages/arb-token-bridge-ui/synpress.cctp.config.ts index 2660bc62d0..3b4a535ab5 100644 --- a/packages/arb-token-bridge-ui/synpress.cctp.config.ts +++ b/packages/arb-token-bridge-ui/synpress.cctp.config.ts @@ -74,7 +74,7 @@ export default defineConfig({ // ]) synpressPlugins(on, config) - setupCypressTasks(on, { requiresNetworkSetup: false }) + setupCypressTasks(on) return config }, baseUrl: 'http://localhost:3000', @@ -83,12 +83,9 @@ export default defineConfig({ } }) -function setupCypressTasks( - on: Cypress.PluginEvents, - { requiresNetworkSetup }: { requiresNetworkSetup: boolean } -) { +function setupCypressTasks(on: Cypress.PluginEvents) { let currentNetworkName: NetworkName | null = null - let networkSetupComplete = !requiresNetworkSetup + let networkSetupComplete = true let walletConnectedToDapp = false on('task', { From 1b1f88ec0d2c74b302fb3aa2b1be74416c9863a6 Mon Sep 17 00:00:00 2001 From: Christophe Date: Thu, 15 Aug 2024 14:50:22 +0000 Subject: [PATCH 12/82] WIP --- packages/arb-token-bridge-ui/synpress.cctp.config.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/arb-token-bridge-ui/synpress.cctp.config.ts b/packages/arb-token-bridge-ui/synpress.cctp.config.ts index 3b4a535ab5..171a80cc64 100644 --- a/packages/arb-token-bridge-ui/synpress.cctp.config.ts +++ b/packages/arb-token-bridge-ui/synpress.cctp.config.ts @@ -29,6 +29,7 @@ if (!process.env.TEST_FILE) { // Wallet funded on Sepolia and ArbSepolia with ETH and USDC const localWallet = new Wallet(process.env.PRIVATE_KEY_CCTP) +console.log(localWallet.address) // Generate a new wallet every time const userWallet = Wallet.createRandom() From 4617247597ac6d9fe37c0e9d8efac39cf39a70ee Mon Sep 17 00:00:00 2001 From: Christophe Date: Thu, 15 Aug 2024 15:04:13 +0000 Subject: [PATCH 13/82] WIP --- .../synpress.cctp.config.ts | 1 - .../tests/e2e/cypress.d.ts | 4 +- .../tests/support/commands.ts | 51 ++++++++++++++++++- .../tests/support/common.ts | 50 +----------------- .../tests/support/index.ts | 1 - 5 files changed, 53 insertions(+), 54 deletions(-) diff --git a/packages/arb-token-bridge-ui/synpress.cctp.config.ts b/packages/arb-token-bridge-ui/synpress.cctp.config.ts index 171a80cc64..3b4a535ab5 100644 --- a/packages/arb-token-bridge-ui/synpress.cctp.config.ts +++ b/packages/arb-token-bridge-ui/synpress.cctp.config.ts @@ -29,7 +29,6 @@ if (!process.env.TEST_FILE) { // Wallet funded on Sepolia and ArbSepolia with ETH and USDC const localWallet = new Wallet(process.env.PRIVATE_KEY_CCTP) -console.log(localWallet.address) // Generate a new wallet every time const userWallet = Wallet.createRandom() 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 29389fc5c3..30423656cb 100644 --- a/packages/arb-token-bridge-ui/tests/e2e/cypress.d.ts +++ b/packages/arb-token-bridge-ui/tests/e2e/cypress.d.ts @@ -21,7 +21,8 @@ import { findClaimButton, selectTransactionsPanelTab, fundUsdc, - fundEth + fundEth, + generateActivityOnChains } from '../support/commands' import { NetworkType, NetworkName } from '../support/common' @@ -66,6 +67,7 @@ declare global { findClaimButton: typeof findClaimButton fundUsdc: typeof fundUsdc fundEth: typeof fundEth + generateActivityOnChains: typeof generateActivityOnChains } } } diff --git a/packages/arb-token-bridge-ui/tests/support/commands.ts b/packages/arb-token-bridge-ui/tests/support/commands.ts index 34c1aeb05e..26c9e406a3 100644 --- a/packages/arb-token-bridge-ui/tests/support/commands.ts +++ b/packages/arb-token-bridge-ui/tests/support/commands.ts @@ -18,7 +18,7 @@ import { } from './common' import { shortenAddress } from '../../src/util/CommonUtils' import { Provider } from '@ethersproject/providers' -import { BigNumber, Wallet, ethers, utils } from 'ethers' +import { BigNumber, Signer, Wallet, ethers, utils } from 'ethers' import { CommonAddress } from '../../src/util/CommonAddressUtils' import { ERC20__factory } from '@arbitrum/sdk/dist/lib/abi/factories/ERC20__factory' @@ -373,6 +373,52 @@ export async function fundEth({ } } +export const wait = (ms = 0): Promise => { + return new Promise(res => setTimeout(res, ms)) +} +export async function generateActivityOnChains({ + parentProvider, + childProvider, + wallet +}: { + parentProvider: Provider + childProvider: Provider + wallet: Wallet +}) { + const keepMining = async (miner: Signer) => { + while (true) { + await ( + await miner.sendTransaction({ + to: await miner.getAddress(), + value: 0, + // random data to make the tx heavy, so that batches are posted sooner (since they're posted according to calldata size) + data: '0x0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000010c3c627574746f6e20636c6173733d226e61766261722d746f67676c65722220747970653d22627574746f6e2220646174612d746f67676c653d22636f6c6c617073652220646174612d7461726765743d22236e6176626172537570706f72746564436f6e74656e742220617269612d636f6e74726f6c733d226e6176626172537570706f72746564436f6e74656e742220617269612d657870616e6465643d2266616c73652220617269612d6c6162656c3d223c253d20676574746578742822546f67676c65206e617669676174696f6e222920253e223e203c7370616e20636c6173733d226e61766261722d746f67676c65722d69636f6e223e3c2f7370616e3e203c2f627574746f6e3e0000000000000000000000000000000000000000' + }) + ).wait() + + await wait(100) + } + } + // whilst waiting for status we mine on both parentChain and childChain + console.log('Generating activity on parentChain...') + const minerParent = Wallet.createRandom().connect(parentProvider) + await fundEth({ + address: await minerParent.getAddress(), + provider: parentProvider, + sourceWallet: wallet + }) + + console.log('Generating activity on childChain...') + const minerChild = Wallet.createRandom().connect(childProvider) + await fundEth({ + address: await minerChild.getAddress(), + provider: childProvider, + sourceWallet: wallet + }) + + await Promise.allSettled([keepMining(minerParent), keepMining(minerChild)]) +} + Cypress.Commands.addAll({ connectToApp, login, @@ -394,5 +440,6 @@ Cypress.Commands.addAll({ findClaimButton, findTransactionDetailsCustomDestinationAddress, fundUsdc, - fundEth + fundEth, + generateActivityOnChains }) diff --git a/packages/arb-token-bridge-ui/tests/support/common.ts b/packages/arb-token-bridge-ui/tests/support/common.ts index d8cafe02a8..08c9e6dda8 100644 --- a/packages/arb-token-bridge-ui/tests/support/common.ts +++ b/packages/arb-token-bridge-ui/tests/support/common.ts @@ -3,12 +3,11 @@ */ import { Provider, StaticJsonRpcProvider } from '@ethersproject/providers' -import { BigNumber, Signer, Wallet, ethers } from 'ethers' +import { BigNumber, ethers } from 'ethers' import { MultiCaller } from '@arbitrum/sdk' import { MULTICALL_TESTNET_ADDRESS } from '../../src/constants' import { defaultL2Network, defaultL3Network } from '../../src/util/networks' import { getChainIdFromProvider } from '../../src/token-bridge-sdk/utils' -import { fundEth } from './commands' export type NetworkType = 'parentChain' | 'childChain' export type NetworkName = @@ -178,53 +177,6 @@ export const visitAfterSomeDelay = ( cy.visit(url, options) } -export const wait = (ms = 0): Promise => { - return new Promise(res => setTimeout(res, ms)) -} - -export async function generateActivityOnChains({ - parentProvider, - childProvider, - wallet -}: { - parentProvider: Provider - childProvider: Provider - wallet: Wallet -}) { - const keepMining = async (miner: Signer) => { - while (true) { - await ( - await miner.sendTransaction({ - to: await miner.getAddress(), - value: 0, - // random data to make the tx heavy, so that batches are posted sooner (since they're posted according to calldata size) - data: '0x0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000010c3c627574746f6e20636c6173733d226e61766261722d746f67676c65722220747970653d22627574746f6e2220646174612d746f67676c653d22636f6c6c617073652220646174612d7461726765743d22236e6176626172537570706f72746564436f6e74656e742220617269612d636f6e74726f6c733d226e6176626172537570706f72746564436f6e74656e742220617269612d657870616e6465643d2266616c73652220617269612d6c6162656c3d223c253d20676574746578742822546f67676c65206e617669676174696f6e222920253e223e203c7370616e20636c6173733d226e61766261722d746f67676c65722d69636f6e223e3c2f7370616e3e203c2f627574746f6e3e0000000000000000000000000000000000000000' - }) - ).wait() - - await wait(100) - } - } - // whilst waiting for status we mine on both parentChain and childChain - console.log('Generating activity on parentChain...') - const minerParent = Wallet.createRandom().connect(parentProvider) - await fundEth({ - address: await minerParent.getAddress(), - provider: parentProvider, - sourceWallet: wallet - }) - - console.log('Generating activity on childChain...') - const minerChild = Wallet.createRandom().connect(childProvider) - await fundEth({ - address: await minerChild.getAddress(), - provider: childProvider, - sourceWallet: wallet - }) - - await Promise.allSettled([keepMining(minerParent), keepMining(minerChild)]) -} - export async function checkForAssertions({ parentProvider, isOrbitTest diff --git a/packages/arb-token-bridge-ui/tests/support/index.ts b/packages/arb-token-bridge-ui/tests/support/index.ts index c446f45741..ae0bbdc8b5 100644 --- a/packages/arb-token-bridge-ui/tests/support/index.ts +++ b/packages/arb-token-bridge-ui/tests/support/index.ts @@ -1,4 +1,3 @@ -import './commands' import '@synthetixio/synpress/support' import logCollector from 'cypress-terminal-report/src/installLogsCollector' From beca0899784ab2585353d42356c4befa27fb6518 Mon Sep 17 00:00:00 2001 From: Christophe Date: Thu, 15 Aug 2024 15:19:54 +0000 Subject: [PATCH 14/82] WIP --- .../synpress.cctp.config.ts | 103 ++++++----------- .../tests/e2e/cypress.d.ts | 4 +- .../tests/support/commands.ts | 99 +---------------- .../tests/support/common.ts | 105 +++++++++++++++++- .../tests/support/index.ts | 1 + 5 files changed, 144 insertions(+), 168 deletions(-) diff --git a/packages/arb-token-bridge-ui/synpress.cctp.config.ts b/packages/arb-token-bridge-ui/synpress.cctp.config.ts index 3b4a535ab5..fa88678fe3 100644 --- a/packages/arb-token-bridge-ui/synpress.cctp.config.ts +++ b/packages/arb-token-bridge-ui/synpress.cctp.config.ts @@ -1,10 +1,10 @@ -import { Wallet } from 'ethers' +import { Wallet, utils } from 'ethers' import { defineConfig } from 'cypress' import { StaticJsonRpcProvider } from '@ethersproject/providers' import synpressPlugins from '@synthetixio/synpress/plugins' import logsPrinter from 'cypress-terminal-report/src/installLogsPrinter' -import { NetworkName } from './tests/support/common' import { getCommonSynpressConfig } from './tests/e2e/getCommonSynpressConfig' +import { setupCypressTasks } from './tests/support/common' const shouldRecordVideo = process.env.CYPRESS_RECORD_VIDEO === 'true' @@ -38,43 +38,44 @@ export default defineConfig({ async setupNodeEvents(on, config) { logsPrinter(on) - // const userWalletAddress = await userWallet.getAddress() - // config.env.ADDRESS = userWalletAddress - // config.env.LOCAL_CCTP_WALLET_PRIVATE_KEY = localWallet.privateKey + const userWalletAddress = await userWallet.getAddress() + config.env.ADDRESS = userWalletAddress + config.env.LOCAL_CCTP_WALLET_PRIVATE_KEY = localWallet.privateKey - // // Fund wallet - // console.log(`Funding user wallet: ${userWalletAddress}`) - // await Promise.all([ - // // Sepolia - // cy.fundEth({ - // address: userWalletAddress, - // provider: sepoliaProvider, - // sourceWallet: localWallet, - // amount: utils.parseEther('0.01') - // }), - // cy.fundUsdc({ - // address: userWalletAddress, - // provider: sepoliaProvider, - // networkType: 'parentChain', - // amount: utils.parseUnits('0.0001', 6) - // }), - // // ArbSepolia - // cy.fundEth({ - // address: userWalletAddress, - // provider: arbSepoliaProvider, - // sourceWallet: localWallet, - // amount: utils.parseEther('0.01') - // }), - // cy.fundUsdc({ - // address: userWalletAddress, - // provider: arbSepoliaProvider, - // networkType: 'childChain', - // amount: utils.parseUnits('0.0001', 6) - // }) - // ]) + setupCypressTasks(on, { requiresNetworkSetup: false }) + + // Fund wallet + console.log(`Funding user wallet: ${userWalletAddress}`) + await Promise.all([ + // Sepolia + cy.task('fundEth', { + address: userWalletAddress, + provider: sepoliaProvider, + sourceWallet: localWallet, + amount: utils.parseEther('0.01') + }), + cy.task('fundUsdc', { + address: userWalletAddress, + provider: sepoliaProvider, + networkType: 'parentChain', + amount: utils.parseUnits('0.0001', 6) + }), + // ArbSepolia + cy.task('fundEth', { + address: userWalletAddress, + provider: arbSepoliaProvider, + sourceWallet: localWallet, + amount: utils.parseEther('0.01') + }), + cy.task('fundUsdc', { + address: userWalletAddress, + provider: arbSepoliaProvider, + networkType: 'childChain', + amount: utils.parseUnits('0.0001', 6) + }) + ]) synpressPlugins(on, config) - setupCypressTasks(on) return config }, baseUrl: 'http://localhost:3000', @@ -82,33 +83,3 @@ export default defineConfig({ supportFile: 'tests/support/index.ts' } }) - -function setupCypressTasks(on: Cypress.PluginEvents) { - let currentNetworkName: NetworkName | null = null - let networkSetupComplete = true - let walletConnectedToDapp = false - - on('task', { - setCurrentNetworkName: (networkName: NetworkName) => { - currentNetworkName = networkName - return null - }, - getCurrentNetworkName: () => { - return currentNetworkName - }, - setNetworkSetupComplete: () => { - networkSetupComplete = true - return null - }, - getNetworkSetupComplete: () => { - return networkSetupComplete - }, - setWalletConnectedToDapp: () => { - walletConnectedToDapp = true - return null - }, - getWalletConnectedToDapp: () => { - return walletConnectedToDapp - } - }) -} 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 30423656cb..29389fc5c3 100644 --- a/packages/arb-token-bridge-ui/tests/e2e/cypress.d.ts +++ b/packages/arb-token-bridge-ui/tests/e2e/cypress.d.ts @@ -21,8 +21,7 @@ import { findClaimButton, selectTransactionsPanelTab, fundUsdc, - fundEth, - generateActivityOnChains + fundEth } from '../support/commands' import { NetworkType, NetworkName } from '../support/common' @@ -67,7 +66,6 @@ declare global { findClaimButton: typeof findClaimButton fundUsdc: typeof fundUsdc fundEth: typeof fundEth - generateActivityOnChains: typeof generateActivityOnChains } } } diff --git a/packages/arb-token-bridge-ui/tests/support/commands.ts b/packages/arb-token-bridge-ui/tests/support/commands.ts index 26c9e406a3..3a7ddbf3f2 100644 --- a/packages/arb-token-bridge-ui/tests/support/commands.ts +++ b/packages/arb-token-bridge-ui/tests/support/commands.ts @@ -325,100 +325,6 @@ export function findClaimButton( return cy.findByLabelText(`Claim ${amountToClaim}`) } -export async function fundUsdc({ - address, // wallet address where funding is required - provider, - amount, - networkType -}: { - address: string - provider: Provider - amount: BigNumber - networkType: NetworkType -}) { - console.log('Funding USDC to user wallet...') - const usdcContractAddress = - networkType === 'parentChain' - ? CommonAddress.Sepolia.USDC - : CommonAddress.ArbitrumSepolia.USDC - - const localWallet = new Wallet(Cypress.env('LOCAL_CCTP_WALLET_PRIVATE_KEY')) - const contract = new ERC20__factory().connect(localWallet.connect(provider)) - const token = contract.attach(usdcContractAddress) - await token.deployed() - const tx = await token.transfer(address, amount) - await tx.wait() -} - -export async function fundEth({ - address, // wallet address where funding is required - provider, - sourceWallet, // source wallet that will fund the `address`, - amount = utils.parseEther('2') -}: { - address: string - provider: Provider - sourceWallet: Wallet - amount?: BigNumber -}) { - console.log(`Funding ETH to user wallet...`) - const balance = await provider.getBalance(address) - // Fund only if the balance is less than 2 eth - if (balance.lt(amount)) { - const tx = await sourceWallet.connect(provider).sendTransaction({ - to: address, - value: amount - }) - await tx.wait() - } -} - -export const wait = (ms = 0): Promise => { - return new Promise(res => setTimeout(res, ms)) -} -export async function generateActivityOnChains({ - parentProvider, - childProvider, - wallet -}: { - parentProvider: Provider - childProvider: Provider - wallet: Wallet -}) { - const keepMining = async (miner: Signer) => { - while (true) { - await ( - await miner.sendTransaction({ - to: await miner.getAddress(), - value: 0, - // random data to make the tx heavy, so that batches are posted sooner (since they're posted according to calldata size) - data: '0x0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000010c3c627574746f6e20636c6173733d226e61766261722d746f67676c65722220747970653d22627574746f6e2220646174612d746f67676c653d22636f6c6c617073652220646174612d7461726765743d22236e6176626172537570706f72746564436f6e74656e742220617269612d636f6e74726f6c733d226e6176626172537570706f72746564436f6e74656e742220617269612d657870616e6465643d2266616c73652220617269612d6c6162656c3d223c253d20676574746578742822546f67676c65206e617669676174696f6e222920253e223e203c7370616e20636c6173733d226e61766261722d746f67676c65722d69636f6e223e3c2f7370616e3e203c2f627574746f6e3e0000000000000000000000000000000000000000' - }) - ).wait() - - await wait(100) - } - } - // whilst waiting for status we mine on both parentChain and childChain - console.log('Generating activity on parentChain...') - const minerParent = Wallet.createRandom().connect(parentProvider) - await fundEth({ - address: await minerParent.getAddress(), - provider: parentProvider, - sourceWallet: wallet - }) - - console.log('Generating activity on childChain...') - const minerChild = Wallet.createRandom().connect(childProvider) - await fundEth({ - address: await minerChild.getAddress(), - provider: childProvider, - sourceWallet: wallet - }) - - await Promise.allSettled([keepMining(minerParent), keepMining(minerChild)]) -} - Cypress.Commands.addAll({ connectToApp, login, @@ -438,8 +344,5 @@ Cypress.Commands.addAll({ closeTransactionDetails, findTransactionInTransactionHistory, findClaimButton, - findTransactionDetailsCustomDestinationAddress, - fundUsdc, - fundEth, - generateActivityOnChains + findTransactionDetailsCustomDestinationAddress }) diff --git a/packages/arb-token-bridge-ui/tests/support/common.ts b/packages/arb-token-bridge-ui/tests/support/common.ts index 08c9e6dda8..f0f479b5ea 100644 --- a/packages/arb-token-bridge-ui/tests/support/common.ts +++ b/packages/arb-token-bridge-ui/tests/support/common.ts @@ -3,11 +3,13 @@ */ import { Provider, StaticJsonRpcProvider } from '@ethersproject/providers' -import { BigNumber, ethers } from 'ethers' +import { BigNumber, Signer, Wallet, ethers, utils } from 'ethers' import { MultiCaller } from '@arbitrum/sdk' import { MULTICALL_TESTNET_ADDRESS } from '../../src/constants' import { defaultL2Network, defaultL3Network } from '../../src/util/networks' import { getChainIdFromProvider } from '../../src/token-bridge-sdk/utils' +import { CommonAddress } from 'packages/arb-token-bridge-ui/src/util/CommonAddressUtils' +import { ERC20__factory } from '@arbitrum/sdk/dist/lib/abi/factories/ERC20__factory' export type NetworkType = 'parentChain' | 'childChain' export type NetworkName = @@ -177,6 +179,53 @@ export const visitAfterSomeDelay = ( cy.visit(url, options) } +export const wait = (ms = 0): Promise => { + return new Promise(res => setTimeout(res, ms)) +} + +export async function generateActivityOnChains({ + parentProvider, + childProvider, + wallet +}: { + parentProvider: Provider + childProvider: Provider + wallet: Wallet +}) { + const keepMining = async (miner: Signer) => { + while (true) { + await ( + await miner.sendTransaction({ + to: await miner.getAddress(), + value: 0, + // random data to make the tx heavy, so that batches are posted sooner (since they're posted according to calldata size) + data: '0x0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000010c3c627574746f6e20636c6173733d226e61766261722d746f67676c65722220747970653d22627574746f6e2220646174612d746f67676c653d22636f6c6c617073652220646174612d7461726765743d22236e6176626172537570706f72746564436f6e74656e742220617269612d636f6e74726f6c733d226e6176626172537570706f72746564436f6e74656e742220617269612d657870616e6465643d2266616c73652220617269612d6c6162656c3d223c253d20676574746578742822546f67676c65206e617669676174696f6e222920253e223e203c7370616e20636c6173733d226e61766261722d746f67676c65722d69636f6e223e3c2f7370616e3e203c2f627574746f6e3e0000000000000000000000000000000000000000' + }) + ).wait() + + await wait(100) + } + } + // whilst waiting for status we mine on both parentChain and childChain + console.log('Generating activity on parentChain...') + const minerParent = Wallet.createRandom().connect(parentProvider) + await fundEth({ + address: await minerParent.getAddress(), + provider: parentProvider, + sourceWallet: wallet + }) + + console.log('Generating activity on childChain...') + const minerChild = Wallet.createRandom().connect(childProvider) + await fundEth({ + address: await minerChild.getAddress(), + provider: childProvider, + sourceWallet: wallet + }) + + await Promise.allSettled([keepMining(minerParent), keepMining(minerChild)]) +} + export async function checkForAssertions({ parentProvider, isOrbitTest @@ -216,6 +265,54 @@ export async function checkForAssertions({ } } +async function fundUsdc({ + address, // wallet address where funding is required + provider, + amount, + networkType +}: { + address: string + provider: Provider + amount: BigNumber + networkType: NetworkType +}) { + console.log('Funding USDC to user wallet...') + const usdcContractAddress = + networkType === 'parentChain' + ? CommonAddress.Sepolia.USDC + : CommonAddress.ArbitrumSepolia.USDC + + const localWallet = new Wallet(Cypress.env('LOCAL_CCTP_WALLET_PRIVATE_KEY')) + const contract = new ERC20__factory().connect(localWallet.connect(provider)) + const token = contract.attach(usdcContractAddress) + await token.deployed() + const tx = await token.transfer(address, amount) + await tx.wait() +} + +async function fundEth({ + address, // wallet address where funding is required + provider, + sourceWallet, // source wallet that will fund the `address`, + amount = utils.parseEther('2') +}: { + address: string + provider: Provider + sourceWallet: Wallet + amount?: BigNumber +}) { + console.log(`Funding ETH to user wallet...`) + const balance = await provider.getBalance(address) + // Fund only if the balance is less than 2 eth + if (balance.lt(amount)) { + const tx = await sourceWallet.connect(provider).sendTransaction({ + to: address, + value: amount + }) + await tx.wait() + } +} + export function setupCypressTasks( on: Cypress.PluginEvents, { requiresNetworkSetup }: { requiresNetworkSetup: boolean } @@ -245,6 +342,12 @@ export function setupCypressTasks( }, getWalletConnectedToDapp: () => { return walletConnectedToDapp + }, + fundEth: (args: Parameters[0]) => { + return fundEth(args) + }, + fundUsdc: (args: Parameters[0]) => { + return fundUsdc(args) } }) } diff --git a/packages/arb-token-bridge-ui/tests/support/index.ts b/packages/arb-token-bridge-ui/tests/support/index.ts index ae0bbdc8b5..0381a41af0 100644 --- a/packages/arb-token-bridge-ui/tests/support/index.ts +++ b/packages/arb-token-bridge-ui/tests/support/index.ts @@ -6,6 +6,7 @@ import { getL2NetworkConfig, getL2TestnetNetworkConfig } from './common' +import './commands' Cypress.Keyboard.defaults({ // tests are flaky in CI with low keystroke delay From b71132b8bafe2d7384a2282abbe2a64ff0febf68 Mon Sep 17 00:00:00 2001 From: Christophe Date: Thu, 15 Aug 2024 15:27:51 +0000 Subject: [PATCH 15/82] Update path --- packages/arb-token-bridge-ui/synpress.cctp.config.ts | 1 - packages/arb-token-bridge-ui/tests/support/common.ts | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/packages/arb-token-bridge-ui/synpress.cctp.config.ts b/packages/arb-token-bridge-ui/synpress.cctp.config.ts index fa88678fe3..1f19d909c3 100644 --- a/packages/arb-token-bridge-ui/synpress.cctp.config.ts +++ b/packages/arb-token-bridge-ui/synpress.cctp.config.ts @@ -43,7 +43,6 @@ export default defineConfig({ config.env.LOCAL_CCTP_WALLET_PRIVATE_KEY = localWallet.privateKey setupCypressTasks(on, { requiresNetworkSetup: false }) - // Fund wallet console.log(`Funding user wallet: ${userWalletAddress}`) await Promise.all([ diff --git a/packages/arb-token-bridge-ui/tests/support/common.ts b/packages/arb-token-bridge-ui/tests/support/common.ts index f0f479b5ea..3697fc7980 100644 --- a/packages/arb-token-bridge-ui/tests/support/common.ts +++ b/packages/arb-token-bridge-ui/tests/support/common.ts @@ -8,7 +8,7 @@ import { MultiCaller } from '@arbitrum/sdk' import { MULTICALL_TESTNET_ADDRESS } from '../../src/constants' import { defaultL2Network, defaultL3Network } from '../../src/util/networks' import { getChainIdFromProvider } from '../../src/token-bridge-sdk/utils' -import { CommonAddress } from 'packages/arb-token-bridge-ui/src/util/CommonAddressUtils' +import { CommonAddress } from '../../../arb-token-bridge-ui/src/util/CommonAddressUtils' import { ERC20__factory } from '@arbitrum/sdk/dist/lib/abi/factories/ERC20__factory' export type NetworkType = 'parentChain' | 'childChain' From 2d954e5ebc0bbe04d980bfbc4e2f8d09892409b9 Mon Sep 17 00:00:00 2001 From: Christophe Date: Thu, 15 Aug 2024 15:42:48 +0000 Subject: [PATCH 16/82] Move setup to depositCctp beforeEach --- .../synpress.cctp.config.ts | 60 ++++++++++--------- .../tests/e2e/specs/depositCctp.cy.ts | 36 +++++++++++ 2 files changed, 67 insertions(+), 29 deletions(-) diff --git a/packages/arb-token-bridge-ui/synpress.cctp.config.ts b/packages/arb-token-bridge-ui/synpress.cctp.config.ts index 1f19d909c3..a3a8b2e6ee 100644 --- a/packages/arb-token-bridge-ui/synpress.cctp.config.ts +++ b/packages/arb-token-bridge-ui/synpress.cctp.config.ts @@ -41,39 +41,41 @@ export default defineConfig({ const userWalletAddress = await userWallet.getAddress() config.env.ADDRESS = userWalletAddress config.env.LOCAL_CCTP_WALLET_PRIVATE_KEY = localWallet.privateKey + config.env.SEPOLIA_INFURA_RPC_URL = SEPOLIA_INFURA_RPC_URL + config.env.ARB_SEPOLIA_INFURA_RPC_URL = ARB_SEPOLIA_INFURA_RPC_URL - setupCypressTasks(on, { requiresNetworkSetup: false }) // Fund wallet console.log(`Funding user wallet: ${userWalletAddress}`) - await Promise.all([ - // Sepolia - cy.task('fundEth', { - address: userWalletAddress, - provider: sepoliaProvider, - sourceWallet: localWallet, - amount: utils.parseEther('0.01') - }), - cy.task('fundUsdc', { - address: userWalletAddress, - provider: sepoliaProvider, - networkType: 'parentChain', - amount: utils.parseUnits('0.0001', 6) - }), - // ArbSepolia - cy.task('fundEth', { - address: userWalletAddress, - provider: arbSepoliaProvider, - sourceWallet: localWallet, - amount: utils.parseEther('0.01') - }), - cy.task('fundUsdc', { - address: userWalletAddress, - provider: arbSepoliaProvider, - networkType: 'childChain', - amount: utils.parseUnits('0.0001', 6) - }) - ]) + // await Promise.all([ + // // Sepolia + // cy.task('fundEth', { + // address: userWalletAddress, + // provider: sepoliaProvider, + // sourceWallet: localWallet, + // amount: utils.parseEther('0.01') + // }), + // cy.task('fundUsdc', { + // address: userWalletAddress, + // provider: sepoliaProvider, + // networkType: 'parentChain', + // amount: utils.parseUnits('0.0001', 6) + // }), + // // ArbSepolia + // cy.task('fundEth', { + // address: userWalletAddress, + // provider: arbSepoliaProvider, + // sourceWallet: localWallet, + // amount: utils.parseEther('0.01') + // }), + // cy.task('fundUsdc', { + // address: userWalletAddress, + // provider: arbSepoliaProvider, + // networkType: 'childChain', + // amount: utils.parseUnits('0.0001', 6) + // }) + // ]) + setupCypressTasks(on, { requiresNetworkSetup: false }) synpressPlugins(on, config) return 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 708821b8b1..3800392a88 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,8 @@ import { zeroToLessThanOneETH } from '../../support/common' import { CommonAddress } from '../../../src/util/CommonAddressUtils' +import { StaticJsonRpcProvider } from '@ethersproject/providers' +import { Wallet, utils } from 'ethers' // common function for this cctp deposit const confirmAndApproveCctpDeposit = () => { @@ -64,6 +66,40 @@ describe('Deposit USDC through CCTP', () => { let USDCAmountToSend = 0.0001 beforeEach(() => { + const userWalletAddress = Cypress.env('ADDRESS') + const sepoliaRpcUrl = Cypress.env('SEPOLIA_INFURA_RPC_URL') + const arbSepoliaRpcUrl = Cypress.env('SEPOLIA_INFURA_RPC_URL') + const localWalletPrivateKey = Cypress.env('LOCAL_CCTP_WALLET_PRIVATE_KEY') + const localWallet = new Wallet(localWalletPrivateKey) + + const sepoliaProvider = new StaticJsonRpcProvider(sepoliaRpcUrl) + const arbSepoliaProvider = new StaticJsonRpcProvider(arbSepoliaRpcUrl) + + cy.task('fundEth', { + address: userWalletAddress, + provider: sepoliaProvider, + sourceWallet: localWallet, + amount: utils.parseEther('0.01') + }) + cy.task('fundUsdc', { + address: userWalletAddress, + provider: sepoliaProvider, + networkType: 'parentChain', + amount: utils.parseUnits('0.0001', 6) + }) + // ArbSepolia + cy.task('fundEth', { + address: userWalletAddress, + provider: arbSepoliaProvider, + sourceWallet: localWallet, + amount: utils.parseEther('0.01') + }) + cy.task('fundUsdc', { + address: userWalletAddress, + provider: arbSepoliaProvider, + networkType: 'childChain', + amount: utils.parseUnits('0.0001', 6) + }) cy.login({ networkType: 'parentChain', networkName: 'sepolia' }) cy.findSourceChainButton('Sepolia') cy.findDestinationChainButton('Arbitrum Sepolia') From c4dcec58071ba3db5b9377ed00419f4a0be83d1f Mon Sep 17 00:00:00 2001 From: Christophe Date: Thu, 15 Aug 2024 16:11:28 +0000 Subject: [PATCH 17/82] WIP --- .../synpress.cctp.config.ts | 60 ++--- .../arb-token-bridge-ui/synpress.config.ts | 223 +++++++++++------- .../tests/e2e/cypress.d.ts | 6 +- .../tests/e2e/specs/depositCctp.cy.ts | 36 --- .../tests/support/common.ts | 17 +- 5 files changed, 181 insertions(+), 161 deletions(-) diff --git a/packages/arb-token-bridge-ui/synpress.cctp.config.ts b/packages/arb-token-bridge-ui/synpress.cctp.config.ts index a3a8b2e6ee..c6ad1ecc2b 100644 --- a/packages/arb-token-bridge-ui/synpress.cctp.config.ts +++ b/packages/arb-token-bridge-ui/synpress.cctp.config.ts @@ -4,7 +4,7 @@ import { StaticJsonRpcProvider } from '@ethersproject/providers' import synpressPlugins from '@synthetixio/synpress/plugins' import logsPrinter from 'cypress-terminal-report/src/installLogsPrinter' import { getCommonSynpressConfig } from './tests/e2e/getCommonSynpressConfig' -import { setupCypressTasks } from './tests/support/common' +import { setupCypressTasks, fundEth, fundUsdc } from './tests/support/common' const shouldRecordVideo = process.env.CYPRESS_RECORD_VIDEO === 'true' @@ -46,34 +46,36 @@ export default defineConfig({ // Fund wallet console.log(`Funding user wallet: ${userWalletAddress}`) - // await Promise.all([ - // // Sepolia - // cy.task('fundEth', { - // address: userWalletAddress, - // provider: sepoliaProvider, - // sourceWallet: localWallet, - // amount: utils.parseEther('0.01') - // }), - // cy.task('fundUsdc', { - // address: userWalletAddress, - // provider: sepoliaProvider, - // networkType: 'parentChain', - // amount: utils.parseUnits('0.0001', 6) - // }), - // // ArbSepolia - // cy.task('fundEth', { - // address: userWalletAddress, - // provider: arbSepoliaProvider, - // sourceWallet: localWallet, - // amount: utils.parseEther('0.01') - // }), - // cy.task('fundUsdc', { - // address: userWalletAddress, - // provider: arbSepoliaProvider, - // networkType: 'childChain', - // amount: utils.parseUnits('0.0001', 6) - // }) - // ]) + await Promise.all([ + // Sepolia + fundEth({ + address: userWalletAddress, + provider: sepoliaProvider, + sourceWallet: localWallet, + amount: utils.parseEther('0.01') + }), + fundUsdc({ + address: userWalletAddress, + provider: sepoliaProvider, + networkType: 'parentChain', + sourceWallet: localWallet, + amount: utils.parseUnits('0.0001', 6) + }), + // ArbSepolia + fundEth({ + address: userWalletAddress, + provider: arbSepoliaProvider, + sourceWallet: localWallet, + amount: utils.parseEther('0.01') + }), + fundUsdc({ + address: userWalletAddress, + provider: arbSepoliaProvider, + networkType: 'childChain', + sourceWallet: localWallet, + amount: utils.parseUnits('0.0001', 6) + }) + ]) setupCypressTasks(on, { requiresNetworkSetup: false }) synpressPlugins(on, config) diff --git a/packages/arb-token-bridge-ui/synpress.config.ts b/packages/arb-token-bridge-ui/synpress.config.ts index 7875da4dab..0ae8b451c8 100644 --- a/packages/arb-token-bridge-ui/synpress.config.ts +++ b/packages/arb-token-bridge-ui/synpress.config.ts @@ -8,12 +8,14 @@ import { Erc20Bridger } from '@arbitrum/sdk' import logsPrinter from 'cypress-terminal-report/src/installLogsPrinter' import { getL2ERC20Address } from './src/util/TokenUtils' import specFiles from './tests/e2e/specfiles.json' +import cctpFiles from './tests/e2e/cctp.json' import { checkForAssertions, generateActivityOnChains, NetworkType, fundEth, - setupCypressTasks + setupCypressTasks, + fundUsdc } from './tests/support/common' import { @@ -23,9 +25,14 @@ import { } from './src/util/networks' import { getCommonSynpressConfig } from './tests/e2e/getCommonSynpressConfig' -const tests = process.env.TEST_FILE - ? [process.env.TEST_FILE] - : specFiles.map(file => file.file) +let tests: string[] +if (process.env.TEST_FILE) { + tests = [process.env.TEST_FILE] +} else if (process.env.E2E_CCTP) { + tests = cctpFiles.map(file => file.file) +} else { + tests = specFiles.map(file => file.file) +} const isOrbitTest = process.env.E2E_ORBIT == 'true' const shouldRecordVideo = process.env.CYPRESS_RECORD_VIDEO === 'true' @@ -47,99 +54,154 @@ export default defineConfig({ e2e: { async setupNodeEvents(on, config) { logsPrinter(on) - registerLocalNetwork() - if (!ethRpcUrl && !isOrbitTest) { - throw new Error('NEXT_PUBLIC_LOCAL_ETHEREUM_RPC_URL variable missing.') - } - if (!arbRpcUrl) { - throw new Error('NEXT_PUBLIC_LOCAL_ARBITRUM_RPC_URL variable missing.') - } - if (!l3RpcUrl && isOrbitTest) { - throw new Error('NEXT_PUBLIC_LOCAL_L3_RPC_URL variable missing.') - } - if (!sepoliaRpcUrl) { - throw new Error( - 'process.env.NEXT_PUBLIC_SEPOLIA_RPC_URL variable missing.' - ) - } - - const userWalletAddress = await userWallet.getAddress() - - // Deploy ERC-20 token to L1 - const l1ERC20Token = await deployERC20ToL1() - - // Deploy ERC-20 token to L2 - await deployERC20ToL2(l1ERC20Token.address) - - // Mint ERC-20 token - // We need this to test token approval - // WETH is pre-approved so we need a new token - const mintedL1Erc20Token = await l1ERC20Token.mint() - await mintedL1Erc20Token.wait() - - // Send minted ERC-20 to the test userWallet - await l1ERC20Token - .connect(localWallet.connect(parentProvider)) - .transfer(userWalletAddress, BigNumber.from(50000000)) - - // Fund the userWallet. We do this to run tests on a small amount of ETH. - await Promise.all([ - fundEth({ - address: userWalletAddress, - provider: parentProvider, - sourceWallet: localWallet, - amount: utils.parseEther('2') - }), - fundEth({ - address: userWalletAddress, - provider: childProvider, - sourceWallet: localWallet, - amount: utils.parseEther('2') + const isCctp = process.env.E2E_CCTP + const sepoliaProvider = new StaticJsonRpcProvider(SEPOLIA_INFURA_RPC_URL) + const arbSepoliaProvider = new StaticJsonRpcProvider( + ARB_SEPOLIA_INFURA_RPC_URL + ) + + if (isCctp) { + if (!process.env.PRIVATE_KEY_CCTP) { + throw new Error('PRIVATE_KEY_CCTP variable missing.') + } + + // Wallet funded on Sepolia and ArbSepolia with ETH and USDC + const localWallet = new Wallet(process.env.PRIVATE_KEY_CCTP) + // Generate a new wallet every time + const randomWallet = Wallet.createRandom() + const randomWalletAddress = await randomWallet.getAddress() + config.env.LOCAL_CCTP_WALLET_PRIVATE_KEY = localWallet.privateKey + await Promise.all([ + // Sepolia + fundEth({ + address: randomWalletAddress, + provider: sepoliaProvider, + sourceWallet: localWallet, + amount: utils.parseEther('0.01') + }), + fundUsdc({ + address: randomWalletAddress, + provider: sepoliaProvider, + networkType: 'parentChain', + sourceWallet: localWallet, + amount: utils.parseUnits('0.0001', 6) + }), + // ArbSepolia + fundEth({ + address: randomWalletAddress, + provider: arbSepoliaProvider, + sourceWallet: localWallet, + amount: utils.parseEther('0.01') + }), + fundUsdc({ + address: randomWalletAddress, + provider: arbSepoliaProvider, + networkType: 'childChain', + sourceWallet: localWallet, + amount: utils.parseUnits('0.0001', 6) + }) + ]) + } else { + const userWalletAddress = await userWallet.getAddress() + registerLocalNetwork() + + if (!ethRpcUrl && !isOrbitTest) { + throw new Error( + 'NEXT_PUBLIC_LOCAL_ETHEREUM_RPC_URL variable missing.' + ) + } + if (!arbRpcUrl) { + throw new Error( + 'NEXT_PUBLIC_LOCAL_ARBITRUM_RPC_URL variable missing.' + ) + } + if (!l3RpcUrl && isOrbitTest) { + throw new Error('NEXT_PUBLIC_LOCAL_L3_RPC_URL variable missing.') + } + if (!sepoliaRpcUrl) { + throw new Error( + 'process.env.NEXT_PUBLIC_SEPOLIA_RPC_URL variable missing.' + ) + } + + // Deploy ERC-20 token to L1 + const l1ERC20Token = await deployERC20ToL1() + + // Deploy ERC-20 token to L2 + await deployERC20ToL2(l1ERC20Token.address) + + // Mint ERC-20 token + // We need this to test token approval + // WETH is pre-approved so we need a new token + const mintedL1Erc20Token = await l1ERC20Token.mint() + await mintedL1Erc20Token.wait() + + // Send minted ERC-20 to the test userWallet + await l1ERC20Token + .connect(localWallet.connect(parentProvider)) + .transfer(userWalletAddress, BigNumber.from(50000000)) + + // Fund the userWallet. We do this to run tests on a small amount of ETH. + await Promise.all([ + fundEth({ + address: userWalletAddress, + provider: parentProvider, + sourceWallet: localWallet, + amount: utils.parseEther('2') + }), + fundEth({ + address: userWalletAddress, + provider: childProvider, + sourceWallet: localWallet, + amount: utils.parseEther('2') + }) + ]) + + // Wrap ETH to test ERC-20 transactions + await Promise.all([wrapEth('parentChain'), wrapEth('childChain')]) + + // Approve WETH + await approveWeth() + + // Generate activity on chains so that assertions get posted and claims can be made + generateActivityOnChains({ + parentProvider, + childProvider, + wallet: localWallet + }) + // Also keep watching assertions since they will act as a proof of activity and claims for withdrawals + checkForAssertions({ parentProvider, isOrbitTest }) + + config.env.ADDRESS = userWalletAddress + config.env.ERC20_TOKEN_ADDRESS_L1 = l1ERC20Token.address + config.env.ERC20_TOKEN_ADDRESS_L2 = await getL2ERC20Address({ + erc20L1Address: l1ERC20Token.address, + l1Provider: parentProvider, + l2Provider: childProvider }) - ]) - - // Wrap ETH to test ERC-20 transactions - await Promise.all([wrapEth('parentChain'), wrapEth('childChain')]) - - // Approve WETH - await approveWeth() - // Generate activity on chains so that assertions get posted and claims can be made - generateActivityOnChains({ - parentProvider, - childProvider, - wallet: localWallet - }) - // Also keep watching assertions since they will act as a proof of activity and claims for withdrawals - checkForAssertions({ parentProvider, isOrbitTest }) + config.env.L1_WETH_ADDRESS = l1WethAddress + config.env.L2_WETH_ADDRESS = l2WethAddress + config.env.REDEEM_RETRYABLE_TEST_TX = + await generateTestTxForRedeemRetryable() + } // Set Cypress variables config.env.ETH_RPC_URL = isOrbitTest ? arbRpcUrl : ethRpcUrl config.env.ARB_RPC_URL = isOrbitTest ? l3RpcUrl : arbRpcUrl config.env.ETH_SEPOLIA_RPC_URL = sepoliaRpcUrl config.env.ARB_SEPOLIA_RPC_URL = arbSepoliaRpcUrl - config.env.ADDRESS = userWalletAddress + config.env.PRIVATE_KEY = userWallet.privateKey config.env.INFURA_KEY = process.env.NEXT_PUBLIC_INFURA_KEY - config.env.ERC20_TOKEN_ADDRESS_L1 = l1ERC20Token.address + config.env.LOCAL_WALLET_PRIVATE_KEY = localWallet.privateKey config.env.ORBIT_TEST = isOrbitTest ? '1' : '0' config.env.CUSTOM_DESTINATION_ADDRESS = await getCustomDestinationAddress() - config.env.ERC20_TOKEN_ADDRESS_L2 = await getL2ERC20Address({ - erc20L1Address: l1ERC20Token.address, - l1Provider: parentProvider, - l2Provider: childProvider - }) - config.env.L1_WETH_ADDRESS = l1WethAddress - config.env.L2_WETH_ADDRESS = l2WethAddress - - config.env.REDEEM_RETRYABLE_TEST_TX = - await generateTestTxForRedeemRetryable() - synpressPlugins(on, config) setupCypressTasks(on, { requiresNetworkSetup: true }) return config @@ -157,6 +219,7 @@ if (typeof INFURA_KEY === 'undefined') { const MAINNET_INFURA_RPC_URL = `https://mainnet.infura.io/v3/${INFURA_KEY}` const SEPOLIA_INFURA_RPC_URL = `https://sepolia.infura.io/v3/${INFURA_KEY}` +const ARB_SEPOLIA_INFURA_RPC_URL = `https://arbitrum-sepolia.infura.io/v3/${INFURA_KEY}` const ethRpcUrl = (() => { // MetaMask comes with a default http://localhost:8545 network with 'localhost' as network name 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 29389fc5c3..5c596b1f97 100644 --- a/packages/arb-token-bridge-ui/tests/e2e/cypress.d.ts +++ b/packages/arb-token-bridge-ui/tests/e2e/cypress.d.ts @@ -19,9 +19,7 @@ import { findTransactionDetailsCustomDestinationAddress, findTransactionInTransactionHistory, findClaimButton, - selectTransactionsPanelTab, - fundUsdc, - fundEth + selectTransactionsPanelTab } from '../support/commands' import { NetworkType, NetworkName } from '../support/common' @@ -64,8 +62,6 @@ declare global { findTransactionDetailsCustomDestinationAddress: typeof findTransactionDetailsCustomDestinationAddress findTransactionInTransactionHistory: typeof findTransactionInTransactionHistory findClaimButton: typeof findClaimButton - fundUsdc: typeof fundUsdc - fundEth: typeof fundEth } } } 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 3800392a88..708821b8b1 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,8 +4,6 @@ import { zeroToLessThanOneETH } from '../../support/common' import { CommonAddress } from '../../../src/util/CommonAddressUtils' -import { StaticJsonRpcProvider } from '@ethersproject/providers' -import { Wallet, utils } from 'ethers' // common function for this cctp deposit const confirmAndApproveCctpDeposit = () => { @@ -66,40 +64,6 @@ describe('Deposit USDC through CCTP', () => { let USDCAmountToSend = 0.0001 beforeEach(() => { - const userWalletAddress = Cypress.env('ADDRESS') - const sepoliaRpcUrl = Cypress.env('SEPOLIA_INFURA_RPC_URL') - const arbSepoliaRpcUrl = Cypress.env('SEPOLIA_INFURA_RPC_URL') - const localWalletPrivateKey = Cypress.env('LOCAL_CCTP_WALLET_PRIVATE_KEY') - const localWallet = new Wallet(localWalletPrivateKey) - - const sepoliaProvider = new StaticJsonRpcProvider(sepoliaRpcUrl) - const arbSepoliaProvider = new StaticJsonRpcProvider(arbSepoliaRpcUrl) - - cy.task('fundEth', { - address: userWalletAddress, - provider: sepoliaProvider, - sourceWallet: localWallet, - amount: utils.parseEther('0.01') - }) - cy.task('fundUsdc', { - address: userWalletAddress, - provider: sepoliaProvider, - networkType: 'parentChain', - amount: utils.parseUnits('0.0001', 6) - }) - // ArbSepolia - cy.task('fundEth', { - address: userWalletAddress, - provider: arbSepoliaProvider, - sourceWallet: localWallet, - amount: utils.parseEther('0.01') - }) - cy.task('fundUsdc', { - address: userWalletAddress, - provider: arbSepoliaProvider, - networkType: 'childChain', - amount: utils.parseUnits('0.0001', 6) - }) cy.login({ networkType: 'parentChain', networkName: 'sepolia' }) cy.findSourceChainButton('Sepolia') cy.findDestinationChainButton('Arbitrum Sepolia') diff --git a/packages/arb-token-bridge-ui/tests/support/common.ts b/packages/arb-token-bridge-ui/tests/support/common.ts index 3697fc7980..a0430a086d 100644 --- a/packages/arb-token-bridge-ui/tests/support/common.ts +++ b/packages/arb-token-bridge-ui/tests/support/common.ts @@ -265,15 +265,17 @@ export async function checkForAssertions({ } } -async function fundUsdc({ +export async function fundUsdc({ address, // wallet address where funding is required provider, amount, - networkType + networkType, + sourceWallet }: { address: string provider: Provider amount: BigNumber + sourceWallet: Wallet networkType: NetworkType }) { console.log('Funding USDC to user wallet...') @@ -282,15 +284,14 @@ async function fundUsdc({ ? CommonAddress.Sepolia.USDC : CommonAddress.ArbitrumSepolia.USDC - const localWallet = new Wallet(Cypress.env('LOCAL_CCTP_WALLET_PRIVATE_KEY')) - const contract = new ERC20__factory().connect(localWallet.connect(provider)) + const contract = new ERC20__factory().connect(sourceWallet.connect(provider)) const token = contract.attach(usdcContractAddress) await token.deployed() const tx = await token.transfer(address, amount) await tx.wait() } -async function fundEth({ +export async function fundEth({ address, // wallet address where funding is required provider, sourceWallet, // source wallet that will fund the `address`, @@ -342,12 +343,6 @@ export function setupCypressTasks( }, getWalletConnectedToDapp: () => { return walletConnectedToDapp - }, - fundEth: (args: Parameters[0]) => { - return fundEth(args) - }, - fundUsdc: (args: Parameters[0]) => { - return fundUsdc(args) } }) } From e533bbc8fc6adeaa8750ae8d546a0502e8954981 Mon Sep 17 00:00:00 2001 From: Christophe Date: Thu, 15 Aug 2024 16:23:43 +0000 Subject: [PATCH 18/82] Separate funding transactions --- .github/workflows/build-test.yml | 28 +++++++++---------- .../synpress.cctp.config.ts | 16 ++++++----- 2 files changed, 23 insertions(+), 21 deletions(-) diff --git a/.github/workflows/build-test.yml b/.github/workflows/build-test.yml index f4375b291f..e93365f4a6 100644 --- a/.github/workflows/build-test.yml +++ b/.github/workflows/build-test.yml @@ -297,21 +297,21 @@ jobs: ${{ fromJson(needs.load-e2e-cctp-files.outputs.matrix) }} steps: - - name: Free Disk Space (Ubuntu) - uses: jlumbroso/free-disk-space@main - with: - # this might remove tools that are actually needed, - # if set to "true" but frees about 6 GB - tool-cache: false + # - name: Free Disk Space (Ubuntu) + # uses: jlumbroso/free-disk-space@main + # with: + # # this might remove tools that are actually needed, + # # if set to "true" but frees about 6 GB + # tool-cache: false - # all of these default to true, but feel free to set to - # "false" if necessary for your workflow - android: true - dotnet: true - haskell: true - large-packages: true - docker-images: false - swap-storage: true + # # all of these default to true, but feel free to set to + # # "false" if necessary for your workflow + # android: true + # dotnet: true + # haskell: true + # large-packages: true + # docker-images: false + # swap-storage: true - name: Checkout uses: actions/checkout@v4 diff --git a/packages/arb-token-bridge-ui/synpress.cctp.config.ts b/packages/arb-token-bridge-ui/synpress.cctp.config.ts index c6ad1ecc2b..d74d977cfd 100644 --- a/packages/arb-token-bridge-ui/synpress.cctp.config.ts +++ b/packages/arb-token-bridge-ui/synpress.cctp.config.ts @@ -54,19 +54,21 @@ export default defineConfig({ sourceWallet: localWallet, amount: utils.parseEther('0.01') }), - fundUsdc({ - address: userWalletAddress, - provider: sepoliaProvider, - networkType: 'parentChain', - sourceWallet: localWallet, - amount: utils.parseUnits('0.0001', 6) - }), // ArbSepolia fundEth({ address: userWalletAddress, provider: arbSepoliaProvider, sourceWallet: localWallet, amount: utils.parseEther('0.01') + }) + ]) + await Promise.all([ + fundUsdc({ + address: userWalletAddress, + provider: sepoliaProvider, + networkType: 'parentChain', + sourceWallet: localWallet, + amount: utils.parseUnits('0.0001', 6) }), fundUsdc({ address: userWalletAddress, From 4190b1771bd5c66dd59f6093ab8959fc8672b4f6 Mon Sep 17 00:00:00 2001 From: Christophe Date: Thu, 15 Aug 2024 16:39:29 +0000 Subject: [PATCH 19/82] Update depositCctp spend --- .../arb-token-bridge-ui/tests/e2e/specs/depositCctp.cy.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 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 708821b8b1..4fe198d17e 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 @@ -86,7 +86,9 @@ describe('Deposit USDC through CCTP', () => { cy.findMoveFundsButton().click() confirmAndApproveCctpDeposit() - cy.confirmMetamaskPermissionToSpend(USDCAmountToSend.toString()) + cy.confirmMetamaskPermissionToSpend({ + spendLimit: USDCAmountToSend.toString() + }) // eslint-disable-next-line cy.wait(40_000) @@ -102,7 +104,9 @@ describe('Deposit USDC through CCTP', () => { cy.fillCustomDestinationAddress() cy.findMoveFundsButton().click() confirmAndApproveCctpDeposit() - cy.confirmMetamaskPermissionToSpend(USDCAmountToSend.toString()) + cy.confirmMetamaskPermissionToSpend({ + spendLimit: USDCAmountToSend.toString() + }) // eslint-disable-next-line cy.wait(40_000) From 0ea6870612396114c51ce3ddd2f51f1d5f3b06fa Mon Sep 17 00:00:00 2001 From: Christophe Date: Thu, 15 Aug 2024 16:56:51 +0000 Subject: [PATCH 20/82] Run all tests --- .github/workflows/build-test.yml | 218 ++++++++--------- .../arb-token-bridge-ui/synpress.config.ts | 223 +++++++----------- 2 files changed, 189 insertions(+), 252 deletions(-) diff --git a/.github/workflows/build-test.yml b/.github/workflows/build-test.yml index e93365f4a6..317726159f 100644 --- a/.github/workflows/build-test.yml +++ b/.github/workflows/build-test.yml @@ -159,115 +159,115 @@ jobs: echo "e2eFiles=$content" >> $GITHUB_OUTPUT # based on https://github.com/Synthetixio/synpress/blob/dev/.github/workflows/e2e_cypress-action.yml - # test-e2e: - # name: "Test E2E${{ matrix.orbit-test == '1' && ' with L3' || '' }} - ${{ matrix.tests.name }}" - # runs-on: ubuntu-latest - # needs: [build, check-files, check-is-hotfix, load-e2e-files] - # if: needs.check-files.outputs.run_tests == 'true' && needs.check-is-hotfix.outputs.is_hotfix == 'false' - # strategy: - # fail-fast: false # If one test fails, let the other tests run - # matrix: - # tests: - # ${{ fromJson(needs.load-e2e-files.outputs.matrix) }} - # orbit-test: ['0', '1'] - - # steps: - # - name: Free Disk Space (Ubuntu) - # uses: jlumbroso/free-disk-space@main - # with: - # # this might remove tools that are actually needed, - # # if set to "true" but frees about 6 GB - # tool-cache: false + test-e2e: + name: "Test E2E${{ matrix.orbit-test == '1' && ' with L3' || '' }} - ${{ matrix.tests.name }}" + runs-on: ubuntu-latest + needs: [build, check-files, check-is-hotfix, load-e2e-files] + if: needs.check-files.outputs.run_tests == 'true' && needs.check-is-hotfix.outputs.is_hotfix == 'false' + strategy: + fail-fast: false # If one test fails, let the other tests run + matrix: + tests: + ${{ fromJson(needs.load-e2e-files.outputs.matrix) }} + orbit-test: ['0', '1'] + + steps: + - name: Free Disk Space (Ubuntu) + uses: jlumbroso/free-disk-space@main + with: + # this might remove tools that are actually needed, + # if set to "true" but frees about 6 GB + tool-cache: false - # # all of these default to true, but feel free to set to - # # "false" if necessary for your workflow - # android: true - # dotnet: true - # haskell: true - # large-packages: true - # docker-images: false - # swap-storage: true - - # - name: Checkout - # uses: actions/checkout@v4 - - # - name: Install node_modules - # uses: OffchainLabs/actions/node-modules/install@main - - # - name: Restore build artifacts - # uses: ./.github/actions/build-artifacts/restore - - # - name: Install cypress - # run: yarn cypress install - - # - name: Install linux dependencies - # run: | - # sudo apt-get install --no-install-recommends -y \ - # fluxbox \ - # xvfb - - # - name: Run xvfb and fluxbox - # run: | - # Xvfb :0 -screen 0 1366x768x24 -listen tcp -ac & - # fluxbox & - # env: - # DISPLAY: :0.0 - - # - name: Run nitro testnode - # uses: OffchainLabs/actions/run-nitro-test-node@a20a76172ce524832ac897bef2fa10a62ed81c29 - # with: - # nitro-testnode-ref: aab133aceadec2e622f15fa438f6327e3165392d - # l3-node: ${{ matrix.orbit-test == '1' }} - # no-l3-token-bridge: ${{ matrix.orbit-test == '0' }} - - # - name: Run e2e tests via cypress-io/github-action - # uses: cypress-io/github-action@8d3918616d8ac34caa2b49afc8b408b6a872a6f5 # pin@v6.7.1 - # with: - # start: yarn start - # command: ${{ matrix.orbit-test == '1' && 'yarn test:e2e:orbit --browser chromium' || 'yarn test:e2e --browser chromium' }} - # wait-on: http://127.0.0.1:3000 - # wait-on-timeout: 120 - # spec: ./packages/arb-token-bridge-ui/tests/e2e/specs/* - # env: - # DISPLAY: :0.0 - # TEST_FILE: ${{ matrix.tests.file }} - # SKIP_METAMASK_SETUP: true - # CYPRESS_RECORD_VIDEO: ${{ matrix.tests.recordVideo }} - # PRIVATE_KEY_CUSTOM: ${{ secrets.E2E_PRIVATE_KEY }} - # PRIVATE_KEY_USER: ${{ secrets.E2E_PRIVATE_KEY_USER }} - # NEXT_PUBLIC_IS_E2E_TEST: true - # NEXT_PUBLIC_INFURA_KEY: ${{ secrets.NEXT_PUBLIC_INFURA_KEY }} - # NEXT_PUBLIC_LOCAL_ETHEREUM_RPC_URL: http://127.0.0.1:8545 - # NEXT_PUBLIC_LOCAL_ARBITRUM_RPC_URL: http://127.0.0.1:8547 - # NEXT_PUBLIC_LOCAL_L3_RPC_URL: http://127.0.0.1:3347 - - # - name: Archive e2e artifacts - # uses: actions/upload-artifact@v4 - # if: always() - # with: - # name: e2e-artifacts-pull-request-${{ github.event.pull_request.number }}-commit-${{ github.sha }} - # path: | - # ./packages/arb-token-bridge-ui/cypress/videos - # ./packages/arb-token-bridge-ui/cypress/screenshots - # continue-on-error: true - - # - name: Throw error if tests failed - # if: steps.e2e-run.outputs.status == 'failed' - # run: exit 1 - - # test-e2e-success: - # name: "Test E2E Success" - # runs-on: ubuntu-latest - # needs: [test-e2e] - # if: always() - # steps: - # - name: E2E Succeeded - # if: needs.test-e2e.result == 'success' || needs.test-e2e.result == 'skipped' - # run: echo "nice" - - # - name: E2E Failed - # if: needs.test-e2e.result != 'success' && needs.test-e2e.result != 'skipped' - # run: exit 1 + # all of these default to true, but feel free to set to + # "false" if necessary for your workflow + android: true + dotnet: true + haskell: true + large-packages: true + docker-images: false + swap-storage: true + + - name: Checkout + uses: actions/checkout@v4 + + - name: Install node_modules + uses: OffchainLabs/actions/node-modules/install@main + + - name: Restore build artifacts + uses: ./.github/actions/build-artifacts/restore + + - name: Install cypress + run: yarn cypress install + + - name: Install linux dependencies + run: | + sudo apt-get install --no-install-recommends -y \ + fluxbox \ + xvfb + + - name: Run xvfb and fluxbox + run: | + Xvfb :0 -screen 0 1366x768x24 -listen tcp -ac & + fluxbox & + env: + DISPLAY: :0.0 + + - name: Run nitro testnode + uses: OffchainLabs/actions/run-nitro-test-node@a20a76172ce524832ac897bef2fa10a62ed81c29 + with: + nitro-testnode-ref: aab133aceadec2e622f15fa438f6327e3165392d + l3-node: ${{ matrix.orbit-test == '1' }} + no-l3-token-bridge: ${{ matrix.orbit-test == '0' }} + + - name: Run e2e tests via cypress-io/github-action + uses: cypress-io/github-action@8d3918616d8ac34caa2b49afc8b408b6a872a6f5 # pin@v6.7.1 + with: + start: yarn start + command: ${{ matrix.orbit-test == '1' && 'yarn test:e2e:orbit --browser chromium' || 'yarn test:e2e --browser chromium' }} + wait-on: http://127.0.0.1:3000 + wait-on-timeout: 120 + spec: ./packages/arb-token-bridge-ui/tests/e2e/specs/* + env: + DISPLAY: :0.0 + TEST_FILE: ${{ matrix.tests.file }} + SKIP_METAMASK_SETUP: true + CYPRESS_RECORD_VIDEO: ${{ matrix.tests.recordVideo }} + PRIVATE_KEY_CUSTOM: ${{ secrets.E2E_PRIVATE_KEY }} + PRIVATE_KEY_USER: ${{ secrets.E2E_PRIVATE_KEY_USER }} + NEXT_PUBLIC_IS_E2E_TEST: true + NEXT_PUBLIC_INFURA_KEY: ${{ secrets.NEXT_PUBLIC_INFURA_KEY }} + NEXT_PUBLIC_LOCAL_ETHEREUM_RPC_URL: http://127.0.0.1:8545 + NEXT_PUBLIC_LOCAL_ARBITRUM_RPC_URL: http://127.0.0.1:8547 + NEXT_PUBLIC_LOCAL_L3_RPC_URL: http://127.0.0.1:3347 + + - name: Archive e2e artifacts + uses: actions/upload-artifact@v4 + if: always() + with: + name: e2e-artifacts-pull-request-${{ github.event.pull_request.number }}-commit-${{ github.sha }} + path: | + ./packages/arb-token-bridge-ui/cypress/videos + ./packages/arb-token-bridge-ui/cypress/screenshots + continue-on-error: true + + - name: Throw error if tests failed + if: steps.e2e-run.outputs.status == 'failed' + run: exit 1 + + test-e2e-success: + name: "Test E2E Success" + runs-on: ubuntu-latest + needs: [test-e2e] + if: always() + steps: + - name: E2E Succeeded + if: needs.test-e2e.result == 'success' || needs.test-e2e.result == 'skipped' + run: echo "nice" + + - name: E2E Failed + if: needs.test-e2e.result != 'success' && needs.test-e2e.result != 'skipped' + run: exit 1 load-e2e-cctp-files: name: "Load e2e CCTP files" @@ -342,7 +342,7 @@ jobs: uses: cypress-io/github-action@8d3918616d8ac34caa2b49afc8b408b6a872a6f5 # pin@v6.7.1 with: start: yarn start - command: 'yarn test:e2e:cctp --browser chromium' + command: 'yarn test:e2e:cctp --browser chrome' wait-on: http://127.0.0.1:3000 wait-on-timeout: 120 spec: ./packages/arb-token-bridge-ui/tests/e2e/specs/* diff --git a/packages/arb-token-bridge-ui/synpress.config.ts b/packages/arb-token-bridge-ui/synpress.config.ts index 0ae8b451c8..7875da4dab 100644 --- a/packages/arb-token-bridge-ui/synpress.config.ts +++ b/packages/arb-token-bridge-ui/synpress.config.ts @@ -8,14 +8,12 @@ import { Erc20Bridger } from '@arbitrum/sdk' import logsPrinter from 'cypress-terminal-report/src/installLogsPrinter' import { getL2ERC20Address } from './src/util/TokenUtils' import specFiles from './tests/e2e/specfiles.json' -import cctpFiles from './tests/e2e/cctp.json' import { checkForAssertions, generateActivityOnChains, NetworkType, fundEth, - setupCypressTasks, - fundUsdc + setupCypressTasks } from './tests/support/common' import { @@ -25,14 +23,9 @@ import { } from './src/util/networks' import { getCommonSynpressConfig } from './tests/e2e/getCommonSynpressConfig' -let tests: string[] -if (process.env.TEST_FILE) { - tests = [process.env.TEST_FILE] -} else if (process.env.E2E_CCTP) { - tests = cctpFiles.map(file => file.file) -} else { - tests = specFiles.map(file => file.file) -} +const tests = process.env.TEST_FILE + ? [process.env.TEST_FILE] + : specFiles.map(file => file.file) const isOrbitTest = process.env.E2E_ORBIT == 'true' const shouldRecordVideo = process.env.CYPRESS_RECORD_VIDEO === 'true' @@ -54,154 +47,99 @@ export default defineConfig({ e2e: { async setupNodeEvents(on, config) { logsPrinter(on) + registerLocalNetwork() - const isCctp = process.env.E2E_CCTP - const sepoliaProvider = new StaticJsonRpcProvider(SEPOLIA_INFURA_RPC_URL) - const arbSepoliaProvider = new StaticJsonRpcProvider( - ARB_SEPOLIA_INFURA_RPC_URL - ) - - if (isCctp) { - if (!process.env.PRIVATE_KEY_CCTP) { - throw new Error('PRIVATE_KEY_CCTP variable missing.') - } - - // Wallet funded on Sepolia and ArbSepolia with ETH and USDC - const localWallet = new Wallet(process.env.PRIVATE_KEY_CCTP) - // Generate a new wallet every time - const randomWallet = Wallet.createRandom() - const randomWalletAddress = await randomWallet.getAddress() - config.env.LOCAL_CCTP_WALLET_PRIVATE_KEY = localWallet.privateKey - await Promise.all([ - // Sepolia - fundEth({ - address: randomWalletAddress, - provider: sepoliaProvider, - sourceWallet: localWallet, - amount: utils.parseEther('0.01') - }), - fundUsdc({ - address: randomWalletAddress, - provider: sepoliaProvider, - networkType: 'parentChain', - sourceWallet: localWallet, - amount: utils.parseUnits('0.0001', 6) - }), - // ArbSepolia - fundEth({ - address: randomWalletAddress, - provider: arbSepoliaProvider, - sourceWallet: localWallet, - amount: utils.parseEther('0.01') - }), - fundUsdc({ - address: randomWalletAddress, - provider: arbSepoliaProvider, - networkType: 'childChain', - sourceWallet: localWallet, - amount: utils.parseUnits('0.0001', 6) - }) - ]) - } else { - const userWalletAddress = await userWallet.getAddress() - registerLocalNetwork() - - if (!ethRpcUrl && !isOrbitTest) { - throw new Error( - 'NEXT_PUBLIC_LOCAL_ETHEREUM_RPC_URL variable missing.' - ) - } - if (!arbRpcUrl) { - throw new Error( - 'NEXT_PUBLIC_LOCAL_ARBITRUM_RPC_URL variable missing.' - ) - } - if (!l3RpcUrl && isOrbitTest) { - throw new Error('NEXT_PUBLIC_LOCAL_L3_RPC_URL variable missing.') - } - if (!sepoliaRpcUrl) { - throw new Error( - 'process.env.NEXT_PUBLIC_SEPOLIA_RPC_URL variable missing.' - ) - } - - // Deploy ERC-20 token to L1 - const l1ERC20Token = await deployERC20ToL1() - - // Deploy ERC-20 token to L2 - await deployERC20ToL2(l1ERC20Token.address) - - // Mint ERC-20 token - // We need this to test token approval - // WETH is pre-approved so we need a new token - const mintedL1Erc20Token = await l1ERC20Token.mint() - await mintedL1Erc20Token.wait() - - // Send minted ERC-20 to the test userWallet - await l1ERC20Token - .connect(localWallet.connect(parentProvider)) - .transfer(userWalletAddress, BigNumber.from(50000000)) - - // Fund the userWallet. We do this to run tests on a small amount of ETH. - await Promise.all([ - fundEth({ - address: userWalletAddress, - provider: parentProvider, - sourceWallet: localWallet, - amount: utils.parseEther('2') - }), - fundEth({ - address: userWalletAddress, - provider: childProvider, - sourceWallet: localWallet, - amount: utils.parseEther('2') - }) - ]) - - // Wrap ETH to test ERC-20 transactions - await Promise.all([wrapEth('parentChain'), wrapEth('childChain')]) - - // Approve WETH - await approveWeth() - - // Generate activity on chains so that assertions get posted and claims can be made - generateActivityOnChains({ - parentProvider, - childProvider, - wallet: localWallet - }) - // Also keep watching assertions since they will act as a proof of activity and claims for withdrawals - checkForAssertions({ parentProvider, isOrbitTest }) - - config.env.ADDRESS = userWalletAddress - config.env.ERC20_TOKEN_ADDRESS_L1 = l1ERC20Token.address - config.env.ERC20_TOKEN_ADDRESS_L2 = await getL2ERC20Address({ - erc20L1Address: l1ERC20Token.address, - l1Provider: parentProvider, - l2Provider: childProvider + if (!ethRpcUrl && !isOrbitTest) { + throw new Error('NEXT_PUBLIC_LOCAL_ETHEREUM_RPC_URL variable missing.') + } + if (!arbRpcUrl) { + throw new Error('NEXT_PUBLIC_LOCAL_ARBITRUM_RPC_URL variable missing.') + } + if (!l3RpcUrl && isOrbitTest) { + throw new Error('NEXT_PUBLIC_LOCAL_L3_RPC_URL variable missing.') + } + if (!sepoliaRpcUrl) { + throw new Error( + 'process.env.NEXT_PUBLIC_SEPOLIA_RPC_URL variable missing.' + ) + } + + const userWalletAddress = await userWallet.getAddress() + + // Deploy ERC-20 token to L1 + const l1ERC20Token = await deployERC20ToL1() + + // Deploy ERC-20 token to L2 + await deployERC20ToL2(l1ERC20Token.address) + + // Mint ERC-20 token + // We need this to test token approval + // WETH is pre-approved so we need a new token + const mintedL1Erc20Token = await l1ERC20Token.mint() + await mintedL1Erc20Token.wait() + + // Send minted ERC-20 to the test userWallet + await l1ERC20Token + .connect(localWallet.connect(parentProvider)) + .transfer(userWalletAddress, BigNumber.from(50000000)) + + // Fund the userWallet. We do this to run tests on a small amount of ETH. + await Promise.all([ + fundEth({ + address: userWalletAddress, + provider: parentProvider, + sourceWallet: localWallet, + amount: utils.parseEther('2') + }), + fundEth({ + address: userWalletAddress, + provider: childProvider, + sourceWallet: localWallet, + amount: utils.parseEther('2') }) + ]) - config.env.L1_WETH_ADDRESS = l1WethAddress - config.env.L2_WETH_ADDRESS = l2WethAddress - config.env.REDEEM_RETRYABLE_TEST_TX = - await generateTestTxForRedeemRetryable() - } + // Wrap ETH to test ERC-20 transactions + await Promise.all([wrapEth('parentChain'), wrapEth('childChain')]) + + // Approve WETH + await approveWeth() + + // Generate activity on chains so that assertions get posted and claims can be made + generateActivityOnChains({ + parentProvider, + childProvider, + wallet: localWallet + }) + // Also keep watching assertions since they will act as a proof of activity and claims for withdrawals + checkForAssertions({ parentProvider, isOrbitTest }) // Set Cypress variables config.env.ETH_RPC_URL = isOrbitTest ? arbRpcUrl : ethRpcUrl config.env.ARB_RPC_URL = isOrbitTest ? l3RpcUrl : arbRpcUrl config.env.ETH_SEPOLIA_RPC_URL = sepoliaRpcUrl config.env.ARB_SEPOLIA_RPC_URL = arbSepoliaRpcUrl - + config.env.ADDRESS = userWalletAddress config.env.PRIVATE_KEY = userWallet.privateKey config.env.INFURA_KEY = process.env.NEXT_PUBLIC_INFURA_KEY - + config.env.ERC20_TOKEN_ADDRESS_L1 = l1ERC20Token.address config.env.LOCAL_WALLET_PRIVATE_KEY = localWallet.privateKey config.env.ORBIT_TEST = isOrbitTest ? '1' : '0' config.env.CUSTOM_DESTINATION_ADDRESS = await getCustomDestinationAddress() + config.env.ERC20_TOKEN_ADDRESS_L2 = await getL2ERC20Address({ + erc20L1Address: l1ERC20Token.address, + l1Provider: parentProvider, + l2Provider: childProvider + }) + config.env.L1_WETH_ADDRESS = l1WethAddress + config.env.L2_WETH_ADDRESS = l2WethAddress + + config.env.REDEEM_RETRYABLE_TEST_TX = + await generateTestTxForRedeemRetryable() + synpressPlugins(on, config) setupCypressTasks(on, { requiresNetworkSetup: true }) return config @@ -219,7 +157,6 @@ if (typeof INFURA_KEY === 'undefined') { const MAINNET_INFURA_RPC_URL = `https://mainnet.infura.io/v3/${INFURA_KEY}` const SEPOLIA_INFURA_RPC_URL = `https://sepolia.infura.io/v3/${INFURA_KEY}` -const ARB_SEPOLIA_INFURA_RPC_URL = `https://arbitrum-sepolia.infura.io/v3/${INFURA_KEY}` const ethRpcUrl = (() => { // MetaMask comes with a default http://localhost:8545 network with 'localhost' as network name From c4522acda2972118fc9eb27d4e02e340957419c7 Mon Sep 17 00:00:00 2001 From: Christophe Date: Thu, 15 Aug 2024 17:23:13 +0000 Subject: [PATCH 21/82] Update approveToken test --- packages/arb-token-bridge-ui/tests/e2e/specs/approveToken.cy.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/arb-token-bridge-ui/tests/e2e/specs/approveToken.cy.ts b/packages/arb-token-bridge-ui/tests/e2e/specs/approveToken.cy.ts index da3ed22763..ea0b4c334b 100644 --- a/packages/arb-token-bridge-ui/tests/e2e/specs/approveToken.cy.ts +++ b/packages/arb-token-bridge-ui/tests/e2e/specs/approveToken.cy.ts @@ -40,7 +40,7 @@ describe('Approve token and deposit afterwards', () => { cy.findByRole('button', { name: /Pay approval fee of/ }).click() - cy.confirmMetamaskPermissionToSpend('1') + cy.confirmMetamaskPermissionToSpend({ spendLimit: '1' }) }) }) }) From c15c6de4a41d9f0faef38f440d81c17763db3328 Mon Sep 17 00:00:00 2001 From: Christophe Date: Thu, 15 Aug 2024 19:44:25 +0000 Subject: [PATCH 22/82] Add cy.confirmMetamaskDataSignatureRequest() --- .../tests/e2e/specs/approveToken.cy.ts | 1 + .../tests/e2e/specs/depositCctp.cy.ts | 2 + .../tests/e2e/specs/withdrawCctp.cy.ts | 10 +- yarn.lock | 105 +++++++----------- 4 files changed, 51 insertions(+), 67 deletions(-) diff --git a/packages/arb-token-bridge-ui/tests/e2e/specs/approveToken.cy.ts b/packages/arb-token-bridge-ui/tests/e2e/specs/approveToken.cy.ts index ea0b4c334b..27ea79e098 100644 --- a/packages/arb-token-bridge-ui/tests/e2e/specs/approveToken.cy.ts +++ b/packages/arb-token-bridge-ui/tests/e2e/specs/approveToken.cy.ts @@ -41,6 +41,7 @@ describe('Approve token and deposit afterwards', () => { name: /Pay approval fee of/ }).click() cy.confirmMetamaskPermissionToSpend({ spendLimit: '1' }) + cy.confirmMetamaskDataSignatureRequest() }) }) }) 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 4fe198d17e..2283a93303 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 @@ -89,6 +89,7 @@ describe('Deposit USDC through CCTP', () => { cy.confirmMetamaskPermissionToSpend({ spendLimit: USDCAmountToSend.toString() }) + cy.confirmMetamaskDataSignatureRequest() // eslint-disable-next-line cy.wait(40_000) @@ -107,6 +108,7 @@ describe('Deposit USDC through CCTP', () => { cy.confirmMetamaskPermissionToSpend({ spendLimit: USDCAmountToSend.toString() }) + cy.confirmMetamaskDataSignatureRequest() // eslint-disable-next-line cy.wait(40_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 84ce90c1ca..3db70bc320 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 @@ -76,7 +76,10 @@ describe('Withdraw USDC through CCTP', () => { cy.findMoveFundsButton().click() confirmAndApproveCctpWithdrawal() - cy.confirmMetamaskPermissionToSpend(USDCAmountToSend.toString()) + cy.confirmMetamaskPermissionToSpend({ + spendLimit: USDCAmountToSend.toString() + }) + cy.confirmMetamaskDataSignatureRequest() // eslint-disable-next-line cy.wait(40_000) cy.confirmMetamaskTransaction() @@ -92,7 +95,10 @@ describe('Withdraw USDC through CCTP', () => { cy.fillCustomDestinationAddress() cy.findMoveFundsButton().click() confirmAndApproveCctpWithdrawal() - cy.confirmMetamaskPermissionToSpend(USDCAmountToSend.toString()) + cy.confirmMetamaskPermissionToSpend({ + spendLimit: USDCAmountToSend.toString() + }) + cy.confirmMetamaskDataSignatureRequest() // eslint-disable-next-line cy.wait(40_000) diff --git a/yarn.lock b/yarn.lock index d114739aec..314e47c623 100644 --- a/yarn.lock +++ b/yarn.lock @@ -497,14 +497,14 @@ "@jridgewell/trace-mapping" "0.3.9" "@cypress/code-coverage@^3.11.0": - version "3.12.44" - resolved "https://registry.yarnpkg.com/@cypress/code-coverage/-/code-coverage-3.12.44.tgz#38ea430f8df77c67e07f283351e4c9f97151b14b" - integrity sha512-5Eau3tnJqZJo1OddOOEMyWs1HCwlAOgDs1rFPaCXJ4a5Y2BR4PH4fAzCdMvIqpBnCiVSL8gOYv6JfND3aUuJJQ== + version "3.12.45" + resolved "https://registry.yarnpkg.com/@cypress/code-coverage/-/code-coverage-3.12.45.tgz#45eeeb53391153767640a5a1a626b0d6e4c417b0" + integrity sha512-QRvdc9Zmner/CxQ1F5jcNVZR8P8VrRTyE8THcisxnB6D3AMIKKSmjYUGH6OnWBDF/vi3CqimuMSbrUfzmPzmhw== dependencies: "@cypress/webpack-preprocessor" "^6.0.0" chalk "4.1.2" dayjs "1.11.12" - debug "4.3.5" + debug "4.3.6" execa "4.1.0" globby "11.1.0" istanbul-lib-coverage "^3.0.0" @@ -536,9 +536,9 @@ uuid "^8.3.2" "@cypress/webpack-dev-server@^3.5.2": - version "3.10.0" - resolved "https://registry.yarnpkg.com/@cypress/webpack-dev-server/-/webpack-dev-server-3.10.0.tgz#42312643579ec6fc10163eb6b644521052820cae" - integrity sha512-oktIWfsOeeXG9JNoWdfANsVX604VPc4KHnU0xwjYwtWxHCLAGl4uMXS7BxxejqtLboNaLySwwGkw3T15weIPug== + version "3.10.1" + resolved "https://registry.yarnpkg.com/@cypress/webpack-dev-server/-/webpack-dev-server-3.10.1.tgz#849dcf88bdab69d6f935fca7baa6af80460caa1a" + integrity sha512-ccgtqF/mtgHjMngaQgiKA3vFzvkel15zyAyq4PA8X0Z6vFZmwAxZe4Tgzdm/vCVfOLLW44OD/HYI//b0U/aDIQ== dependencies: find-up "6.3.0" fs-extra "9.1.0" @@ -548,7 +548,7 @@ semver "^7.5.3" speed-measure-webpack-plugin "1.4.2" tslib "^2.3.1" - webpack-dev-server "^4.7.4" + webpack-dev-server "^4.15.2" webpack-merge "^5.4.0" "@cypress/webpack-preprocessor@^6.0.0": @@ -1652,11 +1652,11 @@ tslib "^2.5.0" "@playwright/test@^1.37.0": - version "1.45.2" - resolved "https://registry.yarnpkg.com/@playwright/test/-/test-1.45.2.tgz#e1b8512e20916720de1c5f5e89a362a252ea78ca" - integrity sha512-JxG9eq92ET75EbVi3s+4sYbcG7q72ECeZNbdBlaMkGcNbiDQ4cAi8U2QP5oKkOx+1gpaiL1LDStmzCaEM1Z6fQ== + version "1.46.0" + resolved "https://registry.yarnpkg.com/@playwright/test/-/test-1.46.0.tgz#ccea6d22c40ee7fa567e4192fafbdf2a907e2714" + integrity sha512-/QYft5VArOrGRP5pgkrfKksqsKA6CEFyGQ/gjNe6q0y4tZ1aaPfq4gIjudr1s3D+pXyrPRdsy4opKDrjBabE5w== dependencies: - playwright "1.45.2" + playwright "1.46.0" "@popperjs/core@^2.9.0": version "2.11.8" @@ -5126,10 +5126,10 @@ debug@4, debug@4.3.4, debug@^4.0.1, debug@^4.1.0, debug@^4.1.1, debug@^4.3.1, de dependencies: ms "2.1.2" -debug@4.3.5: - version "4.3.5" - resolved "https://registry.yarnpkg.com/debug/-/debug-4.3.5.tgz#e83444eceb9fedd4a1da56d671ae2446a01a6e1e" - integrity sha512-pt0bNEmneDIvdL1Xsd9oDQ/wrQRkXDT4AUWlNZNPKvW5x/jyO9VFXkJUP07vQ2upmw5PlaITaPKc31jK13V+jg== +debug@4.3.6: + version "4.3.6" + resolved "https://registry.yarnpkg.com/debug/-/debug-4.3.6.tgz#2ab2c38fbaffebf8aa95fdfe6d88438c7a13c52b" + integrity sha512-O/09Bd4Z1fBrU4VzkhFqVgpPzaGbw6Sm9FEkBT1A/YBXQFGuuSxa1dN2nxgxS34JmKXqYx8CZAwEVoJFImUXIg== dependencies: ms "2.1.2" @@ -6364,9 +6364,9 @@ ethers@^5.1.0, ethers@^5.6.0, ethers@^5.7.2: "@ethersproject/wordlists" "5.7.0" ethers@^6.7.1: - version "6.13.1" - resolved "https://registry.yarnpkg.com/ethers/-/ethers-6.13.1.tgz#2b9f9c7455cde9d38b30fe6589972eb083652961" - integrity sha512-hdJ2HOxg/xx97Lm9HdCWk949BfYqYWpyw4//78SiwOLgASyfrNszfMUNB2joKjvGUdwhHfaiMMFFwacVVoLR9A== + version "6.13.2" + resolved "https://registry.yarnpkg.com/ethers/-/ethers-6.13.2.tgz#4b67d4b49e69b59893931a032560999e5e4419fe" + integrity sha512-9VkriTTed+/27BGuY1s0hf441kqwHJ1wtN2edksEtiRvXx+soxRX3iSXTfFqq2+YwrOqbDoTHjIhQnjJRlzKmg== dependencies: "@adraffy/ens-normalize" "1.10.1" "@noble/curves" "1.2.0" @@ -10358,17 +10358,17 @@ pkg-types@^1.1.1: mlly "^1.7.0" pathe "^1.1.2" -playwright-core@1.45.2: - version "1.45.2" - resolved "https://registry.yarnpkg.com/playwright-core/-/playwright-core-1.45.2.tgz#c8b8b7f66eda47fb2bd24e5435c92d1163022df8" - integrity sha512-ha175tAWb0dTK0X4orvBIqi3jGEt701SMxMhyujxNrgd8K0Uy5wMSwwcQHtyB4om7INUkfndx02XnQ2p6dvLDw== +playwright-core@1.46.0: + version "1.46.0" + resolved "https://registry.yarnpkg.com/playwright-core/-/playwright-core-1.46.0.tgz#2336ac453a943abf0dc95a76c117f9d3ebd390eb" + integrity sha512-9Y/d5UIwuJk8t3+lhmMSAJyNP1BUC/DqP3cQJDQQL/oWqAiuPTLgy7Q5dzglmTLwcBRdetzgNM/gni7ckfTr6A== -playwright@1.45.2: - version "1.45.2" - resolved "https://registry.yarnpkg.com/playwright/-/playwright-1.45.2.tgz#21082072120a2c8a7e3bbb2792e81e8aa367b7a7" - integrity sha512-ReywF2t/0teRvNBpfIgh5e4wnrI/8Su8ssdo5XsQKpjxJj+jspm00jSoz9BTg91TT0c9HRjXO7LBNVrgYj9X0g== +playwright@1.46.0: + version "1.46.0" + resolved "https://registry.yarnpkg.com/playwright/-/playwright-1.46.0.tgz#c7ff490deae41fc1e814bf2cb62109dd9351164d" + integrity sha512-XYJ5WvfefWONh1uPAUAi0H2xXV5S3vrtcnXe6uAOgdGi3aSpqOSXX08IAjXW34xitfuOJsvXU5anXZxPSEQiJw== dependencies: - playwright-core "1.45.2" + playwright-core "1.46.0" optionalDependencies: fsevents "2.3.2" @@ -11859,16 +11859,7 @@ string-length@^4.0.1: char-regex "^1.0.2" strip-ansi "^6.0.0" -"string-width-cjs@npm:string-width@^4.2.0": - version "4.2.3" - resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010" - integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g== - dependencies: - emoji-regex "^8.0.0" - is-fullwidth-code-point "^3.0.0" - strip-ansi "^6.0.1" - -string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.3: +"string-width-cjs@npm:string-width@^4.2.0", string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.3: version "4.2.3" resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010" integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g== @@ -11968,7 +11959,7 @@ string_decoder@~1.1.1: dependencies: safe-buffer "~5.1.0" -"strip-ansi-cjs@npm:strip-ansi@^6.0.1": +"strip-ansi-cjs@npm:strip-ansi@^6.0.1", strip-ansi@^6.0.0, strip-ansi@^6.0.1: version "6.0.1" resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9" integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A== @@ -11982,13 +11973,6 @@ strip-ansi@^3.0.1: dependencies: ansi-regex "^2.0.0" -strip-ansi@^6.0.0, strip-ansi@^6.0.1: - version "6.0.1" - resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9" - integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A== - dependencies: - ansi-regex "^5.0.1" - strip-ansi@^7.0.1: version "7.1.0" resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-7.1.0.tgz#d5b6568ca689d8561370b0707685d22434faff45" @@ -12678,9 +12662,9 @@ uncrypto@^0.1.3: integrity sha512-Ql87qFHB3s/De2ClA9e0gsnS6zXG27SkTiSJwjCc9MebbfapQfuPzumMIUMi38ezPZVNFcHI9sUIepeQfw8J8Q== underscore@^1.13.6: - version "1.13.6" - resolved "https://registry.yarnpkg.com/underscore/-/underscore-1.13.6.tgz#04786a1f589dc6c09f761fc5f45b89e935136441" - integrity sha512-+A5Sja4HP1M08MaXya7p5LvjuM7K6q/2EaC0+iovj/wOcMsTzMvDFbasi/oSapiwOlt252IqsKqPjCl7huKS0A== + version "1.13.7" + resolved "https://registry.yarnpkg.com/underscore/-/underscore-1.13.7.tgz#970e33963af9a7dda228f17ebe8399e5fbe63a10" + integrity sha512-GMXzWtsc57XAtguZgaQViUOzs0KTkk8ojr3/xAxXLITqf/3EMwxC0inyETfDFjH/Krbhuep0HNbbjI9i/q3F3g== unenv@^1.9.0: version "1.9.0" @@ -12990,7 +12974,7 @@ webidl-conversions@^7.0.0: resolved "https://registry.yarnpkg.com/webidl-conversions/-/webidl-conversions-7.0.0.tgz#256b4e1882be7debbf01d05f0aa2039778ea080a" integrity sha512-VwddBukDzu71offAQR975unBIGqfKZpM+8ZX6ySk8nYhVoo5CYaZyzt3YBvYtRtO+aoGlqxPg/B87NGVZ/fu6g== -webpack-dev-middleware@^5.3.1: +webpack-dev-middleware@^5.3.4: version "5.3.4" resolved "https://registry.yarnpkg.com/webpack-dev-middleware/-/webpack-dev-middleware-5.3.4.tgz#eb7b39281cbce10e104eb2b8bf2b63fce49a3517" integrity sha512-BVdTqhhs+0IfoeAf7EoH5WE+exCmqGerHfDM0IL096Px60Tq2Mn9MAbnaGUe6HiMa41KMCYF19gyzZmBcq/o4Q== @@ -13001,10 +12985,10 @@ webpack-dev-middleware@^5.3.1: range-parser "^1.2.1" schema-utils "^4.0.0" -webpack-dev-server@^4.7.4: - version "4.15.1" - resolved "https://registry.yarnpkg.com/webpack-dev-server/-/webpack-dev-server-4.15.1.tgz#8944b29c12760b3a45bdaa70799b17cb91b03df7" - integrity sha512-5hbAst3h3C3L8w6W4P96L5vaV0PxSmJhxZvWKYIdgxOQm8pNZ5dEOmmSLBVpP85ReeyRt6AS1QJNyo/oFFPeVA== +webpack-dev-server@^4.15.2: + version "4.15.2" + resolved "https://registry.yarnpkg.com/webpack-dev-server/-/webpack-dev-server-4.15.2.tgz#9e0c70a42a012560860adb186986da1248333173" + integrity sha512-0XavAZbNJ5sDrCbkpWL8mia0o5WPOd2YGtxrEiZkBK9FjLppIUK2TgxK6qGD2P3hUXTJNNPVibrerKcx5WkR1g== dependencies: "@types/bonjour" "^3.5.9" "@types/connect-history-api-fallback" "^1.3.5" @@ -13034,7 +13018,7 @@ webpack-dev-server@^4.7.4: serve-index "^1.9.1" sockjs "^0.3.24" spdy "^4.0.2" - webpack-dev-middleware "^5.3.1" + webpack-dev-middleware "^5.3.4" ws "^8.13.0" webpack-merge@^5.4.0: @@ -13171,7 +13155,7 @@ word-wrap@^1.2.3, word-wrap@~1.2.3: resolved "https://registry.yarnpkg.com/word-wrap/-/word-wrap-1.2.4.tgz#cb4b50ec9aca570abd1f52f33cd45b6c61739a9f" integrity sha512-2V81OA4ugVo5pRo46hAoD2ivUJx8jXmWXfUkY4KFNw0hEptvN0QfH3K4nHiwzGeKl5rFKedV48QVoqYavy4YpA== -"wrap-ansi-cjs@npm:wrap-ansi@^7.0.0": +"wrap-ansi-cjs@npm:wrap-ansi@^7.0.0", wrap-ansi@^7.0.0: version "7.0.0" resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43" integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q== @@ -13189,15 +13173,6 @@ wrap-ansi@^6.2.0: string-width "^4.1.0" strip-ansi "^6.0.0" -wrap-ansi@^7.0.0: - version "7.0.0" - resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43" - integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q== - dependencies: - ansi-styles "^4.0.0" - string-width "^4.1.0" - strip-ansi "^6.0.0" - wrap-ansi@^8.1.0: version "8.1.0" resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-8.1.0.tgz#56dc22368ee570face1b49819975d9b9a5ead214" From 103adf084dd30130fe3a134427e4feff11a6bbdb Mon Sep 17 00:00:00 2001 From: Christophe Date: Thu, 15 Aug 2024 20:11:12 +0000 Subject: [PATCH 23/82] Wrap with try catch --- .../tests/e2e/specs/approveToken.cy.ts | 4 +++- .../tests/e2e/specs/depositCctp.cy.ts | 8 ++++++-- .../tests/e2e/specs/withdrawCctp.cy.ts | 8 ++++++-- packages/arb-token-bridge-ui/tests/support/index.ts | 10 +--------- 4 files changed, 16 insertions(+), 14 deletions(-) diff --git a/packages/arb-token-bridge-ui/tests/e2e/specs/approveToken.cy.ts b/packages/arb-token-bridge-ui/tests/e2e/specs/approveToken.cy.ts index 27ea79e098..a2b51952a4 100644 --- a/packages/arb-token-bridge-ui/tests/e2e/specs/approveToken.cy.ts +++ b/packages/arb-token-bridge-ui/tests/e2e/specs/approveToken.cy.ts @@ -41,7 +41,9 @@ describe('Approve token and deposit afterwards', () => { name: /Pay approval fee of/ }).click() cy.confirmMetamaskPermissionToSpend({ spendLimit: '1' }) - cy.confirmMetamaskDataSignatureRequest() + try { + cy.confirmMetamaskDataSignatureRequest() + } catch (e) {} }) }) }) 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 2283a93303..8cdc5986f8 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 @@ -89,7 +89,9 @@ describe('Deposit USDC through CCTP', () => { cy.confirmMetamaskPermissionToSpend({ spendLimit: USDCAmountToSend.toString() }) - cy.confirmMetamaskDataSignatureRequest() + try { + cy.confirmMetamaskDataSignatureRequest() + } catch (e) {} // eslint-disable-next-line cy.wait(40_000) @@ -108,7 +110,9 @@ describe('Deposit USDC through CCTP', () => { cy.confirmMetamaskPermissionToSpend({ spendLimit: USDCAmountToSend.toString() }) - cy.confirmMetamaskDataSignatureRequest() + try { + cy.confirmMetamaskDataSignatureRequest() + } catch (e) {} // eslint-disable-next-line cy.wait(40_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 3db70bc320..5975c79718 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 @@ -79,7 +79,9 @@ describe('Withdraw USDC through CCTP', () => { cy.confirmMetamaskPermissionToSpend({ spendLimit: USDCAmountToSend.toString() }) - cy.confirmMetamaskDataSignatureRequest() + try { + cy.confirmMetamaskDataSignatureRequest() + } catch (e) {} // eslint-disable-next-line cy.wait(40_000) cy.confirmMetamaskTransaction() @@ -98,7 +100,9 @@ describe('Withdraw USDC through CCTP', () => { cy.confirmMetamaskPermissionToSpend({ spendLimit: USDCAmountToSend.toString() }) - cy.confirmMetamaskDataSignatureRequest() + try { + cy.confirmMetamaskDataSignatureRequest() + } catch (e) {} // eslint-disable-next-line cy.wait(40_000) diff --git a/packages/arb-token-bridge-ui/tests/support/index.ts b/packages/arb-token-bridge-ui/tests/support/index.ts index 0381a41af0..f17f890e80 100644 --- a/packages/arb-token-bridge-ui/tests/support/index.ts +++ b/packages/arb-token-bridge-ui/tests/support/index.ts @@ -14,15 +14,7 @@ Cypress.Keyboard.defaults({ }) logCollector({ - collectTypes: [ - 'cy:command', - 'cy:log', - 'cons:debug', - 'cons:error', - 'cons:info', - 'cons:log', - 'cons:warn' - ] + collectTypes: ['cy:log', 'cons:debug', 'cons:error', 'cons:info', 'cons:warn'] }) before(() => { From a56f574d510ec679207998d3ab78aa151988efca Mon Sep 17 00:00:00 2001 From: Christophe Date: Thu, 15 Aug 2024 21:16:50 +0000 Subject: [PATCH 24/82] Downgrade synpress --- packages/arb-token-bridge-ui/package.json | 2 +- .../tests/e2e/specs/approveToken.cy.ts | 5 +- .../tests/e2e/specs/depositCctp.cy.ts | 14 +- .../tests/e2e/specs/withdrawCctp.cy.ts | 15 +- yarn.lock | 212 ++++++------------ 5 files changed, 80 insertions(+), 168 deletions(-) diff --git a/packages/arb-token-bridge-ui/package.json b/packages/arb-token-bridge-ui/package.json index c4c0e8636d..5d4b530467 100644 --- a/packages/arb-token-bridge-ui/package.json +++ b/packages/arb-token-bridge-ui/package.json @@ -81,7 +81,7 @@ }, "devDependencies": { "@next/eslint-plugin-next": "^13.1.5", - "@synthetixio/synpress": "3.7.3", + "@synthetixio/synpress": "3.6.0", "@testing-library/react": "^14.2.1", "@types/jest": "^29.5.1", "@types/lodash-es": "^4.17.6", diff --git a/packages/arb-token-bridge-ui/tests/e2e/specs/approveToken.cy.ts b/packages/arb-token-bridge-ui/tests/e2e/specs/approveToken.cy.ts index a2b51952a4..da3ed22763 100644 --- a/packages/arb-token-bridge-ui/tests/e2e/specs/approveToken.cy.ts +++ b/packages/arb-token-bridge-ui/tests/e2e/specs/approveToken.cy.ts @@ -40,10 +40,7 @@ describe('Approve token and deposit afterwards', () => { cy.findByRole('button', { name: /Pay approval fee of/ }).click() - cy.confirmMetamaskPermissionToSpend({ spendLimit: '1' }) - try { - cy.confirmMetamaskDataSignatureRequest() - } catch (e) {} + cy.confirmMetamaskPermissionToSpend('1') }) }) }) 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 8cdc5986f8..708821b8b1 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 @@ -86,12 +86,7 @@ describe('Deposit USDC through CCTP', () => { cy.findMoveFundsButton().click() confirmAndApproveCctpDeposit() - cy.confirmMetamaskPermissionToSpend({ - spendLimit: USDCAmountToSend.toString() - }) - try { - cy.confirmMetamaskDataSignatureRequest() - } catch (e) {} + cy.confirmMetamaskPermissionToSpend(USDCAmountToSend.toString()) // eslint-disable-next-line cy.wait(40_000) @@ -107,12 +102,7 @@ describe('Deposit USDC through CCTP', () => { cy.fillCustomDestinationAddress() cy.findMoveFundsButton().click() confirmAndApproveCctpDeposit() - cy.confirmMetamaskPermissionToSpend({ - spendLimit: USDCAmountToSend.toString() - }) - try { - cy.confirmMetamaskDataSignatureRequest() - } catch (e) {} + cy.confirmMetamaskPermissionToSpend(USDCAmountToSend.toString()) // eslint-disable-next-line cy.wait(40_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 5975c79718..df50ece820 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 @@ -76,12 +76,8 @@ describe('Withdraw USDC through CCTP', () => { cy.findMoveFundsButton().click() confirmAndApproveCctpWithdrawal() - cy.confirmMetamaskPermissionToSpend({ - spendLimit: USDCAmountToSend.toString() - }) - try { - cy.confirmMetamaskDataSignatureRequest() - } catch (e) {} + cy.confirmMetamaskPermissionToSpend(USDCAmountToSend.toString()) + // eslint-disable-next-line cy.wait(40_000) cy.confirmMetamaskTransaction() @@ -97,12 +93,7 @@ describe('Withdraw USDC through CCTP', () => { cy.fillCustomDestinationAddress() cy.findMoveFundsButton().click() confirmAndApproveCctpWithdrawal() - cy.confirmMetamaskPermissionToSpend({ - spendLimit: USDCAmountToSend.toString() - }) - try { - cy.confirmMetamaskDataSignatureRequest() - } catch (e) {} + cy.confirmMetamaskPermissionToSpend(USDCAmountToSend.toString()) // eslint-disable-next-line cy.wait(40_000) diff --git a/yarn.lock b/yarn.lock index 314e47c623..684ae2984a 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2,11 +2,6 @@ # yarn lockfile v1 -"@adraffy/ens-normalize@1.10.0": - version "1.10.0" - resolved "https://registry.yarnpkg.com/@adraffy/ens-normalize/-/ens-normalize-1.10.0.tgz#d2a39395c587e092d77cbbc80acf956a54f38bf7" - integrity sha512-nA9XHtlAkYfJxY7bce8DcN7eKxWWCWkU+1GR9d+U6MbNpfwQp8TI7vqOsBsMcHoT4mBu2kypKoSKnghEzOOq5Q== - "@adraffy/ens-normalize@1.10.1": version "1.10.1" resolved "https://registry.yarnpkg.com/@adraffy/ens-normalize/-/ens-normalize-1.10.1.tgz#63430d04bd8c5e74f8d7d049338f1cd9d4f02069" @@ -496,7 +491,7 @@ dependencies: "@jridgewell/trace-mapping" "0.3.9" -"@cypress/code-coverage@^3.11.0": +"@cypress/code-coverage@^3.10.4": version "3.12.45" resolved "https://registry.yarnpkg.com/@cypress/code-coverage/-/code-coverage-3.12.45.tgz#45eeeb53391153767640a5a1a626b0d6e4c417b0" integrity sha512-QRvdc9Zmner/CxQ1F5jcNVZR8P8VrRTyE8THcisxnB6D3AMIKKSmjYUGH6OnWBDF/vi3CqimuMSbrUfzmPzmhw== @@ -511,7 +506,7 @@ js-yaml "4.1.0" nyc "15.1.0" -"@cypress/request@^2.88.11": +"@cypress/request@2.88.12", "@cypress/request@^2.88.11": version "2.88.12" resolved "https://registry.yarnpkg.com/@cypress/request/-/request-2.88.12.tgz#ba4911431738494a85e93fb04498cb38bc55d590" integrity sha512-tOn+0mDZxASFM+cuAP9szGUGPI1HwWVSvdzm7V4cCsPdFTx6qMj29CwaQmRAMIEhORIUBFBsYROYJcveK4uOjA== @@ -535,7 +530,7 @@ tunnel-agent "^0.6.0" uuid "^8.3.2" -"@cypress/webpack-dev-server@^3.5.2": +"@cypress/webpack-dev-server@^3.4.1": version "3.10.1" resolved "https://registry.yarnpkg.com/@cypress/webpack-dev-server/-/webpack-dev-server-3.10.1.tgz#849dcf88bdab69d6f935fca7baa6af80460caa1a" integrity sha512-ccgtqF/mtgHjMngaQgiKA3vFzvkel15zyAyq4PA8X0Z6vFZmwAxZe4Tgzdm/vCVfOLLW44OD/HYI//b0U/aDIQ== @@ -972,14 +967,6 @@ "@ethersproject/properties" "^5.7.0" "@ethersproject/strings" "^5.7.0" -"@foundry-rs/easy-foundryup@^0.1.3": - version "0.1.3" - resolved "https://registry.yarnpkg.com/@foundry-rs/easy-foundryup/-/easy-foundryup-0.1.3.tgz#f5281aff6b3a98f277bdafcb4330e71f80979ed4" - integrity sha512-Funb4hrSBeikKCmccFT/d3Ud5o92tlIZHTJeMCVk5b54/+CHZHr4g7MmtvO5xrGhxrOebQ0L+ojIj+VixgW7ug== - dependencies: - command-exists "^1.2.9" - ts-interface-checker "^0.1.9" - "@graphql-typed-document-node/core@^3.1.1": version "3.2.0" resolved "https://registry.yarnpkg.com/@graphql-typed-document-node/core/-/core-3.2.0.tgz#5f3d96ec6b2354ad6d8a28bf216a1d97b5426861" @@ -1487,7 +1474,7 @@ resolved "https://registry.yarnpkg.com/@next/swc-win32-x64-msvc/-/swc-win32-x64-msvc-14.2.5.tgz#ed199a920efb510cfe941cd75ed38a7be21e756f" integrity sha512-tEQ7oinq1/CjSG9uSTerca3v4AZ+dFa+4Yu6ihaG8Ud8ddqLQgFGcnwYls13H5X5CPDPZJdYxyeMui6muOLd4g== -"@noble/curves@1.2.0", "@noble/curves@~1.2.0": +"@noble/curves@1.2.0": version "1.2.0" resolved "https://registry.yarnpkg.com/@noble/curves/-/curves-1.2.0.tgz#92d7e12e4e49b23105a2555c6984d41733d65c35" integrity sha512-oYclrNgRaM9SsBUBVbb8M6DTV7ZHRTKugureoYEncY5c65HOmRzvSiTE3y5CYaPYJA/GVkrhXEoF0M3Ya9PMnw== @@ -1511,11 +1498,6 @@ resolved "https://registry.yarnpkg.com/@noble/hashes/-/hashes-1.4.0.tgz#45814aa329f30e4fe0ba49426f49dfccdd066426" integrity sha512-V1JJ1WTRUqHHrOSh597hURcMqVKVGL/ea3kv0gSnEdsEZ0/+VyPghM1lMNGc00z7CIQorSvbKpuJkxvuHbvdbg== -"@noble/hashes@~1.3.0", "@noble/hashes@~1.3.2": - version "1.3.3" - resolved "https://registry.yarnpkg.com/@noble/hashes/-/hashes-1.3.3.tgz#39908da56a4adc270147bb07968bf3b16cfe1699" - integrity sha512-V7/fPHgl+jsVPXqqeOzT8egNj2iBIVt+ECeMMG8TdcnTikP3oaBtUVqpT/gYCR68aEBJSF+XbYUxStjbFMqIIA== - "@nodelib/fs.scandir@2.1.5": version "2.1.5" resolved "https://registry.yarnpkg.com/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz#7619c2eb21b25483f6d167548b4cfd5a7488c3d5" @@ -1651,7 +1633,7 @@ picocolors "^1.0.0" tslib "^2.5.0" -"@playwright/test@^1.37.0": +"@playwright/test@^1.33.0": version "1.46.0" resolved "https://registry.yarnpkg.com/@playwright/test/-/test-1.46.0.tgz#ccea6d22c40ee7fa567e4192fafbdf2a907e2714" integrity sha512-/QYft5VArOrGRP5pgkrfKksqsKA6CEFyGQ/gjNe6q0y4tZ1aaPfq4gIjudr1s3D+pXyrPRdsy4opKDrjBabE5w== @@ -1716,28 +1698,6 @@ dependencies: cross-fetch "^3.1.5" -"@scure/base@~1.1.0", "@scure/base@~1.1.2": - version "1.1.7" - resolved "https://registry.yarnpkg.com/@scure/base/-/base-1.1.7.tgz#fe973311a5c6267846aa131bc72e96c5d40d2b30" - integrity sha512-PPNYBslrLNNUQ/Yad37MHYsNQtK67EhWb6WtSvNLLPo7SdVZgkUjD6Dg+5On7zNwmskf8OX7I7Nx5oN+MIWE0g== - -"@scure/bip32@1.3.2": - version "1.3.2" - resolved "https://registry.yarnpkg.com/@scure/bip32/-/bip32-1.3.2.tgz#90e78c027d5e30f0b22c1f8d50ff12f3fb7559f8" - integrity sha512-N1ZhksgwD3OBlwTv3R6KFEcPojl/W4ElJOeCZdi+vuI5QmTFwLq3OFf2zd2ROpKvxFdgZ6hUpb0dx9bVNEwYCA== - dependencies: - "@noble/curves" "~1.2.0" - "@noble/hashes" "~1.3.2" - "@scure/base" "~1.1.2" - -"@scure/bip39@1.2.1": - version "1.2.1" - resolved "https://registry.yarnpkg.com/@scure/bip39/-/bip39-1.2.1.tgz#5cee8978656b272a917b7871c981e0541ad6ac2a" - integrity sha512-Z3/Fsz1yr904dduJD0NpiyRHhRYHdcnyh73FZWiV+/qhWi83wNJ3NWolYqCEN+ZWsUz2TWwajJggcRE9r1zUYg== - dependencies: - "@noble/hashes" "~1.3.0" - "@scure/base" "~1.1.0" - "@sentry-internal/tracing@7.73.0": version "7.73.0" resolved "https://registry.yarnpkg.com/@sentry-internal/tracing/-/tracing-7.73.0.tgz#4838f31e41d23a6041ef4520519b80f788bf1cac" @@ -2025,21 +1985,18 @@ "@swc/counter" "^0.1.3" tslib "^2.4.0" -"@synthetixio/synpress@3.7.3": - version "3.7.3" - resolved "https://registry.yarnpkg.com/@synthetixio/synpress/-/synpress-3.7.3.tgz#4228002aca09537c24d71e462a8a1a20a3cfb1aa" - integrity sha512-HdeBMXgaiFUHYcpD0BIdHZdn7Pm/yppiHOdfUAMHPwX99333v+FnFj2f4NzFCE/YVZK9OkLeWkCCv62E1O+zvw== +"@synthetixio/synpress@3.6.0": + version "3.6.0" + resolved "https://registry.yarnpkg.com/@synthetixio/synpress/-/synpress-3.6.0.tgz#22cfa515350e17aab109ff34fcae69e49f9b4f23" + integrity sha512-tG2LVaMsJA1QmD8AfOIDKx6YtCKzGa4hWVvn5kn4gzAnBzkLOCNcrsuq6qTQEkKg9WUX5BV4iMVq51mJ1IcmFw== dependencies: - "@cypress/code-coverage" "^3.11.0" - "@cypress/webpack-dev-server" "^3.5.2" + "@cypress/code-coverage" "^3.10.4" + "@cypress/webpack-dev-server" "^3.4.1" "@drptbl/gremlins.js" "^2.2.1" - "@foundry-rs/easy-foundryup" "^0.1.3" - "@playwright/test" "^1.37.0" + "@playwright/test" "^1.33.0" "@testing-library/cypress" "^9.0.0" "@testing-library/react" "^14.0.0" "@types/testing-library__cypress" "^5.0.9" - "@viem/anvil" "^0.0.6" - app-root-path "^3.1.0" axios "^1.4.0" babel-plugin-istanbul "^6.1.1" babel-plugin-react-generate-property "^1.1.2" @@ -2047,20 +2004,17 @@ babel-plugin-transform-react-qa-classes "^1.6.0" babel-plugin-transform-react-styled-components-qa "^2.1.0" bytes32 "^0.0.3" - commander "^11.0.0" - cypress "12.17.3" - cypress-wait-until "^2.0.1" + commander "^10.0.1" + cypress "^12.11.0" + cypress-wait-until "^1.7.2" debug "^4.3.4" - dotenv "^16.3.1" + dotenv "^16.0.3" dotenv-parse-variables "^2.0.0" download "^8.0.0" - ethers "^6.7.1" + ethers "^6.3.0" etherscan-api "^10.3.0" find-config "^1.0.0" - get-port "^7.0.0" node-fetch "^2.6.1" - underscore "^1.13.6" - viem "^1.6.0" wait-on "^7.0.1" "@tanstack/query-core@4.29.11": @@ -2852,16 +2806,6 @@ dependencies: "@vercel/edge-config-fs" "0.1.0" -"@viem/anvil@^0.0.6": - version "0.0.6" - resolved "https://registry.yarnpkg.com/@viem/anvil/-/anvil-0.0.6.tgz#0f6378d2e6a6f2cee1b09570eae994551a6835b4" - integrity sha512-OjKR/+FVwzuygXYFqP8MBal1SXG8bT2gbZwqqB0XuLw81LNBBvmE/Repm6+5kkBh4IUj0PhYdrqOsnayS14Gtg== - dependencies: - execa "^7.1.1" - get-port "^6.1.2" - http-proxy "^1.18.1" - ws "^8.13.0" - "@wagmi/chains@0.2.22": version "0.2.22" resolved "https://registry.yarnpkg.com/@wagmi/chains/-/chains-0.2.22.tgz#25e511e134a00742e4fbf5108613dadf876c5bd9" @@ -3349,11 +3293,6 @@ abab@^2.0.6: resolved "https://registry.yarnpkg.com/abab/-/abab-2.0.6.tgz#41b80f2c871d19686216b82309231cfd3cb3d291" integrity sha512-j2afSsaIENvHZN2B8GOpF566vZ5WVk5opAiMTvWgaQT8DkbOqsTfvNAvHoRGU2zzP8cPoqys+xHTRDWW8L+/BA== -abitype@0.9.8: - version "0.9.8" - resolved "https://registry.yarnpkg.com/abitype/-/abitype-0.9.8.tgz#1f120b6b717459deafd213dfbf3a3dd1bf10ae8c" - integrity sha512-puLifILdm+8sjyss4S+fsUN09obiT1g2YW6CtcQF+QDzxR0euzgEB29MZujC6zMk2a6SVmtttq1fc6+YFA7WYQ== - abitype@^0.3.0: version "0.3.0" resolved "https://registry.yarnpkg.com/abitype/-/abitype-0.3.0.tgz#75150e337d88cc0b2423ed0d3fc36935f139d04c" @@ -3550,11 +3489,6 @@ anymatch@^3.0.0, anymatch@^3.0.3, anymatch@^3.1.3, anymatch@~3.1.2: normalize-path "^3.0.0" picomatch "^2.0.4" -app-root-path@^3.1.0: - version "3.1.0" - resolved "https://registry.yarnpkg.com/app-root-path/-/app-root-path-3.1.0.tgz#5971a2fc12ba170369a7a1ef018c71e6e47c2e86" - integrity sha512-biN3PwB2gUtjaYy/isrU3aNWI5w+fAfvHkSvCKeQGxhmYpwKFUxudR3Yya+KqVRHBmEDYh+/lTozYCFbmzX4nA== - append-transform@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/append-transform/-/append-transform-2.0.0.tgz#99d9d29c7b38391e6f428d28ce136551f0b77e12" @@ -4737,15 +4671,10 @@ combined-stream@^1.0.6, combined-stream@^1.0.8, combined-stream@~1.0.6: dependencies: delayed-stream "~1.0.0" -command-exists@^1.2.9: - version "1.2.9" - resolved "https://registry.yarnpkg.com/command-exists/-/command-exists-1.2.9.tgz#c50725af3808c8ab0260fd60b01fbfa25b954f69" - integrity sha512-LTQ/SGc+s0Xc0Fu5WaKnR0YiygZkm9eKFvyS+fRsU7/ZWFF8ykFM6Pc9aCVf1+xasOOZpO3BAVgVrKvsqKHV7w== - -commander@^11.0.0: - version "11.1.0" - resolved "https://registry.yarnpkg.com/commander/-/commander-11.1.0.tgz#62fdce76006a68e5c1ab3314dc92e800eb83d906" - integrity sha512-yPVavfyCcRhmorC7rWlkHn15b4wDVgVmBA7kV4QVBsF7kv/9TKJAbAXVTxvTnwP8HHKjRCJDClKbciiYS7p0DQ== +commander@^10.0.1: + version "10.0.1" + resolved "https://registry.yarnpkg.com/commander/-/commander-10.0.1.tgz#881ee46b4f77d1c1dccc5823433aa39b022cbe06" + integrity sha512-y4Mg2tXshplEbSGzx7amzPwKKOCGuoSRP/CjEdwwk0FOGlUbq6lKuoyDZTNZkmxHdJtp54hdfY/JUrdL7Xfdug== commander@^2.18.0, commander@^2.20.0, commander@^2.20.3, commander@^2.8.1: version "2.20.3" @@ -5028,12 +4957,7 @@ cypress-wait-until@^1.7.2: resolved "https://registry.yarnpkg.com/cypress-wait-until/-/cypress-wait-until-1.7.2.tgz#7f534dd5a11c89b65359e7a0210f20d3dfc22107" integrity sha512-uZ+M8/MqRcpf+FII/UZrU7g1qYZ4aVlHcgyVopnladyoBrpoaMJ4PKZDrdOJ05H5RHbr7s9Tid635X3E+ZLU/Q== -cypress-wait-until@^2.0.1: - version "2.0.1" - resolved "https://registry.yarnpkg.com/cypress-wait-until/-/cypress-wait-until-2.0.1.tgz#69c575c7207d83e4ae023e2aaecf2b66148c9fc0" - integrity sha512-+IyVnYNiaX1+C+V/LazrJWAi/CqiwfNoRSrFviECQEyolW1gDRy765PZosL2alSSGK8V10Y7BGfOQyZUDgmnjQ== - -cypress@*, cypress@12.17.3: +cypress@*: version "12.17.3" resolved "https://registry.yarnpkg.com/cypress/-/cypress-12.17.3.tgz#1e2b19037236fc60e4a4b3a14f0846be17a1fc0e" integrity sha512-/R4+xdIDjUSLYkiQfwJd630S81KIgicmQOLXotFxVXkl+eTeVO+3bHXxdi5KBh/OgC33HWN33kHX+0tQR/ZWpg== @@ -5081,6 +5005,55 @@ cypress@*, cypress@12.17.3: untildify "^4.0.0" yauzl "^2.10.0" +cypress@^12.11.0: + version "12.17.4" + resolved "https://registry.yarnpkg.com/cypress/-/cypress-12.17.4.tgz#b4dadf41673058493fa0d2362faa3da1f6ae2e6c" + integrity sha512-gAN8Pmns9MA5eCDFSDJXWKUpaL3IDd89N9TtIupjYnzLSmlpVr+ZR+vb4U/qaMp+lB6tBvAmt7504c3Z4RU5KQ== + dependencies: + "@cypress/request" "2.88.12" + "@cypress/xvfb" "^1.2.4" + "@types/node" "^16.18.39" + "@types/sinonjs__fake-timers" "8.1.1" + "@types/sizzle" "^2.3.2" + arch "^2.2.0" + blob-util "^2.0.2" + bluebird "^3.7.2" + buffer "^5.6.0" + cachedir "^2.3.0" + chalk "^4.1.0" + check-more-types "^2.24.0" + cli-cursor "^3.1.0" + cli-table3 "~0.6.1" + commander "^6.2.1" + common-tags "^1.8.0" + dayjs "^1.10.4" + debug "^4.3.4" + enquirer "^2.3.6" + eventemitter2 "6.4.7" + execa "4.1.0" + executable "^4.1.1" + extract-zip "2.0.1" + figures "^3.2.0" + fs-extra "^9.1.0" + getos "^3.2.1" + is-ci "^3.0.0" + is-installed-globally "~0.4.0" + lazy-ass "^1.6.0" + listr2 "^3.8.3" + lodash "^4.17.21" + log-symbols "^4.0.0" + minimist "^1.2.8" + ospath "^1.2.2" + pretty-bytes "^5.6.0" + process "^0.11.10" + proxy-from-env "1.0.0" + request-progress "^3.0.0" + semver "^7.5.3" + supports-color "^8.1.1" + tmp "~0.2.1" + untildify "^4.0.0" + yauzl "^2.10.0" + damerau-levenshtein@^1.0.8: version "1.0.8" resolved "https://registry.yarnpkg.com/damerau-levenshtein/-/damerau-levenshtein-1.0.8.tgz#b43d286ccbd36bc5b2f7ed41caf2d0aba1f8a6e7" @@ -5570,7 +5543,7 @@ dotenv-parse-variables@^2.0.0: debug "^4.3.1" is-string-and-not-blank "^0.0.2" -dotenv@^16.3.1: +dotenv@^16.0.3: version "16.4.5" resolved "https://registry.yarnpkg.com/dotenv/-/dotenv-16.4.5.tgz#cdd3b3b604cb327e286b4762e13502f717cb099f" integrity sha512-ZmdL2rui+eB2YwhsWzjInR8LldtZHGDoQ1ugH85ppHKwpUHL7j7rN0Ti9NCnGiQbhaZ11FpR+7ao1dNsmduNUg== @@ -6363,7 +6336,7 @@ ethers@^5.1.0, ethers@^5.6.0, ethers@^5.7.2: "@ethersproject/web" "5.7.1" "@ethersproject/wordlists" "5.7.0" -ethers@^6.7.1: +ethers@^6.3.0: version "6.13.2" resolved "https://registry.yarnpkg.com/ethers/-/ethers-6.13.2.tgz#4b67d4b49e69b59893931a032560999e5e4419fe" integrity sha512-9VkriTTed+/27BGuY1s0hf441kqwHJ1wtN2edksEtiRvXx+soxRX3iSXTfFqq2+YwrOqbDoTHjIhQnjJRlzKmg== @@ -7067,16 +7040,6 @@ get-port-please@^3.1.2: resolved "https://registry.yarnpkg.com/get-port-please/-/get-port-please-3.1.2.tgz#502795e56217128e4183025c89a48c71652f4e49" integrity sha512-Gxc29eLs1fbn6LQ4jSU4vXjlwyZhF5HsGuMAa7gqBP4Rw4yxxltyDUuF5MBclFzDTXO+ACchGQoeela4DSfzdQ== -get-port@^6.1.2: - version "6.1.2" - resolved "https://registry.yarnpkg.com/get-port/-/get-port-6.1.2.tgz#c1228abb67ba0e17fb346da33b15187833b9c08a" - integrity sha512-BrGGraKm2uPqurfGVj/z97/zv8dPleC6x9JBNRTrDNtCkkRF4rPwrQXFgL7+I+q8QSdU4ntLQX2D7KIxSy8nGw== - -get-port@^7.0.0: - version "7.1.0" - resolved "https://registry.yarnpkg.com/get-port/-/get-port-7.1.0.tgz#d5a500ebfc7aa705294ec2b83cc38c5d0e364fec" - integrity sha512-QB9NKEeDg3xxVwCCwJQ9+xycaz6pBB6iQ76wiWMl1927n0Kir6alPiP+yuiICLLU4jpMe08dXfpebuQppFA2zw== - get-stream@3.0.0, get-stream@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/get-stream/-/get-stream-3.0.0.tgz#8e943d1358dc37555054ecbe2edb05aa174ede14" @@ -8202,11 +8165,6 @@ isomorphic-ws@^4.0.1: resolved "https://registry.yarnpkg.com/isomorphic-ws/-/isomorphic-ws-4.0.1.tgz#55fd4cd6c5e6491e76dc125938dd863f5cd4f2dc" integrity sha512-BhBvN2MBpWTaSHdWRb/bwdZJ1WaehQ2L1KngkCkfLUGF0mAWAT1sQUQacEmQ0jXkFw/czDXPNQSL5u2/Krsz1w== -isows@1.0.3: - version "1.0.3" - resolved "https://registry.yarnpkg.com/isows/-/isows-1.0.3.tgz#93c1cf0575daf56e7120bab5c8c448b0809d0d74" - integrity sha512-2cKei4vlmg2cxEjm3wVSqn8pcoRF/LX/wpifuuNquFO4SQmPwarClT+SUCA2lt+l581tTeZIPIZuIDo2jWN1fg== - isstream@~0.1.2: version "0.1.2" resolved "https://registry.yarnpkg.com/isstream/-/isstream-0.1.2.tgz#47e63f7af55afa6f92e1500e690eb8b8529c099a" @@ -12661,11 +12619,6 @@ uncrypto@^0.1.3: resolved "https://registry.yarnpkg.com/uncrypto/-/uncrypto-0.1.3.tgz#e1288d609226f2d02d8d69ee861fa20d8348ef2b" integrity sha512-Ql87qFHB3s/De2ClA9e0gsnS6zXG27SkTiSJwjCc9MebbfapQfuPzumMIUMi38ezPZVNFcHI9sUIepeQfw8J8Q== -underscore@^1.13.6: - version "1.13.7" - resolved "https://registry.yarnpkg.com/underscore/-/underscore-1.13.7.tgz#970e33963af9a7dda228f17ebe8399e5fbe63a10" - integrity sha512-GMXzWtsc57XAtguZgaQViUOzs0KTkk8ojr3/xAxXLITqf/3EMwxC0inyETfDFjH/Krbhuep0HNbbjI9i/q3F3g== - unenv@^1.9.0: version "1.9.0" resolved "https://registry.yarnpkg.com/unenv/-/unenv-1.9.0.tgz#469502ae85be1bd3a6aa60f810972b1a904ca312" @@ -12901,20 +12854,6 @@ verror@1.10.0: core-util-is "1.0.2" extsprintf "^1.2.0" -viem@^1.6.0: - version "1.21.4" - resolved "https://registry.yarnpkg.com/viem/-/viem-1.21.4.tgz#883760e9222540a5a7e0339809202b45fe6a842d" - integrity sha512-BNVYdSaUjeS2zKQgPs+49e5JKocfo60Ib2yiXOWBT6LuVxY1I/6fFX3waEtpXvL1Xn4qu+BVitVtMh9lyThyhQ== - dependencies: - "@adraffy/ens-normalize" "1.10.0" - "@noble/curves" "1.2.0" - "@noble/hashes" "1.3.2" - "@scure/bip32" "1.3.2" - "@scure/bip39" "1.2.1" - abitype "0.9.8" - isows "1.0.3" - ws "8.13.0" - w3c-xmlserializer@^4.0.0: version "4.0.0" resolved "https://registry.yarnpkg.com/w3c-xmlserializer/-/w3c-xmlserializer-4.0.0.tgz#aebdc84920d806222936e3cdce408e32488a3073" @@ -13210,11 +13149,6 @@ ws@7.4.6, ws@7.5.10, ws@^7.4.5, ws@^7.5.1: resolved "https://registry.yarnpkg.com/ws/-/ws-7.5.10.tgz#58b5c20dc281633f6c19113f39b349bd8bd558d9" integrity sha512-+dbF1tHwZpXcbOJdVOkzLDxZP1ailvSxM6ZweXTegylPny803bFhA+vqBYw4s31NSAk4S2Qz+AKXK9a4wkdjcQ== -ws@8.13.0: - version "8.13.0" - resolved "https://registry.yarnpkg.com/ws/-/ws-8.13.0.tgz#9a9fb92f93cf41512a0735c8f4dd09b8a1211cd0" - integrity sha512-x9vcZYTrFPC7aSIbj7sRCYo7L/Xb8Iy+pW0ng0wt2vCJv7M9HOMy0UoN3rr+IFC7hb7vXoqS+P9ktyLLLhO+LA== - ws@8.17.1, ws@^8.11.0, ws@^8.13.0, ws@^8.5.0: version "8.17.1" resolved "https://registry.yarnpkg.com/ws/-/ws-8.17.1.tgz#9293da530bb548febc95371d90f9c878727d919b" From 861adc5589c6831a6fc2a25c9d752f076b6e1059 Mon Sep 17 00:00:00 2001 From: Christophe Date: Thu, 15 Aug 2024 21:17:10 +0000 Subject: [PATCH 25/82] Add back cy:command to logs --- packages/arb-token-bridge-ui/tests/support/index.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/packages/arb-token-bridge-ui/tests/support/index.ts b/packages/arb-token-bridge-ui/tests/support/index.ts index f17f890e80..74ca0188e5 100644 --- a/packages/arb-token-bridge-ui/tests/support/index.ts +++ b/packages/arb-token-bridge-ui/tests/support/index.ts @@ -14,7 +14,14 @@ Cypress.Keyboard.defaults({ }) logCollector({ - collectTypes: ['cy:log', 'cons:debug', 'cons:error', 'cons:info', 'cons:warn'] + collectTypes: [ + 'cy:command', + 'cy:log', + 'cons:debug', + 'cons:error', + 'cons:info', + 'cons:warn' + ] }) before(() => { From 0cbdad39dd744bd9deeedb933ae74c032f7f00d6 Mon Sep 17 00:00:00 2001 From: Christophe Date: Mon, 19 Aug 2024 15:21:42 +0000 Subject: [PATCH 26/82] Cleanup --- packages/arb-token-bridge-ui/package.json | 2 +- .../synpress.cctp.config.ts | 11 +- .../tests/e2e/specs/depositCctp.cy.ts | 11 +- .../tests/support/commands.ts | 4 - yarn.lock | 311 +++++++++++------- 5 files changed, 217 insertions(+), 122 deletions(-) diff --git a/packages/arb-token-bridge-ui/package.json b/packages/arb-token-bridge-ui/package.json index 5d4b530467..c4c0e8636d 100644 --- a/packages/arb-token-bridge-ui/package.json +++ b/packages/arb-token-bridge-ui/package.json @@ -81,7 +81,7 @@ }, "devDependencies": { "@next/eslint-plugin-next": "^13.1.5", - "@synthetixio/synpress": "3.6.0", + "@synthetixio/synpress": "3.7.3", "@testing-library/react": "^14.2.1", "@types/jest": "^29.5.1", "@types/lodash-es": "^4.17.6", diff --git a/packages/arb-token-bridge-ui/synpress.cctp.config.ts b/packages/arb-token-bridge-ui/synpress.cctp.config.ts index d74d977cfd..f1f5b0937f 100644 --- a/packages/arb-token-bridge-ui/synpress.cctp.config.ts +++ b/packages/arb-token-bridge-ui/synpress.cctp.config.ts @@ -5,9 +5,14 @@ import synpressPlugins from '@synthetixio/synpress/plugins' import logsPrinter from 'cypress-terminal-report/src/installLogsPrinter' import { getCommonSynpressConfig } from './tests/e2e/getCommonSynpressConfig' import { setupCypressTasks, fundEth, fundUsdc } from './tests/support/common' +import specFiles from './tests/e2e/cctp.json' const shouldRecordVideo = process.env.CYPRESS_RECORD_VIDEO === 'true' +const tests = 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') { throw new Error('Infura API key not provided') @@ -23,10 +28,6 @@ if (!process.env.PRIVATE_KEY_CCTP) { throw new Error('PRIVATE_KEY_CCTP variable missing.') } -if (!process.env.TEST_FILE) { - throw new Error('process.env.TEST_FILE is missing.') -} - // Wallet funded on Sepolia and ArbSepolia with ETH and USDC const localWallet = new Wallet(process.env.PRIVATE_KEY_CCTP) // Generate a new wallet every time @@ -84,7 +85,7 @@ export default defineConfig({ return config }, baseUrl: 'http://localhost:3000', - specPattern: [process.env.TEST_FILE], + specPattern: tests, supportFile: 'tests/support/index.ts' } }) 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 708821b8b1..8b104fdaad 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 @@ -86,7 +86,11 @@ describe('Deposit USDC through CCTP', () => { cy.findMoveFundsButton().click() confirmAndApproveCctpDeposit() - cy.confirmMetamaskPermissionToSpend(USDCAmountToSend.toString()) + // cy.confirmMetamaskPermissionToSpend({ + // spendLimit: USDCAmountToSend.toString() + // }) + cy.confirmMetamaskTransaction({ gasConfig: 'market' }) + cy.confirmMetamaskTransaction({ gasConfig: 'market' }) // eslint-disable-next-line cy.wait(40_000) @@ -102,7 +106,10 @@ describe('Deposit USDC through CCTP', () => { cy.fillCustomDestinationAddress() cy.findMoveFundsButton().click() confirmAndApproveCctpDeposit() - cy.confirmMetamaskPermissionToSpend(USDCAmountToSend.toString()) + // cy.confirmMetamaskPermissionToSpend({ + // spendLimit: USDCAmountToSend.toString() + // }) + cy.confirmMetamaskTransaction({ gasConfig: 'market' }) // eslint-disable-next-line cy.wait(40_000) diff --git a/packages/arb-token-bridge-ui/tests/support/commands.ts b/packages/arb-token-bridge-ui/tests/support/commands.ts index 3a7ddbf3f2..31c661cd8c 100644 --- a/packages/arb-token-bridge-ui/tests/support/commands.ts +++ b/packages/arb-token-bridge-ui/tests/support/commands.ts @@ -17,10 +17,6 @@ import { getL2NetworkConfig } from './common' import { shortenAddress } from '../../src/util/CommonUtils' -import { Provider } from '@ethersproject/providers' -import { BigNumber, Signer, Wallet, ethers, utils } from 'ethers' -import { CommonAddress } from '../../src/util/CommonAddressUtils' -import { ERC20__factory } from '@arbitrum/sdk/dist/lib/abi/factories/ERC20__factory' function shouldChangeNetwork(networkName: NetworkName) { // synpress throws if trying to connect to a network we are already connected to diff --git a/yarn.lock b/yarn.lock index 684ae2984a..d114739aec 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2,6 +2,11 @@ # yarn lockfile v1 +"@adraffy/ens-normalize@1.10.0": + version "1.10.0" + resolved "https://registry.yarnpkg.com/@adraffy/ens-normalize/-/ens-normalize-1.10.0.tgz#d2a39395c587e092d77cbbc80acf956a54f38bf7" + integrity sha512-nA9XHtlAkYfJxY7bce8DcN7eKxWWCWkU+1GR9d+U6MbNpfwQp8TI7vqOsBsMcHoT4mBu2kypKoSKnghEzOOq5Q== + "@adraffy/ens-normalize@1.10.1": version "1.10.1" resolved "https://registry.yarnpkg.com/@adraffy/ens-normalize/-/ens-normalize-1.10.1.tgz#63430d04bd8c5e74f8d7d049338f1cd9d4f02069" @@ -491,22 +496,22 @@ dependencies: "@jridgewell/trace-mapping" "0.3.9" -"@cypress/code-coverage@^3.10.4": - version "3.12.45" - resolved "https://registry.yarnpkg.com/@cypress/code-coverage/-/code-coverage-3.12.45.tgz#45eeeb53391153767640a5a1a626b0d6e4c417b0" - integrity sha512-QRvdc9Zmner/CxQ1F5jcNVZR8P8VrRTyE8THcisxnB6D3AMIKKSmjYUGH6OnWBDF/vi3CqimuMSbrUfzmPzmhw== +"@cypress/code-coverage@^3.11.0": + version "3.12.44" + resolved "https://registry.yarnpkg.com/@cypress/code-coverage/-/code-coverage-3.12.44.tgz#38ea430f8df77c67e07f283351e4c9f97151b14b" + integrity sha512-5Eau3tnJqZJo1OddOOEMyWs1HCwlAOgDs1rFPaCXJ4a5Y2BR4PH4fAzCdMvIqpBnCiVSL8gOYv6JfND3aUuJJQ== dependencies: "@cypress/webpack-preprocessor" "^6.0.0" chalk "4.1.2" dayjs "1.11.12" - debug "4.3.6" + debug "4.3.5" execa "4.1.0" globby "11.1.0" istanbul-lib-coverage "^3.0.0" js-yaml "4.1.0" nyc "15.1.0" -"@cypress/request@2.88.12", "@cypress/request@^2.88.11": +"@cypress/request@^2.88.11": version "2.88.12" resolved "https://registry.yarnpkg.com/@cypress/request/-/request-2.88.12.tgz#ba4911431738494a85e93fb04498cb38bc55d590" integrity sha512-tOn+0mDZxASFM+cuAP9szGUGPI1HwWVSvdzm7V4cCsPdFTx6qMj29CwaQmRAMIEhORIUBFBsYROYJcveK4uOjA== @@ -530,10 +535,10 @@ tunnel-agent "^0.6.0" uuid "^8.3.2" -"@cypress/webpack-dev-server@^3.4.1": - version "3.10.1" - resolved "https://registry.yarnpkg.com/@cypress/webpack-dev-server/-/webpack-dev-server-3.10.1.tgz#849dcf88bdab69d6f935fca7baa6af80460caa1a" - integrity sha512-ccgtqF/mtgHjMngaQgiKA3vFzvkel15zyAyq4PA8X0Z6vFZmwAxZe4Tgzdm/vCVfOLLW44OD/HYI//b0U/aDIQ== +"@cypress/webpack-dev-server@^3.5.2": + version "3.10.0" + resolved "https://registry.yarnpkg.com/@cypress/webpack-dev-server/-/webpack-dev-server-3.10.0.tgz#42312643579ec6fc10163eb6b644521052820cae" + integrity sha512-oktIWfsOeeXG9JNoWdfANsVX604VPc4KHnU0xwjYwtWxHCLAGl4uMXS7BxxejqtLboNaLySwwGkw3T15weIPug== dependencies: find-up "6.3.0" fs-extra "9.1.0" @@ -543,7 +548,7 @@ semver "^7.5.3" speed-measure-webpack-plugin "1.4.2" tslib "^2.3.1" - webpack-dev-server "^4.15.2" + webpack-dev-server "^4.7.4" webpack-merge "^5.4.0" "@cypress/webpack-preprocessor@^6.0.0": @@ -967,6 +972,14 @@ "@ethersproject/properties" "^5.7.0" "@ethersproject/strings" "^5.7.0" +"@foundry-rs/easy-foundryup@^0.1.3": + version "0.1.3" + resolved "https://registry.yarnpkg.com/@foundry-rs/easy-foundryup/-/easy-foundryup-0.1.3.tgz#f5281aff6b3a98f277bdafcb4330e71f80979ed4" + integrity sha512-Funb4hrSBeikKCmccFT/d3Ud5o92tlIZHTJeMCVk5b54/+CHZHr4g7MmtvO5xrGhxrOebQ0L+ojIj+VixgW7ug== + dependencies: + command-exists "^1.2.9" + ts-interface-checker "^0.1.9" + "@graphql-typed-document-node/core@^3.1.1": version "3.2.0" resolved "https://registry.yarnpkg.com/@graphql-typed-document-node/core/-/core-3.2.0.tgz#5f3d96ec6b2354ad6d8a28bf216a1d97b5426861" @@ -1474,7 +1487,7 @@ resolved "https://registry.yarnpkg.com/@next/swc-win32-x64-msvc/-/swc-win32-x64-msvc-14.2.5.tgz#ed199a920efb510cfe941cd75ed38a7be21e756f" integrity sha512-tEQ7oinq1/CjSG9uSTerca3v4AZ+dFa+4Yu6ihaG8Ud8ddqLQgFGcnwYls13H5X5CPDPZJdYxyeMui6muOLd4g== -"@noble/curves@1.2.0": +"@noble/curves@1.2.0", "@noble/curves@~1.2.0": version "1.2.0" resolved "https://registry.yarnpkg.com/@noble/curves/-/curves-1.2.0.tgz#92d7e12e4e49b23105a2555c6984d41733d65c35" integrity sha512-oYclrNgRaM9SsBUBVbb8M6DTV7ZHRTKugureoYEncY5c65HOmRzvSiTE3y5CYaPYJA/GVkrhXEoF0M3Ya9PMnw== @@ -1498,6 +1511,11 @@ resolved "https://registry.yarnpkg.com/@noble/hashes/-/hashes-1.4.0.tgz#45814aa329f30e4fe0ba49426f49dfccdd066426" integrity sha512-V1JJ1WTRUqHHrOSh597hURcMqVKVGL/ea3kv0gSnEdsEZ0/+VyPghM1lMNGc00z7CIQorSvbKpuJkxvuHbvdbg== +"@noble/hashes@~1.3.0", "@noble/hashes@~1.3.2": + version "1.3.3" + resolved "https://registry.yarnpkg.com/@noble/hashes/-/hashes-1.3.3.tgz#39908da56a4adc270147bb07968bf3b16cfe1699" + integrity sha512-V7/fPHgl+jsVPXqqeOzT8egNj2iBIVt+ECeMMG8TdcnTikP3oaBtUVqpT/gYCR68aEBJSF+XbYUxStjbFMqIIA== + "@nodelib/fs.scandir@2.1.5": version "2.1.5" resolved "https://registry.yarnpkg.com/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz#7619c2eb21b25483f6d167548b4cfd5a7488c3d5" @@ -1633,12 +1651,12 @@ picocolors "^1.0.0" tslib "^2.5.0" -"@playwright/test@^1.33.0": - version "1.46.0" - resolved "https://registry.yarnpkg.com/@playwright/test/-/test-1.46.0.tgz#ccea6d22c40ee7fa567e4192fafbdf2a907e2714" - integrity sha512-/QYft5VArOrGRP5pgkrfKksqsKA6CEFyGQ/gjNe6q0y4tZ1aaPfq4gIjudr1s3D+pXyrPRdsy4opKDrjBabE5w== +"@playwright/test@^1.37.0": + version "1.45.2" + resolved "https://registry.yarnpkg.com/@playwright/test/-/test-1.45.2.tgz#e1b8512e20916720de1c5f5e89a362a252ea78ca" + integrity sha512-JxG9eq92ET75EbVi3s+4sYbcG7q72ECeZNbdBlaMkGcNbiDQ4cAi8U2QP5oKkOx+1gpaiL1LDStmzCaEM1Z6fQ== dependencies: - playwright "1.46.0" + playwright "1.45.2" "@popperjs/core@^2.9.0": version "2.11.8" @@ -1698,6 +1716,28 @@ dependencies: cross-fetch "^3.1.5" +"@scure/base@~1.1.0", "@scure/base@~1.1.2": + version "1.1.7" + resolved "https://registry.yarnpkg.com/@scure/base/-/base-1.1.7.tgz#fe973311a5c6267846aa131bc72e96c5d40d2b30" + integrity sha512-PPNYBslrLNNUQ/Yad37MHYsNQtK67EhWb6WtSvNLLPo7SdVZgkUjD6Dg+5On7zNwmskf8OX7I7Nx5oN+MIWE0g== + +"@scure/bip32@1.3.2": + version "1.3.2" + resolved "https://registry.yarnpkg.com/@scure/bip32/-/bip32-1.3.2.tgz#90e78c027d5e30f0b22c1f8d50ff12f3fb7559f8" + integrity sha512-N1ZhksgwD3OBlwTv3R6KFEcPojl/W4ElJOeCZdi+vuI5QmTFwLq3OFf2zd2ROpKvxFdgZ6hUpb0dx9bVNEwYCA== + dependencies: + "@noble/curves" "~1.2.0" + "@noble/hashes" "~1.3.2" + "@scure/base" "~1.1.2" + +"@scure/bip39@1.2.1": + version "1.2.1" + resolved "https://registry.yarnpkg.com/@scure/bip39/-/bip39-1.2.1.tgz#5cee8978656b272a917b7871c981e0541ad6ac2a" + integrity sha512-Z3/Fsz1yr904dduJD0NpiyRHhRYHdcnyh73FZWiV+/qhWi83wNJ3NWolYqCEN+ZWsUz2TWwajJggcRE9r1zUYg== + dependencies: + "@noble/hashes" "~1.3.0" + "@scure/base" "~1.1.0" + "@sentry-internal/tracing@7.73.0": version "7.73.0" resolved "https://registry.yarnpkg.com/@sentry-internal/tracing/-/tracing-7.73.0.tgz#4838f31e41d23a6041ef4520519b80f788bf1cac" @@ -1985,18 +2025,21 @@ "@swc/counter" "^0.1.3" tslib "^2.4.0" -"@synthetixio/synpress@3.6.0": - version "3.6.0" - resolved "https://registry.yarnpkg.com/@synthetixio/synpress/-/synpress-3.6.0.tgz#22cfa515350e17aab109ff34fcae69e49f9b4f23" - integrity sha512-tG2LVaMsJA1QmD8AfOIDKx6YtCKzGa4hWVvn5kn4gzAnBzkLOCNcrsuq6qTQEkKg9WUX5BV4iMVq51mJ1IcmFw== +"@synthetixio/synpress@3.7.3": + version "3.7.3" + resolved "https://registry.yarnpkg.com/@synthetixio/synpress/-/synpress-3.7.3.tgz#4228002aca09537c24d71e462a8a1a20a3cfb1aa" + integrity sha512-HdeBMXgaiFUHYcpD0BIdHZdn7Pm/yppiHOdfUAMHPwX99333v+FnFj2f4NzFCE/YVZK9OkLeWkCCv62E1O+zvw== dependencies: - "@cypress/code-coverage" "^3.10.4" - "@cypress/webpack-dev-server" "^3.4.1" + "@cypress/code-coverage" "^3.11.0" + "@cypress/webpack-dev-server" "^3.5.2" "@drptbl/gremlins.js" "^2.2.1" - "@playwright/test" "^1.33.0" + "@foundry-rs/easy-foundryup" "^0.1.3" + "@playwright/test" "^1.37.0" "@testing-library/cypress" "^9.0.0" "@testing-library/react" "^14.0.0" "@types/testing-library__cypress" "^5.0.9" + "@viem/anvil" "^0.0.6" + app-root-path "^3.1.0" axios "^1.4.0" babel-plugin-istanbul "^6.1.1" babel-plugin-react-generate-property "^1.1.2" @@ -2004,17 +2047,20 @@ babel-plugin-transform-react-qa-classes "^1.6.0" babel-plugin-transform-react-styled-components-qa "^2.1.0" bytes32 "^0.0.3" - commander "^10.0.1" - cypress "^12.11.0" - cypress-wait-until "^1.7.2" + commander "^11.0.0" + cypress "12.17.3" + cypress-wait-until "^2.0.1" debug "^4.3.4" - dotenv "^16.0.3" + dotenv "^16.3.1" dotenv-parse-variables "^2.0.0" download "^8.0.0" - ethers "^6.3.0" + ethers "^6.7.1" etherscan-api "^10.3.0" find-config "^1.0.0" + get-port "^7.0.0" node-fetch "^2.6.1" + underscore "^1.13.6" + viem "^1.6.0" wait-on "^7.0.1" "@tanstack/query-core@4.29.11": @@ -2806,6 +2852,16 @@ dependencies: "@vercel/edge-config-fs" "0.1.0" +"@viem/anvil@^0.0.6": + version "0.0.6" + resolved "https://registry.yarnpkg.com/@viem/anvil/-/anvil-0.0.6.tgz#0f6378d2e6a6f2cee1b09570eae994551a6835b4" + integrity sha512-OjKR/+FVwzuygXYFqP8MBal1SXG8bT2gbZwqqB0XuLw81LNBBvmE/Repm6+5kkBh4IUj0PhYdrqOsnayS14Gtg== + dependencies: + execa "^7.1.1" + get-port "^6.1.2" + http-proxy "^1.18.1" + ws "^8.13.0" + "@wagmi/chains@0.2.22": version "0.2.22" resolved "https://registry.yarnpkg.com/@wagmi/chains/-/chains-0.2.22.tgz#25e511e134a00742e4fbf5108613dadf876c5bd9" @@ -3293,6 +3349,11 @@ abab@^2.0.6: resolved "https://registry.yarnpkg.com/abab/-/abab-2.0.6.tgz#41b80f2c871d19686216b82309231cfd3cb3d291" integrity sha512-j2afSsaIENvHZN2B8GOpF566vZ5WVk5opAiMTvWgaQT8DkbOqsTfvNAvHoRGU2zzP8cPoqys+xHTRDWW8L+/BA== +abitype@0.9.8: + version "0.9.8" + resolved "https://registry.yarnpkg.com/abitype/-/abitype-0.9.8.tgz#1f120b6b717459deafd213dfbf3a3dd1bf10ae8c" + integrity sha512-puLifILdm+8sjyss4S+fsUN09obiT1g2YW6CtcQF+QDzxR0euzgEB29MZujC6zMk2a6SVmtttq1fc6+YFA7WYQ== + abitype@^0.3.0: version "0.3.0" resolved "https://registry.yarnpkg.com/abitype/-/abitype-0.3.0.tgz#75150e337d88cc0b2423ed0d3fc36935f139d04c" @@ -3489,6 +3550,11 @@ anymatch@^3.0.0, anymatch@^3.0.3, anymatch@^3.1.3, anymatch@~3.1.2: normalize-path "^3.0.0" picomatch "^2.0.4" +app-root-path@^3.1.0: + version "3.1.0" + resolved "https://registry.yarnpkg.com/app-root-path/-/app-root-path-3.1.0.tgz#5971a2fc12ba170369a7a1ef018c71e6e47c2e86" + integrity sha512-biN3PwB2gUtjaYy/isrU3aNWI5w+fAfvHkSvCKeQGxhmYpwKFUxudR3Yya+KqVRHBmEDYh+/lTozYCFbmzX4nA== + append-transform@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/append-transform/-/append-transform-2.0.0.tgz#99d9d29c7b38391e6f428d28ce136551f0b77e12" @@ -4671,10 +4737,15 @@ combined-stream@^1.0.6, combined-stream@^1.0.8, combined-stream@~1.0.6: dependencies: delayed-stream "~1.0.0" -commander@^10.0.1: - version "10.0.1" - resolved "https://registry.yarnpkg.com/commander/-/commander-10.0.1.tgz#881ee46b4f77d1c1dccc5823433aa39b022cbe06" - integrity sha512-y4Mg2tXshplEbSGzx7amzPwKKOCGuoSRP/CjEdwwk0FOGlUbq6lKuoyDZTNZkmxHdJtp54hdfY/JUrdL7Xfdug== +command-exists@^1.2.9: + version "1.2.9" + resolved "https://registry.yarnpkg.com/command-exists/-/command-exists-1.2.9.tgz#c50725af3808c8ab0260fd60b01fbfa25b954f69" + integrity sha512-LTQ/SGc+s0Xc0Fu5WaKnR0YiygZkm9eKFvyS+fRsU7/ZWFF8ykFM6Pc9aCVf1+xasOOZpO3BAVgVrKvsqKHV7w== + +commander@^11.0.0: + version "11.1.0" + resolved "https://registry.yarnpkg.com/commander/-/commander-11.1.0.tgz#62fdce76006a68e5c1ab3314dc92e800eb83d906" + integrity sha512-yPVavfyCcRhmorC7rWlkHn15b4wDVgVmBA7kV4QVBsF7kv/9TKJAbAXVTxvTnwP8HHKjRCJDClKbciiYS7p0DQ== commander@^2.18.0, commander@^2.20.0, commander@^2.20.3, commander@^2.8.1: version "2.20.3" @@ -4957,7 +5028,12 @@ cypress-wait-until@^1.7.2: resolved "https://registry.yarnpkg.com/cypress-wait-until/-/cypress-wait-until-1.7.2.tgz#7f534dd5a11c89b65359e7a0210f20d3dfc22107" integrity sha512-uZ+M8/MqRcpf+FII/UZrU7g1qYZ4aVlHcgyVopnladyoBrpoaMJ4PKZDrdOJ05H5RHbr7s9Tid635X3E+ZLU/Q== -cypress@*: +cypress-wait-until@^2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/cypress-wait-until/-/cypress-wait-until-2.0.1.tgz#69c575c7207d83e4ae023e2aaecf2b66148c9fc0" + integrity sha512-+IyVnYNiaX1+C+V/LazrJWAi/CqiwfNoRSrFviECQEyolW1gDRy765PZosL2alSSGK8V10Y7BGfOQyZUDgmnjQ== + +cypress@*, cypress@12.17.3: version "12.17.3" resolved "https://registry.yarnpkg.com/cypress/-/cypress-12.17.3.tgz#1e2b19037236fc60e4a4b3a14f0846be17a1fc0e" integrity sha512-/R4+xdIDjUSLYkiQfwJd630S81KIgicmQOLXotFxVXkl+eTeVO+3bHXxdi5KBh/OgC33HWN33kHX+0tQR/ZWpg== @@ -5005,55 +5081,6 @@ cypress@*: untildify "^4.0.0" yauzl "^2.10.0" -cypress@^12.11.0: - version "12.17.4" - resolved "https://registry.yarnpkg.com/cypress/-/cypress-12.17.4.tgz#b4dadf41673058493fa0d2362faa3da1f6ae2e6c" - integrity sha512-gAN8Pmns9MA5eCDFSDJXWKUpaL3IDd89N9TtIupjYnzLSmlpVr+ZR+vb4U/qaMp+lB6tBvAmt7504c3Z4RU5KQ== - dependencies: - "@cypress/request" "2.88.12" - "@cypress/xvfb" "^1.2.4" - "@types/node" "^16.18.39" - "@types/sinonjs__fake-timers" "8.1.1" - "@types/sizzle" "^2.3.2" - arch "^2.2.0" - blob-util "^2.0.2" - bluebird "^3.7.2" - buffer "^5.6.0" - cachedir "^2.3.0" - chalk "^4.1.0" - check-more-types "^2.24.0" - cli-cursor "^3.1.0" - cli-table3 "~0.6.1" - commander "^6.2.1" - common-tags "^1.8.0" - dayjs "^1.10.4" - debug "^4.3.4" - enquirer "^2.3.6" - eventemitter2 "6.4.7" - execa "4.1.0" - executable "^4.1.1" - extract-zip "2.0.1" - figures "^3.2.0" - fs-extra "^9.1.0" - getos "^3.2.1" - is-ci "^3.0.0" - is-installed-globally "~0.4.0" - lazy-ass "^1.6.0" - listr2 "^3.8.3" - lodash "^4.17.21" - log-symbols "^4.0.0" - minimist "^1.2.8" - ospath "^1.2.2" - pretty-bytes "^5.6.0" - process "^0.11.10" - proxy-from-env "1.0.0" - request-progress "^3.0.0" - semver "^7.5.3" - supports-color "^8.1.1" - tmp "~0.2.1" - untildify "^4.0.0" - yauzl "^2.10.0" - damerau-levenshtein@^1.0.8: version "1.0.8" resolved "https://registry.yarnpkg.com/damerau-levenshtein/-/damerau-levenshtein-1.0.8.tgz#b43d286ccbd36bc5b2f7ed41caf2d0aba1f8a6e7" @@ -5099,10 +5126,10 @@ debug@4, debug@4.3.4, debug@^4.0.1, debug@^4.1.0, debug@^4.1.1, debug@^4.3.1, de dependencies: ms "2.1.2" -debug@4.3.6: - version "4.3.6" - resolved "https://registry.yarnpkg.com/debug/-/debug-4.3.6.tgz#2ab2c38fbaffebf8aa95fdfe6d88438c7a13c52b" - integrity sha512-O/09Bd4Z1fBrU4VzkhFqVgpPzaGbw6Sm9FEkBT1A/YBXQFGuuSxa1dN2nxgxS34JmKXqYx8CZAwEVoJFImUXIg== +debug@4.3.5: + version "4.3.5" + resolved "https://registry.yarnpkg.com/debug/-/debug-4.3.5.tgz#e83444eceb9fedd4a1da56d671ae2446a01a6e1e" + integrity sha512-pt0bNEmneDIvdL1Xsd9oDQ/wrQRkXDT4AUWlNZNPKvW5x/jyO9VFXkJUP07vQ2upmw5PlaITaPKc31jK13V+jg== dependencies: ms "2.1.2" @@ -5543,7 +5570,7 @@ dotenv-parse-variables@^2.0.0: debug "^4.3.1" is-string-and-not-blank "^0.0.2" -dotenv@^16.0.3: +dotenv@^16.3.1: version "16.4.5" resolved "https://registry.yarnpkg.com/dotenv/-/dotenv-16.4.5.tgz#cdd3b3b604cb327e286b4762e13502f717cb099f" integrity sha512-ZmdL2rui+eB2YwhsWzjInR8LldtZHGDoQ1ugH85ppHKwpUHL7j7rN0Ti9NCnGiQbhaZ11FpR+7ao1dNsmduNUg== @@ -6336,10 +6363,10 @@ ethers@^5.1.0, ethers@^5.6.0, ethers@^5.7.2: "@ethersproject/web" "5.7.1" "@ethersproject/wordlists" "5.7.0" -ethers@^6.3.0: - version "6.13.2" - resolved "https://registry.yarnpkg.com/ethers/-/ethers-6.13.2.tgz#4b67d4b49e69b59893931a032560999e5e4419fe" - integrity sha512-9VkriTTed+/27BGuY1s0hf441kqwHJ1wtN2edksEtiRvXx+soxRX3iSXTfFqq2+YwrOqbDoTHjIhQnjJRlzKmg== +ethers@^6.7.1: + version "6.13.1" + resolved "https://registry.yarnpkg.com/ethers/-/ethers-6.13.1.tgz#2b9f9c7455cde9d38b30fe6589972eb083652961" + integrity sha512-hdJ2HOxg/xx97Lm9HdCWk949BfYqYWpyw4//78SiwOLgASyfrNszfMUNB2joKjvGUdwhHfaiMMFFwacVVoLR9A== dependencies: "@adraffy/ens-normalize" "1.10.1" "@noble/curves" "1.2.0" @@ -7040,6 +7067,16 @@ get-port-please@^3.1.2: resolved "https://registry.yarnpkg.com/get-port-please/-/get-port-please-3.1.2.tgz#502795e56217128e4183025c89a48c71652f4e49" integrity sha512-Gxc29eLs1fbn6LQ4jSU4vXjlwyZhF5HsGuMAa7gqBP4Rw4yxxltyDUuF5MBclFzDTXO+ACchGQoeela4DSfzdQ== +get-port@^6.1.2: + version "6.1.2" + resolved "https://registry.yarnpkg.com/get-port/-/get-port-6.1.2.tgz#c1228abb67ba0e17fb346da33b15187833b9c08a" + integrity sha512-BrGGraKm2uPqurfGVj/z97/zv8dPleC6x9JBNRTrDNtCkkRF4rPwrQXFgL7+I+q8QSdU4ntLQX2D7KIxSy8nGw== + +get-port@^7.0.0: + version "7.1.0" + resolved "https://registry.yarnpkg.com/get-port/-/get-port-7.1.0.tgz#d5a500ebfc7aa705294ec2b83cc38c5d0e364fec" + integrity sha512-QB9NKEeDg3xxVwCCwJQ9+xycaz6pBB6iQ76wiWMl1927n0Kir6alPiP+yuiICLLU4jpMe08dXfpebuQppFA2zw== + get-stream@3.0.0, get-stream@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/get-stream/-/get-stream-3.0.0.tgz#8e943d1358dc37555054ecbe2edb05aa174ede14" @@ -8165,6 +8202,11 @@ isomorphic-ws@^4.0.1: resolved "https://registry.yarnpkg.com/isomorphic-ws/-/isomorphic-ws-4.0.1.tgz#55fd4cd6c5e6491e76dc125938dd863f5cd4f2dc" integrity sha512-BhBvN2MBpWTaSHdWRb/bwdZJ1WaehQ2L1KngkCkfLUGF0mAWAT1sQUQacEmQ0jXkFw/czDXPNQSL5u2/Krsz1w== +isows@1.0.3: + version "1.0.3" + resolved "https://registry.yarnpkg.com/isows/-/isows-1.0.3.tgz#93c1cf0575daf56e7120bab5c8c448b0809d0d74" + integrity sha512-2cKei4vlmg2cxEjm3wVSqn8pcoRF/LX/wpifuuNquFO4SQmPwarClT+SUCA2lt+l581tTeZIPIZuIDo2jWN1fg== + isstream@~0.1.2: version "0.1.2" resolved "https://registry.yarnpkg.com/isstream/-/isstream-0.1.2.tgz#47e63f7af55afa6f92e1500e690eb8b8529c099a" @@ -10316,17 +10358,17 @@ pkg-types@^1.1.1: mlly "^1.7.0" pathe "^1.1.2" -playwright-core@1.46.0: - version "1.46.0" - resolved "https://registry.yarnpkg.com/playwright-core/-/playwright-core-1.46.0.tgz#2336ac453a943abf0dc95a76c117f9d3ebd390eb" - integrity sha512-9Y/d5UIwuJk8t3+lhmMSAJyNP1BUC/DqP3cQJDQQL/oWqAiuPTLgy7Q5dzglmTLwcBRdetzgNM/gni7ckfTr6A== +playwright-core@1.45.2: + version "1.45.2" + resolved "https://registry.yarnpkg.com/playwright-core/-/playwright-core-1.45.2.tgz#c8b8b7f66eda47fb2bd24e5435c92d1163022df8" + integrity sha512-ha175tAWb0dTK0X4orvBIqi3jGEt701SMxMhyujxNrgd8K0Uy5wMSwwcQHtyB4om7INUkfndx02XnQ2p6dvLDw== -playwright@1.46.0: - version "1.46.0" - resolved "https://registry.yarnpkg.com/playwright/-/playwright-1.46.0.tgz#c7ff490deae41fc1e814bf2cb62109dd9351164d" - integrity sha512-XYJ5WvfefWONh1uPAUAi0H2xXV5S3vrtcnXe6uAOgdGi3aSpqOSXX08IAjXW34xitfuOJsvXU5anXZxPSEQiJw== +playwright@1.45.2: + version "1.45.2" + resolved "https://registry.yarnpkg.com/playwright/-/playwright-1.45.2.tgz#21082072120a2c8a7e3bbb2792e81e8aa367b7a7" + integrity sha512-ReywF2t/0teRvNBpfIgh5e4wnrI/8Su8ssdo5XsQKpjxJj+jspm00jSoz9BTg91TT0c9HRjXO7LBNVrgYj9X0g== dependencies: - playwright-core "1.46.0" + playwright-core "1.45.2" optionalDependencies: fsevents "2.3.2" @@ -11817,7 +11859,16 @@ string-length@^4.0.1: char-regex "^1.0.2" strip-ansi "^6.0.0" -"string-width-cjs@npm:string-width@^4.2.0", string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.3: +"string-width-cjs@npm:string-width@^4.2.0": + version "4.2.3" + resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010" + integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g== + dependencies: + emoji-regex "^8.0.0" + is-fullwidth-code-point "^3.0.0" + strip-ansi "^6.0.1" + +string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.3: version "4.2.3" resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010" integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g== @@ -11917,7 +11968,7 @@ string_decoder@~1.1.1: dependencies: safe-buffer "~5.1.0" -"strip-ansi-cjs@npm:strip-ansi@^6.0.1", strip-ansi@^6.0.0, strip-ansi@^6.0.1: +"strip-ansi-cjs@npm:strip-ansi@^6.0.1": version "6.0.1" resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9" integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A== @@ -11931,6 +11982,13 @@ strip-ansi@^3.0.1: dependencies: ansi-regex "^2.0.0" +strip-ansi@^6.0.0, strip-ansi@^6.0.1: + version "6.0.1" + resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9" + integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A== + dependencies: + ansi-regex "^5.0.1" + strip-ansi@^7.0.1: version "7.1.0" resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-7.1.0.tgz#d5b6568ca689d8561370b0707685d22434faff45" @@ -12619,6 +12677,11 @@ uncrypto@^0.1.3: resolved "https://registry.yarnpkg.com/uncrypto/-/uncrypto-0.1.3.tgz#e1288d609226f2d02d8d69ee861fa20d8348ef2b" integrity sha512-Ql87qFHB3s/De2ClA9e0gsnS6zXG27SkTiSJwjCc9MebbfapQfuPzumMIUMi38ezPZVNFcHI9sUIepeQfw8J8Q== +underscore@^1.13.6: + version "1.13.6" + resolved "https://registry.yarnpkg.com/underscore/-/underscore-1.13.6.tgz#04786a1f589dc6c09f761fc5f45b89e935136441" + integrity sha512-+A5Sja4HP1M08MaXya7p5LvjuM7K6q/2EaC0+iovj/wOcMsTzMvDFbasi/oSapiwOlt252IqsKqPjCl7huKS0A== + unenv@^1.9.0: version "1.9.0" resolved "https://registry.yarnpkg.com/unenv/-/unenv-1.9.0.tgz#469502ae85be1bd3a6aa60f810972b1a904ca312" @@ -12854,6 +12917,20 @@ verror@1.10.0: core-util-is "1.0.2" extsprintf "^1.2.0" +viem@^1.6.0: + version "1.21.4" + resolved "https://registry.yarnpkg.com/viem/-/viem-1.21.4.tgz#883760e9222540a5a7e0339809202b45fe6a842d" + integrity sha512-BNVYdSaUjeS2zKQgPs+49e5JKocfo60Ib2yiXOWBT6LuVxY1I/6fFX3waEtpXvL1Xn4qu+BVitVtMh9lyThyhQ== + dependencies: + "@adraffy/ens-normalize" "1.10.0" + "@noble/curves" "1.2.0" + "@noble/hashes" "1.3.2" + "@scure/bip32" "1.3.2" + "@scure/bip39" "1.2.1" + abitype "0.9.8" + isows "1.0.3" + ws "8.13.0" + w3c-xmlserializer@^4.0.0: version "4.0.0" resolved "https://registry.yarnpkg.com/w3c-xmlserializer/-/w3c-xmlserializer-4.0.0.tgz#aebdc84920d806222936e3cdce408e32488a3073" @@ -12913,7 +12990,7 @@ webidl-conversions@^7.0.0: resolved "https://registry.yarnpkg.com/webidl-conversions/-/webidl-conversions-7.0.0.tgz#256b4e1882be7debbf01d05f0aa2039778ea080a" integrity sha512-VwddBukDzu71offAQR975unBIGqfKZpM+8ZX6ySk8nYhVoo5CYaZyzt3YBvYtRtO+aoGlqxPg/B87NGVZ/fu6g== -webpack-dev-middleware@^5.3.4: +webpack-dev-middleware@^5.3.1: version "5.3.4" resolved "https://registry.yarnpkg.com/webpack-dev-middleware/-/webpack-dev-middleware-5.3.4.tgz#eb7b39281cbce10e104eb2b8bf2b63fce49a3517" integrity sha512-BVdTqhhs+0IfoeAf7EoH5WE+exCmqGerHfDM0IL096Px60Tq2Mn9MAbnaGUe6HiMa41KMCYF19gyzZmBcq/o4Q== @@ -12924,10 +13001,10 @@ webpack-dev-middleware@^5.3.4: range-parser "^1.2.1" schema-utils "^4.0.0" -webpack-dev-server@^4.15.2: - version "4.15.2" - resolved "https://registry.yarnpkg.com/webpack-dev-server/-/webpack-dev-server-4.15.2.tgz#9e0c70a42a012560860adb186986da1248333173" - integrity sha512-0XavAZbNJ5sDrCbkpWL8mia0o5WPOd2YGtxrEiZkBK9FjLppIUK2TgxK6qGD2P3hUXTJNNPVibrerKcx5WkR1g== +webpack-dev-server@^4.7.4: + version "4.15.1" + resolved "https://registry.yarnpkg.com/webpack-dev-server/-/webpack-dev-server-4.15.1.tgz#8944b29c12760b3a45bdaa70799b17cb91b03df7" + integrity sha512-5hbAst3h3C3L8w6W4P96L5vaV0PxSmJhxZvWKYIdgxOQm8pNZ5dEOmmSLBVpP85ReeyRt6AS1QJNyo/oFFPeVA== dependencies: "@types/bonjour" "^3.5.9" "@types/connect-history-api-fallback" "^1.3.5" @@ -12957,7 +13034,7 @@ webpack-dev-server@^4.15.2: serve-index "^1.9.1" sockjs "^0.3.24" spdy "^4.0.2" - webpack-dev-middleware "^5.3.4" + webpack-dev-middleware "^5.3.1" ws "^8.13.0" webpack-merge@^5.4.0: @@ -13094,7 +13171,7 @@ word-wrap@^1.2.3, word-wrap@~1.2.3: resolved "https://registry.yarnpkg.com/word-wrap/-/word-wrap-1.2.4.tgz#cb4b50ec9aca570abd1f52f33cd45b6c61739a9f" integrity sha512-2V81OA4ugVo5pRo46hAoD2ivUJx8jXmWXfUkY4KFNw0hEptvN0QfH3K4nHiwzGeKl5rFKedV48QVoqYavy4YpA== -"wrap-ansi-cjs@npm:wrap-ansi@^7.0.0", wrap-ansi@^7.0.0: +"wrap-ansi-cjs@npm:wrap-ansi@^7.0.0": version "7.0.0" resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43" integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q== @@ -13112,6 +13189,15 @@ wrap-ansi@^6.2.0: string-width "^4.1.0" strip-ansi "^6.0.0" +wrap-ansi@^7.0.0: + version "7.0.0" + resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43" + integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q== + dependencies: + ansi-styles "^4.0.0" + string-width "^4.1.0" + strip-ansi "^6.0.0" + wrap-ansi@^8.1.0: version "8.1.0" resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-8.1.0.tgz#56dc22368ee570face1b49819975d9b9a5ead214" @@ -13149,6 +13235,11 @@ ws@7.4.6, ws@7.5.10, ws@^7.4.5, ws@^7.5.1: resolved "https://registry.yarnpkg.com/ws/-/ws-7.5.10.tgz#58b5c20dc281633f6c19113f39b349bd8bd558d9" integrity sha512-+dbF1tHwZpXcbOJdVOkzLDxZP1ailvSxM6ZweXTegylPny803bFhA+vqBYw4s31NSAk4S2Qz+AKXK9a4wkdjcQ== +ws@8.13.0: + version "8.13.0" + resolved "https://registry.yarnpkg.com/ws/-/ws-8.13.0.tgz#9a9fb92f93cf41512a0735c8f4dd09b8a1211cd0" + integrity sha512-x9vcZYTrFPC7aSIbj7sRCYo7L/Xb8Iy+pW0ng0wt2vCJv7M9HOMy0UoN3rr+IFC7hb7vXoqS+P9ktyLLLhO+LA== + ws@8.17.1, ws@^8.11.0, ws@^8.13.0, ws@^8.5.0: version "8.17.1" resolved "https://registry.yarnpkg.com/ws/-/ws-8.17.1.tgz#9293da530bb548febc95371d90f9c878727d919b" From fe1e06f8af0e5f1522f07273c8a437d30e8a0484 Mon Sep 17 00:00:00 2001 From: Christophe Date: Mon, 19 Aug 2024 15:55:25 +0000 Subject: [PATCH 27/82] Manually approve spending --- .../tests/e2e/specs/depositCctp.cy.ts | 30 ++++++++++++------- .../tests/e2e/specs/withdrawCctp.cy.ts | 24 +++++++++++---- 2 files changed, 39 insertions(+), 15 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 8b104fdaad..2420b2960b 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 @@ -52,7 +52,9 @@ const confirmAndApproveCctpDeposit = () => { .should('be.enabled') .click() - cy.findByText(/I understand that I have to/).click() + cy.findByText(/I understand that I have to/) + .should('be.visible') + .click() cy.findByRole('button', { name: /Pay approval fee of/ }).click() @@ -86,15 +88,21 @@ describe('Deposit USDC through CCTP', () => { cy.findMoveFundsButton().click() confirmAndApproveCctpDeposit() + // cy.confirmMetamaskPermissionToSpend({ - // spendLimit: USDCAmountToSend.toString() + // spendLimit: USDCAmountToSend.toString(), + // shouldWaitForPopupClosure: true // }) - cy.confirmMetamaskTransaction({ gasConfig: 'market' }) - cy.confirmMetamaskTransaction({ gasConfig: 'market' }) + cy.wait(2_000) + cy.switchToMetamaskWindow() + cy.findByTestId('page-container-footer-next').should('be.visible').click() + cy.wait(1_000) + cy.findByTestId('page-container-footer-next').should('be.visible').click() + cy.switchToCypressWindow() // eslint-disable-next-line cy.wait(40_000) - cy.confirmMetamaskTransaction() + cy.confirmMetamaskTransaction(undefined) cy.findTransactionInTransactionHistory({ duration: 'a minute', amount: USDCAmountToSend, @@ -106,14 +114,16 @@ describe('Deposit USDC through CCTP', () => { cy.fillCustomDestinationAddress() cy.findMoveFundsButton().click() confirmAndApproveCctpDeposit() - // cy.confirmMetamaskPermissionToSpend({ - // spendLimit: USDCAmountToSend.toString() - // }) - cy.confirmMetamaskTransaction({ gasConfig: 'market' }) + cy.wait(2_000) + cy.switchToMetamaskWindow() + cy.findByTestId('page-container-footer-next').should('be.visible').click() + cy.wait(1_000) + cy.findByTestId('page-container-footer-next').should('be.visible').click() + cy.switchToCypressWindow() // eslint-disable-next-line cy.wait(40_000) - cy.confirmMetamaskTransaction() + cy.confirmMetamaskTransaction(undefined) const txData = { amount: USDCAmountToSend, symbol: 'USDC' } cy.findTransactionInTransactionHistory({ duration: 'a minute', 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 df50ece820..d0cf9fe78a 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 @@ -42,7 +42,9 @@ export const confirmAndApproveCctpWithdrawal = () => { .should('be.enabled') .click() - cy.findByText(/I understand that I have to/).click() + cy.findByText(/I understand that I have to/) + .should('be.visible') + .click() cy.findByRole('button', { name: /Pay approval fee of/ }).click() @@ -76,11 +78,17 @@ describe('Withdraw USDC through CCTP', () => { cy.findMoveFundsButton().click() confirmAndApproveCctpWithdrawal() - cy.confirmMetamaskPermissionToSpend(USDCAmountToSend.toString()) + + cy.wait(2_000) + cy.switchToMetamaskWindow() + cy.findByTestId('page-container-footer-next').should('be.visible').click() + cy.wait(1_000) + cy.findByTestId('page-container-footer-next').should('be.visible').click() + cy.switchToCypressWindow() // eslint-disable-next-line cy.wait(40_000) - cy.confirmMetamaskTransaction() + cy.confirmMetamaskTransaction(undefined) cy.findTransactionInTransactionHistory({ duration: 'a minute', amount: USDCAmountToSend, @@ -93,11 +101,17 @@ describe('Withdraw USDC through CCTP', () => { cy.fillCustomDestinationAddress() cy.findMoveFundsButton().click() confirmAndApproveCctpWithdrawal() - cy.confirmMetamaskPermissionToSpend(USDCAmountToSend.toString()) + + cy.wait(2_000) + cy.switchToMetamaskWindow() + cy.findByTestId('page-container-footer-next').should('be.visible').click() + cy.wait(1_000) + cy.findByTestId('page-container-footer-next').should('be.visible').click() + cy.switchToCypressWindow() // eslint-disable-next-line cy.wait(40_000) - cy.confirmMetamaskTransaction() + cy.confirmMetamaskTransaction(undefined) const txData = { amount: USDCAmountToSend, symbol: 'USDC' From 7e268737e80f80c2e87b7f29a5dd2fdd5db7549b Mon Sep 17 00:00:00 2001 From: Christophe Date: Mon, 19 Aug 2024 16:24:08 +0000 Subject: [PATCH 28/82] WIP --- packages/arb-token-bridge-ui/synpress.cctp.config.ts | 1 + packages/arb-token-bridge-ui/tests/e2e/specs/depositCctp.cy.ts | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/arb-token-bridge-ui/synpress.cctp.config.ts b/packages/arb-token-bridge-ui/synpress.cctp.config.ts index f1f5b0937f..27e90a7668 100644 --- a/packages/arb-token-bridge-ui/synpress.cctp.config.ts +++ b/packages/arb-token-bridge-ui/synpress.cctp.config.ts @@ -42,6 +42,7 @@ export default defineConfig({ const userWalletAddress = await userWallet.getAddress() config.env.ADDRESS = userWalletAddress config.env.LOCAL_CCTP_WALLET_PRIVATE_KEY = localWallet.privateKey + config.env.PRIVATE_KEY = userWallet.privateKey config.env.SEPOLIA_INFURA_RPC_URL = SEPOLIA_INFURA_RPC_URL config.env.ARB_SEPOLIA_INFURA_RPC_URL = ARB_SEPOLIA_INFURA_RPC_URL 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 2420b2960b..a7ad39179e 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 @@ -94,7 +94,7 @@ describe('Deposit USDC through CCTP', () => { // shouldWaitForPopupClosure: true // }) cy.wait(2_000) - cy.switchToMetamaskWindow() + cy.switchToMetamaskNotification() cy.findByTestId('page-container-footer-next').should('be.visible').click() cy.wait(1_000) cy.findByTestId('page-container-footer-next').should('be.visible').click() From 6e8bcc6e0de2d24eb7e6d036bf036b44fa624b47 Mon Sep 17 00:00:00 2001 From: Christophe Date: Mon, 19 Aug 2024 16:40:56 +0000 Subject: [PATCH 29/82] Test approveToken --- .../tests/e2e/specs/approveToken.cy.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/packages/arb-token-bridge-ui/tests/e2e/specs/approveToken.cy.ts b/packages/arb-token-bridge-ui/tests/e2e/specs/approveToken.cy.ts index da3ed22763..f25acfe0d0 100644 --- a/packages/arb-token-bridge-ui/tests/e2e/specs/approveToken.cy.ts +++ b/packages/arb-token-bridge-ui/tests/e2e/specs/approveToken.cy.ts @@ -40,7 +40,13 @@ describe('Approve token and deposit afterwards', () => { cy.findByRole('button', { name: /Pay approval fee of/ }).click() - cy.confirmMetamaskPermissionToSpend('1') + // cy.confirmMetamaskPermissionToSpend({ spendLimit: '1' }) + cy.wait(2_000) + cy.switchToMetamaskNotification() + cy.findByTestId('page-container-footer-next').should('be.visible').click() + cy.wait(1_000) + cy.findByTestId('page-container-footer-next').should('be.visible').click() + cy.switchToCypressWindow() }) }) }) From 25fa4d421a5288bf1efdb98e5ce1fff5a7412763 Mon Sep 17 00:00:00 2001 From: Christophe Date: Mon, 19 Aug 2024 17:43:04 +0000 Subject: [PATCH 30/82] WIP --- .../tests/e2e/specs/approveToken.cy.ts | 13 ++++---- .../tests/e2e/specs/depositCctp.cy.ts | 30 ++++++++----------- .../tests/e2e/specs/withdrawCctp.cy.ts | 26 ++++++++-------- 3 files changed, 32 insertions(+), 37 deletions(-) diff --git a/packages/arb-token-bridge-ui/tests/e2e/specs/approveToken.cy.ts b/packages/arb-token-bridge-ui/tests/e2e/specs/approveToken.cy.ts index f25acfe0d0..c0a1ea4e4e 100644 --- a/packages/arb-token-bridge-ui/tests/e2e/specs/approveToken.cy.ts +++ b/packages/arb-token-bridge-ui/tests/e2e/specs/approveToken.cy.ts @@ -40,13 +40,12 @@ describe('Approve token and deposit afterwards', () => { cy.findByRole('button', { name: /Pay approval fee of/ }).click() - // cy.confirmMetamaskPermissionToSpend({ spendLimit: '1' }) - cy.wait(2_000) - cy.switchToMetamaskNotification() - cy.findByTestId('page-container-footer-next').should('be.visible').click() - cy.wait(1_000) - cy.findByTestId('page-container-footer-next').should('be.visible').click() - cy.switchToCypressWindow() + cy.confirmMetamaskPermissionToSpend({ + spendLimit: '1', + shouldWaitForPopupClosure: true + }).then(approved => { + cy.wrap(approved).should('be.true') + }) }) }) }) 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 a7ad39179e..932334f308 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 @@ -88,17 +88,12 @@ describe('Deposit USDC through CCTP', () => { cy.findMoveFundsButton().click() confirmAndApproveCctpDeposit() - - // cy.confirmMetamaskPermissionToSpend({ - // spendLimit: USDCAmountToSend.toString(), - // shouldWaitForPopupClosure: true - // }) - cy.wait(2_000) - cy.switchToMetamaskNotification() - cy.findByTestId('page-container-footer-next').should('be.visible').click() - cy.wait(1_000) - cy.findByTestId('page-container-footer-next').should('be.visible').click() - cy.switchToCypressWindow() + cy.confirmMetamaskPermissionToSpend({ + spendLimit: USDCAmountToSend.toString(), + shouldWaitForPopupClosure: true + }).then(approved => { + cy.wrap(approved).should('be.true') + }) // eslint-disable-next-line cy.wait(40_000) @@ -114,12 +109,13 @@ describe('Deposit USDC through CCTP', () => { cy.fillCustomDestinationAddress() cy.findMoveFundsButton().click() confirmAndApproveCctpDeposit() - cy.wait(2_000) - cy.switchToMetamaskWindow() - cy.findByTestId('page-container-footer-next').should('be.visible').click() - cy.wait(1_000) - cy.findByTestId('page-container-footer-next').should('be.visible').click() - cy.switchToCypressWindow() + + cy.confirmMetamaskPermissionToSpend({ + spendLimit: USDCAmountToSend.toString(), + shouldWaitForPopupClosure: true + }).then(approved => { + cy.wrap(approved).should('be.true') + }) // eslint-disable-next-line cy.wait(40_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 d0cf9fe78a..b75e5ab54d 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,13 +78,12 @@ describe('Withdraw USDC through CCTP', () => { cy.findMoveFundsButton().click() confirmAndApproveCctpWithdrawal() - - cy.wait(2_000) - cy.switchToMetamaskWindow() - cy.findByTestId('page-container-footer-next').should('be.visible').click() - cy.wait(1_000) - cy.findByTestId('page-container-footer-next').should('be.visible').click() - cy.switchToCypressWindow() + cy.confirmMetamaskPermissionToSpend({ + spendLimit: USDCAmountToSend.toString(), + shouldWaitForPopupClosure: true + }).then(approved => { + cy.wrap(approved).should('be.true') + }) // eslint-disable-next-line cy.wait(40_000) @@ -98,16 +97,17 @@ describe('Withdraw USDC through CCTP', () => { it('should initiate withdrawing USDC to custom destination address through CCTP successfully', () => { cy.typeAmount(USDCAmountToSend) + // cy.findByPlaceholderText(/enter amount/i).type(String(USDCAmountToSend)) cy.fillCustomDestinationAddress() cy.findMoveFundsButton().click() confirmAndApproveCctpWithdrawal() - cy.wait(2_000) - cy.switchToMetamaskWindow() - cy.findByTestId('page-container-footer-next').should('be.visible').click() - cy.wait(1_000) - cy.findByTestId('page-container-footer-next').should('be.visible').click() - cy.switchToCypressWindow() + cy.confirmMetamaskPermissionToSpend({ + spendLimit: USDCAmountToSend.toString(), + shouldWaitForPopupClosure: true + }).then(approved => { + cy.wrap(approved).should('be.true') + }) // eslint-disable-next-line cy.wait(40_000) From 1b316ceb4eb7461d9f995e1d165e89cffcbfa5e8 Mon Sep 17 00:00:00 2001 From: Christophe Date: Mon, 19 Aug 2024 18:38:32 +0000 Subject: [PATCH 31/82] Add confirmSpending command --- .../arb-token-bridge-ui/synpress.cctp.config.ts | 4 ++-- .../arb-token-bridge-ui/tests/e2e/cypress.d.ts | 4 +++- .../tests/e2e/specs/approveToken.cy.ts | 7 +++---- .../tests/e2e/specs/depositCctp.cy.ts | 12 +++--------- .../tests/e2e/specs/withdrawCctp.cy.ts | 16 ++++------------ .../tests/support/commands.ts | 14 +++++++++++++- 6 files changed, 28 insertions(+), 29 deletions(-) diff --git a/packages/arb-token-bridge-ui/synpress.cctp.config.ts b/packages/arb-token-bridge-ui/synpress.cctp.config.ts index 27e90a7668..4602110171 100644 --- a/packages/arb-token-bridge-ui/synpress.cctp.config.ts +++ b/packages/arb-token-bridge-ui/synpress.cctp.config.ts @@ -70,14 +70,14 @@ export default defineConfig({ provider: sepoliaProvider, networkType: 'parentChain', sourceWallet: localWallet, - amount: utils.parseUnits('0.0001', 6) + amount: utils.parseUnits('0.0002', 6) }), fundUsdc({ address: userWalletAddress, provider: arbSepoliaProvider, networkType: 'childChain', sourceWallet: localWallet, - amount: utils.parseUnits('0.0001', 6) + amount: utils.parseUnits('0.0002', 6) }) ]) 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 5c596b1f97..2b5ef93310 100644 --- a/packages/arb-token-bridge-ui/tests/e2e/cypress.d.ts +++ b/packages/arb-token-bridge-ui/tests/e2e/cypress.d.ts @@ -19,7 +19,8 @@ import { findTransactionDetailsCustomDestinationAddress, findTransactionInTransactionHistory, findClaimButton, - selectTransactionsPanelTab + selectTransactionsPanelTab, + confirmSpending } from '../support/commands' import { NetworkType, NetworkName } from '../support/common' @@ -62,6 +63,7 @@ declare global { findTransactionDetailsCustomDestinationAddress: typeof findTransactionDetailsCustomDestinationAddress findTransactionInTransactionHistory: typeof findTransactionInTransactionHistory findClaimButton: typeof findClaimButton + confirmSpending: typeof confirmSpending } } } diff --git a/packages/arb-token-bridge-ui/tests/e2e/specs/approveToken.cy.ts b/packages/arb-token-bridge-ui/tests/e2e/specs/approveToken.cy.ts index c0a1ea4e4e..3af8f09699 100644 --- a/packages/arb-token-bridge-ui/tests/e2e/specs/approveToken.cy.ts +++ b/packages/arb-token-bridge-ui/tests/e2e/specs/approveToken.cy.ts @@ -40,12 +40,11 @@ describe('Approve token and deposit afterwards', () => { cy.findByRole('button', { name: /Pay approval fee of/ }).click() - cy.confirmMetamaskPermissionToSpend({ - spendLimit: '1', + cy.confirmSpending({ shouldWaitForPopupClosure: true - }).then(approved => { - cy.wrap(approved).should('be.true') }) + + // TODO: add an assertion here }) }) }) 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 932334f308..c2f03870b5 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 @@ -76,7 +76,7 @@ describe('Deposit USDC through CCTP', () => { tokenAddress: CommonAddress.Sepolia.USDC }) - cy.typeAmount(USDCAmountToSend) + cy.findByPlaceholderText(/enter amount/i).type(String(USDCAmountToSend)) cy.findGasFeeSummary(zeroToLessThanOneETH) cy.findGasFeeForChain('Sepolia', zeroToLessThanOneETH) cy.findGasFeeForChain( @@ -88,11 +88,8 @@ describe('Deposit USDC through CCTP', () => { cy.findMoveFundsButton().click() confirmAndApproveCctpDeposit() - cy.confirmMetamaskPermissionToSpend({ - spendLimit: USDCAmountToSend.toString(), + cy.confirmSpending({ shouldWaitForPopupClosure: true - }).then(approved => { - cy.wrap(approved).should('be.true') }) // eslint-disable-next-line @@ -110,11 +107,8 @@ describe('Deposit USDC through CCTP', () => { cy.findMoveFundsButton().click() confirmAndApproveCctpDeposit() - cy.confirmMetamaskPermissionToSpend({ - spendLimit: USDCAmountToSend.toString(), + cy.confirmSpending({ shouldWaitForPopupClosure: true - }).then(approved => { - cy.wrap(approved).should('be.true') }) // eslint-disable-next-line 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 b75e5ab54d..718216dd13 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 @@ -66,10 +66,11 @@ describe('Withdraw USDC through CCTP', () => { tokenName: 'USDC', tokenAddress: CommonAddress.ArbitrumSepolia.USDC }) + + cy.findByPlaceholderText(/enter amount/i).type(String(USDCAmountToSend)) }) it('should initiate withdrawing USDC to the same address through CCTP successfully', () => { - cy.typeAmount(USDCAmountToSend) cy.findByText('Gas estimates are not available for this action.').should( 'be.visible' ) @@ -78,13 +79,9 @@ describe('Withdraw USDC through CCTP', () => { cy.findMoveFundsButton().click() confirmAndApproveCctpWithdrawal() - cy.confirmMetamaskPermissionToSpend({ - spendLimit: USDCAmountToSend.toString(), + cy.confirmSpending({ shouldWaitForPopupClosure: true - }).then(approved => { - cy.wrap(approved).should('be.true') }) - // eslint-disable-next-line cy.wait(40_000) cy.confirmMetamaskTransaction(undefined) @@ -96,17 +93,12 @@ describe('Withdraw USDC through CCTP', () => { }) it('should initiate withdrawing USDC to custom destination address through CCTP successfully', () => { - cy.typeAmount(USDCAmountToSend) - // cy.findByPlaceholderText(/enter amount/i).type(String(USDCAmountToSend)) cy.fillCustomDestinationAddress() cy.findMoveFundsButton().click() confirmAndApproveCctpWithdrawal() - cy.confirmMetamaskPermissionToSpend({ - spendLimit: USDCAmountToSend.toString(), + cy.confirmSpending({ shouldWaitForPopupClosure: true - }).then(approved => { - cy.wrap(approved).should('be.true') }) // eslint-disable-next-line diff --git a/packages/arb-token-bridge-ui/tests/support/commands.ts b/packages/arb-token-bridge-ui/tests/support/commands.ts index 31c661cd8c..af0e1e1eb7 100644 --- a/packages/arb-token-bridge-ui/tests/support/commands.ts +++ b/packages/arb-token-bridge-ui/tests/support/commands.ts @@ -321,6 +321,17 @@ export function findClaimButton( return cy.findByLabelText(`Claim ${amountToClaim}`) } +/** + * Currently, Synpress confirmMetamaskPermissionToSpend is clicking only once + * We need to call it twice to confirm it + */ +export function confirmSpending( + params: Parameters[0] +) { + cy.confirmMetamaskPermissionToSpend(params) + cy.confirmMetamaskPermissionToSpend(params) +} + Cypress.Commands.addAll({ connectToApp, login, @@ -340,5 +351,6 @@ Cypress.Commands.addAll({ closeTransactionDetails, findTransactionInTransactionHistory, findClaimButton, - findTransactionDetailsCustomDestinationAddress + findTransactionDetailsCustomDestinationAddress, + confirmSpending }) From 4d47ca3f454b6c0a74ad686e4877a20af406802a Mon Sep 17 00:00:00 2001 From: Christophe Date: Wed, 21 Aug 2024 10:58:00 +0000 Subject: [PATCH 32/82] WIP --- .github/workflows/build-test.yml | 28 +++++++++---------- .../tests/e2e/specs/depositCctp.cy.ts | 2 +- .../tests/e2e/specs/withdrawCctp.cy.ts | 2 +- 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/.github/workflows/build-test.yml b/.github/workflows/build-test.yml index 317726159f..9994f517bc 100644 --- a/.github/workflows/build-test.yml +++ b/.github/workflows/build-test.yml @@ -297,21 +297,21 @@ jobs: ${{ fromJson(needs.load-e2e-cctp-files.outputs.matrix) }} steps: - # - name: Free Disk Space (Ubuntu) - # uses: jlumbroso/free-disk-space@main - # with: - # # this might remove tools that are actually needed, - # # if set to "true" but frees about 6 GB - # tool-cache: false + - name: Free Disk Space (Ubuntu) + uses: jlumbroso/free-disk-space@main + with: + # this might remove tools that are actually needed, + # if set to "true" but frees about 6 GB + tool-cache: false - # # all of these default to true, but feel free to set to - # # "false" if necessary for your workflow - # android: true - # dotnet: true - # haskell: true - # large-packages: true - # docker-images: false - # swap-storage: true + # all of these default to true, but feel free to set to + # "false" if necessary for your workflow + android: true + dotnet: true + haskell: true + large-packages: true + docker-images: false + swap-storage: true - name: Checkout uses: actions/checkout@v4 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 c2f03870b5..452d1272e3 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 @@ -76,7 +76,7 @@ describe('Deposit USDC through CCTP', () => { tokenAddress: CommonAddress.Sepolia.USDC }) - cy.findByPlaceholderText(/enter amount/i).type(String(USDCAmountToSend)) + cy.typeAmount(USDCAmountToSend) cy.findGasFeeSummary(zeroToLessThanOneETH) cy.findGasFeeForChain('Sepolia', zeroToLessThanOneETH) cy.findGasFeeForChain( 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 718216dd13..ffea1bfcb6 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 @@ -67,7 +67,7 @@ describe('Withdraw USDC through CCTP', () => { tokenAddress: CommonAddress.ArbitrumSepolia.USDC }) - cy.findByPlaceholderText(/enter amount/i).type(String(USDCAmountToSend)) + cy.typeAmount(USDCAmountToSend) }) it('should initiate withdrawing USDC to the same address through CCTP successfully', () => { From 3cf381d7bdf25a917e869d11432f2a066a2d7a32 Mon Sep 17 00:00:00 2001 From: Christophe Date: Wed, 21 Aug 2024 11:17:49 +0000 Subject: [PATCH 33/82] Create account per test --- .../synpress.cctp.config.ts | 40 ++++--------------- .../tests/e2e/specs/depositCctp.cy.ts | 35 +++++++++++++++- 2 files changed, 41 insertions(+), 34 deletions(-) diff --git a/packages/arb-token-bridge-ui/synpress.cctp.config.ts b/packages/arb-token-bridge-ui/synpress.cctp.config.ts index 4602110171..3486afb6fb 100644 --- a/packages/arb-token-bridge-ui/synpress.cctp.config.ts +++ b/packages/arb-token-bridge-ui/synpress.cctp.config.ts @@ -28,6 +28,10 @@ if (!process.env.PRIVATE_KEY_CCTP) { throw new Error('PRIVATE_KEY_CCTP variable missing.') } +if (!process.env.PRIVATE_KEY_USER) { + throw new Error('PRIVATE_KEY_USER variable missing.') +} + // Wallet funded on Sepolia and ArbSepolia with ETH and USDC const localWallet = new Wallet(process.env.PRIVATE_KEY_CCTP) // Generate a new wallet every time @@ -42,44 +46,14 @@ export default defineConfig({ const userWalletAddress = await userWallet.getAddress() config.env.ADDRESS = userWalletAddress config.env.LOCAL_CCTP_WALLET_PRIVATE_KEY = localWallet.privateKey - config.env.PRIVATE_KEY = userWallet.privateKey + // config.env.PRIVATE_KEY = userWallet.privateKey + config.env.PRIVATE_KEY = process.env.PRIVATE_KEY_USER + config.env.PRIVATE_KEY_CCTP = process.env.PRIVATE_KEY_CCTP config.env.SEPOLIA_INFURA_RPC_URL = SEPOLIA_INFURA_RPC_URL config.env.ARB_SEPOLIA_INFURA_RPC_URL = ARB_SEPOLIA_INFURA_RPC_URL // Fund wallet console.log(`Funding user wallet: ${userWalletAddress}`) - await Promise.all([ - // Sepolia - fundEth({ - address: userWalletAddress, - provider: sepoliaProvider, - sourceWallet: localWallet, - amount: utils.parseEther('0.01') - }), - // ArbSepolia - fundEth({ - address: userWalletAddress, - provider: arbSepoliaProvider, - sourceWallet: localWallet, - amount: utils.parseEther('0.01') - }) - ]) - await Promise.all([ - fundUsdc({ - address: userWalletAddress, - provider: sepoliaProvider, - networkType: 'parentChain', - sourceWallet: localWallet, - amount: utils.parseUnits('0.0002', 6) - }), - fundUsdc({ - address: userWalletAddress, - provider: arbSepoliaProvider, - networkType: 'childChain', - sourceWallet: localWallet, - amount: utils.parseUnits('0.0002', 6) - }) - ]) 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 452d1272e3..3b4fbe1a36 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 @@ -2,8 +2,10 @@ * When user wants to bridge USDC through CCTP from L1 to L2 */ -import { zeroToLessThanOneETH } from '../../support/common' +import { fundEth, fundUsdc, zeroToLessThanOneETH } from '../../support/common' import { CommonAddress } from '../../../src/util/CommonAddressUtils' +import { BigNumber, Wallet, utils } from 'ethers' +import { StaticJsonRpcProvider } from '@ethersproject/providers' // common function for this cctp deposit const confirmAndApproveCctpDeposit = () => { @@ -66,6 +68,37 @@ describe('Deposit USDC through CCTP', () => { let USDCAmountToSend = 0.0001 beforeEach(() => { + cy.log('Creating new wallet') + const userWallet = Wallet.createRandom() + const userWalletAddress = userWallet.address + const localWallet = new Wallet(process.env.PRIVATE_KEY_CCTP) + const arbSepoliaProvider = new StaticJsonRpcProvider( + Cypress.env('ARB_SEPOLIA_INFURA_RPC_URL') + ) + + cy.importMetamaskAccount(userWallet.privateKey) + cy.switchMetamaskAccount(3 + Cypress.currentRetry) + + cy.log(`Funding wallet ${userWallet.address}`) + // Arbitrum Sepolia + cy.wrap( + fundEth({ + address: userWalletAddress, + provider: arbSepoliaProvider, + sourceWallet: localWallet, + amount: utils.parseEther('0.01') + }) + ).then(() => {}) + cy.wrap( + fundUsdc({ + address: userWalletAddress, + provider: arbSepoliaProvider, + networkType: 'childChain', + sourceWallet: localWallet, + amount: BigNumber.from(USDCAmountToSend * 2) + }) + ).then(() => {}) + cy.login({ networkType: 'parentChain', networkName: 'sepolia' }) cy.findSourceChainButton('Sepolia') cy.findDestinationChainButton('Arbitrum Sepolia') From a54e1e689db1858e461c2354991203c25c387c64 Mon Sep 17 00:00:00 2001 From: Christophe Date: Wed, 21 Aug 2024 11:24:08 +0000 Subject: [PATCH 34/82] Change browser --- .github/workflows/build-test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-test.yml b/.github/workflows/build-test.yml index 9994f517bc..3acc03a1f5 100644 --- a/.github/workflows/build-test.yml +++ b/.github/workflows/build-test.yml @@ -342,7 +342,7 @@ jobs: uses: cypress-io/github-action@8d3918616d8ac34caa2b49afc8b408b6a872a6f5 # pin@v6.7.1 with: start: yarn start - command: 'yarn test:e2e:cctp --browser chrome' + command: 'yarn test:e2e:cctp --browser chromium' wait-on: http://127.0.0.1:3000 wait-on-timeout: 120 spec: ./packages/arb-token-bridge-ui/tests/e2e/specs/* From 56e7cec40816537005104e90b9254961ad815d9e Mon Sep 17 00:00:00 2001 From: Christophe Date: Wed, 21 Aug 2024 11:27:43 +0000 Subject: [PATCH 35/82] Update beforeEach setup --- .../tests/e2e/specs/depositCctp.cy.ts | 10 +++--- .../tests/e2e/specs/withdrawCctp.cy.ts | 35 ++++++++++++++++++- 2 files changed, 39 insertions(+), 6 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 3b4fbe1a36..14baabfa51 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 @@ -72,8 +72,8 @@ describe('Deposit USDC through CCTP', () => { const userWallet = Wallet.createRandom() const userWalletAddress = userWallet.address const localWallet = new Wallet(process.env.PRIVATE_KEY_CCTP) - const arbSepoliaProvider = new StaticJsonRpcProvider( - Cypress.env('ARB_SEPOLIA_INFURA_RPC_URL') + const sepoliaProvider = new StaticJsonRpcProvider( + Cypress.env('SEPOLIA_INFURA_RPC_URL') ) cy.importMetamaskAccount(userWallet.privateKey) @@ -84,7 +84,7 @@ describe('Deposit USDC through CCTP', () => { cy.wrap( fundEth({ address: userWalletAddress, - provider: arbSepoliaProvider, + provider: sepoliaProvider, sourceWallet: localWallet, amount: utils.parseEther('0.01') }) @@ -92,8 +92,8 @@ describe('Deposit USDC through CCTP', () => { cy.wrap( fundUsdc({ address: userWalletAddress, - provider: arbSepoliaProvider, - networkType: 'childChain', + provider: sepoliaProvider, + networkType: 'parentChain', sourceWallet: localWallet, amount: BigNumber.from(USDCAmountToSend * 2) }) 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 ffea1bfcb6..55fe0b57e9 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,7 +3,9 @@ */ import { CommonAddress } from 'packages/arb-token-bridge-ui/src/util/CommonAddressUtils' -import { zeroToLessThanOneETH } from '../../support/common' +import { fundEth, fundUsdc, zeroToLessThanOneETH } from '../../support/common' +import { BigNumber, Wallet, utils } from 'ethers' +import { StaticJsonRpcProvider } from '@ethersproject/providers' // common function for this cctp withdrawal export const confirmAndApproveCctpWithdrawal = () => { @@ -57,6 +59,37 @@ describe('Withdraw USDC through CCTP', () => { // log in to metamask before withdrawal beforeEach(() => { + const userWallet = Wallet.createRandom() + const userWalletAddress = userWallet.address + const localWallet = new Wallet(process.env.PRIVATE_KEY_CCTP) + + const arbSepoliaProvider = new StaticJsonRpcProvider( + Cypress.env('ARB_SEPOLIA_INFURA_RPC_URL') + ) + + cy.importMetamaskAccount(userWallet.privateKey) + cy.switchMetamaskAccount(3 + Cypress.currentRetry) + + cy.log(`Funding wallet ${userWallet.address}`) + // Arbitrum Sepolia + cy.wrap( + fundEth({ + address: userWalletAddress, + provider: arbSepoliaProvider, + sourceWallet: localWallet, + amount: utils.parseEther('0.01') + }) + ).then(() => {}) + cy.wrap( + fundUsdc({ + address: userWalletAddress, + provider: arbSepoliaProvider, + networkType: 'childChain', + sourceWallet: localWallet, + amount: BigNumber.from(USDCAmountToSend * 2) + }) + ).then(() => {}) + cy.login({ networkType: 'childChain', networkName: 'arbitrum-sepolia' }) cy.findSourceChainButton('Arbitrum Sepolia') cy.findDestinationChainButton('Sepolia') From 91ab959744f06685a992f64c90c6b4c893cc95e9 Mon Sep 17 00:00:00 2001 From: Christophe Date: Wed, 21 Aug 2024 12:03:51 +0000 Subject: [PATCH 36/82] Fix localWallet setup --- .../synpress.cctp.config.ts | 11 +++---- .../tests/e2e/specs/depositCctp.cy.ts | 20 ++++++++---- .../tests/e2e/specs/withdrawCctp.cy.ts | 32 ++++++++++++------- 3 files changed, 39 insertions(+), 24 deletions(-) diff --git a/packages/arb-token-bridge-ui/synpress.cctp.config.ts b/packages/arb-token-bridge-ui/synpress.cctp.config.ts index 3486afb6fb..355cd92f1f 100644 --- a/packages/arb-token-bridge-ui/synpress.cctp.config.ts +++ b/packages/arb-token-bridge-ui/synpress.cctp.config.ts @@ -21,8 +21,8 @@ if (typeof INFURA_KEY === 'undefined') { const SEPOLIA_INFURA_RPC_URL = `https://sepolia.infura.io/v3/${INFURA_KEY}` const ARB_SEPOLIA_INFURA_RPC_URL = `https://arbitrum-sepolia.infura.io/v3/${INFURA_KEY}` -const sepoliaProvider = new StaticJsonRpcProvider(SEPOLIA_INFURA_RPC_URL) -const arbSepoliaProvider = new StaticJsonRpcProvider(ARB_SEPOLIA_INFURA_RPC_URL) +// const sepoliaProvider = new StaticJsonRpcProvider(SEPOLIA_INFURA_RPC_URL) +// const arbSepoliaProvider = new StaticJsonRpcProvider(ARB_SEPOLIA_INFURA_RPC_URL) if (!process.env.PRIVATE_KEY_CCTP) { throw new Error('PRIVATE_KEY_CCTP variable missing.') @@ -43,8 +43,8 @@ export default defineConfig({ async setupNodeEvents(on, config) { logsPrinter(on) - const userWalletAddress = await userWallet.getAddress() - config.env.ADDRESS = userWalletAddress + // const userWalletAddress = await userWallet.getAddress() + // config.env.ADDRESS = userWalletAddress config.env.LOCAL_CCTP_WALLET_PRIVATE_KEY = localWallet.privateKey // config.env.PRIVATE_KEY = userWallet.privateKey config.env.PRIVATE_KEY = process.env.PRIVATE_KEY_USER @@ -52,9 +52,6 @@ export default defineConfig({ config.env.SEPOLIA_INFURA_RPC_URL = SEPOLIA_INFURA_RPC_URL config.env.ARB_SEPOLIA_INFURA_RPC_URL = ARB_SEPOLIA_INFURA_RPC_URL - // Fund wallet - console.log(`Funding user wallet: ${userWalletAddress}`) - setupCypressTasks(on, { requiresNetworkSetup: false }) synpressPlugins(on, config) return 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 14baabfa51..64f294a181 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 @@ -65,13 +65,13 @@ const confirmAndApproveCctpDeposit = () => { describe('Deposit USDC through CCTP', () => { // Happy Path - let USDCAmountToSend = 0.0001 + const USDCAmountToSend = 0.0001 beforeEach(() => { cy.log('Creating new wallet') const userWallet = Wallet.createRandom() const userWalletAddress = userWallet.address - const localWallet = new Wallet(process.env.PRIVATE_KEY_CCTP) + const localWallet = new Wallet(Cypress.env('PRIVATE_KEY_CCTP')) const sepoliaProvider = new StaticJsonRpcProvider( Cypress.env('SEPOLIA_INFURA_RPC_URL') ) @@ -88,16 +88,24 @@ describe('Deposit USDC through CCTP', () => { sourceWallet: localWallet, amount: utils.parseEther('0.01') }) - ).then(() => {}) - cy.wrap( + ).then(() => { fundUsdc({ address: userWalletAddress, provider: sepoliaProvider, networkType: 'parentChain', sourceWallet: localWallet, - amount: BigNumber.from(USDCAmountToSend * 2) + amount: utils.parseUnits('0.0002', 6) }) - ).then(() => {}) + }) + // cy.wrap( + // fundUsdc({ + // address: userWalletAddress, + // provider: sepoliaProvider, + // networkType: 'parentChain', + // sourceWallet: localWallet, + // amount: utils.parseUnits('0.0002', 6) + // }) + // ).then(() => {}) cy.login({ networkType: 'parentChain', networkName: 'sepolia' }) cy.findSourceChainButton('Sepolia') 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 55fe0b57e9..906ae034b7 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 @@ -61,7 +61,7 @@ describe('Withdraw USDC through CCTP', () => { beforeEach(() => { const userWallet = Wallet.createRandom() const userWalletAddress = userWallet.address - const localWallet = new Wallet(process.env.PRIVATE_KEY_CCTP) + const localWallet = new Wallet(Cypress.env('PRIVATE_KEY_CCTP')) const arbSepoliaProvider = new StaticJsonRpcProvider( Cypress.env('ARB_SEPOLIA_INFURA_RPC_URL') @@ -79,16 +79,26 @@ describe('Withdraw USDC through CCTP', () => { sourceWallet: localWallet, amount: utils.parseEther('0.01') }) - ).then(() => {}) - cy.wrap( - fundUsdc({ - address: userWalletAddress, - provider: arbSepoliaProvider, - networkType: 'childChain', - sourceWallet: localWallet, - amount: BigNumber.from(USDCAmountToSend * 2) - }) - ).then(() => {}) + ).then(() => { + cy.wrap( + fundUsdc({ + address: userWalletAddress, + provider: arbSepoliaProvider, + networkType: 'childChain', + sourceWallet: localWallet, + amount: utils.parseUnits('0.0002', 6) + }) + ) + }) + // cy.wrap( + // fundUsdc({ + // address: userWalletAddress, + // provider: arbSepoliaProvider, + // networkType: 'childChain', + // sourceWallet: localWallet, + // amount: utils.parseUnits('0.0002', 6) + // }) + // ).then(() => {}) cy.login({ networkType: 'childChain', networkName: 'arbitrum-sepolia' }) cy.findSourceChainButton('Arbitrum Sepolia') From ead5eb030a623f871f476c37d5207f337c085d90 Mon Sep 17 00:00:00 2001 From: Christophe Date: Wed, 21 Aug 2024 14:52:32 +0000 Subject: [PATCH 37/82] Cleanup --- package.json | 2 +- .../TransferPanel/AdvancedSettings.tsx | 1 + .../synpress.cctp.config.ts | 124 ++++++++++++++++-- .../arb-token-bridge-ui/synpress.config.ts | 8 +- .../tests/e2e/specs/depositCctp.cy.ts | 51 +------ .../tests/e2e/specs/withdrawCctp.cy.ts | 53 +------- .../tests/support/commands.ts | 2 +- .../tests/support/common.ts | 5 + 8 files changed, 131 insertions(+), 115 deletions(-) diff --git a/package.json b/package.json index 498ec9f8ea..c60ae31523 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,7 @@ "lint": "yarn workspace arb-token-bridge-ui lint", "lint:fix": "yarn workspace arb-token-bridge-ui lint:fix", "test:e2e": "yarn workspace arb-token-bridge-ui env-cmd --silent --file .e2e.env yarn synpress run --configFile synpress.config.ts", - "test:e2e:cctp": "yarn workspace arb-token-bridge-ui env-cmd --silent --file .e2e.env yarn synpress run --configFile synpress.cctp.config.ts", + "test:e2e:cctp": "yarn test:e2e --configFile synpress.cctp.config.ts", "test:e2e:orbit": "E2E_ORBIT=true yarn test:e2e" }, "resolutions": { diff --git a/packages/arb-token-bridge-ui/src/components/TransferPanel/AdvancedSettings.tsx b/packages/arb-token-bridge-ui/src/components/TransferPanel/AdvancedSettings.tsx index ca44aef3ff..a6fb791c63 100644 --- a/packages/arb-token-bridge-ui/src/components/TransferPanel/AdvancedSettings.tsx +++ b/packages/arb-token-bridge-ui/src/components/TransferPanel/AdvancedSettings.tsx @@ -263,6 +263,7 @@ export const AdvancedSettings = () => { onChange={e => setDestinationAddress(e.target.value?.toLowerCase().trim()) } + aria-label="Custom Destination Address Input" /> {isEOA && (