Skip to content

Instantly share code, notes, and snippets.

@maricalucian
Last active January 31, 2021 22:09
Show Gist options
  • Save maricalucian/a9e9dd5a2c733e287f0daab869d928f5 to your computer and use it in GitHub Desktop.
Save maricalucian/a9e9dd5a2c733e287f0daab869d928f5 to your computer and use it in GitHub Desktop.
#!/bin/bash
cd /home/xxxx/concordium-software
sender="4AFB4H2ZLgMP21Nc16EgeYxxxxxxxxxxxxxxxxxxxx"
receiver="3Dzqktcd1ecZr2ZGK8EWhyyyyyyyyyyyyyyyyyyyyy"
pass="passsss\r\n"
#total transactions
txToSend=100
#transaction in a batch
txInBatch=10
#sleep between tx in a batch
sleepBetweenTx=1
#sleep between batches
sleepBetweenBatches=2
txSuccess=0
while [ $txSuccess -lt $txToSend ]; do
transactions=()
#determine batch size
batchSize="$(($txToSend-$txSuccess))"
if [ "$batchSize" -gt "$txInBatch" ]; then
batchSize=$txInBatch
fi
echo "Seding a batch of $batchSize txs"
x=1
: > t1.log
while [ $x -le $batchSize ]; do
echo "Sending tx $x in batch"
expect <<EOF >>t1.log
set timeout -1
spawn ./concordium-client --grpc-ip 127.0.0.01 --grpc-port 10000 transaction send-gtu --amount 0.1 --receiver "$receiver" --sender "$sender" --no-confirm --no-wait
expect "Enter password for signing key:"
send -- $pass
expect eof
EOF
x=$(($x + 1))
# transactions+=("tranzactiaaa $x")
sleep $sleepBetweenTx
done
echo "Reading tx ids from log file"
transactions=($(cat t1.log | grep "sent to the baker" | cut -d "'" -f 2))
echo "Checking tx status"
for tx in "${transactions[@]}"; do
res="$(./concordium-client transaction status $tx)"
while [ "$(echo $res | grep -c "pending")" -eq 1 ]; do
echo "Tx $tx is pending"
sleep 5
res="$(./concordium-client transaction status $tx)"
done
if [ "$(echo $res | grep -c " with status \"success"\")" -eq 1 ]; then
echo "Tx $tx success"
txSuccess=$(($txSuccess + 1))
else
echo "Tx $tx failed"
fi
done
sleep $sleepBetweenBatches
done
echo "END. Sent ${txSuccess} txs"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment