Skip to content

Commit

Permalink
fix: look for certificates from both networks
Browse files Browse the repository at this point in the history
  • Loading branch information
atanmarko committed Dec 15, 2023
1 parent 7cc6888 commit 6ebfaf2
Showing 1 changed file with 22 additions and 17 deletions.
39 changes: 22 additions & 17 deletions tests/test_certificates_broadcasted.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ source $LOCAL_ERC20_HOME/tests/utils.sh


function get_last_sequncer_generated_certificate () {
local last_certificate=`docker compose logs topos-sequencer | grep -e 'Submitting new certificate to the TCE network: ' | awk -F': ' '{print $3}' | tail -1` > /dev/null
local last_certificate=`docker compose logs $1 | grep -e 'Submitting new certificate to the TCE network: ' | awk -F': ' '{print $3}' | tail -1` > /dev/null
echo $last_certificate
}

Expand All @@ -29,34 +29,39 @@ fi


# Perform test
echo "Executing test to check if certificates are broadcasted..."
# Get last certificate generated by topos sequencer
test_certificate=$(get_last_sequncer_generated_certificate topos-sequencer)
echo "Topos certificate: $test_certificate"
echo "Executing test to check if certificates are broadcasted and delivered..."
# Get last certificate generated by topos sequencer and incal sequencers
topos_certificate=$(get_last_sequncer_generated_certificate topos-sequencer)
incal_certificate=$(get_last_sequncer_generated_certificate incal-sequencer)
echo "Topos certificate: $topos_certificate, incal certificate $incal_certificate"

# Get TCE endpoints
TCE_NODES=$(docker compose config --services | grep -e topos-node)
TCE_NODES_NUMBER=$(echo $TCE_NODES | wc -w)
NUMBER_OF_DELIVERIES=$(echo $TCE_NODES | wc -w)
NUMBER_OF_DELIVERIES=$(($NUMBER_OF_DELIVERIES*2)) # Each node receives 2 certificates (one topos, one incal certificate)

for i in {1..10};
do
counter=0
for node in $TCE_NODES
do
echo "Checking if certificate $test_certificate is delivered to $node"
delivered=$(check_certificate_delivered $node $test_certificate)
if [ $delivered -eq 0 ]; then
echo "Certificate $test_certificate delivered to $node"
counter=$((counter+1))
else
echo "Certificate $test_certificate IS NOT delivered to $node"
fi
for test_certificate in $topos_certificate $incal_certificate
do
echo "Checking if certificate $test_certificate is delivered to $node"
delivered=$(check_certificate_delivered $node $test_certificate)
if [ $delivered -eq 0 ]; then
echo "Certificate $test_certificate delivered to $node"
counter=$((counter+1))
else
echo "Certificate $test_certificate IS NOT delivered to $node"
fi
done
done
if [ $counter -eq $TCE_NODES_NUMBER ]; then
echo "Certificate $test_certificate delivered to all TCE nodes"
if [ $counter -eq $NUMBER_OF_DELIVERIES ]; then
echo "Certificates $topos_certificate and $incal_certificate delivered to all TCE nodes"
break
else
echo "Certificate $test_certificate IS NOT delivered to all TCE nodes"
echo "Certificate $topos_certificate and $incal_certificate ARE NOT delivered to all TCE nodes"
if [[ "$i" != '10' ]]; then
echo "Trying again in 5 seconds for $(($i+1)) time"
sleep 5
Expand Down

0 comments on commit 6ebfaf2

Please sign in to comment.