Skip to content

Commit

Permalink
Some cleanup to bash test script
Browse files Browse the repository at this point in the history
  • Loading branch information
sveitser committed Aug 26, 2024
1 parent 90e12dd commit 4210058
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 22 deletions.
47 changes: 25 additions & 22 deletions espresso-tests/migration-test.bash
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
#!/usr/bin/env bash
set -euoa pipefail
set -euo pipefail
set -a # automatically export all variables
set -x # print each command before executing it, for debugging

#change to the test node directory
cd ..
# Find directory of this script
TEST_DIR="$(dirname $(readlink -f $0))"
TESTNODE_DIR="$(dirname "$TEST_DIR")"
ORBIT_ACTIONS_DIR="$TESTNODE_DIR/orbit-actions"

#Initialize a standard network not compatible with espresso
cd "$TESTNODE_DIR"

# Initialize a standard network not compatible with espresso
./test-node.bash --simple --init-force --detach

#start espresso sequencer node
# Start espresso sequencer node
docker compose up espresso-dev-node --detach

# enter the directory for the appropriate .env file
cd espresso-tests
# source the env file to export required
. .env

cd ..
# Export environment variables in .env file
. "$TEST_DIR/.env"

#export l2 owner private key
PRIVATE_KEY=$(docker compose run scripts print-private-key --account l2owner | tail -n 1 | tr -d '\r\n')
# Export l2 owner private key
PRIVATE_KEY="$(docker compose run scripts print-private-key --account l2owner | tail -n 1 | tr -d '\r\n')"

# enter orbit actions directory to run deployment scripts
cd orbit-actions
cd "$ORBIT_ACTIONS_DIR"

git submodule update --init

yarn

#echo for debug
Expand All @@ -33,9 +33,9 @@ echo "Deploying Espresso Osp"
forge script --chain $CHAIN_NAME contracts/parent-chain/contract-upgrades/DeployEspressoOsp.s.sol:DeployEspressoOsp --rpc-url $RPC_URL --broadcast -vvvv

#extract new_osp_entry from run-latest.json
NEW_OSP_ENTRY=$(cd broadcast/DeployEspressoOsp.s.sol/1337; cat run-latest.json | jq -r '.transactions[4].contractAddress')
NEW_OSP_ENTRY=$(cat broadcast/DeployEspressoOsp.s.sol/1337/run-latest.json | jq -r '.transactions[4].contractAddress')

echo $NEW_OSP_ENTRY
echo "Deployed new OspEntry at $NEW_OSP_ENTRY"

#echo for debug
echo "Deploying Espresso Osp migration action"
Expand All @@ -44,27 +44,30 @@ echo "Deploying Espresso Osp migration action"
forge script --chain $CHAIN_NAME contracts/parent-chain/contract-upgrades/DeployEspressoOspMigrationAction.s.sol --rpc-url $RPC_URL --broadcast -vvvv

#capture new OSP address
OSP_MIGRATION_ACTION=$(cd broadcast/DeployEspressoOspMigrationAction.s.sol/1337; cat run-latest.json | jq -r '.transactions[0].contractAddress')
OSP_MIGRATION_ACTION=$(cat broadcast/DeployEspressoOspMigrationAction.s.sol/1337/run-latest.json | jq -r '.transactions[0].contractAddress')

echo $OSP_MIGRATION_ACTION
echo "Deployed new OspMigrationAction at $OSP_MIGRATION_ACTION"

# use cast to call the upgradeExecutor to execute the l1 upgrade actions.

cast send $UPGRADE_EXECUTOR "execute(address, bytes)" $OSP_MIGRATION_ACTION $(cast calldata "perform()") --rpc-url $RPC_URL --private-key $PRIVATE_KEY

echo "Executed OspMigrationAction via UpgradeExecutor"

#shutdown nitro node
docker stop nitro-testnode-sequencer-1

#start nitro node in new docker container with espresso image (create a new script to do this from pieces of test-node.bash)
cd ..; ./espresso-tests/create-espresso-integrated-nitro-node.bash
cd $TESTNODE_DIR
./espresso-tests/create-espresso-integrated-nitro-node.bash

#echo for debug
echo "Deploying ArbOS action"

#forge script to deploy the Espresso ArbOS upgrade acdtion.
forge script --chain $L2_CHAIN_NAME contracts/child-chain/arbos-upgrade/DeployArbOSUpgradeAction.s.sol:DeployArbOSUpgradeAction --rpc-url $L2_RPC_URL --broadcast -vvvv

ARBOS_UPGRADE_ACTION=$(cd broadcast/DeployEspressoOspMigrationAction.s.sol/412346; cat run-latest.json | jq -r '.transactions[0].contractAddress')
ARBOS_UPGRADE_ACTION=$(cat broadcast/DeployEspressoOspMigrationAction.s.sol/412346/run-latest.json | jq -r '.transactions[0].contractAddress')



Expand Down
1 change: 1 addition & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
devShells = forEachSupportedSystem ({ pkgs }: {
default = pkgs.mkShell {
packages = with pkgs; [
bashInteractive
nodejs
yarn
openssl # used by test-node.bash
Expand Down

0 comments on commit 4210058

Please sign in to comment.