Skip to content

Commit

Permalink
f No use continuing if we never subscribed
Browse files Browse the repository at this point in the history
So try again after some time and panic if it still fails
  • Loading branch information
tnull committed Feb 15, 2023
1 parent 506537f commit ae0002c
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions lightning-transaction-sync/tests/integration_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}

Expand Down

0 comments on commit ae0002c

Please sign in to comment.