Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions tests/common/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -620,6 +620,18 @@ async fn settle_force_close_balance<E: ElectrumApi>(
peer_node.sync_wallets().unwrap();
}

// The sweeper only tracks the output once the `SpendableOutputs` event was handled in the
// background, and only broadcasts the sweep on a subsequent sync.
exponential_backoff_poll(|| {
node.sync_wallets().unwrap();
let pending_balances = node.list_balances().pending_balances_from_channel_closures;
let is_broadcast = pending_balances
.iter()
.any(|balance| !matches!(balance, PendingSweepBalance::PendingBroadcast { .. }));
is_broadcast.then_some(())
})
.await;

let balances = node.list_balances();
assert!(balances.lightning_balances.is_empty(), "Unexpected balance state: {:?}", balances);
assert_eq!(balances.pending_balances_from_channel_closures.len(), 1);
Expand Down
22 changes: 16 additions & 6 deletions tests/integration_tests_rust.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2943,8 +2943,11 @@ async fn do_connection_restart_behavior(persist: bool) {
assert_eq!(peer_details_a.is_persisted, persist);
assert!(peer_details_a.is_connected);

// Sleep a bit to allow for the connection to happen.
tokio::time::sleep(std::time::Duration::from_secs(5)).await;
// Wait for node B to register the inbound connection.
common::exponential_backoff_poll(|| {
node_b.list_peers().iter().any(|p| p.is_connected).then_some(())
})
.await;

let peer_details_b = node_b.list_peers().first().unwrap().clone();
assert_eq!(peer_details_b.node_id, node_id_a);
Expand All @@ -2957,10 +2960,14 @@ async fn do_connection_restart_behavior(persist: bool) {
node_b.start().unwrap();
node_a.start().unwrap();

// Sleep a bit to allow for the reconnect to happen.
tokio::time::sleep(std::time::Duration::from_secs(5)).await;

if persist {
// Wait for the reconnect to happen.
common::exponential_backoff_poll(|| {
let is_connected = |node: &TestNode| node.list_peers().iter().any(|p| p.is_connected);
(is_connected(&node_a) && is_connected(&node_b)).then_some(())
})
.await;

let peer_details_a = node_a.list_peers().first().unwrap().clone();
assert_eq!(peer_details_a.node_id, node_id_b);
assert_eq!(peer_details_a.is_persisted, persist);
Expand All @@ -2969,8 +2976,11 @@ async fn do_connection_restart_behavior(persist: bool) {
let peer_details_b = node_b.list_peers().first().unwrap().clone();
assert_eq!(peer_details_b.node_id, node_id_a);
assert_eq!(peer_details_b.is_persisted, false);
assert!(peer_details_a.is_connected);
assert!(peer_details_b.is_connected);
} else {
// Sleep a bit so that an unexpected reconnect would have had time to happen.
tokio::time::sleep(std::time::Duration::from_secs(5)).await;

assert!(node_a.list_peers().is_empty());
assert!(node_b.list_peers().is_empty());
}
Expand Down
Loading