@@ -25,6 +25,27 @@ if [ -e "$SCRIPT_DIR/shell_env" ]; then
2525 source " $SCRIPT_DIR /shell_env"
2626fi
2727
28+ get_address_balance () {
29+ local txhash txix amount total_amount _
30+
31+ # Repeat in case `query utxo` fails
32+ for _ in {1..3}; do
33+ total_amount=0
34+ while read -r txhash txix amount _; do
35+ if [ -z " $txhash " ] || [ -z " $txix " ]; then
36+ continue
37+ fi
38+ total_amount=" $(( total_amount + amount)) "
39+ done <<< " $(cardano-cli latest query utxo " $@ " | grep " lovelace" )"
40+
41+ if [ " $total_amount " -gt 0 ]; then
42+ break
43+ fi
44+ done
45+
46+ echo " $total_amount "
47+ }
48+
2849rm -rf " $STATE_CLUSTER "
2950mkdir -p " $STATE_CLUSTER " /{byron,shelley,webserver}
3051cd " $STATE_CLUSTER /.."
3657
3758# copy faucet address and keys
3859cp " $TESTNET_DIR " /shelley/faucet.* " $STATE_CLUSTER /shelley"
60+ [ -e " $STATE_CLUSTER /shelley/faucet.addr" ] || \
61+ { echo " The \` $STATE_CLUSTER /shelley/faucet.addr\` not found, line $LINENO " >&2 ; exit 1; } # assert
62+ [ -e " $STATE_CLUSTER /shelley/faucet.vkey" ] || \
63+ { echo " The \` $STATE_CLUSTER /shelley/faucet.vkey\` not found, line $LINENO " >&2 ; exit 1; } # assert
64+ [ -e " $STATE_CLUSTER /shelley/faucet.skey" ] || \
65+ { echo " The \` $STATE_CLUSTER /shelley/faucet.skey\` not found, line $LINENO " >&2 ; exit 1; } # assert
3966
4067# copy configuration files
4168cp " $SCRIPT_DIR " /cardano-node-* " $STATE_CLUSTER "
@@ -48,6 +75,8 @@ ln -rs "$STATE_CLUSTER/genesis-shelley.json" "$STATE_CLUSTER/shelley/genesis.jso
4875ln -rs " $STATE_CLUSTER /genesis-alonzo.json" " $STATE_CLUSTER /shelley/genesis.alonzo.json"
4976ln -rs " $STATE_CLUSTER /genesis-conway.json" " $STATE_CLUSTER /shelley/genesis.conway.json"
5077
78+ NETWORK_MAGIC=" $( jq ' .networkMagic' " $STATE_CLUSTER /shelley/genesis.json" ) "
79+
5180# edit port numbers in configuration
5281RELAY1_EKG=" %%EKG_PORT_RELAY1%%"
5382RELAY1_PROMETHEUS=" %%PROMETHEUS_PORT_RELAY1%%"
174203[ -S " $CARDANO_NODE_SOCKET_PATH " ] || { echo " Failed to start the relay node, line $LINENO " >&2 ; exit 1; } # assert
175204
176205echo " Waiting to make sure the chain is synced"
177- NETWORK_MAGIC=" $( jq ' .networkMagic' " $STATE_CLUSTER /shelley/genesis.json" ) "
178206for _ in {1..600}; do
179207 sync_progress=" $( cardano-cli query tip --testnet-magic " $NETWORK_MAGIC " | jq -r ' .syncProgress' ) "
180208 if [ " $sync_progress " = " 100.00" ]; then
@@ -208,4 +236,9 @@ if [ -n "${DBSYNC_REPO:-""}" ]; then
208236 done
209237fi
210238
239+ get_address_balance \
240+ --testnet-magic " $NETWORK_MAGIC " \
241+ --address " $( < " $STATE_CLUSTER /shelley/faucet.addr" ) " \
242+ > " ${STATE_CLUSTER} /start-cluster.log"
243+
211244echo " Cluster started. Run \` $SCRIPT_DIR /stop-cluster\` to stop"
0 commit comments