run_blockchain_tests.sh improvements

This commit is contained in:
LLFourn 2021-05-21 13:21:41 +10:00
parent 4c92daf517
commit d2a981efee
No known key found for this signature in database
GPG Key ID: A27093B54DA11F65

View File

@ -1,7 +1,13 @@
#!/bin/sh #!/bin/sh
#
# Script for running the tests for a specific blockchain by starting up the backends in docker. usage() {
# simply run ./run_blockchain_tests [esplora|electrum] cat <<'EOF'
Script for running the bdk blockchain tests for a specific blockchain by starting up the backend in docker.
Usage: ./run_blockchain_tests.sh [esplora|electrum] [test name].
EOF
}
eprintln(){ eprintln(){
echo "$@" >&2 echo "$@" >&2
@ -10,13 +16,16 @@ eprintln(){
cleanup() { cleanup() {
if test "$id"; then if test "$id"; then
eprintln "cleaning up $blockchain docker container $id"; eprintln "cleaning up $blockchain docker container $id";
docker rm -fv "$id"; docker rm -fv "$id" > /dev/null;
fi fi
trap - EXIT INT
} }
# Makes sure we clean up the container at the end or if ^C # Makes sure we clean up the container at the end or if ^C
trap 'rc=$?; cleanup; exit $rc' EXIT INT trap 'rc=$?; cleanup; exit $rc' EXIT INT
blockchain=${1:-electrum}
blockchain="$1"
test_name="$2"
case "$blockchain" in case "$blockchain" in
electrum) electrum)
@ -29,8 +38,9 @@ case "$blockchain" in
export BDK_ESPLORA_URL=http://127.0.0.1:3002 export BDK_ESPLORA_URL=http://127.0.0.1:3002
;; ;;
*) *)
echo "'$blockchain' is not a blockchain we can test (electrum,esplora)"; usage;
exit 1; exit 1;
;;
esac esac
# taken from https://github.com/bitcoindevkit/bitcoin-regtest-box # taken from https://github.com/bitcoindevkit/bitcoin-regtest-box
@ -45,10 +55,10 @@ cli(){
docker exec -it "$id" /root/bitcoin-cli -regtest -rpcuser=admin -rpcpassword=passw $@ docker exec -it "$id" /root/bitcoin-cli -regtest -rpcuser=admin -rpcpassword=passw $@
} }
eprintln "running getwalletinfo unitl bitcoind seems to be alive" eprintln "running getwalletinfo until bitcoind seems to be alive"
while ! cli getwalletinfo >/dev/null; do sleep 1; done while ! cli getwalletinfo >/dev/null; do sleep 1; done
# sleep again for good measure! # sleep again for good measure!
sleep 1; sleep 1;
cargo test --features "test-blockchains,$blockchain" --no-default-features "$blockchain::bdk_blockchain_tests" cargo test --features "test-blockchains,$blockchain" --no-default-features "$blockchain::bdk_blockchain_tests::$test_name"