diff --git a/scripts/run_simulation_2_nodes.sh b/scripts/run_simulation_2_nodes.sh index a4104d99348b57655f895aeb9a0d73f52f399d4e..27e8dcc6b63204836eef7e243425766341f25327 100755 --- a/scripts/run_simulation_2_nodes.sh +++ b/scripts/run_simulation_2_nodes.sh @@ -7,9 +7,27 @@ export MNEMONIC='before exclude interest push zone jealous boat ice chimney juic export RPC_URL=http://127.0.0.1:8545; export CHAIN_ID=636363; +# Check if RPC node is available before starting the simulation +MAX_ATTEMPTS=5 +DELAY_BETWEEN_ATTEMPS=3 +attempt=1 + +while true; do + # test=$(curl --fail --max-time 3 --header 'Content-Type: application/json' --data '{"jsonrpc":"2.0","method":"eth_blockNumber","params":[],"id":83 }' --location $RPC_URL | grep '"result":"0x0"') + response=$(curl -s -o /dev/null --header 'Content-Type: application/json' --data '{"jsonrpc":"2.0","method":"eth_blockNumber","params":[],"id":83 }' -w "%{http_code}" $RPC_URL) + if [ "$response" == "200" ]; then + break + fi + + echo "RPC node not ready, let's wait $DELAY_BETWEEN_ATTEMPS seconds" + sleep "$DELAY_BETWEEN_ATTEMPS" + + attempt=$((attempt + 1)) + if [ "$attempt" -gt "$MAX_ATTEMPTS" ]; then + exit 1 + fi +done -# ./target/release/testnet-injector simulate-bx-from-csv ../movement-data/public-transport/MF_user_mobility_june-to-august-2023_mulhouse_dataset/anonymized_june-to-august-2023_mulhouse_dataset.csv $TOTAL_SIMULATION_TIME & -# Send BX ./target/release/testnet-injector simulate-bx-from-csv ./data/anonymized_june-to-november-2023_france_dataset.csv $TOTAL_SIMULATION_TIME & echo "TOTAL_SIMULATION_TIME = $TOTAL_SIMULATION_TIME and block time = $BLOCK_TIME"