accept multiple expected outputs

This commit is contained in:
Rob Walker 2018-08-16 14:33:14 -07:00
parent 79d24ee227
commit 2b48daaeba
1 changed files with 21 additions and 8 deletions

View File

@ -18,13 +18,26 @@ fi
garbage_address=vS3ngn1TfQmpsW1Z4NkLuqNAQFF3dYQw8UZ6TCx9bmq
check_balance_output() {
declare expected_output="$1"
exec 42>&1
output=$($wallet balance | tee >(cat - >&42))
if [[ ! "$output" =~ $expected_output ]]; then
echo "Balance is incorrect. Expected: $expected_output"
exit 1
fi
# TODO go back to a single expected_output once snaps and wallet
# are in sync
#
# declare expected_output="$1"
# exec 42>&1
# output=$($wallet balance | tee >(cat - >&42))
# if [[ ! "$output" =~ $expected_output ]]; then
# echo "Balance is incorrect. Expected: $expected_output"
# exit 1
# fi
exec 42>&1
output=$($wallet balance | tee >(cat - >&42))
for expected_output in "$@"; do
if [[ "$output" =~ $expected_output ]]; then
return 0
fi
done
echo "Balance is incorrect. Expected: $expected_output"
exit 1
}
pay_and_confirm() {
@ -35,7 +48,7 @@ pay_and_confirm() {
$wallet reset
$wallet address
check_balance_output "No account found"
check_balance_output "No account found" "Your balance is: 0"
$wallet airdrop --tokens 60
check_balance_output "Your balance is: 60"
$wallet airdrop --tokens 40