diff --git a/.github/workflows/test-all.yml b/.github/workflows/test-all.yml new file mode 100644 index 0000000..3e48eae --- /dev/null +++ b/.github/workflows/test-all.yml @@ -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 diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml deleted file mode 100644 index 6c7f97b..0000000 --- a/.pre-commit-config.yaml +++ /dev/null @@ -1,60 +0,0 @@ -exclude: | - (?x)( - ^packages/arb-avm-cpp/external/keccak/| - ^packages/arb-bridge-eth/installed_contracts/ - ) -repos: - - repo: https://github.com/psf/black - rev: stable - hooks: - - id: black - language_version: python3 - - repo: https://gitlab.com/pycqa/flake8 - rev: 3.9.0 - hooks: - - id: flake8 - - repo: git://github.com/doublify/pre-commit-clang-format - rev: master - hooks: - - id: clang-format - - repo: git://github.com/dnephin/pre-commit-golang - rev: master - hooks: - - id: go-fmt - - repo: https://github.com/pre-commit/mirrors-prettier - rev: "v2.2.1" # Use the sha or tag you want to point at - hooks: - - id: prettier - - repo: https://github.com/pre-commit/mirrors-eslint - rev: "v7.24.0" # Use the sha / tag you want to point at - hooks: - - id: eslint - args: [--fix] - types: [text] - # ignore prettier config - files: \.[jt]sx?$ - additional_dependencies: - - "eslint@7.3.1" - - "typescript@3.8.3" - - "@typescript-eslint/parser@3.4.0" - - "@typescript-eslint/eslint-plugin@3.4.0" - - eslint-config-prettier@6.11.0 - - repo: https://github.com/syntaqx/git-hooks - rev: v0.0.16 - hooks: - - id: circleci-config-validate - - repo: local - hooks: - - id: prettier-soldity - name: prettier-soldity - language: node - entry: ./node_modules/.bin/prettier --write --list-different - files: \.sol$ - additional_dependencies: - - "prettier@2.0.5" - - "prettier-plugin-solidity@^1.0.0-alpha.54" - - id: go-vet - name: Go Vet - entry: ./scripts/run-go-packages "go list ./... | grep -v 'arb-node-core/ethbridge[^/]*contracts' | xargs go vet" - language: script - files: \.go$ diff --git a/customNetwork.json b/customNetwork.json index 1a2f1df..be59f7c 100644 --- a/customNetwork.json +++ b/customNetwork.json @@ -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 + } +] diff --git a/package.json b/package.json index f516e1e..7866187 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/packages/block-verification-in-parent-chain-assertion/scripts/exec.ts b/packages/block-verification-in-parent-chain-assertion/scripts/exec.ts index f28536d..ba58282 100644 --- a/packages/block-verification-in-parent-chain-assertion/scripts/exec.ts +++ b/packages/block-verification-in-parent-chain-assertion/scripts/exec.ts @@ -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}`) @@ -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 @@ -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 `) - process.exit() + process.exit(1) } const childChainBlockNumber = Number(process.argv[2]); diff --git a/packages/custom-gateway-bridging/scripts/exec.js b/packages/custom-gateway-bridging/scripts/exec.js index 5fa6a75..9efeba6 100644 --- a/packages/custom-gateway-bridging/scripts/exec.js +++ b/packages/custom-gateway-bridging/scripts/exec.js @@ -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 @@ -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() diff --git a/packages/delayedInbox-l2msg/scripts/normalTx.js b/packages/delayedInbox-l2msg/scripts/normalTx.js index 3130ede..2664002 100644 --- a/packages/delayedInbox-l2msg/scripts/normalTx.js +++ b/packages/delayedInbox-l2msg/scripts/normalTx.js @@ -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 } /** diff --git a/packages/delayedInbox-l2msg/scripts/withdrawFunds.js b/packages/delayedInbox-l2msg/scripts/withdrawFunds.js index 366a253..ee7b527 100644 --- a/packages/delayedInbox-l2msg/scripts/withdrawFunds.js +++ b/packages/delayedInbox-l2msg/scripts/withdrawFunds.js @@ -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 } } diff --git a/packages/eth-deposit-to-different-address/scripts/exec.js b/packages/eth-deposit-to-different-address/scripts/exec.js index db210b3..ad5b93d 100644 --- a/packages/eth-deposit-to-different-address/scripts/exec.js +++ b/packages/eth-deposit-to-different-address/scripts/exec.js @@ -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 diff --git a/packages/eth-deposit/scripts/exec.js b/packages/eth-deposit/scripts/exec.js index f39d13b..0c46ca8 100644 --- a/packages/eth-deposit/scripts/exec.js +++ b/packages/eth-deposit/scripts/exec.js @@ -85,17 +85,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 wallet's balance on the child chain should be updated now diff --git a/packages/eth-withdraw/scripts/exec.js b/packages/eth-withdraw/scripts/exec.js index 2529438..69c64a8 100644 --- a/packages/eth-withdraw/scripts/exec.js +++ b/packages/eth-withdraw/scripts/exec.js @@ -41,10 +41,9 @@ const main = async () => { const initialEthBalance = await childChainWallet.getBalance() if (initialEthBalance.lt(withdrawAmount)) { - console.log( + throw new Error( `Oops - not enough balance; fund your wallet on the child chain ${childChainWallet.address} with at least 0.000001 ether (or your chain's gas token)` ) - process.exit(1) } console.log('Wallet properly funded: initiating withdrawal now') @@ -71,7 +70,7 @@ const main = async () => { const withdrawEventsData = withdrawTransactionReceipt.getChildToParentEvents() console.log('Withdrawal data:', withdrawEventsData) console.log( - `To claim funds (after dispute period), see outbox-execute repo 🫡` + `To claim funds (after dispute period), run the outbox-execute tutorial using the transaction hash ${withdrawTransactionReceipt.transactionHash} 🫡` ) } diff --git a/packages/greeter/scripts/exec.js b/packages/greeter/scripts/exec.js index 4cf1f34..010ad5d 100644 --- a/packages/greeter/scripts/exec.js +++ b/packages/greeter/scripts/exec.js @@ -205,7 +205,7 @@ const main = async () => { `Retryable ticket is executed on the child chain 🥳 ${messageResult.childTxReceipt.transactionHash}` ) } else { - console.log( + throw new Error( `Retryable ticket failed to execute on the child chain. Status: ${ParentToChildMessageStatus[status]}` ) } diff --git a/packages/outbox-execute/scripts/exec.js b/packages/outbox-execute/scripts/exec.js index 03eb137..b693598 100644 --- a/packages/outbox-execute/scripts/exec.js +++ b/packages/outbox-execute/scripts/exec.js @@ -36,17 +36,15 @@ const main = async transactionHash => { * we assume this is a transaction that triggered a child-to-parent message on the child chain (i.e., ArbSys.sendTxToL1) */ if (!transactionHash) { - console.error( + throw new Error( 'Provide a transaction hash of a transaction that sent a child-to-parent message' ) - return } if ( !transactionHash.startsWith('0x') || transactionHash.trim().length != 66 ) { - console.error(`Hmm, ${transactionHash} doesn't look like a txn hash...`) - return + throw new Error(`Hmm, ${transactionHash} doesn't look like a txn hash...`) } /** @@ -73,8 +71,7 @@ const main = async transactionHash => { (await childToParentMessage.status(childChainProvider)) == ChildToParentMessageStatus.EXECUTED ) { - console.log(`Message already executed! Nothing else to do here`) - return + throw new Error(`Message already executed! Nothing else to do here`) } /** @@ -108,7 +105,7 @@ if (process.argv.length < 3) { `Missing transaction hash of the child chain that sent a child-to-parent message` ) console.log(`Usage: yarn run outbox-exec `) - process.exit() + process.exit(1) } const transactionHash = process.argv[2] diff --git a/packages/parent-chain-confirmation-checker/scripts/exec.ts b/packages/parent-chain-confirmation-checker/scripts/exec.ts index bd63d0a..6c99c4f 100644 --- a/packages/parent-chain-confirmation-checker/scripts/exec.ts +++ b/packages/parent-chain-confirmation-checker/scripts/exec.ts @@ -52,7 +52,7 @@ const main = async () => { break default: - console.log(`Unknown action: ${args.action}`) + throw new Error(`Unknown action: ${args.action}`) } } diff --git a/packages/redeem-pending-retryable/package.json b/packages/redeem-pending-retryable/package.json index 9791fe1..9dde4df 100644 --- a/packages/redeem-pending-retryable/package.json +++ b/packages/redeem-pending-retryable/package.json @@ -4,7 +4,7 @@ "version": "1.0.0", "scripts": { "build": "hardhat compile", - "createFailedRetryable": "node scripts/exec-createFailedRetryable.js", + "createFailedRetryable": "hardhat run scripts/exec-createFailedRetryable.js", "redeemPendingRetryable": "node scripts/exec-redeem.js" }, "dependencies": { diff --git a/packages/redeem-pending-retryable/scripts/exec-redeem.js b/packages/redeem-pending-retryable/scripts/exec-redeem.js index 9a40559..2305278 100644 --- a/packages/redeem-pending-retryable/scripts/exec-redeem.js +++ b/packages/redeem-pending-retryable/scripts/exec-redeem.js @@ -38,10 +38,9 @@ const main = async parentChainTransactionHash => { !parentChainTransactionHash.startsWith('0x') || parentChainTransactionHash.trim().length != 66 ) { - console.log( + throw new Error( `Hmm, ${parentChainTransactionHash} doesn't look like a txn hash...` ) - return } /** @@ -86,7 +85,7 @@ if (process.argv.length < 3) { `Missing the transaction hash on the parent chain that created the pending retryable ticket` ) console.log(`Usage: yarn run redeemPendingRetryable 0x`) - process.exit() + process.exit(1) } const transactionHash = process.argv[2] diff --git a/packages/token-deposit/scripts/exec.js b/packages/token-deposit/scripts/exec.js index 5f0d08a..202a637 100644 --- a/packages/token-deposit/scripts/exec.js +++ b/packages/token-deposit/scripts/exec.js @@ -137,17 +137,19 @@ const main = async () => { /** * The `complete` boolean tells us if the parent-to-child message was successful */ - childTransactionReceipt.complete - ? console.log( - `Message was successfully executed on the child chain: status: ${ - ParentToChildMessageStatus[childTransactionReceipt.status] - }` - ) - : console.log( - `Message failed to be executed on the child chain: status ${ - ParentToChildMessageStatus[childTransactionReceipt.status] - }` - ) + if (childTransactionReceipt.complete) { + console.log( + `Message was successfully executed on the child chain: status: ${ + ParentToChildMessageStatus[childTransactionReceipt.status] + }` + ) + } else { + throw new Error( + `Message failed to be executed on the child chain: status ${ + ParentToChildMessageStatus[childTransactionReceipt.status] + }` + ) + } /** * Get the Bridge token balance diff --git a/packages/token-withdraw/scripts/exec.js b/packages/token-withdraw/scripts/exec.js index ff22368..e1a641b 100644 --- a/packages/token-withdraw/scripts/exec.js +++ b/packages/token-withdraw/scripts/exec.js @@ -129,17 +129,19 @@ const main = async () => { /** * The `complete` boolean tells us if the parent-to-child message was successful */ - childTransactionReceipt.complete - ? console.log( - `Message was successfully executed on the child chain: status: ${ - ParentToChildMessageStatus[childTransactionReceipt.status] - }` - ) - : console.log( - `Message failed to be executed on the child chain: status ${ - ParentToChildMessageStatus[childTransactionReceipt.status] - }` - ) + if (childTransactionReceipt.complete) { + console.log( + `Message was successfully executed on the child chain: status: ${ + ParentToChildMessageStatus[childTransactionReceipt.status] + }` + ) + } else { + throw new Error( + `Message failed to be executed on the child chain: status ${ + ParentToChildMessageStatus[childTransactionReceipt.status] + }` + ) + } console.log(`Setup complete`) /** diff --git a/tests/runAll.sh b/tests/runAll.sh new file mode 100755 index 0000000..fe1a50e --- /dev/null +++ b/tests/runAll.sh @@ -0,0 +1,102 @@ +#!/bin/bash + +# Constants +tutorialsDirectory="packages" + +# Variables +runResults=() +exitCode=0 + +# Helper function +################### +run_tutorial() { + local script_root="$1" + local script_command="$2" + local script_build="$3" + + # Move to folder + cd "$tutorialsDirectory/$script_root" + + if [ "$script_build" = "true" ] + then + # Build + yarn run build + + # Check build status + buildStatus=$? + runResults+=("[$script_root] Build status: $buildStatus") + if [ $buildStatus -gt 0 ] + then + runResults+=("[$script_root] Build ERROR - Check log for more information") + cd "../.." + return + fi + fi + + # Run tutorial + yarn run $script_command + + # Check execution status + execStatus=$? + runResults+=("[$script_root] Execution status: $execStatus") + if [ $execStatus -gt 0 ] + then + runResults+=("[$script_root] Execution ERROR - Check log for more information") + exitCode=1 + fi + + # Going to root + cd "../.." +} + +# Run all tutorials +##################### +# We start with eth-withdraw, because we want to save the transaction hash of the withdrawal +# to be used in outbox-exec. Since this script is expected to be run on the nitro-testnode +# confirm periods are much shorter and by the time we run outbox-exec, this withdrawal should +# be ready to be executed +run_tutorial "eth-withdraw" "withdrawETH" | tee output +withdrawalTransactionHash=$(cat output | tail -1 | grep -oE '0x[a-fA-F0-9]+') +rm output + +# We now run the rest of the tutorials +run_tutorial "address-table" "exec" +run_tutorial "contract-deposit" "start" +run_tutorial "custom-gateway-bridging" "exec" +run_tutorial "custom-token-bridging" "custom-token-bridging" +run_tutorial "delayedInbox-l2msg" "normalTx" +run_tutorial "delayedInbox-l2msg" "withdrawFunds" +run_tutorial "demo-dapp-election" "exec" +run_tutorial "demo-dapp-pet-shop" "exec" +run_tutorial "eth-deposit" "depositETH" +run_tutorial "eth-deposit-to-different-address" "exec" +run_tutorial "gas-estimation" "exec" +run_tutorial "greeter" "greeter" +run_tutorial "token-deposit" "token-deposit" +run_tutorial "token-withdraw" "token-withdraw" + +# These two tutorials should be run together. We get the transaction hash from the first one +# and execute the second one using that transaction hash +run_tutorial "redeem-pending-retryable" "createFailedRetryable" | tee output +retryableTransactionHash=$(cat output | tail -1 | grep -oE '0x[a-fA-F0-9]+') +rm output +run_tutorial "redeem-pending-retryable" "redeemPendingRetryable $retryableTransactionHash" + +# We finish by running parent-chain-confirmation-checker, block-verification-in-parent-chain-assertion and outbox-execute +run_tutorial "parent-chain-confirmation-checker" "checkConfirmation --txHash $withdrawalTransactionHash" +run_tutorial "parent-chain-confirmation-checker" "findSubmissionTx --txHash $withdrawalTransactionHash" +run_tutorial "block-verification-in-parent-chain-assertion" "exec 10" +run_tutorial "outbox-execute" "outbox-exec $withdrawalTransactionHash" + +# Show final results +###################### +echo "***********" +echo "* RESULTS *" +echo "***********" +IFS="" +for log in ${runResults[@]} +do + echo "$log" +done + +exit $exitCode \ No newline at end of file