Skip to content

Commit

Permalink
tests: adding waiting mecanism to wait for the server to up instead o…
Browse files Browse the repository at this point in the history
…f using a simple sleep
  • Loading branch information
amin authored and Oumaimafisaoui committed Oct 18, 2024
1 parent 322a17a commit 9752cf4
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion tests/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,15 @@ elif test -f "/app/web3/${EXERCISE}".test.js; then
cp "/app/web3/${EXERCISE}.test.js" /jail/test
# Launch a local node
xx hardhat node >/dev/null &
sleep 0.2 # Short wait for the node to be ready but students should check.
echo "Waiting for Hardhat server to start..."

# Loop until the server responds
until nc -z localhost 8545; do
echo "Server is not up yet. Retrying in a seconds..."
sleep 1
done

echo "Hardhat server is up!"
# Launch the tests
xx hardhat test "/jail/test/${EXERCISE}.test.js"
else
Expand Down

0 comments on commit 9752cf4

Please sign in to comment.