Skip to content

test: verify the node receives a silent payment - #87

Merged
rustaceanrob merged 1 commit into
kernel-node:masterfrom
pzafonte:itest-recieve-payment
Jul 24, 2026
Merged

test: verify the node receives a silent payment#87
rustaceanrob merged 1 commit into
kernel-node:masterfrom
pzafonte:itest-recieve-payment

Conversation

@pzafonte

Copy link
Copy Markdown
Contributor

Core cannot send to a silent payment address, so the test builds the BIP-352 payment itself from a P2WPKH coinbase output, broadcasts it through Core, and mines it. The node, connected to Core, scans the block and its balance reflects the payment.

Adds helpers to import keys and read the receive address and balance over the control socket, and silentpayments as a dev-dependency to build the payment.

@rustaceanrob

Copy link
Copy Markdown
Contributor

Needs a rebase

@pzafonte
pzafonte force-pushed the itest-recieve-payment branch from 8126b30 to b24a392 Compare July 22, 2026 14:13
Comment thread tests/common/mod.rs Outdated
Comment thread tests/common/mod.rs Outdated
@yancyribbens

Copy link
Copy Markdown
Contributor

Core cannot send to a silent payment address,

Is this just a temporary solution until core can send to a silent payment address? I see there are some PRs to add SilentPayments to core although I haven't inspected them closely.

@rustaceanrob

Copy link
Copy Markdown
Contributor

Is this just a temporary solution until core can send to a silent payment address? I see there are some PRs to add SilentPayments to core although I haven't inspected them closely.

Silent payments sending definitely won't make it into the October release, so we're looking at 8-9 months minimum. The sending code is pretty readable here as well so I think it's fine.

@rustaceanrob

Copy link
Copy Markdown
Contributor

Tested 5 times and passed each time with no intermittent failures. Nice job.

Comment thread tests/wallet_receive.rs
const SYNC_TIMEOUT: Duration = Duration::from_secs(60);

#[test]
fn receives_a_silent_payment() {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think it's a bad idea to add this as a unit test. This is by definition an integration test and should exist separately from unit tests.

@yancyribbens

Copy link
Copy Markdown
Contributor

Runningcargo test I get the following error out of the box:

test connects_to_bitcoin_core ... FAILED
 
failures:
 
---- connects_to_bitcoin_core stdout ----
 
thread 'connects_to_bitcoin_core' (61607) panicked at tests/common/mod.rs:228:9:
node did not exit within 45s after stop
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
 
 
failures:
    connects_to_bitcoin_core

IIUC I don't think running a bitcoin core node should be required to run the unit test suit.

@rustaceanrob

Copy link
Copy Markdown
Contributor

It isn't a unit test, integration tests run by default. cargo test --lib --workspace is what you're looking for.

@yancyribbens

Copy link
Copy Markdown
Contributor

That also fails for me.

It isn't a unit test, integration tests run by default. cargo test --lib --workspace is what you're looking for.

test follows_bitcoin_core_chain ... FAILED
 
failures:
 
---- follows_bitcoin_core_chain stdout ----
 
thread 'follows_bitcoin_core_chain' (62153) panicked at tests/common/mod.rs:228:9:
node did not exit within 45s after stop
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
 
 
failures:
    follows_bitcoin_core_chain

@rustaceanrob

Copy link
Copy Markdown
Contributor

BITCOIND_EXE needs to be set with a path to Bitcoin Core, if it isn't already. FWIW that also seems to be an intermittent failure in this project we need to sort out.

I think it is maybe an annoyance at worst for us to have some extra steps for testing, but given Bitcoin Core is the dominant implementation and this is a node software, I think it is prudent we have tests for these scenarios.

Core cannot send to a silent payment address, so the test builds the
BIP-352 payment itself from a P2WPKH coinbase output, broadcasts it
through Core, and mines it. The node, connected to Core, scans the block
and its balance reflects the payment.

Adds helpers to import keys and read the receive address and
balance over the control socket, and silentpayments as a dev-dependency
to build the payment.
@pzafonte
pzafonte force-pushed the itest-recieve-payment branch from b24a392 to b25fdf1 Compare July 24, 2026 14:33
@pzafonte

Copy link
Copy Markdown
Contributor Author

Silent payments sending definitely won't make it into the October release, so we're looking at 8-9 months minimum.

corepc-node caps us at Core 30.2 anyway, so this would also need a silent-payments-capable Core to be available through corepc-node as well

@rustaceanrob

Copy link
Copy Markdown
Contributor

tACK b25fdf1

@yancyribbens if you have a different test layout suggestion please open an issue and I'll review

@rustaceanrob
rustaceanrob merged commit 81509a7 into kernel-node:master Jul 24, 2026
2 checks passed
@yancyribbens

Copy link
Copy Markdown
Contributor

Interesting, I didn't realize "cargo test" would run both unit and integration tests. I wonder if it would be worth documenting how to run wallet unit tests and also run unit tests separately in CI. I guess for now I can just "cd ./crates/wallet && cargo test" to run only the wallet unit tests.

@rustaceanrob

Copy link
Copy Markdown
Contributor

https://doc.rust-lang.org/cargo/commands/cargo-test.html#description:

Compile and execute unit, integration, and documentation tests.

The cargo test command runs the entire suite, including integration tests and doc tests.

cargo test --lib is the unit test flag. I think a markdown on testing in the doc folder would be useful, since we have the added requirement of a bitcoin core binary.

@yancyribbens

Copy link
Copy Markdown
Contributor

The cargo test command runs the entire suite, including integration tests and doc tests.

Yeah I see that now, thanks.

cargo test --lib is the unit test flag. I think a markdown on testing in the doc folder would be useful, since we have the added requirement of a bitcoin core binary.

This doesn't run any tests as you may have noticed. It doesn't look like the node has any unit tests which I think is the reason.

@rustaceanrob

Copy link
Copy Markdown
Contributor

Yeah, not sure why but needs the extra workspace flag. We can start to document this stuff for sure.

@yancyribbens

Copy link
Copy Markdown
Contributor

Yeah, not sure why but needs the extra workspace flag. We can start to document this stuff for sure.

Oh, nice that works also with workspace: cargo test --lib --workspace. I though I had tried that before and it failed but I must have been mistaken.

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.

3 participants