From e14062809385c82a2ed5fda4ea79254d0e00e435 Mon Sep 17 00:00:00 2001 From: Elias Rohrer Date: Mon, 16 Nov 2026 12:19:46 +0100 Subject: [PATCH 1/3] Wait for the sweep in force-close test helper `settle_force_close_balance` asserted that the sweeper tracks the closed channel's output right after the sync that matured it. However, the output only reaches the sweeper once the `SpendableOutputs` event was handled in the background, and its sweep is only broadcast on a subsequent sync. On a slow CI runner the check could hence run while the funds were no longer a lightning balance and not yet a pending sweep balance, failing `channel_full_cycle_force_close`. We now keep syncing until the sweeper reports the sweep as broadcast before checking the balances. Co-Authored-By: HAL 9000 --- tests/common/mod.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/tests/common/mod.rs b/tests/common/mod.rs index 1ebd5b25bf..278caa461c 100644 --- a/tests/common/mod.rs +++ b/tests/common/mod.rs @@ -620,6 +620,18 @@ async fn settle_force_close_balance( 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); From 43081c3dbd371755bf519be0bb07a8df0d064552 Mon Sep 17 00:00:00 2001 From: Elias Rohrer Date: Mon, 16 Nov 2026 12:19:46 +0100 Subject: [PATCH 2/3] Poll for peer connections in restart test `connection_restart_behavior` slept for five seconds each time it waited for a connection to be established, i.e., 20 seconds per run, even though the peers usually connect right away. We now poll the peer lists instead and only keep the fixed wait where the test checks that no reconnect happens, as that can't be polled for. Co-Authored-By: HAL 9000 --- tests/integration_tests_rust.rs | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/tests/integration_tests_rust.rs b/tests/integration_tests_rust.rs index 8ce5bdb236..734d82970c 100644 --- a/tests/integration_tests_rust.rs +++ b/tests/integration_tests_rust.rs @@ -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); @@ -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); @@ -2971,6 +2978,9 @@ async fn do_connection_restart_behavior(persist: bool) { assert_eq!(peer_details_b.is_persisted, false); assert!(peer_details_a.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()); } From 2ff7183891d63d7cf991fa5e20168e5259097ce3 Mon Sep 17 00:00:00 2001 From: Elias Rohrer Date: Tue, 17 Nov 2026 13:14:29 +0100 Subject: [PATCH 3/3] Check node B's connection state after restart The persisted-peer branch of the connection restart test asserted node A's connection state twice and never checked node B's, so a missing reconnect on B's side would not have been caught by that assertion. Assert on node B's peer details instead, as originally intended. Co-Authored-By: HAL 9000 --- tests/integration_tests_rust.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/integration_tests_rust.rs b/tests/integration_tests_rust.rs index 734d82970c..3b2e7dfffc 100644 --- a/tests/integration_tests_rust.rs +++ b/tests/integration_tests_rust.rs @@ -2976,7 +2976,7 @@ 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;