Skip to content

Make corepc-node optional in payjoin-test-utils#1424

Open
DanGould wants to merge 2 commits intopayjoin:masterfrom
DanGould:test-utils-no-bitcoind
Open

Make corepc-node optional in payjoin-test-utils#1424
DanGould wants to merge 2 commits intopayjoin:masterfrom
DanGould:test-utils-no-bitcoind

Conversation

@DanGould
Copy link
Copy Markdown
Contributor

@DanGould DanGould commented Mar 19, 2026

Test constants (ORIGINAL_PSBT, EXAMPLE_URL, etc.) and the TestServices infrastructure don't require bitcoind. Only init_bitcoind* functions need the corepc-node crate, which downloads a ~40MB binary at build time.

Gate corepc-node behind a bitcoind feature (default = on) so downstream consumers can import payjoin-test-utils for constants without triggering the bitcoind download. This unblocks nix environments and CI setups that provide their own bitcoind via BITCOIND_EXE.

The split lets FFI bindings import test constants (originalPsbt(), exampleUrl()) without downloading bitcoind — so dart test, python
-m pytest, npm test work in any environment, not just ones with network access. No new bindings needed — the constants are already
exported through payjoin-ffi's test_utils.rs; the only blocker was corepc-node's build.rs firing unconditionally.

This was claude baby. I needed this for an agent in nix with no network.

Pull Request Checklist

Please confirm the following before requesting review:

@coveralls
Copy link
Copy Markdown
Collaborator

coveralls commented Mar 19, 2026

Pull Request Test Coverage Report for Build 23634000801

Details

  • 39 of 51 (76.47%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 84.129%

Changes Missing Coverage Covered Lines Changed/Added Lines %
payjoin-test-utils/src/bitcoind.rs 39 51 76.47%
Totals Coverage Status
Change from base Build 23607944477: 0.0%
Covered Lines: 10649
Relevant Lines: 12658

💛 - Coveralls

Comment on lines +22 to +29
#[cfg(feature = "bitcoind")]
use bitcoin::Amount;
#[cfg(feature = "bitcoind")]
pub use corepc_node;
#[cfg(feature = "bitcoind")]
use corepc_node::AddressType;
#[cfg(feature = "bitcoind")]
use tracing::Level;
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: to avoid this kind of confusing feature gating we should move bitcoind to its own module and feature gate the whole thing once

Copy link
Copy Markdown
Contributor Author

@DanGould DanGould Mar 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

o yeah I was only concerned about the gates being clean in a group and forgot about that option. good call.

Copy link
Copy Markdown
Collaborator

@spacebear21 spacebear21 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

concept ACK with one structural change request

@DanGould DanGould force-pushed the test-utils-no-bitcoind branch 2 times, most recently from 9d2151a to 87d590c Compare March 19, 2026 16:59
@DanGould DanGould marked this pull request as ready for review March 20, 2026 03:10
@DanGould DanGould marked this pull request as draft March 20, 2026 05:30
@DanGould DanGould force-pushed the test-utils-no-bitcoind branch from 87d590c to b22f5e6 Compare March 23, 2026 08:07
Add a bitcoind feature flag to gate corepc-node dependency and
move bitcoind helpers behind #[cfg(feature = "bitcoind")].
Downstream crates opt in via features = ["bitcoind"].
@DanGould DanGould force-pushed the test-utils-no-bitcoind branch from b22f5e6 to 5c59429 Compare March 23, 2026 08:38
Copy link
Copy Markdown
Collaborator

@arminsabouri arminsabouri left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

utACK 5c59429

@DanGould
Copy link
Copy Markdown
Contributor Author

I will merge 5c59429 as tested but I also have a follow-up commit on this branch to make it optional for ffi. This is useful for Nix in a user that doesn't have network access for agents. PR there coming immediately after.

@DanGould DanGould marked this pull request as ready for review March 23, 2026 15:09
@DanGould
Copy link
Copy Markdown
Contributor Author

Ah nevermind I tried to merge with the ACK but am not allowed because of the requested changes, so I pushed the 2nd commit.

@DanGould DanGould marked this pull request as draft March 23, 2026 15:12
@DanGould DanGould marked this pull request as draft March 23, 2026 15:12
Split _test-utils into _test-utils (constants + TestServices only)
and _test-utils-bitcoind (adds BitcoindEnv, RpcClient, etc.).
This lets FFI consumers like Dart unit tests import test constants
without triggering the corepc-node/bitcoind download.

Update all binding-generation and test scripts to use
_test-utils-bitcoind where integration-test types are needed.
@DanGould DanGould force-pushed the test-utils-no-bitcoind branch from 4099199 to cd56b57 Compare March 27, 2026 06:19
@DanGould DanGould requested a review from spacebear21 March 27, 2026 12:06
@DanGould DanGould marked this pull request as ready for review March 27, 2026 12:06
Copy link
Copy Markdown
Collaborator

@spacebear21 spacebear21 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This approach seems harmless so ACKing now, but I just realized something that I wish I'd thought of on my first review: couldn't this whole thing be avoided by just making the download flag optional on corepc-node? So test utils would always ship with bitcoind functionality but the 40mb binary and network access become optional. In the nix.flake we already skip download and set BITCOIND_EXE.

EDIT: #514 just got merged. I wonder if it solves the issue you were experiencing with the networkless agent?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants