diff --git a/lightning-transaction-sync/tests/integration_tests.rs b/lightning-transaction-sync/tests/integration_tests.rs index 40f5e496b78..5a40f44a9d6 100644 --- a/lightning-transaction-sync/tests/integration_tests.rs +++ b/lightning-transaction-sync/tests/integration_tests.rs @@ -64,19 +64,23 @@ fn generate_blocks_and_wait(num: usize) { } fn wait_for_block(min_height: usize) { - let mut cur_height = get_electrsd().client.block_headers_subscribe().map_or(0, |header| header.height); + let mut header = match get_electrsd().client.block_headers_subscribe() { + Ok(header) => header, + Err(_) => { + std::thread::sleep(Duration::from_secs(3)); + get_electrsd().client.block_headers_subscribe().expect("failed to subscribe to block headers") + } + }; loop { - if cur_height >= min_height { + if header.height >= min_height { break; } - let header = exponential_backoff_poll(|| { + header = exponential_backoff_poll(|| { get_electrsd().trigger().expect("failed to trigger electrsd"); get_electrsd().client.ping().expect("failed to ping electrsd"); get_electrsd().client.block_headers_pop().expect("failed to pop block header") }); - - cur_height = header.height; } }