Skip to content

Commit ad11bdf

Browse files
committed
feat(e2e): fetch deployment data from testnodes
Signed-off-by: Tomás Migone <[email protected]>
1 parent a3fa719 commit ad11bdf

File tree

5 files changed

+33
-11
lines changed

5 files changed

+33
-11
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,5 @@ coverage.json
2222

2323
# Local test files
2424
addresses-local.json
25-
arbitrum-addresses-local.json
25+
arbitrum-addresses-local.json
26+
localNetwork.json

e2e/scenarios/fixtures/bridge.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export interface BridgeFixture {
1717

1818
export const getBridgeFixture = (signers: SignerWithAddress[]): BridgeFixture => {
1919
return {
20-
deploymentFile: '../arbitrum-sdk/localNetwork.json',
20+
deploymentFile: 'localNetwork.json',
2121
funder: signers[0],
2222
accountsToFund: [
2323
{

scripts/e2e

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ source $(pwd)/scripts/evm
77
# Allow overriding config
88
ADDRESS_BOOK=${ADDRESS_BOOK:-"addresses-local.json"}
99
ARBITRUM_ADDRESS_BOOK=${ARBITRUM_ADDRESS_BOOK:-"arbitrum-addresses-local.json"}
10-
ARBITRUM_DEPLOYMENT_FILE=${ARBITRUM_DEPLOYMENT_FILE:-"$(pwd)/../arbitrum-sdk/localNetwork.json"}
10+
ARBITRUM_DEPLOYMENT_FILE=${ARBITRUM_DEPLOYMENT_FILE:-"localNetwork.json"}
1111
L1_NETWORK=${L1_NETWORK:-"localhost"}
1212
L2_NETWORK=${L2_NETWORK} # By default run only L1 tests on localhost network
1313
L1_GRAPH_CONFIG=${L1_GRAPH_CONFIG:-"config/graph.localhost.yml"}
@@ -139,7 +139,7 @@ function test_e2e_scenarios_bridge () {
139139
yarn build
140140

141141
# Start evm
142-
if [[ "$NETWORK" == "localhost" ]]; then
142+
if [[ "$L1_NETWORK" == "localhost" ]]; then
143143
evm_kill
144144
evm_start
145145
fi
@@ -171,7 +171,7 @@ fi
171171

172172
# Configure bridge
173173
if [[ -n "$L2_NETWORK" ]]; then
174-
configure_bridge "$L1_NETWORK" "$L1_GRAPH_CONFIG" "$L2_NETWORK" "$L2_GRAPH_CONFIG" "$ADDRESS_BOOK" "$ARBITRUM_ADDRESS_BOOK"
174+
configure_bridge "$L1_NETWORK" "$L1_GRAPH_CONFIG" "$L2_NETWORK" "$L2_GRAPH_CONFIG" "$ADDRESS_BOOK" "$ARBITRUM_ADDRESS_BOOK" "$ARBITRUM_DEPLOYMENT_FILE"
175175
fi
176176

177177

@@ -191,7 +191,7 @@ fi
191191

192192
## Cleanup
193193
# Exit error mode so the evm instance always gets killed
194-
if [[ "$NETWORK" == "localhost" ]]; then
194+
if [[ "$L1_NETWORK" == "localhost" ]]; then
195195
set +e
196196
result=0
197197

tasks/bridge/to-l2.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import { cliOpts } from '../../cli/defaults'
33
import { sendToL2 } from '../../cli/commands/bridge/to-l2'
44
import { loadEnv } from '../../cli/env'
55
import { TASK_NITRO_SETUP_SDK } from '../deployment/nitro'
6-
import { BigNumber } from 'ethers'
76

87
export const TASK_BRIDGE_TO_L2 = 'bridge:send-to-l2'
98

@@ -27,7 +26,7 @@ task(TASK_BRIDGE_TO_L2, 'Bridge GRT tokens from L1 to L2')
2726
console.log('> Sending GRT to L2')
2827
const graph = hre.graph(taskArgs)
2928

30-
// Add nitro test node networks to sdk
29+
// If local, add nitro test node networks to sdk
3130
if (taskArgs.deploymentFile) {
3231
console.log('> Adding nitro test node network to sdk')
3332
await hre.run(TASK_NITRO_SETUP_SDK, { deploymentFile: taskArgs.deploymentFile })

tasks/deployment/nitro.ts

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,12 @@ import { subtask, task } from 'hardhat/config'
33
import { cliOpts } from '../../cli/defaults'
44
import { addCustomNetwork } from '@arbitrum/sdk/dist/lib/dataEntities/networks'
55
import fs from 'fs'
6+
import { execSync } from 'child_process'
67

78
export const TASK_NITRO_FUND_ACCOUNTS = 'nitro:fund-accounts'
89
export const TASK_NITRO_SETUP_SDK = 'nitro:sdk-setup'
910
export const TASK_NITRO_SETUP_ADDRESS_BOOK = 'nitro:address-book-setup'
11+
export const TASK_NITRO_FETCH_DEPLOYMENT_FILE = 'nitro:fetch-deployment-file'
1012

1113
task(TASK_NITRO_FUND_ACCOUNTS, 'Funds protocol accounts on Arbitrum Nitro testnodes')
1214
.addOptionalParam('graphConfig', cliOpts.graphConfig.description)
@@ -77,7 +79,7 @@ task(TASK_NITRO_FUND_ACCOUNTS, 'Funds protocol accounts on Arbitrum Nitro testno
7779
// Arbitrum SDK does not support Nitro testnodes out of the box
7880
// This adds the testnodes to the SDK configuration
7981
subtask(TASK_NITRO_SETUP_SDK, 'Adds nitro testnodes to SDK config')
80-
.addParam('deploymentFile', 'The testnode deployment file to use')
82+
.addParam('deploymentFile', 'The testnode deployment file to use', 'localNetwork.json')
8183
.setAction(async (taskArgs) => {
8284
if (!fs.existsSync(taskArgs.deploymentFile)) {
8385
throw new Error(`Deployment file not found: ${taskArgs.deploymentFile}`)
@@ -89,13 +91,33 @@ subtask(TASK_NITRO_SETUP_SDK, 'Adds nitro testnodes to SDK config')
8991
})
9092
})
9193

94+
subtask(TASK_NITRO_FETCH_DEPLOYMENT_FILE, 'Fetches nitro deployment file from a local testnode')
95+
.addParam(
96+
'deploymentFile',
97+
'Path to the file where to deployment file will be saved',
98+
'localNetwork.json',
99+
)
100+
.setAction(async (taskArgs) => {
101+
console.log(`Attempting to fetch deployment file from testnode...`)
102+
103+
const command =
104+
'docker exec $(docker ps -qf "name=sequencer") cat /deployment/localNetwork.json > localNetwork.json'
105+
const stdOut = execSync(command)
106+
console.log(stdOut.toString())
107+
108+
if (!fs.existsSync(taskArgs.deploymentFile)) {
109+
throw new Error(`Unable to fetch deployment file: ${taskArgs.deploymentFile}`)
110+
}
111+
console.log(`Deployment file saved to ${taskArgs.deploymentFile}`)
112+
})
113+
92114
// Read arbitrum contract addresses from deployment file and write them to the address book
93115
task(TASK_NITRO_SETUP_ADDRESS_BOOK, 'Write arbitrum addresses to address book')
94116
.addParam('deploymentFile', 'The testnode deployment file to use')
95117
.addParam('arbitrumAddressBook', 'Arbitrum address book file')
96-
.setAction(async (taskArgs) => {
118+
.setAction(async (taskArgs, hre) => {
97119
if (!fs.existsSync(taskArgs.deploymentFile)) {
98-
throw new Error(`Deployment file not found: ${taskArgs.deploymentFile}`)
120+
await hre.run(TASK_NITRO_FETCH_DEPLOYMENT_FILE, taskArgs)
99121
}
100122
const deployment = JSON.parse(fs.readFileSync(taskArgs.deploymentFile, 'utf-8'))
101123

0 commit comments

Comments
 (0)