test(common): connect verify_event_not_served through connect_client

verify_event_not_served connected with `Client::connect` and then slept
100 ms per status poll for up to two seconds before the first query. The
sleep-first loop paid at least one interval on every call and, under
scheduler pressure, could miss the connected transition and report a
false connection failure.

Use the shared `connect_client` helper, which awaits the connection
attempt itself and fails the test with the SDK's reason. The absence
check that follows is unchanged.

Validation: `cargo check -p ngit-grasp --tests`; the callers are covered
by the purgatory and lifecycle binaries measured in the following
commits.

Assisted-by: Claude Fable 5.1
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
DanConwayDev
2026-09-18 14:23:08 +00:00
co-authored by Claude Fable 5.1
parent 5ef7480a01
commit 654102a17d
+3 -18
View File
@@ -16,6 +16,8 @@ use nostr_sdk::prelude::*;
use std::path::Path;
use std::time::Duration;
use super::relay::connect_client;
// NOTE: Using rust-nostr Kind variants:
// - Kind::RepoState.as_u16() -> Kind::RepoState (30618)
// - Kind::GitPullRequest.as_u16() -> Kind::GitPullRequest (1618)
@@ -452,24 +454,7 @@ pub async fn verify_event_not_served(
.add_relay(relay_url)
.await
.map_err(|e| format!("Failed to add relay: {}", e))?;
client.connect().await;
// Wait for connection
let mut connected = false;
for _ in 0..20 {
tokio::time::sleep(Duration::from_millis(100)).await;
let relays = client.relays().await;
if relays.values().any(|r| r.status().is_connected()) {
connected = true;
break;
}
}
if !connected {
client.disconnect().await;
return Err("Failed to connect to relay".to_string());
}
connect_client(&client).await;
// Check that event is NOT served
let filter = Filter::new().id(*event_id);