Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add CI flow for testing all tutorials #132

Merged
merged 14 commits into from
Jan 10, 2025
39 changes: 39 additions & 0 deletions .github/workflows/test-all.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Test all tutorials
run-name: Test all tutorials

on:
pull_request:
branches:
- master

env:
PRIVATE_KEY: "b6b15c8cb491557369f3c7d2c287b053eb229daa9c22138887752191c9520659"
CHAIN_RPC: "http://127.0.0.1:3347"
PARENT_CHAIN_RPC: "http://127.0.0.1:8547"
# Env variables for specific tutorials
L1_RPC: "http://127.0.0.1:8545"
TransferTo: "0x3f1Eae7D46d88F08fc2F8ed27FCb2AB183EB2d0E"

jobs:
test-all:
name: Test all tutorials
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Install node_modules
uses: OffchainLabs/actions/node-modules/install@main

- name: Set up the local node
# https://github.com/OffchainLabs/actions/blob/feat-simplify/run-nitro-test-node/action.yml
uses: OffchainLabs/actions/run-nitro-test-node@feat-simplify
with:
nitro-testnode-ref: release
args: --tokenbridge --l3node --l3-token-bridge

- name: Copy .env
run: cp ./.env-sample ./.env

- name: Test
run: yarn run testAll
60 changes: 0 additions & 60 deletions .pre-commit-config.yaml

This file was deleted.

