Skip to content
This repository has been archived by the owner on Oct 31, 2024. It is now read-only.

Commit

Permalink
feat: explicit wait for network to be healthy (#53)
Browse files Browse the repository at this point in the history
Signed-off-by: Jawad Tariq <[email protected]>
  • Loading branch information
JDawg287 authored Jan 10, 2024
1 parent e5afbd1 commit e49461a
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 5 deletions.
2 changes: 1 addition & 1 deletion tests/test_cert_delivery.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ if [ $is_running -eq 1 ]; then
sleep 5 # Warm up network
fi


wait_network_healthy
# Perform test
echo "Executing test to check if certificates are broadcasted and delivered..."
# Get last certificate generated by topos sequencer and incal sequencers
Expand Down
2 changes: 1 addition & 1 deletion tests/test_cert_inclusion.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ fi
export ERC20_MESSAGING_CONTRACT_ADDRESS=$(get_erc20_contract_address)
export TOPOS_CORE_PROXY_CONTRACT_ADDRESS=$(get_topos_core_proxy_contract_address)


wait_network_healthy
# Perform test
echo "Executing certificate inclusion test..."
check_artifacts
Expand Down
2 changes: 1 addition & 1 deletion tests/test_cert_production.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ if [ $is_running -eq 1 ]; then
sleep 5 # Warm up network
fi


wait_network_healthy
# Perform test
echo "Executing block cert production test..."
# Get last block number created on the topos polygon edge node
Expand Down
2 changes: 1 addition & 1 deletion tests/test_cert_sequencer_delivery.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ fi
export ERC20_MESSAGING_CONTRACT_ADDRESS=$(get_erc20_contract_address)
export TOPOS_CORE_PROXY_CONTRACT_ADDRESS=$(get_topos_core_proxy_contract_address)


wait_network_healthy
# Make token transaction on incal network targeting topos network
# In should be delivered to target topos sequencer
echo "Executing test of certificate delivery to target topos sequencer..."
Expand Down
2 changes: 1 addition & 1 deletion tests/test_transaction_in_certificate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ if [ $is_running -eq 1 ]; then
fi
export ERC20_MESSAGING_CONTRACT_ADDRESS=$(get_erc20_contract_address)


wait_network_healthy
# Make token transaction
echo "Executing test of transaction inclusion in certificate..."
check_artifacts
Expand Down
16 changes: 16 additions & 0 deletions tests/utils.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,22 @@ check_network_health () {
fi
}

function wait_network_healthy () {
while true;
do
echo "Waiting for network to be healthy..."
healthy=$(check_network_health)
if [ $healthy -eq 0 ]; then
echo "Network is healthy"
break
else
echo "Network is not healthy yet, trying again in 5 seconds"
sleep 5
continue
fi
done
}

is_network_running() {
SERVICE_NAMES=$(docker compose config --dry-run --services | grep -e node -e sequencer)
COUNT=$(docker compose ps -aq $SERVICE_NAMES | wc -l)
Expand Down

0 comments on commit e49461a

Please sign in to comment.