2018-11-11 08:19:04 -08:00
|
|
|
#!/usr/bin/env bash
|
2018-07-02 14:14:34 -07:00
|
|
|
#
|
2019-09-18 10:03:54 -07:00
|
|
|
# solana-cli integration sanity test
|
2018-07-02 14:14:34 -07:00
|
|
|
#
|
2018-11-11 09:25:59 -08:00
|
|
|
set -e
|
2018-07-02 14:14:34 -07:00
|
|
|
|
2018-09-07 09:46:21 -07:00
|
|
|
cd "$(dirname "$0")"/..
|
2018-07-02 14:14:34 -07:00
|
|
|
|
2018-09-16 13:53:24 -07:00
|
|
|
# shellcheck source=multinode-demo/common.sh
|
|
|
|
source multinode-demo/common.sh
|
|
|
|
|
2019-05-06 07:38:26 -07:00
|
|
|
if [[ -z $1 ]]; then # no network argument, use localhost by default
|
2019-09-18 10:03:54 -07:00
|
|
|
args=(--url http://127.0.0.1:8899)
|
2018-07-13 22:10:39 -07:00
|
|
|
else
|
2019-09-18 10:03:54 -07:00
|
|
|
args=("$@")
|
2018-07-13 22:10:39 -07:00
|
|
|
fi
|
2018-07-02 14:14:34 -07:00
|
|
|
|
2020-05-19 20:07:30 -07:00
|
|
|
args+=(--keypair "$SOLANA_CONFIG_DIR"/faucet.json)
|
2018-11-10 17:07:31 -08:00
|
|
|
|
2019-01-16 16:00:12 -08:00
|
|
|
node_readiness=false
|
2018-10-24 21:56:46 -07:00
|
|
|
timeout=60
|
2018-10-25 10:20:17 -07:00
|
|
|
while [[ $timeout -gt 0 ]]; do
|
2020-09-10 12:05:57 -07:00
|
|
|
set +e
|
2021-04-13 17:50:59 -07:00
|
|
|
output=$($solana_cli "${args[@]}" transaction-count --commitment finalized)
|
2020-09-10 12:05:57 -07:00
|
|
|
rc=$?
|
|
|
|
set -e
|
|
|
|
if [[ $rc -eq 0 && -n $output ]]; then
|
2019-01-16 16:00:12 -08:00
|
|
|
node_readiness=true
|
2018-10-24 21:56:46 -07:00
|
|
|
break
|
|
|
|
fi
|
|
|
|
sleep 2
|
|
|
|
(( timeout=timeout-2 ))
|
|
|
|
done
|
2019-01-16 16:00:12 -08:00
|
|
|
if ! "$node_readiness"; then
|
|
|
|
echo "Timed out waiting for cluster to start"
|
2018-10-24 21:56:46 -07:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2019-09-18 10:03:54 -07:00
|
|
|
(
|
|
|
|
set -x
|
|
|
|
$solana_cli "${args[@]}" address
|
2020-05-19 20:07:30 -07:00
|
|
|
$solana_cli "${args[@]}" balance
|
2019-09-18 10:03:54 -07:00
|
|
|
$solana_cli "${args[@]}" ping --count 5 --interval 0
|
2020-05-19 20:07:30 -07:00
|
|
|
$solana_cli "${args[@]}" balance
|
2019-09-18 10:03:54 -07:00
|
|
|
)
|
2018-07-02 14:14:34 -07:00
|
|
|
|
|
|
|
echo PASS
|
|
|
|
exit 0
|