core-lightning/daemon/test/scripts/setup.sh
Rusty Russell d8892c4dda test: do version check during setup.
Waiting until lightningd is up is too long: do a --version test in setup,
and then check that all reported versions match later on.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-11-08 21:50:55 +10:30

53 lines
1.0 KiB
Bash
Executable File

#! /bin/sh -e
. `dirname $0`/vars.sh
VERSION=$(`dirname $0`/../../lightning-cli --version | head -n1)
[ $VERSION = `git describe --always --dirty` ] || (echo Wrong version $VERSION >&2; exit 1)
if $CLI getinfo 2>/dev/null; then
echo $DAEMON already running >&2
exit 1
fi
# Start clean
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 &
i=0
while ! $CLI getinfo >/dev/null 2>&1; do
if [ $i -gt 30 ]; then
echo $DAEMON start failed? >&1
exit 1
fi
sleep 1
i=$(($i + 1))
done
# Make sure they have segwit support!
if $CLI getblockchaininfo | grep -q '"segwit"'; then :
else
echo This bitcoind does not have segwit support. >&2
echo Please install a recent one >&2
exit 1
fi
scripts/generate-block.sh init
A1=`scripts/get-new-address.sh`
TX=`$CLI sendmany "" "{ \"$A1\":0.01 }"`
scripts/generate-block.sh