-
Notifications
You must be signed in to change notification settings - Fork 390
Refactor TestEnv::wait_until_electrum_sees_block
to be more concrete.
#1640
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Refactor TestEnv::wait_until_electrum_sees_block
to be more concrete.
#1640
Conversation
4684a43
to
ce565ac
Compare
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
@@ -716,6 +717,7 @@ fn tx_can_become_unconfirmed_after_reorg() -> anyhow::Result<()> { | |||
// Check that no new anchors are added during current reorg. | |||
assert!(initial_anchors.is_superset(&update.tx_update.anchors)); | |||
|
|||
// TODO: Fails here. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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?
Description
Before, the signature of
TestEnv::wait_until_electrum_sees_block
only took in adelay: Duration
input. It was not clear which block we were waiting for exactly. This PR adds 2 inputs to this method: ablock_height
target, and an optionalblock_hash
method. Just having theblock_height
method 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_block
to have a height target, and an optional block hash target.TestEnv::wait_until_electrum_tip_syncs_with_bitcoind
.Checklists
All Submissions:
cargo fmt
andcargo clippy
before committingNew Features: