-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Poll until timeout or until send-l2 succeeds
- Loading branch information
Showing
1 changed file
with
36 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |