diff --git a/.circleci/config.yml b/.circleci/config.yml index 9bc4c848ab36e..3f28d15e2b4cd 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -719,6 +719,9 @@ jobs: - run: name: Test the stack command: make devnet-test + - run: + name: Run Celo e2e tests + command: op-e2e/celo/run_all_tests.sh - run: name: Dump op-node logs command: | diff --git a/op-e2e/celo/run_all_tests.sh b/op-e2e/celo/run_all_tests.sh new file mode 100755 index 0000000000000..876f3dddb40e7 --- /dev/null +++ b/op-e2e/celo/run_all_tests.sh @@ -0,0 +1,54 @@ +#!/bin/bash +set -eo pipefail + +SCRIPT_DIR=$(readlink -f "$(dirname "$0")") +source "$SCRIPT_DIR/shared.sh" + +## Start geth +cd "$SCRIPT_DIR/../.." || exit 1 +trap 'cd "$SCRIPT_DIR/../.." && make devnet-down' EXIT # kill bg job at exit +make devnet-up + +# Wait for geth to be ready +for _ in {1..10} +do + if cast block &> /dev/null + then + break + fi + sleep 0.2 +done + +## Run tests +echo Geth ready, start tests +failures=0 +tests=0 +cd "$SCRIPT_DIR" || exit 1 +for f in test_* +do + echo -e "\nRun $f" + if "./$f" + then + tput setaf 2 || true + echo "PASS $f" + else + tput setaf 1 || true + echo "FAIL $f ❌" + ((failures++)) || true + fi + tput init || true + ((tests++)) || true +done + +## Final summary +echo +if [[ $failures -eq 0 ]] +then + tput setaf 2 || true + echo All tests succeeded! +else + tput setaf 1 || true + echo $failures/$tests failed. +fi +tput init || true +exit $failures diff --git a/op-e2e/celo/shared.sh b/op-e2e/celo/shared.sh new file mode 100644 index 0000000000000..913d77a5c79cc --- /dev/null +++ b/op-e2e/celo/shared.sh @@ -0,0 +1,9 @@ +#!/bin/bash +#shellcheck disable=SC2034 # unused vars make sense in a shared file + +export ETH_RPC_URL=http://127.0.0.1:9545 + +ACC_PRIVKEY=ac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80 +ACC_ADDR=$(cast wallet address $ACC_PRIVKEY) +REGISTRY_ADDR=0x000000000000000000000000000000000000ce10 +TOKEN_ADDR=0x471ece3750da237f93b8e339c536989b8978a438 diff --git a/op-e2e/celo/test_token_duality.sh b/op-e2e/celo/test_token_duality.sh new file mode 100755 index 0000000000000..abb8fd9e78211 --- /dev/null +++ b/op-e2e/celo/test_token_duality.sh @@ -0,0 +1,12 @@ +#!/bin/bash +#shellcheck disable=SC2086 +set -eo pipefail + +source shared.sh + +# Send token and check balance +balance_before=$(cast balance 0x000000000000000000000000000000000000dEaD) +cast send --private-key $ACC_PRIVKEY $TOKEN_ADDR 'function transfer(address to, uint256 value) external returns (bool)' 0x000000000000000000000000000000000000dEaD 100 +balance_after=$(cast balance 0x000000000000000000000000000000000000dEaD) +echo "Balance change: $balance_before -> $balance_after" +[[ $((balance_before + 100)) -eq $balance_after ]] || (echo "Balance did not change as expected"; exit 1)