diff --git a/tests/common/sync_helpers.rs b/tests/common/sync_helpers.rs index dbd3aca..668b5fc 100644 --- a/tests/common/sync_helpers.rs +++ b/tests/common/sync_helpers.rs @@ -45,6 +45,24 @@ pub async fn wait_for_new_descendant_live_generation( } } +pub async fn wait_for_full_repo_live_coverage(relay: &TestRelay, timeout: Duration) { + let deadline = tokio::time::Instant::now() + timeout; + loop { + let log = std::fs::read_to_string(relay.log_path()).unwrap_or_default(); + let installed = log + .rfind("new_full_repos=1") + .is_some_and(|offset| log[offset..].contains("Extended core live coverage")); + if installed { + return; + } + assert!( + tokio::time::Instant::now() < deadline, + "full-repository live coverage was not installed before the deadline" + ); + tokio::task::yield_now().await; + } +} + // NOTE: Using rust-nostr Kind variants: // - Kind::GitIssue.as_u16() -> Kind::GitIssue (1621) // - Kind::Comment.as_u16() -> Kind::Comment (1111) diff --git a/tests/sync/metrics.rs b/tests/sync/metrics.rs index 1b79413..9c60bff 100644 --- a/tests/sync/metrics.rs +++ b/tests/sync/metrics.rs @@ -18,7 +18,8 @@ use crate::common::{ port, sync_helpers::{ create_repo_announcement, fetch_metrics, setup_announcement_on_relay, - wait_for_sync_connection, MetricsTestHarness, ParsedMetrics, TestClient, + wait_for_full_repo_live_coverage, wait_for_sync_connection, MetricsTestHarness, + ParsedMetrics, TestClient, }, TestRelay, }; @@ -433,8 +434,7 @@ async fn test_live_sync_event_count() { .await .expect("Sync connection should be established"); - // Additional delay to ensure purgatory promotion completes on syncing relay - tokio::time::sleep(Duration::from_secs(4)).await; + wait_for_full_repo_live_coverage(&syncing_relay, Duration::from_secs(20)).await; // Now add Layer 2 patch events (not announcements) - these are accepted immediately // (Layer 2 events are accepted directly to DB, no purgatory)