From ae0002cf38809c5ecb34c31f463c84548f887256 Mon Sep 17 00:00:00 2001 From: Elias Rohrer Date: Tue, 14 Feb 2023 19:02:05 -0600 Subject: [PATCH] f No use continuing if we never subscribed So try again after some time and panic if it still fails --- .../tests/integration_tests.rs | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) 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; } }