Skip to content

Commit 313ef9d

Browse files
committed
Run node tests
Currently we have a job for each supported version of Bitcoin Core and in it we run the integration tests. Note also that `node` is currently not a member of the workspace. So it misses out on all the benefits of `run_task` (e.g., linting). However `node` cannot be directly run using `run_task` because of its unusual features but since we already have the `Integration` job set up to manage these features we can just run the `node` tests from there also. This has the added advantage that the same downloaded Bitcoin Core binary will be used (I hope). Add a script and call it from the `Integration` job. In the script first run the `node` tests and then run the integration tests.
1 parent 5afc0ab commit 313ef9d

File tree

3 files changed

+53
-3
lines changed

3 files changed

+53
-3
lines changed

.github/workflows/rust.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,4 +232,4 @@ jobs:
232232
- name: "Select toolchain"
233233
uses: dtolnay/rust-toolchain@stable
234234
- name: "Run integration tests"
235-
run: cd integration_test && cargo test --features=${{ matrix.feature }}
235+
run: ./contrib/version_specific_tests.sh ${{ matrix.feature }}

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[workspace]
2-
members = ["client", "types", "jsonrpc"]
3-
exclude = ["integration_test", "node", "verify"]
2+
members = ["client", "types", "jsonrpc", "node"]
3+
exclude = ["integration_test", "verify"]
44
resolver = "2"
55

66
[patch.crates-io.corepc-client]

contrib/version_specific_tests.sh

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
#!/usr/bin/env bash
2+
#
3+
# Run Bitcoin Core version specific tests (the `integration_test` and `node` crates.)
4+
#
5+
# The `node` crate features are different from a normal crate because:
6+
#
7+
# - `node` cannot be built with --no-default-features
8+
# - `node` expects at least one version feature e.g., --features=28_0
9+
# - `node` supports downloading the Bitcoin Core binary and also running `bitcoind` from the host.
10+
#
11+
# In CI we always want to download the Bitcoin Core binary. This means we always enable `download`.
12+
# Also, we always enable exactly one feature (even though multiple features will just cause the
13+
# higher one to override the lower one).
14+
#
15+
# These comments apply to the integration test crate also because it depends on `node`.
16+
17+
set -euox pipefail
18+
19+
REPO_DIR=$(git rev-parse --show-toplevel)
20+
NODE_DIR="$REPO_DIR/node"
21+
INTEGRATION_TEST_DIR="$REPO_DIR/integration_test"
22+
23+
main() {
24+
local version_feature="${1}"
25+
26+
do_node_tests "$version_feature"
27+
do_integration_tests "$version_feature"
28+
}
29+
30+
do_node_tests() {
31+
local version_feature="${1}"
32+
33+
pushd "$NODE_DIR" > /dev/null
34+
cargo test --features=download,"$version_feature"
35+
popd > /dev/null
36+
}
37+
38+
do_integration_tests() {
39+
local version_feature="${1}"
40+
41+
pushd "$NODE_DIR" > /dev/null
42+
cargo test --features="$version_feature"
43+
popd > /dev/null
44+
}
45+
46+
#
47+
# Main script
48+
#
49+
main "$@"
50+
exit 0

0 commit comments

Comments
 (0)