diff --git a/espresso-tests/migration-test.bash b/espresso-tests/migration-test.bash index 342b7bb4..20967e22 100755 --- a/espresso-tests/migration-test.bash +++ b/espresso-tests/migration-test.bash @@ -1,8 +1,15 @@ #!/usr/bin/env bash + +fail(){ + echo "$*" 1>&2; exit -1; +} + set -euo pipefail set -a # automatically export all variables set -x # print each command before executing it, for debugging + + # Find directory of this script TEST_DIR="$(dirname $(readlink -f $0))" TESTNODE_DIR="$(dirname "$TEST_DIR")" @@ -19,8 +26,10 @@ docker compose up espresso-dev-node --detach # Export environment variables in .env file . "$TEST_DIR/.env" -# Export l2 owner private key +# Export l2 owner private key and address PRIVATE_KEY="$(docker compose run scripts print-private-key --account l2owner | tail -n 1 | tr -d '\r\n')" +OWNER_ADDRESS="$(docker compose run scripts print-address --account l2owner | tail -n 1 | tr -d '\r\n')" + cd "$ORBIT_ACTIONS_DIR" @@ -67,26 +76,46 @@ while ! curl -s $L2_RPC_URL > /dev/null; do sleep 5 done - echo "Deploying ArbOS action" -<<<<<<< HEAD + +#forge script to deploy the Espresso ArbOS upgrade acdtion. cd $ORBIT_ACTIONS_DIR 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=$(cat broadcast/DeployArbOSUpgradeAction.s.sol/412346/run-latest.json | jq -r '.transactions[0].contractAddress') echo "Deployed ArbOSUpgradeAction at $ARBOS_UPGRADE_ACTION" -======= -#sleep for a bit to allow the espresso sequencer to start before we attempt to talk to the RPC endpoint. -sleep 20s -cd orbit-actions +cast send $UPGRADE_EXECUTOR "execute(address, bytes)" $ARBOS_UPGRADE_ACTION $(cast calldata "perform()") --rpc-url $L2_RPC_URL --private-key $PRIVATE_KEY -#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 +#check the upgrade happened -ARBOS_UPGRADE_ACTION=$(cd broadcast/DeployEspressoOspMigrationAction.s.sol/412346; cat run-latest.json | jq -r '.transactions[0].contractAddress') +ARBOS_VERSION_AFTER_UPGRADE=$(cast call "0x0000000000000000000000000000000000000064" "arbOSVersion()" --rpc-url $L2_RPC_URL --private-key $PRIVATE_KEY) -cast send $UPGRADE_EXECUTOR "execute(address, bytes)" 0x4e5b65FB12d4165E22f5861D97A33BA45c006114 $(cast calldata "perform()") --rpc-yrl $L2_RPC_URL --broadcast -vvvv ->>>>>>> 76f7f47 (add sleep and cast call to test bash script.) +#The arbsys precompile is returning 55 for the arbos version which indicates that the value internally is 0 +if [ $ARBOS_VERSION_AFTER_UPGRADE != "0x0000000000000000000000000000000000000000000000000000000000000090" ]; then + fail "ArbOS version not updated: Expected 35, Actual $ARBOS_VERSION_AFTER_UPGRADE" +fi -#check the upgrade happened +#test for new OSP address +OSP_ADDR=$(cast call $CHALLENGE_MANAGER_ADDRESS $(cast calldata "osp()") --rpc-url $RPC_URL --private-key $PRIVATE_KEY) + +if [ $NEW_OSP_ENTRY != $OSP_ADDR ]; then + fail "OSP has not been set to newly deployed OSP: \n Newly deployed: $NEW_OSP_ENTRY \n Currently set OSP: $OSP_ADDR" +fi +# check for balance update and transactions actually being sequenced +ORIGINAL_OWNER_BALANCE=$(cast balance $OWNER_ADDRESS -e) + +docker compose run scripts send-l2 --ethamount 100 --to l2owner --wait + +NEW_OWNER_BALANCE=$(cast balance $OWNER_ADDRESS -e) + +if [ $(($ORIGINAL_OWNER_BALANCE + 100)) != $NEW_OWNER_BALANCE ]; then + fail "Owner balance should have increased: Expected amount: $(($ORIGINAL_OWNER_BALANCE + 100)), Actual ammount: $NEW_OWNER_BALANCE" +fi + +docker compose run scripts send-l2 --ethamount 100 --to l2owner --wait + +FINAL_OWNER_BALANCE=$(cast balance $OWNER_ADDRESS -e) +if [ $(($NEW_OWNER_BALANCE + 100)) != $FINAL_OWNER_BALANCE ]; then + fail "Owner balance should have increased: Expected amount: $(($ORIGINAL_OWNER_BALANCE + 100)), Actual ammount: $NEW_OWNER_BALANCE" +fi \ No newline at end of file