You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

run-bitcoind-for-test.sh.in 1.1KB

1234567891011121314151617181920212223242526272829303132
  1. #!/bin/bash
  2. # Copyright (c) 2013 The Bitcoin Core developers
  3. # Distributed under the MIT/X11 software license, see the accompanying
  4. # file COPYING or http://www.opensource.org/licenses/mit-license.php.
  5. #
  6. DATADIR="@abs_top_builddir@/.bitcoin"
  7. rm -rf "$DATADIR"
  8. mkdir -p "$DATADIR"/regtest
  9. touch "$DATADIR/regtest/debug.log"
  10. tail -q -n 1 -F "$DATADIR/regtest/debug.log" | grep -m 1 -q "Done loading" &
  11. WAITER=$!
  12. PORT=`expr 10000 + $$ % 55536`
  13. "@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` &
  14. BITCOIND=$!
  15. #Install a watchdog.
  16. (sleep 10 && kill -0 $WAITER 2>/dev/null && kill -9 $BITCOIND $$)&
  17. wait $WAITER
  18. if [ -n "$TIMEOUT" ]; then
  19. timeout "$TIMEOUT"s "$@" $PORT
  20. RETURN=$?
  21. else
  22. "$@" $PORT
  23. RETURN=$?
  24. fi
  25. (sleep 15 && kill -0 $BITCOIND 2>/dev/null && kill -9 $BITCOIND $$)&
  26. kill $BITCOIND && wait $BITCOIND
  27. # timeout returns 124 on timeout, otherwise the return value of the child
  28. exit $RETURN