refactor(testenv)!: make wait_until_electrum_sees_block concrete#2231
Open
evanlinjin wants to merge 1 commit into
Open
refactor(testenv)!: make wait_until_electrum_sees_block concrete#2231evanlinjin wants to merge 1 commit into
wait_until_electrum_sees_block concrete#2231evanlinjin wants to merge 1 commit into
Conversation
Previously `TestEnv::wait_until_electrum_sees_block` only took a `timeout` and returned as soon as Electrum emitted any new-block notification, so it was not clear which block was actually being waited for. Add `block_height` and an optional `block_hash` so callers state exactly which block Electrum must be aware of. When the notified tip has already advanced past `block_height`, the header at that height is fetched explicitly so the expected `block_hash` can still be verified. Introduce `TestEnv::wait_until_electrum_tip_syncs_with_bitcoind`, a convenience wrapper that waits until Electrum's tip matches bitcoind's chain tip (both height and hash), and migrate all existing call sites to it. https://claude.ai/code/session_016gJvi98Q65QnanBFxe2UUn
5 tasks
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #2231 +/- ##
==========================================
+ Coverage 77.69% 78.65% +0.96%
==========================================
Files 29 30 +1
Lines 5801 5909 +108
Branches 271 279 +8
==========================================
+ Hits 4507 4648 +141
+ Misses 1223 1185 -38
- Partials 71 76 +5
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
A from-scratch reimplementation of #1640 on top of the current
master.TestEnv::wait_until_electrum_sees_blockpreviously only took atimeoutand returned as soon as Electrum emitted any new-block notification. That made it ambiguous which block was actually being waited for, and it could return before Electrum had caught up to the block the test cared about.This PR makes the wait concrete:
wait_until_electrum_sees_blocknow takesblock_height: usizeandblock_hash: Option<BlockHash>, so callers state exactly which block Electrum must be aware of. If the notified tip has already advanced pastblock_height, the header at that height is fetched explicitly so the expectedblock_hashcan still be verified.wait_until_electrum_tip_syncs_with_bitcoindwaits until Electrum's tip matches bitcoind's chain tip (both height and hash). All existing call sites are migrated to it, since in every case the intent was "wait until Electrum catches up to the freshly mined/reorged tip".Notes to the reviewers
block_heightand checking its hash does not guarantee the spk histories are current. Receiving a block-tip notification does, because of how Electrs indexes. This is captured in aNOTEin the code.block_height, the header atblock_heightis fetched directly to verify the hash, rather than relying on the notification header.trigger()placement:electrsd.trigger()is kept inside the polling loop (matching the previousmasterbehaviour) so Electrs keeps getting nudged to re-index — this is important for reorgs, where the tip changes without a height change.TestEnv::wait_until_electrum_sees_blockto be more concrete. #1640 (a// TODO: Fails here.marker and a struck-through doc comment) are intentionally left out.Changelog notice
TestEnv::wait_until_electrum_sees_blocknow takes ablock_heightand an optionalblock_hash(breaking change tobdk_testenv).TestEnv::wait_until_electrum_tip_syncs_with_bitcoind.Checklists
All Submissions:
New Features:
Bugfixes:
https://claude.ai/code/session_016gJvi98Q65QnanBFxe2UUn
Generated by Claude Code