diff --git a/tests/test_cert_inclusion.sh b/tests/test_cert_inclusion.sh index 360a01b..804cff4 100755 --- a/tests/test_cert_inclusion.sh +++ b/tests/test_cert_inclusion.sh @@ -41,7 +41,17 @@ echo "Executing certificate inclusion test..." check_artifacts incal_subnet_id=$(get_incal_subnet_id) receipts_root=$(send_token_with_retry 3 $incal_subnet_id $TOPOS_HOST_PORT) +receipts_root_valid=$? echo "Receipts root hash: $receipts_root" +if [ $receipts_root_valid -eq 1 ]; then + echo "Transaction send token failed" + if [ $network_started -eq 1 ]; then + echo "Shutting down network started for this test" + stop_network + fi + exit 1 +fi + is_certificate_present=$(check_certificate_inclusion_with_retry 3 $receipts_root) if [ $is_certificate_present -eq 0 ]; then echo "Certificate is present" diff --git a/tests/test_cert_sequencer_delivery.sh b/tests/test_cert_sequencer_delivery.sh new file mode 100755 index 0000000..be58e6c --- /dev/null +++ b/tests/test_cert_sequencer_delivery.sh @@ -0,0 +1,76 @@ +#!/bin/bash +set -e + +source $LOCAL_ERC20_HOME/tests/utils.sh + + +function receipts_root_in_delivered_certificate() +{ + echo $(docker logs topos-sequencer 2>&1 | grep -e "Received certificate from TCE " | \ + awk -F 'receipts_root_hash: "' '{print $2}' | awk -F '\",' '{print $1}' | tail -1) +} + + +network_started=0 + +# Start network if it is not running +is_running=$(is_network_running) +if [ $is_running -eq 1 ]; then + echo "Test network is not running, starting it now..." + start_network + network_started=1 + sleep 5 # Warm up network +fi +export ERC20_MESSAGING_CONTRACT_ADDRESS=$(get_erc20_contract_address) +export TOPOS_CORE_PROXY_CONTRACT_ADDRESS=$(get_topos_core_proxy_contract_address) + + +# 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..." +check_artifacts +topos_subnet_id=$(get_topos_subnet_id) +receipts_root_hash=$(send_token_with_retry 3 $topos_subnet_id $INCAL_HOST_PORT) +transaction_valid=$? +echo "Transaction send token result: $transaction_valid, receipts root hash: $receipts_root_hash" +if [ $transaction_valid -eq 1 ]; then + echo "Transaction send token failed" + if [ $network_started -eq 1 ]; then + echo "Shutting down network started for this test" + stop_network + fi + exit 1 +fi + + +# Check if transaction is delivered to target topos sequncer +# Wait multiple times to give time to target sequencer to catch up +# Check receipts root in delivered certificate +for i in {1..10}; +do + delivered_receipts_root_hash=$(receipts_root_in_delivered_certificate) + echo "Receipts root hash in delivered certificate: $delivered_receipts_root_hash" + if [ "$delivered_receipts_root_hash" == "$receipts_root_hash" ]; then + echo "Transaction with correct receipt root hash is delivered to target sequencer" + break + else + echo "Transaction is not delivered to target sequencer" + if [[ "$i" != '10' ]]; then + echo "Trying again in 5 seconds for $(($i+1)) time" + sleep 5 + continue + fi + if [ $network_started -eq 1 ]; then + echo "Test failed, shutting down network started for this test" + stop_network + fi + exit 1 + fi +done + + +# Stop network if started for this test +if [ $network_started -eq 1 ]; then + echo "Shutting down network started for this test" + stop_network +fi diff --git a/tests/test_transaction_in_certificate.sh b/tests/test_transaction_in_certificate.sh index f42e271..94069f1 100755 --- a/tests/test_transaction_in_certificate.sh +++ b/tests/test_transaction_in_certificate.sh @@ -33,7 +33,7 @@ tx_hash=$(send_token_with_retry 3 $topos_subnet_id $INCAL_HOST_PORT "txhash") transaction_valid=$? echo "Transaction send token result: $transaction_valid, tx hash: $tx_hash" if [ $transaction_valid -eq 1 ]; then - echo "Transaction send token failed, shutting down network started for this test" + echo "Transaction send token failed" if [ $network_started -eq 1 ]; then echo "Shutting down network started for this test" stop_network