diff --git a/tests/test_certificates_broadcasted.sh b/tests/test_certificates_broadcasted.sh index 2f6d27a..81971de 100755 --- a/tests/test_certificates_broadcasted.sh +++ b/tests/test_certificates_broadcasted.sh @@ -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 } @@ -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