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
612eprintln (){
713 echo " $@ " >&2
@@ -10,13 +16,16 @@ eprintln(){
1016cleanup () {
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
1825trap ' rc=$?; cleanup; exit $rc' EXIT INT
19- blockchain=${1:- electrum}
26+
27+ blockchain=" $1 "
28+ test_name=" $2 "
2029
2130case " $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"
4959while ! cli getwalletinfo > /dev/null; do sleep 1; done
5060
5161# sleep again for good measure!
5262sleep 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