diff --git a/multinode-demo/test/wallet-sanity.sh b/multinode-demo/test/wallet-sanity.sh new file mode 100755 index 00000000000000..4a121bd34c4376 --- /dev/null +++ b/multinode-demo/test/wallet-sanity.sh @@ -0,0 +1,31 @@ +#!/bin/bash -e +# +# Wallet sanity test +# + +here=$(dirname "$0") +cd $here/../.. + +wallet="./multinode-demo/wallet.sh $1" + +# Tokens transferred to this address are lost forever... +garbage_address=vS3ngn1TfQmpsW1Z4NkLuqNAQFF3dYQw8UZ6TCx9bmq + +check_balance() { + declare expected_balance="Your balance is: $1" + exec 42>&1 + balance=$($wallet balance | tee >(cat - >&42)) + if [[ ! "$balance" =~ "$expected_balance" ]]; then + echo "Balance is incorrect. Expected: $expected_balance" + exit 1 + fi +} + +$wallet address +check_balance 0 +$wallet airdrop --tokens 100 +check_balance 100 +$wallet pay --to $garbage_address --tokens 100 +check_balance 0 + +exit 0