This repository has been archived by the owner on Oct 31, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: test for certificate production for empty blocks
- Loading branch information
Marko Atanasievski
committed
Dec 12, 2023
1 parent
ee2710b
commit 4b45b88
Showing
5 changed files
with
132 additions
and
3 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
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
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
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 |
---|---|---|
@@ -0,0 +1,66 @@ | ||
#!/bin/bash | ||
|
||
start_network () { | ||
echo "Starting local infra network..." | ||
docker compose up -d | ||
local ret=$? | ||
echo "Local infra network started with result: $ret" | ||
return $ret | ||
} | ||
|
||
|
||
stop_network () { | ||
echo "Stopping local infra network..." | ||
docker compose down --volumes | ||
local ret=$? | ||
echo "Local infra network stopped with result: $ret" | ||
return $ret | ||
} | ||
|
||
|
||
check_network_health () { | ||
# Check if all relevant containers are healthy | ||
# TODO: Add healcheck for sequencers, currenly only tce and polygon edge nodes are checked | ||
SERVICE_NAMES=$(docker compose config --dry-run --services | grep -e node) | ||
EXPECTED=$(docker compose ps -aq $SERVICE_NAMES | wc -l) | ||
COUNT=$(docker inspect --format "{{.State.Health.Status }}" $(docker compose ps -aq $SERVICE_NAMES) | grep "^healthy$"|wc -l) | ||
echo "Number of Healthy containers: $COUNT" | ||
if [[ $COUNT -eq $EXPECTED ]]; then | ||
echo "All expected containers healthy" | ||
return 0 | ||
else | ||
echo "Unhealthy containers" | ||
docker compose -f tools/docker-compose.yml ps -a peer boot | ||
return 1 | ||
fi | ||
} | ||
|
||
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) | ||
if [[ $COUNT -eq 0 ]]; then | ||
echo "Network is not running" | ||
return 1 | ||
else | ||
echo "Network is running" | ||
return 0 | ||
fi | ||
} | ||
|
||
|
||
if [ $1 = 'start' ]; then | ||
start_network | ||
exit $? | ||
elif [ $1 = 'stop' ]; then | ||
stop_network | ||
exit $? | ||
elif [ $1 = 'check' ]; then | ||
check_network_health | ||
exit $? | ||
elif [ $1 = 'is_running' ]; then | ||
is_network_running | ||
exit $? | ||
else | ||
echo "Invalid argument" | ||
exit 1 | ||
fi |
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 |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#!/bin/bash | ||
|
||
network_started=0 | ||
|
||
# Start network if it is not running | ||
$LOCAL_ERC20_HOME/tests/network.sh is_running | ||
is_running=$? | ||
if [ $is_running -eq 1 ]; then | ||
echo "Test network is not running, starting it now..." | ||
$LOCAL_ERC20_HOME/tests/network.sh start | ||
network_started=1 | ||
sleep 5 # Warn up network | ||
fi | ||
|
||
|
||
# Perform test | ||
echo "Executing block cert production test..." | ||
|
||
# Get last block number created on the topos polygon edge node | ||
last_block_topos=`docker compose logs topos-node-1 | grep -e topos::edge -e '"polygon.blockchain": "new block"' | \ | ||
grep -o 'number:[[:alnum:]]\{1,100\}' | awk -F ":" '{print $2}' | tail -1` | ||
echo "Topos subnet last block: $last_block_topos" | ||
|
||
# Check if certificate with this block number is produced on the topos sequencer | ||
docker compose logs topos-sequencer | grep -e 'on_subnet_runtime_proxy_event : NewCertificate' | grep -e "block_number: $last_block_topos" | ||
ret=$? | ||
if [ $ret -eq 0 ]; then | ||
echo "Certificate for block $last_block_topos produced on topos sequencer" | ||
else | ||
echo "Certificate for block $last_block_topos IS NOT produced on topos sequencer" | ||
exit 1 | ||
fi | ||
|
||
|
||
# Stop network if started for this test | ||
if [ $network_started -eq 1 ]; then | ||
echo "Shutting down network started for this test" | ||
$LOCAL_ERC20_HOME/tests/network.sh stop | ||
fi |