Skip to content

Commit 9fe087a

Browse files
authored
Merge pull request #74 from lightningdevkit/fix-test-reliability
Wait for LSP channel readiness in tests
2 parents 600cc7a + 09e5d42 commit 9fe087a

1 file changed

Lines changed: 34 additions & 0 deletions

File tree

orange-sdk/src/trusted_wallet/dummy.rs

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,40 @@ impl DummyTrustedWallet {
284284
panic!("No usable channels found {channels:?}");
285285
}
286286

287+
for _ in 0..iterations {
288+
let lsp_clone = Arc::clone(&lsp);
289+
let ldk_node_id = ldk_node.node_id();
290+
let is_usable = blocking_with_timeout(
291+
"dummy LSP channel list",
292+
Duration::from_secs(5),
293+
move || {
294+
lsp_clone
295+
.list_channels()
296+
.iter()
297+
.any(|c| c.counterparty_node_id == ldk_node_id && c.is_usable)
298+
},
299+
)
300+
.await;
301+
if is_usable {
302+
break;
303+
}
304+
tokio::time::sleep(Duration::from_secs(1)).await;
305+
}
306+
307+
let lsp_clone = Arc::clone(&lsp);
308+
let ldk_node_id = ldk_node.node_id();
309+
let lsp_channels = blocking_with_timeout(
310+
"dummy final LSP channel list",
311+
Duration::from_secs(5),
312+
move || lsp_clone.list_channels(),
313+
)
314+
.await;
315+
if !lsp_channels.iter().any(|c| c.counterparty_node_id == ldk_node_id && c.is_usable) {
316+
panic!(
317+
"No usable LSP-side channel found for dummy node {ldk_node_id}: {lsp_channels:?}"
318+
);
319+
}
320+
287321
DummyTrustedWallet { current_bal_msats, payments, ldk_node, payment_success_flag }
288322
}
289323

0 commit comments

Comments
 (0)