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 <noreply@anthropic.com>
This commit is contained in:
DanConwayDev
2026-09-17 18:22:34 +00:00
co-authored by Claude Fable 5.1
parent 6c3b33e3a6
commit 0c755beb44
3 changed files with 5 additions and 11 deletions
+1 -1
View File
@@ -454,7 +454,7 @@ async fn test_pagination_for_large_historic_sync() {
.add_relay(syncing.url()) .add_relay(syncing.url())
.await .await
.expect("Failed to add syncing relay to client"); .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. // Poll until every issue has paginated across, up to a bounded deadline.
let deadline = tokio::time::Instant::now() + Duration::from_secs(30); let deadline = tokio::time::Instant::now() + Duration::from_secs(30);
+2 -2
View File
@@ -486,7 +486,7 @@ async fn test_live_sync_layer3_events() {
.authenticator(SignerAuthenticator::new(temp_keys)) .authenticator(SignerAuthenticator::new(temp_keys))
.build(); .build();
if client.add_relay(relay_b.url()).await.is_ok() { 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); 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<Event>; let events_found: Vec<Event>;
if client.add_relay(relay_b.url()).await.is_ok() { 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()); let filter = Filter::new().kind(Kind::GitIssue).author(keys.public_key());
+2 -8
View File
@@ -159,10 +159,7 @@ async fn purgatory_fetch_batches_available_tips_and_isolates_missing_oids() {
.add_relay(source.url()) .add_relay(source.url())
.await .await
.expect("add source relay"); .expect("add source relay");
source_client crate::common::relay::connect_client(&source_client).await;
.connect()
.and_wait(Duration::from_secs(30))
.await;
source_client source_client
.send_event(&source_announcement) .send_event(&source_announcement)
.await .await
@@ -239,10 +236,7 @@ async fn purgatory_fetch_batches_available_tips_and_isolates_missing_oids() {
.add_relay(mock.url()) .add_relay(mock.url())
.await .await
.expect("add mock relay"); .expect("add mock relay");
mock_client crate::common::relay::connect_client(&mock_client).await;
.connect()
.and_wait(Duration::from_secs(30))
.await;
mock_client mock_client
.send_event(&syncing_announcement) .send_event(&syncing_announcement)
.await .await