11#! /usr/bin/env bash
22# This is a utility function for creating assertions at the end of thie test.
33
4- fail () {
5- echo " $* " 1>&2 ; exit 1;
6- }
7-
84set -euo pipefail
9- set -a # automatically export all variables
10- set -x # print each command before executing it, for debugging
115
126# CI is "true" in the CI
137CI=" ${CI:- false} "
148
15- # Output debug information on CI
9+ # Output debug information on CI or when DEBUG is set
1610DEBUG=" ${DEBUG:- false} "
1711if [ " $CI " = " true" ]; then
18- set -x
1912 DEBUG=true
2013fi
2114
22- # Show the command we are running, then run it. Due to piping this spawns a
23- # subshell so does not work for command like `cd` or `source`.
24- function run {
25- echo -e " \033[34m>>> $* \033[0m"
26- " $@ " 2>&1 | fmt
27- }
28-
29- function cd {
30- emph " cd $* "
31- builtin cd " $@ "
32- }
33-
34- function emph {
35- echo -e " \033[34m>>> $* \033[0m\n"
36- }
15+ # Simple helpers
16+ info () { echo " # $* " ; }
3717
38- # Display only the last line of piped input, continuously updating
39- function fmt {
40- # Leave output unchanged in DEBUG mode
41- if [ " $DEBUG " = " true" ]; then
42- cat
43- return
44- fi
45- # rewrite the last line to avoid noisy output
46- while read -r line; do
47- tput cr
48- tput el
49- echo " $line " | cut -c -" $( tput cols) " | tr -d ' \r\n'
50- done
51- echo
52- }
53-
54- # Show something with a comment in front, to distinguish it from console output.
55- function info {
56- echo " # $@ "
57- }
5818
5919# Remove log files on exit
6020trap " exit" INT TERM
@@ -79,33 +39,33 @@ function cleanup {
7939 fi
8040}
8141
82- # Find directory of this script, the project, and the orbit-actions submodule
83- TEST_DIR=" $( dirname $( readlink -f $0 ) ) "
42+ TEST_DIR=" $( cd " $( dirname " ${BASH_SOURCE[0]} " ) " && pwd -P) "
8443TESTNODE_LOG_FILE=$( mktemp -t nitro-test-node-logs-XXXXXXXX)
8544ESPRESSO_DEVNODE_LOG_FILE=$( mktemp -t espresso-dev-node-logs-XXXXXXXX)
8645TESTNODE_DIR=" $( dirname " $TEST_DIR " ) "
8746ENV_FILE=" $TEST_DIR /.env"
8847# Hide docker compose warnings about orphaned containers.
8948export COMPOSE_IGNORE_ORPHANS=true
9049
91- info Ensuring docker compose project is stopped
92- run docker compose down -v --remove-orphans
50+ info " Ensuring docker compose project is stopped"
51+ docker compose down -v --remove-orphans
52+
53+ # source "$TESTNODE_DI R/common.bash"
54+ cd " $( dirname " $0 " ) "
9355
9456source ./common.bash
95- info Deploying a Espresso Nitro stack with caff node also enabled
96- emph ./test-node.bash --espresso $( get_espresso_image_flag) --caff-node --validate --tokenbridge --init-force --detach
57+ info " Deploying an Espresso Nitro stack with caff node enabled"
9758if [ " $DEBUG " = " true" ]; then
98- .. /test-node.bash --espresso $( get_espresso_image_flag) --caff-node --tokenbridge --init-force --detach
59+ " $TESTNODE_DIR /test-node.bash" --espresso $( get_espresso_image_flag) --caff-node --tokenbridge --init-force --detach
9960else
10061 info " This command starts up an entire Nitro stack. It takes a long time."
10162 info " Run \` tail -f $TESTNODE_LOG_FILE \` to see logs, if necessary."
10263 echo
103- .. /test-node.bash --espresso $( get_espresso_image_flag) --validate --tokenbridge --caff-node --init-force --detach > " $TESTNODE_LOG_FILE " 2>&1
64+ " $TESTNODE_DIR /test-node.bash" --espresso $( get_espresso_image_flag) --validate --tokenbridge --caff-node --init-force --detach > " $TESTNODE_LOG_FILE " 2>&1
10465fi
10566
10667# Start espresso sequencer node for the purposes of the test e.g. not needed for the real migration.
10768info " Starting a local Espresso confirmation layer development node"
108- emph docker compose up espresso-dev-node --detach
10969if [ " $DEBUG " = " true" ]; then
11070 docker compose up espresso-dev-node --detach
11171else
11777
11878info " Load environment variables in $ENV_FILE "
11979# A similar env file should be supplied for whatever
120- emph . " $TEST_DIR /.env "
121- . " $TEST_DIR /.env "
80+ info " Sourcing $ENV_FILE "
81+ . " $ENV_FILE "
12282echo
12383info " Loaded env vars:"
12484echo
12585cat " $TEST_DIR /.env" | sed ' s/^/ /'
12686echo
12787
128- function trim-last {
129- tail -n 1 | tr -d ' \r\n'
130-
131- }
88+ trim-last () { tail -n 1 | tr -d ' \r\n' ; }
13289function get-addr {
13390 local file=" $1 "
13491 local path=" $2 "
@@ -186,7 +143,7 @@ echo "DELAY_SECONDS: $DELAY_SECONDS"
186143echo " FUTURE_SECONDS: $FUTURE_SECONDS "
187144
188145# Now we stop the sequencer
189- run docker stop nitro-testnode-sequencer-1
146+ docker stop nitro-testnode-sequencer-1 || true
190147
191148USER_L1_PRIVATE_KEY=" $( docker compose run scripts print-private-key --account funnel 2> /dev/null | trim-last) "
192149# This is a private key used for testing, save to print
222179sleep 120
223180
224181
225- has_force_inclusion_log () {
226- local container_name=" caff-node-1"
227- local search_string=" force inclusion is going to happen"
228- if docker logs " $container_name " 2>&1 | grep -q " $search_string " ; then
229- return 1
230- else
231- return 0
232- fi
233- }
182+ # has_force_inclusion_log() {
183+ # local container_name="caff-node-1"
184+ # local search_string="force inclusion is going to happen"
185+ # if docker logs "$container_name" 2>&1 | grep -q "$search_string"; then
186+ # return 1
187+ # else
188+ # return 0
189+ # fi
190+ # }
191+
234192
193+ # if has_force_inclusion_log "caff-node-1" "force inclusion is going to happen"; then
194+ # echo "It printed force inclusion is going to happen log"
195+ # docker compose down --remove-orphans
196+ # exit 0
197+ # else
198+ # echo "Caff node did not print force inclusion log"
199+ # exit 1
200+ # fi
235201
236- if has_force_inclusion_log " caff-node-1" " force inclusion is going to happen" ; then
202+ if docker logs " caff-node-1" 2>&1 | grep -q " force inclusion is going to happen" ; then
237203 echo " It printed force inclusion is going to happen log"
238204 docker compose down --remove-orphans
239205 exit 0
0 commit comments