From 0c755beb44bfcea9e15625ae4a146ec9752a68e9 Mon Sep 17 00:00:00 2001 From: DanConwayDev Date: Thu, 17 Sep 2026 18:22:34 +0000 Subject: [PATCH] test(sync): await connection attempts instead of status notifications Five sync tests waited for relay connections with connect().and_wait(30 s). That call checks the relay status and then subscribes to status notifications; a loopback connection that completes between the two is never observed, and the caller sleeps for the whole timeout. Under scheduler pressure this turns a sub-millisecond connect into a 30 s stall. Use the shared connect_client helper, which awaits the connection attempts through try_connect and fails the test if any relay refuses. Validation: the sync test binary passed (114 tests, 1 ignored) after the change; formatting and all-targets Clippy with warnings denied pass. Assisted-by: Claude Fable 5.1 Co-Authored-By: Claude Fable 5.1 --- tests/sync/historic_sync.rs | 2 +- tests/sync/live_sync.rs | 4 ++-- tests/sync/purgatory_fetch.rs | 10 ++-------- 3 files changed, 5 insertions(+), 11 deletions(-) diff --git a/tests/sync/historic_sync.rs b/tests/sync/historic_sync.rs index 8db7a43..efd2e24 100644 --- a/tests/sync/historic_sync.rs +++ b/tests/sync/historic_sync.rs @@ -454,7 +454,7 @@ async fn test_pagination_for_large_historic_sync() { .add_relay(syncing.url()) .await .expect("Failed to add syncing relay to client"); - client.connect().and_wait(Duration::from_secs(30)).await; + crate::common::relay::connect_client(&client).await; // Poll until every issue has paginated across, up to a bounded deadline. let deadline = tokio::time::Instant::now() + Duration::from_secs(30); diff --git a/tests/sync/live_sync.rs b/tests/sync/live_sync.rs index b815355..a12966c 100644 --- a/tests/sync/live_sync.rs +++ b/tests/sync/live_sync.rs @@ -486,7 +486,7 @@ async fn test_live_sync_layer3_events() { .authenticator(SignerAuthenticator::new(temp_keys)) .build(); if client.add_relay(relay_b.url()).await.is_ok() { - client.connect().and_wait(Duration::from_secs(30)).await; + crate::common::relay::connect_client(&client).await; let fetch_filter = Filter::new().kind(Kind::Comment).id(comment_id); @@ -642,7 +642,7 @@ async fn test_live_sync_event_ordering() { let events_found: Vec; if client.add_relay(relay_b.url()).await.is_ok() { - client.connect().and_wait(Duration::from_secs(30)).await; + crate::common::relay::connect_client(&client).await; let filter = Filter::new().kind(Kind::GitIssue).author(keys.public_key()); diff --git a/tests/sync/purgatory_fetch.rs b/tests/sync/purgatory_fetch.rs index 3fc4f90..92bee40 100644 --- a/tests/sync/purgatory_fetch.rs +++ b/tests/sync/purgatory_fetch.rs @@ -159,10 +159,7 @@ async fn purgatory_fetch_batches_available_tips_and_isolates_missing_oids() { .add_relay(source.url()) .await .expect("add source relay"); - source_client - .connect() - .and_wait(Duration::from_secs(30)) - .await; + crate::common::relay::connect_client(&source_client).await; source_client .send_event(&source_announcement) .await @@ -239,10 +236,7 @@ async fn purgatory_fetch_batches_available_tips_and_isolates_missing_oids() { .add_relay(mock.url()) .await .expect("add mock relay"); - mock_client - .connect() - .and_wait(Duration::from_secs(30)) - .await; + crate::common::relay::connect_client(&mock_client).await; mock_client .send_event(&syncing_announcement) .await