Skip to content

Commit d2a981e

Browse files
committed
run_blockchain_tests.sh improvements
1 parent 4c92daf commit d2a981e

File tree

1 file changed

+18
-8
lines changed

1 file changed

+18
-8
lines changed

run_blockchain_tests.sh

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
11
#!/bin/sh
2-
#
3-
# Script for running the tests for a specific blockchain by starting up the backends in docker.
4-
# simply run ./run_blockchain_tests [esplora|electrum]
2+
3+
usage() {
4+
cat <<'EOF'
5+
Script for running the bdk blockchain tests for a specific blockchain by starting up the backend in docker.
6+
7+
Usage: ./run_blockchain_tests.sh [esplora|electrum] [test name].
8+
9+
EOF
10+
}
511

612
eprintln(){
713
echo "$@" >&2
@@ -10,13 +16,16 @@ eprintln(){
1016
cleanup() {
1117
if test "$id"; then
1218
eprintln "cleaning up $blockchain docker container $id";
13-
docker rm -fv "$id";
19+
docker rm -fv "$id" > /dev/null;
1420
fi
21+
trap - EXIT INT
1522
}
1623

1724
# Makes sure we clean up the container at the end or if ^C
1825
trap 'rc=$?; cleanup; exit $rc' EXIT INT
19-
blockchain=${1:-electrum}
26+
27+
blockchain="$1"
28+
test_name="$2"
2029

2130
case "$blockchain" in
2231
electrum)
@@ -29,8 +38,9 @@ case "$blockchain" in
2938
export BDK_ESPLORA_URL=http://127.0.0.1:3002
3039
;;
3140
*)
32-
echo "'$blockchain' is not a blockchain we can test (electrum,esplora)";
41+
usage;
3342
exit 1;
43+
;;
3444
esac
3545

3646
# taken from https://github.com/bitcoindevkit/bitcoin-regtest-box
@@ -45,10 +55,10 @@ cli(){
4555
docker exec -it "$id" /root/bitcoin-cli -regtest -rpcuser=admin -rpcpassword=passw $@
4656
}
4757

48-
eprintln "running getwalletinfo unitl bitcoind seems to be alive"
58+
eprintln "running getwalletinfo until bitcoind seems to be alive"
4959
while ! cli getwalletinfo >/dev/null; do sleep 1; done
5060

5161
# sleep again for good measure!
5262
sleep 1;
5363

54-
cargo test --features "test-blockchains,$blockchain" --no-default-features "$blockchain::bdk_blockchain_tests"
64+
cargo test --features "test-blockchains,$blockchain" --no-default-features "$blockchain::bdk_blockchain_tests::$test_name"

0 commit comments

Comments
 (0)