2013-05-28 01:55:01 +02:00
|
|
|
#!/bin/bash
|
2014-03-18 10:11:00 +01:00
|
|
|
# Copyright (c) 2013 The Bitcoin Core developers
|
|
|
|
# Distributed under the MIT/X11 software license, see the accompanying
|
|
|
|
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
|
|
|
#
|
2013-05-28 01:55:01 +02:00
|
|
|
DATADIR="@abs_top_builddir@/.bitcoin"
|
|
|
|
rm -rf "$DATADIR"
|
|
|
|
mkdir -p "$DATADIR"/regtest
|
|
|
|
touch "$DATADIR/regtest/debug.log"
|
|
|
|
tail -q -n 1 -F "$DATADIR/regtest/debug.log" | grep -m 1 -q "Done loading" &
|
|
|
|
WAITER=$!
|
2013-10-28 08:41:40 +01:00
|
|
|
PORT=`expr $BASHPID + 10000`
|
2014-06-21 13:34:36 +02:00
|
|
|
"@abs_top_builddir@/src/bitcoind@EXEEXT@" -connect=0.0.0.0 -datadir="$DATADIR" -rpcuser=user -rpcpassword=pass -listen -keypool=3 -debug -debug=net -logtimestamps -port=$PORT -whitelist=127.0.0.1 -regtest -rpcport=`expr $PORT + 1` &
|
2013-05-28 01:55:01 +02:00
|
|
|
BITCOIND=$!
|
|
|
|
|
|
|
|
#Install a watchdog.
|
|
|
|
(sleep 10 && kill -0 $WAITER 2>/dev/null && kill -9 $BITCOIND $$)&
|
|
|
|
wait $WAITER
|
|
|
|
|
|
|
|
if [ -n "$TIMEOUT" ]; then
|
2013-10-28 08:41:40 +01:00
|
|
|
timeout "$TIMEOUT"s "$@" $PORT
|
2013-05-28 01:55:01 +02:00
|
|
|
RETURN=$?
|
|
|
|
else
|
2013-10-28 08:41:40 +01:00
|
|
|
"$@" $PORT
|
2013-05-28 01:55:01 +02:00
|
|
|
RETURN=$?
|
|
|
|
fi
|
|
|
|
|
|
|
|
(sleep 15 && kill -0 $BITCOIND 2>/dev/null && kill -9 $BITCOIND $$)&
|
|
|
|
kill $BITCOIND && wait $BITCOIND
|
|
|
|
|
|
|
|
# timeout returns 124 on timeout, otherwise the return value of the child
|
|
|
|
exit $RETURN
|