1+ #! /bin/bash
2+ set -eo pipefail
3+
4+ # Cleanup on exit
5+ trap ' docker stop esplora-tests-explorer || true; [ -n "$datadir" ] && rm -rf "$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
44+
45+ # TODO exit with an error code if the tests fail
0 commit comments