mirror of
https://relay.ngit.dev/npub15qydau2hjma6ngxkl2cyar74wzyjshvl65za5k5rl69264ar2exs5cyejr/ngit-grasp.git
synced 2026-10-05 15:08:24 +00:00
Production soak of bccbb54 showed nostr-pub.wellorder.net disconnect at 16:30:57 while its connection worker was still fetching NIP-11. The delayed result was accepted at 16:31:19, marked Healthy, and started fresh sync against an already dead SDK session. Because the event loop was spawned after the disconnect notification, that lifecycle could also remain falsely connected.
Revalidate the SDK relay status when a successful setup result reaches the sync actor. A peer that vanished after the handshake but before setup completed is handled through the existing failed-attempt path, which restores Disconnected state and records backoff without starting subscriptions or an event loop.
A deterministic dual-protocol fixture coordinates WebSocket teardown with the NIP-11 request and proves the stale result is rejected. The earlier flapping fixture now includes a short established dwell so it continues to model post-setup failure rather than this new setup race.
Correctness assumes RelayStatus::Connected is the authoritative final setup gate. A disconnect immediately after that gate remains handled by the normal event-loop notification path. NIP-11 timeout policy, reconnect pacing, and broader lifecycle serialization are excluded.
Validated with cargo test --lib (650 passed), cargo test --test sync (89 passed, 1 ignored), both focused reconnect lifecycle scenarios, and nix build .#ngit-grasp.
50 lines
1.5 KiB
Rust
50 lines
1.5 KiB
Rust
//! Proactive Sync Integration Tests
|
|
//!
|
|
//! This test file organizes tests for ngit-grasp's proactive sync functionality.
|
|
//! Tests are grouped into submodules by sync scenario:
|
|
//!
|
|
//! - `historic_sync` - Tests for sync from pre-configured bootstrap relay (historic events)
|
|
//! - `discovery` - Tests for relay discovery from announcement events
|
|
//! - `live_sync` - Tests for real-time sync after connection established
|
|
//! - `tag_variations` - Tests for different Layer 2/3 tag types
|
|
//! - `catchup` - Tests for catchup sync after disconnect (not yet implemented)
|
|
//! - `metrics` - Tests for Prometheus metrics integration
|
|
//!
|
|
//! # Running Tests
|
|
//!
|
|
//! ```bash
|
|
//! # Run all sync tests
|
|
//! cargo test --test sync
|
|
//!
|
|
//! # Run with output
|
|
//! cargo test --test sync -- --nocapture
|
|
//!
|
|
//! # Run specific test
|
|
//! cargo test --test sync test_bootstrap_syncs -- --nocapture
|
|
//!
|
|
//! # Run ignored tests (like catchup)
|
|
//! cargo test --test sync -- --ignored
|
|
//! ```
|
|
|
|
// Include the common test utilities
|
|
mod common;
|
|
|
|
// Include sync test submodules (located in tests/sync/)
|
|
mod sync {
|
|
pub mod adaptive_pagination;
|
|
pub mod catchup;
|
|
pub mod discovery;
|
|
pub mod historic_recovery;
|
|
pub mod historic_sync;
|
|
pub mod live_sync;
|
|
pub mod maintainer_reprocessing;
|
|
pub mod metrics;
|
|
pub mod naughty_list_scheduling;
|
|
pub mod neg_concurrency;
|
|
pub mod purgatory_fetch;
|
|
pub mod reconnect_backoff;
|
|
pub mod req_concurrency;
|
|
pub mod stale_connect_result;
|
|
pub mod tag_variations;
|
|
}
|