Skip to content

Commit d1a6d1d

Browse files
committed
exponential backoff fix
1 parent 61bed84 commit d1a6d1d

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

tests/common/mod.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -448,16 +448,10 @@ pub(crate) fn wait_for_block<E: ElectrumApi>(electrs: &E, min_height: usize) {
448448
}
449449

450450
pub(crate) fn wait_for_tx<E: ElectrumApi>(electrs: &E, txid: Txid) {
451-
let mut tx_res = electrs.transaction_get(&txid);
452-
loop {
453-
if tx_res.is_ok() {
454-
break;
455-
}
456-
tx_res = exponential_backoff_poll(|| {
457-
electrs.ping().unwrap();
458-
Some(electrs.transaction_get(&txid))
459-
});
460-
}
451+
exponential_backoff_poll(|| {
452+
electrs.ping().unwrap();
453+
electrs.transaction_get(&txid).ok()
454+
});
461455
}
462456

463457
pub(crate) fn wait_for_outpoint_spend<E: ElectrumApi>(electrs: &E, outpoint: OutPoint) {
@@ -500,9 +494,13 @@ where
500494
pub(crate) fn premine_and_distribute_funds<E: ElectrumApi>(
501495
bitcoind: &BitcoindClient, electrs: &E, addrs: Vec<Address>, amount: Amount,
502496
) {
497+
println!("JOOST: Premining...");
503498
premine_blocks(bitcoind, electrs);
504499

500+
println!("JOOST: Distributing funds...");
505501
distribute_funds_unconfirmed(bitcoind, electrs, addrs, amount);
502+
503+
println!("JOOST: Generate blocks and wait...");
506504
generate_blocks_and_wait(bitcoind, electrs, 1);
507505
}
508506

@@ -530,6 +528,8 @@ pub(crate) fn distribute_funds_unconfirmed<E: ElectrumApi>(
530528
.parse()
531529
.unwrap();
532530

531+
println!("JOOST: wait for txid {}", txid);
532+
533533
wait_for_tx(electrs, txid);
534534

535535
txid

0 commit comments

Comments
 (0)