Add balance check retries

This commit is contained in:
Tyera Eulberg 2018-11-01 11:08:50 -06:00 committed by Tyera Eulberg
parent af1283e92c
commit 102354c218
1 changed files with 14 additions and 5 deletions

View File

@ -20,11 +20,20 @@ garbage_address=vS3ngn1TfQmpsW1Z4NkLuqNAQFF3dYQw8UZ6TCx9bmq
check_balance_output() {
declare expected_output="$1"
exec 42>&1
output=$($solana_wallet "${entrypoint[@]}" balance | tee >(cat - >&42))
if [[ ! "$output" =~ $expected_output ]]; then
echo "Balance is incorrect. Expected: $expected_output"
exit 1
fi
attempts=3
while [[ $attempts -gt 0 ]]; do
output=$($solana_wallet "${entrypoint[@]}" balance | tee >(cat - >&42))
if [[ "$output" =~ $expected_output ]]; then
break
else
sleep 1
(( attempts=attempts-1 ))
if [[ $attempts -eq 0 ]]; then
echo "Balance is incorrect. Expected: $expected_output"
exit 1
fi
fi
done
}
pay_and_confirm() {