Skip to content

Commit

Permalink
ci: run e2e tests with L3 (#1789)
Browse files Browse the repository at this point in the history
  • Loading branch information
brtkx authored Jul 26, 2024
1 parent 444992f commit e502a9b
Show file tree
Hide file tree
Showing 22 changed files with 290 additions and 108 deletions.
10 changes: 6 additions & 4 deletions .github/workflows/build-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ jobs:
# based on https://github.com/Synthetixio/synpress/blob/dev/.github/workflows/e2e_cypress-action.yml
test-e2e:
name: "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'
Expand All @@ -169,6 +169,7 @@ jobs:
matrix:
tests:
${{ fromJson(needs.load-e2e-files.outputs.matrix) }}
orbit-test: ['0', '1']

steps:
- name: Free Disk Space (Ubuntu)
Expand Down Expand Up @@ -216,14 +217,14 @@ jobs:
uses: OffchainLabs/actions/run-nitro-test-node@a20a76172ce524832ac897bef2fa10a62ed81c29
with:
nitro-testnode-ref: aab133aceadec2e622f15fa438f6327e3165392d
l3-node: false
no-l3-token-bridge: true
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 # [email protected]
with:
start: yarn start
command: yarn test:e2e --browser chromium
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/*
Expand All @@ -237,6 +238,7 @@ jobs:
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
Expand Down
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ It is important for any code change to pass both unit and end-to-end tests. This
1. First, make sure you have a Nitro test node running. Follow the instructions [here](https://docs.arbitrum.io/node-running/how-tos/local-dev-node).
Use the following command to run your test nodes locally for our tests.
Use the following command to run your test nodes locally for our tests. You may omit `--l3node --l3-token-bridge` if you don't intend on testing Orbit chains.

```bash
./test-node.bash --init --no-simple --tokenbridge --l3node --l3-token-bridge
Expand Down Expand Up @@ -158,6 +158,12 @@ It is important for any code change to pass both unit and end-to-end tests. This
$ yarn test:e2e:cctp
```

6. For Orbit tests, run

```bash
$ yarn test:e2e:orbit
```

Read more about the test setup [here](/packages/arb-token-bridge-ui/tests/e2e/README.md).

<br />
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
"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": "E2E_CCTP=true yarn test:e2e",
"test:e2e:orbit": "E2E_ORBIT=true yarn test:e2e"
},
"resolutions": {
"**/@walletconnect/ethereum-provider": "2.13.1",
Expand Down
4 changes: 4 additions & 0 deletions packages/arb-token-bridge-ui/.e2e.env.sample
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
NEXT_PUBLIC_INFURA_KEY=
NETWORK_NAME=localhost

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

CYPRESS_RECORD_VIDEO=false

# We don't use PRIVATE_KEY because Synpress is looking for that to set up MetaMask
Expand Down
4 changes: 3 additions & 1 deletion packages/arb-token-bridge-ui/src/hooks/useNetworks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ import {
arbitrumNova,
arbitrumSepolia,
localL1Network as local,
localL2Network as arbitrumLocal
localL2Network as arbitrumLocal,
localL3Network as l3Local
} from '../util/wagmi/wagmiAdditionalNetworks'

import { getDestinationChainIds } from '../util/networks'
Expand All @@ -38,6 +39,7 @@ export function isSupportedChainId(
arbitrumNova.id,
arbitrumSepolia.id,
arbitrumLocal.id,
l3Local.id,
local.id,
...getOrbitChains().map(chain => chain.chainId),
...customChainIds
Expand Down
9 changes: 8 additions & 1 deletion packages/arb-token-bridge-ui/src/types/ChainQueryParam.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ const chainQueryParams = [
'arbitrum-nova',
'arbitrum-sepolia',
'custom-localhost',
'arbitrum-localhost'
'arbitrum-localhost',
'l3-localhost'
] as const

export type ChainKeyQueryParam = (typeof chainQueryParams)[number]
Expand Down Expand Up @@ -61,6 +62,9 @@ export function getChainQueryParamForChain(chainId: ChainId): ChainQueryParam {
case ChainId.ArbitrumLocal:
return 'arbitrum-localhost'

case ChainId.L3Local:
return 'l3-localhost'

default:
const customChain = getCustomChainFromLocalStorageById(chainId)

Expand Down Expand Up @@ -105,6 +109,9 @@ export function getChainForChainKeyQueryParam(
case 'arbitrum-localhost':
return customChains.localL2Network

case 'l3-localhost':
return customChains.localL3Network

default:
const orbitChain = getOrbitChains().find(
chain =>
Expand Down
8 changes: 8 additions & 0 deletions packages/arb-token-bridge-ui/src/util/bridgeUiConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,14 @@ export function getBridgeUiConfigForChain(chainId: number): BridgeUiConfig {
name: 'Arbitrum Local'
}
}
case ChainId.L3Local:
return {
color: '#12AAFF',
network: {
name: 'L3 Local',
logo: '/images/OrbitLogo.svg'
}
}
case ChainId.ArbitrumNova:
return {
color: '#E57310',
Expand Down
45 changes: 43 additions & 2 deletions packages/arb-token-bridge-ui/src/util/networks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ export enum ChainId {
ArbitrumNova = 42170,
// L2 Testnets
ArbitrumSepolia = 421614,
ArbitrumLocal = 412346
ArbitrumLocal = 412346,
// L3 Testnets
L3Local = 333333
}

type L1Network = {
Expand Down Expand Up @@ -300,6 +302,38 @@ export const defaultL2Network: ArbitrumNetwork = {
}
}

export const defaultL3Network: ArbitrumNetwork = {
chainId: 333333,
parentChainId: ChainId.ArbitrumLocal,
confirmPeriodBlocks: 20,
ethBridge: {
bridge: '0xA584795e24628D9c067A6480b033C9E96281fcA3',
inbox: '0xDcA690902d3154886Ec259308258D10EA5450996',
outbox: '0xda243bD61B011024FC923164db75Dde198AC6175',
rollup: '0xf9B0F86aCc3e42B7DF373c9a8adb2803BF0a7662',
sequencerInbox: '0x16c54EE2015CD824415c2077F4103f444E00A8cb'
},
isCustom: true,
name: 'L3 Local',
retryableLifetimeSeconds: 604800,
tokenBridge: {
parentCustomGateway: '0xA191D519260A06b32f8D04c84b9F457B8Caa0514',
parentErc20Gateway: '0x6B0805Fc6e275ef66a0901D0CE68805631E271e5',
parentGatewayRouter: '0xfE03DBdf7A126994dBd749631D7fbaB58C618c58',
parentMultiCall: '0x20a3627Dcc53756E38aE3F92717DE9B23617b422',
parentProxyAdmin: '0x1A61102c26ad3f64bA715B444C93388491fd8E68',
parentWeth: '0xA1abD387192e3bb4e84D3109181F9f005aBaF5CA',
parentWethGateway: '0x77603b0ea6a797C74Fa9ef11b5BdE04A4E03D550',
childCustomGateway: '0xD4816AeF8f85A3C1E01Cd071a81daD4fa941625f',
childErc20Gateway: '0xaa7d51aFFEeB32d99b1CB2fd6d81D7adA4a896e8',
childGatewayRouter: '0x8B6BC759226f8Fe687c8aD8Cc0DbF85E095e9297',
childMultiCall: '0x052B15c8Ff0544287AE689C4F2FC53A3905d7Db3',
childProxyAdmin: '0x36C56eC2CF3a3f53db9F01d0A5Ae84b36fb0A1e2',
childWeth: '0x582a8dBc77f665dF2c49Ce0a138978e9267dd968',
childWethGateway: '0xA6AB233B3c7bfd0399834897b5073974A3D467e2'
}
}

export const localL1NetworkRpcUrl = loadEnvironmentVariableWithFallback({
env: process.env.NEXT_PUBLIC_LOCAL_ETHEREUM_RPC_URL,
fallback: 'http://127.0.0.1:8545'
Expand All @@ -308,13 +342,19 @@ export const localL2NetworkRpcUrl = loadEnvironmentVariableWithFallback({
env: process.env.NEXT_PUBLIC_LOCAL_ARBITRUM_RPC_URL,
fallback: 'http://127.0.0.1:8547'
})
export const localL3NetworkRpcUrl = loadEnvironmentVariableWithFallback({
env: process.env.NEXT_PUBLIC_LOCAL_L3_RPC_URL,
fallback: 'http://127.0.0.1:3347'
})

export function registerLocalNetwork() {
try {
rpcURLs[defaultL1Network.chainId] = localL1NetworkRpcUrl
rpcURLs[defaultL2Network.chainId] = localL2NetworkRpcUrl
rpcURLs[defaultL3Network.chainId] = localL3NetworkRpcUrl

registerCustomArbitrumNetwork(defaultL2Network)
registerCustomArbitrumNetwork(defaultL3Network)
} catch (error: any) {
console.error(`Failed to register local network: ${error.message}`)
}
Expand All @@ -323,7 +363,8 @@ export function registerLocalNetwork() {
export function isNetwork(chainId: ChainId) {
const customChains = getCustomChainsFromLocalStorage()
const isMainnetOrbitChain = chainId in orbitMainnets
const isTestnetOrbitChain = chainId in orbitTestnets
const isL3Local = chainId === ChainId.L3Local
const isTestnetOrbitChain = chainId in orbitTestnets || isL3Local

const isEthereumMainnet = chainId === ChainId.Ethereum

Expand Down
6 changes: 5 additions & 1 deletion packages/arb-token-bridge-ui/src/util/wagmi/getWagmiChain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ import {
arbitrumNova,
arbitrumSepolia,
localL1Network,
localL2Network
localL2Network,
localL3Network
} from './wagmiAdditionalNetworks'
import { ChainId } from '../networks'
import { getCustomChainFromLocalStorageById } from '../networks'
Expand Down Expand Up @@ -53,6 +54,9 @@ export function getWagmiChain(chainId: number): Chain {
case ChainId.ArbitrumLocal:
return localL2Network

case ChainId.L3Local:
return localL3Network

default:
throw new Error(`[getWagmiChain] Unexpected chain id: ${chainId}`)
}
Expand Down
2 changes: 2 additions & 0 deletions packages/arb-token-bridge-ui/src/util/wagmi/setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
arbitrumSepolia,
localL1Network as local,
localL2Network as arbitrumLocal,
localL3Network as l3Local,
holesky
} from './wagmiAdditionalNetworks'
import { isTestingEnvironment } from '../CommonUtils'
Expand Down Expand Up @@ -40,6 +41,7 @@ const chainList = isTestingEnvironment
// add local environments during testing
local,
arbitrumLocal,
l3Local,
// user-added custom chains
...customChains
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,27 @@ export const localL2Network: Chain = {
}
},
blockExplorers: {
default: { name: 'Blockscout', url: '' }
default: { name: 'Blockscout', url: 'https://etherscan.io' }
}
}

/**
* For e2e testing
*/
export const localL3Network: Chain = {
id: ChainId.L3Local,
name: 'L3 Local',
network: 'l3-localhost',
nativeCurrency: ether,
rpcUrls: {
default: {
http: [rpcURLs[ChainId.L3Local]!]
},
public: {
http: [rpcURLs[ChainId.L3Local]!]
}
},
blockExplorers: {
default: { name: 'Blockscout', url: 'https://etherscan.io' }
}
}
Loading

0 comments on commit e502a9b

Please sign in to comment.