Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
anodar committed Feb 26, 2024
1 parent 74e07df commit 7cbc226
Showing 1 changed file with 36 additions and 10 deletions.
46 changes: 36 additions & 10 deletions .github/workflows/testnode.bash
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 7cbc226

Please sign in to comment.