Skip to content

Commit 52da8e1

Browse files
committed
Remove uses of sleep when waiting for syncs
1 parent 3475015 commit 52da8e1

1 file changed

Lines changed: 32 additions & 4 deletions

File tree

‎orange-sdk/tests/integration_tests.rs‎

Lines changed: 32 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -451,7 +451,14 @@ fn run_test_pay_lightning_from_self_custody(amountless: bool) {
451451

452452
// wait for sync
453453
generate_blocks(&bitcoind, 6);
454-
tokio::time::sleep(Duration::from_secs(5)).await;
454+
test_utils::wait_for_condition("wallet sync after channel open", || async {
455+
wallet.channels().iter().any(|a| a.confirmations.is_some_and(|c| c > 0) && a.is_usable)
456+
&& third_party
457+
.list_channels()
458+
.iter()
459+
.any(|a| a.confirmations.is_some_and(|c| c > 0) && a.is_usable)
460+
})
461+
.await;
455462

456463
let starting_bal = wallet.get_balance().await.unwrap();
457464

@@ -535,7 +542,14 @@ fn run_test_pay_bolt12_from_self_custody(amountless: bool) {
535542

536543
// wait for sync
537544
generate_blocks(&bitcoind, 6);
538-
tokio::time::sleep(Duration::from_secs(5)).await;
545+
test_utils::wait_for_condition("wallet sync after channel open", || async {
546+
wallet.channels().iter().any(|a| a.confirmations.is_some_and(|c| c > 0) && a.is_usable)
547+
&& third_party
548+
.list_channels()
549+
.iter()
550+
.any(|a| a.confirmations.is_some_and(|c| c > 0) && a.is_usable)
551+
})
552+
.await;
539553

540554
let starting_bal = wallet.get_balance().await.unwrap();
541555

@@ -1238,7 +1252,14 @@ fn test_concurrent_payments() {
12381252

12391253
// Wait for sync
12401254
generate_blocks(&bitcoind, 6);
1241-
tokio::time::sleep(Duration::from_secs(5)).await;
1255+
test_utils::wait_for_condition("wallet sync after channel open", || async {
1256+
wallet.channels().iter().any(|a| a.confirmations.is_some_and(|c| c > 0) && a.is_usable)
1257+
&& third_party
1258+
.list_channels()
1259+
.iter()
1260+
.any(|a| a.confirmations.is_some_and(|c| c > 0) && a.is_usable)
1261+
})
1262+
.await;
12421263

12431264
// receive to trusted wallet as well
12441265
let uri =
@@ -1817,7 +1838,14 @@ fn test_lsp_connectivity_fallback() {
18171838

18181839
// confirm channel
18191840
generate_blocks(&bitcoind, 6);
1820-
tokio::time::sleep(Duration::from_secs(5)).await;
1841+
test_utils::wait_for_condition("wallet sync after channel open", || async {
1842+
wallet.channels().iter().any(|a| a.confirmations.is_some_and(|c| c > 0) && a.is_usable)
1843+
&& third_party
1844+
.list_channels()
1845+
.iter()
1846+
.any(|a| a.confirmations.is_some_and(|c| c > 0) && a.is_usable)
1847+
})
1848+
.await;
18211849

18221850
// spend some of the balance so we have some inbound capacity
18231851
let amount = Amount::from_sats(10_000).unwrap();

0 commit comments

Comments
 (0)