Skip to content

Commit c20a15a

Browse files
committed
Add Docker-based test runner
1 parent c56b3e1 commit c20a15a

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

tests/run-docker.sh

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#!/bin/bash
2+
set -eo pipefail
3+
4+
# Cleanup on exit
5+
trap 'docker stop esplora-tests-explorer || true; [ -n "$datadir" ] && rm -r "$datadir" || true' EXIT
6+
7+
# Build the Esplora docker image
8+
(
9+
cd ..
10+
[ -n "$SKIP_BUILD_BASE" ] || docker build -t blockstream/esplora-base:latest -f Dockerfile.deps .
11+
[ -n "$SKIP_BUILD_IMAGE" ] || docker build -t esplora .
12+
)
13+
14+
# Run Esplora/Electrs in regtest mode
15+
datadir=$(mktemp -d /tmp/esplora-tests.XXXXX)
16+
docker run -v $datadir:/data --rm -t --name esplora-tests-explorer \
17+
-v $HOME/workspace/blockstream/esplora/run.sh:/srv/explorer/run.sh \
18+
-e EXPOSE_BITCOIND_RPC=1 \
19+
esplora bash -c "/srv/explorer/run.sh bitcoin-regtest explorer" \
20+
&
21+
sleep 1
22+
23+
cont_ip=$(docker inspect esplora-tests-explorer | jq -r '.[0].NetworkSettings.IPAddress')
24+
export BASE_URL=http://$cont_ip/regtest
25+
26+
# Wait for the HTTP REST API to become available
27+
while ! curl $BASE_URL/api/blocks/tip/height; do
28+
sleep 0.5
29+
done
30+
31+
# Load the default wallet (needed for the Cypress tests)
32+
docker exec esplora-tests-explorer cli -rpcwait loadwallet default
33+
34+
# Grab the bitcoin cookie
35+
bitcoind_cookie=$(docker exec esplora-tests-explorer cat /data/bitcoin/regtest/.cookie)
36+
export BITCOIND_URL=http://$bitcoind_cookie@$cont_ip:18443/
37+
38+
# Build Cypress and run the tests
39+
docker build -t esplora-tests-cypress .
40+
docker run -it --rm \
41+
-v $PWD/cypress/videos:/tests/cypress/videos -v $PWD/cypress/screenshots:/tests/cypress/screenshots \
42+
-e BASE_URL -e BITCOIND_URL \
43+
esplora-tests-cypress

0 commit comments

Comments
 (0)