-
Notifications
You must be signed in to change notification settings - Fork 4.4k
/
wallet-sanity.sh
executable file
·47 lines (39 loc) · 1.17 KB
/
wallet-sanity.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/bin/bash -e
#
# Wallet sanity test
#
cd "$(dirname "$0")"/..
# shellcheck source=multinode-demo/common.sh
source multinode-demo/common.sh
if [[ -z $1 ]]; then # no network argument, use default
entrypoint=()
else
entrypoint=(-n "$1")
fi
# Tokens transferred to this address are lost forever...
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
}
pay_and_confirm() {
exec 42>&1
signature=$($solana_wallet "${entrypoint[@]}" pay "$@" | tee >(cat - >&42))
$solana_wallet "${entrypoint[@]}" confirm "$signature"
}
$solana_keygen
$solana_wallet "${entrypoint[@]}" address
check_balance_output "No account found" "Your balance is: 0"
$solana_wallet "${entrypoint[@]}" airdrop 60
check_balance_output "Your balance is: 60"
$solana_wallet "${entrypoint[@]}" airdrop 40
check_balance_output "Your balance is: 100"
pay_and_confirm $garbage_address 99
check_balance_output "Your balance is: 1"
echo PASS
exit 0