diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3fadd3443b..b5bb62a8bb 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -154,7 +154,7 @@ jobs: cd matic-cli/devnet/code/contracts npm run truffle exec scripts/deposit.js -- --network development $(jq -r .root.tokens.MaticToken contractAddresses.json) 100000000000000000000 cd - - bash bor/integration-tests/smoke_test.sh + timeout 20m bash bor/integration-tests/smoke_test.sh - name: Upload logs if: always() diff --git a/integration-tests/smoke_test.sh b/integration-tests/smoke_test.sh index fe623a437f..62ca370ee7 100644 --- a/integration-tests/smoke_test.sh +++ b/integration-tests/smoke_test.sh @@ -3,38 +3,42 @@ set -e balanceInit=$(docker exec bor0 bash -c "bor attach /root/.bor/data/bor.ipc -exec 'Math.round(web3.fromWei(eth.getBalance(eth.accounts[0])))'") -delay=600 +stateSyncFound="false" +checkpointFound="false" +SECONDS=0 +start_time=$SECONDS -echo "Wait ${delay} seconds for state-sync..." -sleep $delay +while true +do + + balance=$(docker exec bor0 bash -c "bor attach /root/.bor/data/bor.ipc -exec 'Math.round(web3.fromWei(eth.getBalance(eth.accounts[0])))'") + if ! [[ "$balance" =~ ^[0-9]+$ ]]; then + echo "Something is wrong! Can't find the balance of first account in bor network." + exit 1 + fi -balance=$(docker exec bor0 bash -c "bor attach /root/.bor/data/bor.ipc -exec 'Math.round(web3.fromWei(eth.getBalance(eth.accounts[0])))'") + if (( $balance > $balanceInit )); then + if [ $stateSyncFound != "true" ]; then + stateSyncTime=$(( SECONDS - start_time )) + stateSyncFound="true" + fi + fi -if ! [[ "$balance" =~ ^[0-9]+$ ]]; then - echo "Something is wrong! Can't find the balance of first account in bor network." - exit 1 -fi + checkpointID=$(curl -sL http://localhost:1317/checkpoints/latest | jq .result.id) -echo "Found matic balance on account[0]: " $balance + if [ $checkpointID != "null" ]; then + if [ $checkpointFound != "true" ]; then + checkpointTime=$(( SECONDS - start_time )) + checkpointFound="true" + fi + fi -if (( $balance <= $balanceInit )); then - echo "Balance in bor network has not increased. This indicates that something is wrong with state sync." - exit 1 -fi + if [ $stateSyncFound == "true" ] && [ $checkpointFound == "true" ]; then + break + fi -delayCheckpoint=300 - -echo "Wait ${delayCheckpoint} seconds for checkpoint..." -sleep $delayCheckpoint - -checkpointID=$(curl -sL http://localhost:1317/checkpoints/latest | jq .result.id) - -if [ $checkpointID == "null" ]; then - echo "Something is wrong! Could not find any checkpoint." - exit 1 -else - echo "Found checkpoint ID:" $checkpointID -fi - -echo "All tests have passed!" +done +echo "Both state sync and checkpoint went through. All tests have passed!" +echo "Time taken for state sync: $(printf '%02dm:%02ds\n' $(($stateSyncTime%3600/60)) $(($stateSyncTime%60)))" +echo "Time taken for checkpoint: $(printf '%02dm:%02ds\n' $(($checkpointTime%3600/60)) $(($checkpointTime%60)))"