2013-05-27 16:55:01 -07:00
|
|
|
#!/bin/bash
|
2014-10-22 18:48:19 -07:00
|
|
|
# Copyright (c) 2013-2014 The Bitcoin Core developers
|
|
|
|
# Distributed under the MIT software license, see the accompanying
|
2014-03-18 02:11:00 -07:00
|
|
|
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
|
|
|
#
|
2016-01-07 18:55:56 -08:00
|
|
|
ZCASH_LOAD_TIMEOUT=500
|
2015-11-30 12:03:21 -08:00
|
|
|
DATADIR="@abs_top_builddir@/.zcash"
|
2013-05-27 16:55:01 -07:00
|
|
|
rm -rf "$DATADIR"
|
|
|
|
mkdir -p "$DATADIR"/regtest
|
2017-01-18 03:11:50 -08:00
|
|
|
touch "$DATADIR/zcash.conf"
|
2013-05-27 16:55:01 -07:00
|
|
|
touch "$DATADIR/regtest/debug.log"
|
|
|
|
tail -q -n 1 -F "$DATADIR/regtest/debug.log" | grep -m 1 -q "Done loading" &
|
|
|
|
WAITER=$!
|
2014-08-15 20:15:49 -07:00
|
|
|
PORT=`expr 10000 + $$ % 55536`
|
2015-11-30 12:03:21 -08:00
|
|
|
"@abs_top_builddir@/src/zcashd@EXEEXT@" -connect=0.0.0.0 -datadir="$DATADIR" -rpcuser=user -rpcpassword=pass -listen -keypool=3 -debug -debug=net -logtimestamps -checkmempool=0 -relaypriority=0 -port=$PORT -whitelist=127.0.0.1 -regtest -rpcport=`expr $PORT + 1` &
|
2013-05-27 16:55:01 -07:00
|
|
|
BITCOIND=$!
|
|
|
|
|
|
|
|
#Install a watchdog.
|
2016-01-07 18:55:56 -08:00
|
|
|
(sleep "$ZCASH_LOAD_TIMEOUT" && kill -0 $WAITER 2>/dev/null && kill -9 $BITCOIND $$)&
|
2013-05-27 16:55:01 -07:00
|
|
|
wait $WAITER
|
|
|
|
|
|
|
|
if [ -n "$TIMEOUT" ]; then
|
2013-10-28 00:41:40 -07:00
|
|
|
timeout "$TIMEOUT"s "$@" $PORT
|
2013-05-27 16:55:01 -07:00
|
|
|
RETURN=$?
|
|
|
|
else
|
2013-10-28 00:41:40 -07:00
|
|
|
"$@" $PORT
|
2013-05-27 16:55:01 -07:00
|
|
|
RETURN=$?
|
|
|
|
fi
|
|
|
|
|
2016-01-07 18:55:56 -08:00
|
|
|
(sleep "$ZCASH_LOAD_TIMEOUT" && kill -0 $BITCOIND 2>/dev/null && kill -9 $BITCOIND $$)&
|
2013-05-27 16:55:01 -07:00
|
|
|
kill $BITCOIND && wait $BITCOIND
|
|
|
|
|
|
|
|
# timeout returns 124 on timeout, otherwise the return value of the child
|
2014-10-01 13:47:33 -07:00
|
|
|
|
|
|
|
# If $RETURN is not 0, the test failed. Dump the tail of the debug log.
|
|
|
|
if [ $RETURN -ne 0 ]; then tail -n 200 $DATADIR/regtest/debug.log; fi
|
|
|
|
|
2013-05-27 16:55:01 -07:00
|
|
|
exit $RETURN
|