test: use random port/rpcport for bitcoind.

This means we don't get confused if a testnet bitcoind already running.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell
2016-08-26 15:44:04 +09:30
parent 754616c45a
commit b22bdfcbe8
3 changed files with 13 additions and 3 deletions

View File

@@ -11,10 +11,16 @@ fi
rm -rf $DATADIR
mkdir $DATADIR
# Find a free port (racy, but hey)
PORT=`findport 18332`
RPCPORT=`findport $(($PORT + 1))`
# Create appropriate config file so cmdline matches.
cat > $DATADIR/bitcoin.conf <<EOF
regtest=1
testnet=0
rpcport=$RPCPORT
port=$PORT
EOF
$DAEMON &

View File

@@ -11,4 +11,10 @@ else
SEQ_ENFORCEMENT=false
fi
findport()
{
PORT=$1
while netstat -ntl | grep -q ":$PORT "; do PORT=$(($PORT + 1)); done
echo $PORT
}
#PREFIX="valgrind --vgdb-error=1"