Skip to content

test(shared): add post-IBD tip wait helper - #449

Merged
0xB10C merged 1 commit into
peer-observer:masterfrom
deadmanoz:feature/test-bitcoind-wait-tip
May 28, 2026
Merged

0xB10C merged 1 commit into
peer-observer:masterfrom
deadmanoz:feature/test-bitcoind-wait-tip

Conversation

@deadmanoz

@deadmanoz deadmanoz commented May 26, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

This came out of reviewing the compact block reconstruction integration tests in #420. Those tests need a deterministic way to know that a regtest node has connected a mined block and left IBD before the next step tries to trigger post-IBD behaviour.

This adds shared::testing::node::mine_and_wait_for_tip, which mines one block on the given node, polls until that block is the active tip, verifies initial_block_download is false, and then drains the validation interface queue.

The existing p2p-extractor address-announcement and rpc-extractor getorphantxs tests both utilise the helper instead of generating a block and immediately asserting on IBD state. That should make the tests less sensitive to slow hardware (e.g. the hardware I actually use for testing, a VM on a 10yr old server!!) where bitcoind has not yet advanced all relevant state by the next line of test code.

UPDATE: The helper currently takes a single client because both call sites here are single-node. When the cross-node case lands (PR #420's test_integration_logextractor_saw_new_header is the obvious next caller, where node2 mines and node1 observes), the signature can grow to (miner, observer) or split into a dedicated mine_and_wait_for_tip_observed_by helper without disturbing the current callers.

Testing

My usual stress: 50 consecutive runs of the integration suite on older hardware, all green.

Comment thread extractors/rpc/tests/integration.rs Resolved
Comment thread shared/src/testing/node.rs Resolved
Comment thread shared/src/testing/node.rs Resolved
Comment thread shared/src/testing/node.rs Outdated
Comment on lines +41 to +42
miner: &bitcoind::Client,
observer: &bitcoind::Client,

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.

All callers currently pass the same client as miner and observer. Can simplify it for now.

Suggested change
miner: &bitcoind::Client,
observer: &bitcoind::Client,
miner: &bitcoind::Client,

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Absolutely. This change was originally motivated by seeing test_integration_logextractor_saw_new_header (https://github.com/peer-observer/peer-observer/pull/420/changes#diff-a50a41ef033e3a5a57ce05a9bce73f5551b216e71f7cf1315f15215963a235e3R700) in #420, where the two node variant would be useful, hence the two clients.

But happy to collapse to one for the current state of the codebase, and extend when #420 is in.

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.

I see! I wasn't aware of that.

@deadmanoz
deadmanoz force-pushed the feature/test-bitcoind-wait-tip branch from 8e915b4 to 0093b93 Compare May 28, 2026 02:45
@deadmanoz

Copy link
Copy Markdown
Collaborator Author

Addressed review feedback:

  • Made the 120s timeout a POST_IBD_TIP_TIMEOUT constant, there's no longer a timeout argument
  • Dropped the address: &Address parameter, the helper now uses &REGTEST_ADDRESS directly
  • Collapsed the (miner, observer) signature to a single node parameter for now, can have a new 2-signature variant as is needed for Watching compact block reconstructions via log-extractor #420 later

@0xB10C

0xB10C commented May 28, 2026

Copy link
Copy Markdown
Collaborator

Looks good to me, thanks!

@0xB10C
0xB10C merged commit 1cb5ceb into peer-observer:master May 28, 2026
12 checks passed
@deadmanoz
deadmanoz deleted the feature/test-bitcoind-wait-tip branch May 28, 2026 08:43
m4ycon added a commit to m4ycon/peer-observer that referenced this pull request May 30, 2026
m4ycon added a commit to m4ycon/peer-observer that referenced this pull request May 30, 2026
m4ycon added a commit to m4ycon/peer-observer that referenced this pull request Jun 3, 2026
m4ycon added a commit to m4ycon/peer-observer that referenced this pull request Jun 11, 2026
m4ycon added a commit to m4ycon/peer-observer that referenced this pull request Jun 12, 2026
m4ycon added a commit to m4ycon/peer-observer that referenced this pull request Jun 29, 2026
m4ycon added a commit to m4ycon/peer-observer that referenced this pull request Jun 29, 2026
m4ycon added a commit to m4ycon/peer-observer that referenced this pull request Jun 29, 2026
m4ycon added a commit to m4ycon/peer-observer that referenced this pull request Jun 29, 2026
0xB10C pushed a commit that referenced this pull request Jun 30, 2026
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.

2 participants