Refactor TestEnv::wait_until_electrum_sees_block to be more concrete.#1640
Open
evanlinjin wants to merge 1 commit intobitcoindevkit:masterfrom
Open
Refactor TestEnv::wait_until_electrum_sees_block to be more concrete.#1640evanlinjin wants to merge 1 commit intobitcoindevkit:masterfrom
TestEnv::wait_until_electrum_sees_block to be more concrete.#1640evanlinjin wants to merge 1 commit intobitcoindevkit:masterfrom
Conversation
4684a43 to
ce565ac
Compare
evanlinjin
commented
Oct 4, 2024
Add inputs `block_height` and `block_hash` so that it is more concrete what exactly we are waiting for. Introduce `TestEnv::wait_until_electrum_tip_syncs_with_bitcoind`.
ce565ac to
0025f14
Compare
LagginTimes
reviewed
May 17, 2025
| // Check that no new anchors are added during current reorg. | ||
| assert!(initial_anchors.is_superset(&update.tx_update.anchors)); | ||
|
|
||
| // TODO: Fails here. |
Contributor
There was a problem hiding this comment.
Nit: This is now outdated since the test passes.
| self.electrsd.client.block_headers_subscribe()?; | ||
| /// Wait until Electrum is aware of a block of a given `block_height` (and optionally, matches | ||
| /// the given `block_hash`). | ||
| pub fn wait_until_electrum_sees_block( |
Contributor
There was a problem hiding this comment.
Since wait_until_electrum_sees_block now accepts any height and optional hash, would it be helpful to add unit tests for a non-tip height or a mismatched hash?
Contributor
There was a problem hiding this comment.
Is wait_until_electrum_sees_block(non_tip_height, Some(hash), …) still expected to succeed when invoked after wait_until_electrum_tip_syncs_with_bitcoind(), given that the chain tip has already advanced past non_tip_height?
See: LagginTimes@1a055c7 for the tests that prompted this question.
8 tasks
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
Before, the signature of
TestEnv::wait_until_electrum_sees_blockonly took in adelay: Durationinput. It was not clear which block we were waiting for exactly. This PR adds 2 inputs to this method: ablock_heighttarget, and an optionalblock_hashmethod. Just having theblock_heightmethod waits until Electrs sees a block at that height, and all spk histories are up to date to that block. If the caller also includes ablock_hash, we wait until Electrs sees a block at the given height, also has that block hash.We also introduce a new method:
TestEnv::wait_until_electrum_tip_syncs_with_bitcoind. The method name is self-explanatory.Notes to the reviewers
It's a breaking change for
bdk_testenv. The API now makes more sense.Changelog notice
TestEnv::wait_until_electrum_sees_blockto have a height target, and an optional block hash target.TestEnv::wait_until_electrum_tip_syncs_with_bitcoind.Checklists
All Submissions:
cargo fmtandcargo clippybefore committingNew Features: