test(sync): wait for full live coverage before metric delivery

A connected source socket and a fixed delay do not prove that purgatory promotion has installed full-repository filters. The live-event metric test could publish both patches during state-only coverage and correctly observe no live sync increments.

Wait with a bounded deadline for the full-repository AddFilters generation to complete its core live extension before publishing. This keeps the metric assertion tied specifically to live delivery.

Validated with the focused live sync event-count integration test.
This commit is contained in:
DanConwayDev
2026-08-12 15:34:02 +00:00
parent b3938c84dd
commit e3e0cfd3a5
2 changed files with 21 additions and 3 deletions
+18
View File
@@ -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)
+3 -3
View File
@@ -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)