Skip to content

Commit ae0002c

Browse files
committed
f No use continuing if we never subscribed
So try again after some time and panic if it still fails
1 parent 506537f commit ae0002c

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

lightning-transaction-sync/tests/integration_tests.rs

+9-5
Original file line numberDiff line numberDiff line change
@@ -64,19 +64,23 @@ fn generate_blocks_and_wait(num: usize) {
6464
}
6565

6666
fn wait_for_block(min_height: usize) {
67-
let mut cur_height = get_electrsd().client.block_headers_subscribe().map_or(0, |header| header.height);
67+
let mut header = match get_electrsd().client.block_headers_subscribe() {
68+
Ok(header) => header,
69+
Err(_) => {
70+
std::thread::sleep(Duration::from_secs(3));
71+
get_electrsd().client.block_headers_subscribe().expect("failed to subscribe to block headers")
72+
}
73+
};
6874

6975
loop {
70-
if cur_height >= min_height {
76+
if header.height >= min_height {
7177
break;
7278
}
73-
let header = exponential_backoff_poll(|| {
79+
header = exponential_backoff_poll(|| {
7480
get_electrsd().trigger().expect("failed to trigger electrsd");
7581
get_electrsd().client.ping().expect("failed to ping electrsd");
7682
get_electrsd().client.block_headers_pop().expect("failed to pop block header")
7783
});
78-
79-
cur_height = header.height;
8084
}
8185
}
8286

0 commit comments

Comments
 (0)