diff --git a/.github/workflows/testnode.bash b/.github/workflows/testnode.bash index 64fb160f..1e191417 100755 --- a/.github/workflows/testnode.bash +++ b/.github/workflows/testnode.bash @@ -1,14 +1,40 @@ -#!/usr/bin/env bash -# The script starts up the test node (with timeout 1 minute), with option to -# run l2 transactions to make sure node is working +#!/bin/bash +# The script starts up the test node and waits until the timeout (10min) or +# until send-l2 succeeds. +GITHUB_WORKSPACE=. +# Start the test node and get PID, to terminate it once send-l2 is done. +${GITHUB_WORKSPACE}/test-node.bash --init > output.log 2>&1 & +PID=$! -timeout 20m ${GITHUB_WORKSPACE}/test-node.bash --init --detach -sleep 20m -${GITHUB_WORKSPACE}/test-node.bash script send-l2 --ethamount 100 --to user_l2user --wait || exit_status=$? +sleep 5m -if [ -n "$exit_status" ] && [ $exit_status -ne 0 ] && [ $exit_status -ne 124 ]; then - echo "Testnode failed." - exit $exit_status +START=$(date +%s) +SUCCEDED=0 + +while true; do + if ${GITHUB_WORKSPACE}/test-node.bash script send-l2 --ethamount 100 --to user_l2user --wait; then + echo "Sending l2 transaction succeeded" + SUCCEDED=1 + break + fi + + # Check if the timeout (10 min) has been reached. + NOW=$(date +%s) + DIFF=$((NOW - START)) + if [ "$DIFF" -ge 600 ]; then + echo "Timed out" + break + fi + + sleep 10 +done + +# Shut down the test node and wait for it to terminate. +kill $PID +wait $PID + +if [ "$SUCCEDED" -eq 0 ]; then + exit 1 fi -echo "Testnode succeeded." +exit 0