Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 2 additions & 11 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,5 @@ jobs:
restore-keys: ccache-${{ runner.os }}-
- name: Checkout Bitcoin Core
run: git clone --depth 1 --branch master https://github.com/bitcoin/bitcoin.git
- name: Build Bitcoin Core
run: |
cd bitcoin
cmake -B build -DENABLE_WALLET=ON -DBUILD_TESTS=OFF -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache
cmake --build build -j $(nproc)
- name: Run Bitcoin Core Daemon
run: cd bitcoin && ./build/bin/bitcoin node -chain=regtest -ipcbind=unix -server -debug=ipc -daemon
- name: Run Test Suite
env:
BITCOIN_BIN: ${{ github.workspace }}/bitcoin/build/bin/bitcoin
run: cargo test
- name: Build & Run Test Suite
run: contrib/run-tests.sh bitcoin
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ cargo build

## Running integration tests

The integration tests connect to a running bitcoin node via IPC.
The integration tests connect to a running bitcoin node via IPC. For a single test script, see `contrib/run-tests.sh`.

### 1. Build Bitcoin Core

Expand Down
47 changes: 47 additions & 0 deletions contrib/run-tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#!/usr/bin/env bash
#
# Build Bitcoin Core, launch a regtest node with IPC enabled, run the
# integration test suite against it, and shut the node down.
#
# Usage: contrib/run-tests.sh <path-to-bitcoin-source>

set -euo pipefail

if [ "$#" -ne 1 ]; then
echo "Usage: $0 <path-to-bitcoin-source>" >&2
exit 1
fi

BITCOIN_SRC=$(cd "$1" && pwd)
REPO_ROOT=$(cd "$(dirname "$0")/.." && pwd)
BITCOIN_BIN="$BITCOIN_SRC/build/bin/bitcoin"

echo "==> Building Bitcoin Core in $BITCOIN_SRC"
(
cd "$BITCOIN_SRC"
CMAKE_ARGS=(-DENABLE_WALLET=ON -DBUILD_TESTS=OFF)
if command -v ccache >/dev/null 2>&1; then
CMAKE_ARGS+=(-DCMAKE_C_COMPILER_LAUNCHER=ccache
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache)
fi
cmake -B build "${CMAKE_ARGS[@]}"
cmake --build build -j"$(nproc)"
)

stop_bitcoin() {
if [ -n "${BITCOIN_STARTED:-}" ]; then
echo "==> Stopping bitcoin"
"$BITCOIN_BIN" rpc -chain=regtest stop || true
fi
}
trap stop_bitcoin EXIT

echo "==> Starting bitcoin node (regtest, IPC)"
"$BITCOIN_BIN" node -chain=regtest -ipcbind=unix -server -debug=ipc -daemon
BITCOIN_STARTED=1

echo "==> Running cargo test"
(
cd "$REPO_ROOT"
BITCOIN_BIN="$BITCOIN_BIN" cargo test
)
Loading