114 changes: 77 additions & 37 deletions customNetwork.json
Original file line number Diff line number Diff line change
@@ -1,38 +1,78 @@
{
"chainID": 412346,
"confirmPeriodBlocks": 20,
"ethBridge": {
"bridge": "0x5eCF728ffC5C5E802091875f96281B5aeECf6C49",
"inbox": "0x9f8c1c641336A371031499e3c362e40d58d0f254",
"outbox": "0x50143333b44Ea46255BEb67255C9Afd35551072F",
"rollup": "0x7d98BA231d29D5C202981542C0291718A7358c63",
"sequencerInbox": "0x18d19C5d3E685f5be5b9C86E097f0E439285D216"
[
{
"chainID": 412346,
"confirmPeriodBlocks": 20,
"ethBridge": {
"bridge": "0x5eCF728ffC5C5E802091875f96281B5aeECf6C49",
"inbox": "0x9f8c1c641336A371031499e3c362e40d58d0f254",
"outbox": "0x50143333b44Ea46255BEb67255C9Afd35551072F",
"rollup": "0x7d98BA231d29D5C202981542C0291718A7358c63",
"sequencerInbox": "0x18d19C5d3E685f5be5b9C86E097f0E439285D216"
},
"explorerUrl": "",
"isArbitrum": true,
"isCustom": true,
"name": "ArbLocal",
"partnerChainID": 1337,
"retryableLifetimeSeconds": 604800,
"nitroGenesisBlock": 0,
"nitroGenesisL1Block": 0,
"depositTimeout": 900000,
"tokenBridge": {
"parentGatewayRouter": "0x093AAa96CD4387A68FC0e24C60140938Dc812549",
"childGatewayRouter": "0x32656396981868E925280FB772b3f806892cf4bF",
"parentErc20Gateway": "0x00D9fE1a2B67B8151aEdE8855c95E58D73FB4245",
"childErc20Gateway": "0x7424e3DAAAAcd867c85ceB75c1E00119F2ee5eb7",
"parentCustomGateway": "0x8407E6180dC009D20D26D4BABB4790C1d4E6D2aA",
"childCustomGateway": "0x0B35cfE62314C3852A0942b5830c728353BD654F",
"parentWethGateway": "0xB8F48Ba39fCfB44d70F6008fe1bf4F3E744044AF",
"childWethGateway": "0x67aE8014BD1A0c1Ed747715d22b3b3a188aC324B",
"parentWeth": "0x7E32b54800705876d3b5cFbc7d9c226a211F7C1a",
"childWeth": "0xA1abD387192e3bb4e84D3109181F9f005aBaF5CA",
"parentProxyAdmin": "0x2A1f38c9097e7883570e0b02BFBE6869Cc25d8a3",
"childProxyAdmin": "0x9F95547ABB0FfC92b4E37b3124d1e8613d5aB74A",
"parentMultiCall": "0x49117fC32930E324F2E9A7BeA588FFb26008b8eC",
"childMultiCall": "0x6B1E93aE298B64e8f5b9f43B65Dd8F1eaA6DD4c3"
},
"chainId": 412346,
"parentChainId": 1337
},
"explorerUrl": "",
"isArbitrum": true,
"isCustom": true,
"name": "ArbLocal",
"partnerChainID": 1337,
"retryableLifetimeSeconds": 604800,
"nitroGenesisBlock": 0,
"nitroGenesisL1Block": 0,
"depositTimeout": 900000,
"tokenBridge": {
"parentGatewayRouter": "0x093AAa96CD4387A68FC0e24C60140938Dc812549",
"childGatewayRouter": "0x32656396981868E925280FB772b3f806892cf4bF",
"parentErc20Gateway": "0x00D9fE1a2B67B8151aEdE8855c95E58D73FB4245",
"childErc20Gateway": "0x7424e3DAAAAcd867c85ceB75c1E00119F2ee5eb7",
"parentCustomGateway": "0x8407E6180dC009D20D26D4BABB4790C1d4E6D2aA",
"childCustomGateway": "0x0B35cfE62314C3852A0942b5830c728353BD654F",
"parentWethGateway": "0xB8F48Ba39fCfB44d70F6008fe1bf4F3E744044AF",
"childWethGateway": "0x67aE8014BD1A0c1Ed747715d22b3b3a188aC324B",
"parentWeth": "0x7E32b54800705876d3b5cFbc7d9c226a211F7C1a",
"childWeth": "0xA1abD387192e3bb4e84D3109181F9f005aBaF5CA",
"parentProxyAdmin": "0x2A1f38c9097e7883570e0b02BFBE6869Cc25d8a3",
"childProxyAdmin": "0x9F95547ABB0FfC92b4E37b3124d1e8613d5aB74A",
"parentMultiCall": "0x49117fC32930E324F2E9A7BeA588FFb26008b8eC",
"childMultiCall": "0x6B1E93aE298B64e8f5b9f43B65Dd8F1eaA6DD4c3"
},
"chainId": 412346,
"parentChainId": 1337
}
{
"chainID": 333333,
"confirmPeriodBlocks": 20,
"ethBridge": {
"bridge": "0xA584795e24628D9c067A6480b033C9E96281fcA3",
"inbox": "0xDcA690902d3154886Ec259308258D10EA5450996",
"outbox": "0xda243bD61B011024FC923164db75Dde198AC6175",
"rollup": "0xfe808cD61B3fe45c67c47B17DB49B96Fb2BFDfae",
"sequencerInbox": "0x16c54EE2015CD824415c2077F4103f444E00A8cb"
},
"explorerUrl": "",
"isArbitrum": true,
"isCustom": true,
"name": "ArbLocalL3",
"partnerChainID": 412346,
"retryableLifetimeSeconds": 604800,
"nitroGenesisBlock": 0,
"nitroGenesisL1Block": 0,
"depositTimeout": 900000,
"tokenBridge": {
"parentGatewayRouter": "0xfE03DBdf7A126994dBd749631D7fbaB58C618c58",
"childGatewayRouter": "0x8B6BC759226f8Fe687c8aD8Cc0DbF85E095e9297",
"parentErc20Gateway": "0x6B0805Fc6e275ef66a0901D0CE68805631E271e5",
"childErc20Gateway": "0xaa7d51aFFEeB32d99b1CB2fd6d81D7adA4a896e8",
"parentCustomGateway": "0xA191D519260A06b32f8D04c84b9F457B8Caa0514",
"childCustomGateway": "0xD4816AeF8f85A3C1E01Cd071a81daD4fa941625f",
"parentWethGateway": "0x77603b0ea6a797C74Fa9ef11b5BdE04A4E03D550",
"childWethGateway": "0xA6AB233B3c7bfd0399834897b5073974A3D467e2",
"parentWeth": "0xA1abD387192e3bb4e84D3109181F9f005aBaF5CA",
"childWeth": "0x582a8dBc77f665dF2c49Ce0a138978e9267dd968",
"parentProxyAdmin": "0x1A61102c26ad3f64bA715B444C93388491fd8E68",
"childProxyAdmin": "0x36C56eC2CF3a3f53db9F01d0A5Ae84b36fb0A1e2",
"parentMultiCall": "0x20a3627Dcc53756E38aE3F92717DE9B23617b422",
"childMultiCall": "0x052B15c8Ff0544287AE689C4F2FC53A3905d7Db3"
},
"chainId": 333333,
"parentChainId": 412346
}
]
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
},
"scripts": {
"lint": "eslint .",
"format": "prettier './**/*.{js,json,md,yml,sol}' --write && yarn run lint --fix"
"format": "prettier './**/*.{js,json,md,yml,sol}' --write && yarn run lint --fix",
"testAll": "tests/runAll.sh"
},
"devDependencies": {
"chai": "^4.3.4",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,7 @@ const main = async (childChainBlockNumberToVerify: number) => {
const nodeCreatedEventFilter = rollup.filters.NodeCreated(nodeId)
const nodeCreatedEvents = await rollup.queryFilter(nodeCreatedEventFilter)
if (!nodeCreatedEvents) {
console.error(`INTERNAL ERROR: NodeCreated events not found for Rblock/node: ${nodeId}`)
return
throw new Error(`INTERNAL ERROR: NodeCreated events not found for Rblock/node: ${nodeId}`)
}
const nodeCreatedEvent = nodeCreatedEvents[0]
console.log(`NodeCreated event found in transaction ${nodeCreatedEvent.transactionHash}`)
Expand All @@ -56,8 +55,7 @@ const main = async (childChainBlockNumberToVerify: number) => {
* Finding the assertion within the NodeCreated event, and getting the afterState
*/
if (!nodeCreatedEvent.args) {
console.error(`INTERNAL ERROR: NodeCreated event does not have an assertion for Rblock/node: ${nodeId}`)
return
throw new Error(`INTERNAL ERROR: NodeCreated event does not have an assertion for Rblock/node: ${nodeId}`)
}
const assertion = nodeCreatedEvent.args.assertion
const afterState = assertion.afterState
Expand Down Expand Up @@ -91,7 +89,7 @@ const main = async (childChainBlockNumberToVerify: number) => {
if (process.argv.length < 3) {
console.log(`Missing block number of the child chain to verify whether it has been processed in the latest ${useCreatedNodeInsteadOfConfirmed ? 'created' : 'confirmed'} RBlock/node`)
console.log(`Usage: yarn run exec <block number>`)
process.exit()
process.exit(1)
}

const childChainBlockNumber = Number(process.argv[2]);
Expand Down
48 changes: 26 additions & 22 deletions packages/custom-gateway-bridging/scripts/exec.js
Original file line number Diff line number Diff line change
Expand Up @@ -287,17 +287,19 @@ const main = async () => {
/**
* The `complete` boolean tells us if the cross-chain message was successful
*/
childChainDepositResult.complete
? console.log(
`Deposit to the child chain complete. Status: ${
ParentToChildMessageStatus[childChainDepositResult.status]
}`
)
: console.log(
`Deposit to the child chain failed. Status ${
ParentToChildMessageStatus[childChainDepositResult.status]
}`
)
if (childChainDepositResult.complete) {
console.log(
`Deposit to the child chain complete. Status: ${
ParentToChildMessageStatus[childChainDepositResult.status]
}`
)
} else {
throw new Error(
`Deposit to the child chain failed. Status ${
ParentToChildMessageStatus[childChainDepositResult.status]
}`
)
}

/**
* Get the Bridge token balance
Expand Down Expand Up @@ -427,17 +429,19 @@ const main = async () => {
/**
* The `complete` boolean tells us if the cross-chain message was successful
*/
childChainFinalResult.complete
? console.log(
`Deposit on child chain successful. Status: ${
ParentToChildMessageStatus[childChainFinalResult.status]
}`
)
: console.log(
`Deposit on child chain failed. Status: ${
ParentToChildMessageStatus[childChainFinalResult.status]
}`
)
if (childChainFinalResult.complete) {
console.log(
`Deposit on child chain successful. Status: ${
ParentToChildMessageStatus[childChainFinalResult.status]
}`
)
} else {
throw new Error(
`Deposit on child chain failed. Status: ${
ParentToChildMessageStatus[childChainFinalResult.status]
}`
)
}
}

main()
Expand Down
3 changes: 1 addition & 2 deletions packages/delayedInbox-l2msg/scripts/normalTx.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,9 @@ const main = async () => {
if (status == true) {
console.log(`Transaction executed on the child chain!!! 🥳`)
} else {
console.log(
throw new Error(
`The transaction failed to execute on the child chain. Please verify if the gas provided was enough`
)
return
}

/**
Expand Down
3 changes: 1 addition & 2 deletions packages/delayedInbox-l2msg/scripts/withdrawFunds.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,9 @@ const main = async () => {
`Transaction executed on the child chain!!! 🥳 After a challenge period has passed, you can go to https://bridge.arbitrum.io/ to execute your withdrawal and receive your funds!`
)
} else {
console.log(
throw new Error(
`The transaction failed to execute on the child chain. Please verify if the gas provided was enough`
)
return
}
}

Expand Down
24 changes: 13 additions & 11 deletions packages/eth-deposit-to-different-address/scripts/exec.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,17 +90,19 @@ const main = async () => {
/**
* The `complete` boolean tells us if the cross-chain message was successful
*/
transactionResult.complete
? console.log(
`Message successfully executed on the child chain. Status: ${
EthDepositMessageStatus[await transactionResult.message.status()]
}`
)
: console.log(
`Message failed execution on the child chain . Status ${
EthDepositMessageStatus[await transactionResult.message.status()]
}`
)
if (transactionResult.complete) {
console.log(
`Message successfully executed on the child chain. Status: ${
EthDepositMessageStatus[await transactionResult.message.status()]
}`
)
} else {
throw new Error(
`Message failed execution on the child chain . Status ${
EthDepositMessageStatus[await transactionResult.message.status()]
}`
)
}

/**
* Our destination address balance should be updated now
Expand Down
Loading
Loading