mirror of
https://relay.ngit.dev/npub15qydau2hjma6ngxkl2cyar74wzyjshvl65za5k5rl69264ar2exs5cyejr/ngit-grasp.git
synced 2026-10-05 15:08:24 +00:00
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:
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user