diff options
| author | DanConwayDev <DanConwayDev@protonmail.com> | 2026-02-23 09:22:41 +0000 |
|---|---|---|
| committer | DanConwayDev <DanConwayDev@protonmail.com> | 2026-02-23 12:05:07 +0000 |
| commit | 9f15929b10825c2f55434a98794fc551794cad2b (patch) | |
| tree | 3787a6f76021f7888eb462d1b41e014aa866bf9e | |
| parent | 49b9405dfcbb872686acdd7abc12dc9c94adc2ab (diff) | |
remove recursive relay discovery test
Recursive discovery relied on announcement events being gossiped across
relays regardless of whether they listed the service. Now that
announcements enter purgatory until state event and git data arrive,
cross-relay discovery cannot be triggered by a synced announcement alone,
making the three-relay recursive discovery scenario impossible.
| -rw-r--r-- | tests/sync/discovery.rs | 131 | ||||
| -rw-r--r-- | tests/sync/mod.rs | 10 |
2 files changed, 4 insertions, 137 deletions
diff --git a/tests/sync/discovery.rs b/tests/sync/discovery.rs index 5fcda69..d45a290 100644 --- a/tests/sync/discovery.rs +++ b/tests/sync/discovery.rs | |||
| @@ -3,10 +3,6 @@ | |||
| 3 | //! Tests for relay discovery from announcement events. | 3 | //! Tests for relay discovery from announcement events. |
| 4 | //! When a relay receives an announcement listing another relay, | 4 | //! When a relay receives an announcement listing another relay, |
| 5 | //! it should discover and connect to that relay to sync events. | 5 | //! it should discover and connect to that relay to sync events. |
| 6 | //! | ||
| 7 | //! # Tests | ||
| 8 | //! - Test 2: Direct Layer 3 discovery from Layer 2 | ||
| 9 | //! - Test 3: Recursive multi-hop Layer 3 discovery | ||
| 10 | 6 | ||
| 11 | use std::time::Duration; | 7 | use std::time::Duration; |
| 12 | 8 | ||
| @@ -240,130 +236,3 @@ async fn test_relay_discovery_via_announcements_with_historic_sync() { | |||
| 240 | ); | 236 | ); |
| 241 | } | 237 | } |
| 242 | 238 | ||
| 243 | /// Test 3: 3-relay recursive discovery - relay discovers third relay through bootstrap | ||
| 244 | /// | ||
| 245 | /// Scenario: | ||
| 246 | /// ```text | ||
| 247 | /// relay_a (SUT) relay_b (bootstrap) relay_c (discovered) | ||
| 248 | /// │ │ │ | ||
| 249 | /// │ │ has announcement_x │ has announcement_y | ||
| 250 | /// │ │ listing A+B+C │ listing A+C | ||
| 251 | /// │ │ │ | ||
| 252 | /// ├────connect──────────► │ | ||
| 253 | /// │◄───sync announcement_x─────────────────────── | ||
| 254 | /// │ │ | ||
| 255 | /// │ discovers relay_c from announcement_x │ | ||
| 256 | /// │ │ | ||
| 257 | /// ├─────────────connect─────────────────────────► | ||
| 258 | /// │◄────────────sync announcement_y─────────────┘ | ||
| 259 | /// ``` | ||
| 260 | /// | ||
| 261 | /// This tests that relay_a: | ||
| 262 | /// 1. Connects to relay_b (configured as bootstrap) | ||
| 263 | /// 2. Receives announcement_x which lists relay_c | ||
| 264 | /// 3. Discovers and connects to relay_c | ||
| 265 | /// 4. Syncs announcement_y from relay_c | ||
| 266 | /// | ||
| 267 | #[tokio::test] | ||
| 268 | async fn test_recursive_relay_discovery_via_announcements_with_historic_sync() { | ||
| 269 | // 1. Start all three relays | ||
| 270 | |||
| 271 | // relay_b - will be the bootstrap relay, has announcement_x | ||
| 272 | let relay_b = TestRelay::start().await; | ||
| 273 | println!( | ||
| 274 | "relay_b (bootstrap) started at {} (domain: {})", | ||
| 275 | relay_b.url(), | ||
| 276 | relay_b.domain() | ||
| 277 | ); | ||
| 278 | |||
| 279 | // relay_c - will be discovered via announcement_x, has announcement_y | ||
| 280 | let relay_c = TestRelay::start().await; | ||
| 281 | println!( | ||
| 282 | "relay_c (to be discovered) started at {} (domain: {})", | ||
| 283 | relay_c.url(), | ||
| 284 | relay_c.domain() | ||
| 285 | ); | ||
| 286 | |||
| 287 | // relay_a - SUT, starts with relay_b as bootstrap | ||
| 288 | let relay_a = TestRelay::start_with_sync(Some(relay_b.url().to_string())).await; | ||
| 289 | println!( | ||
| 290 | "relay_a (SUT) started at {} (domain: {})", | ||
| 291 | relay_a.url(), | ||
| 292 | relay_a.domain() | ||
| 293 | ); | ||
| 294 | |||
| 295 | // 2. Create test keys (one for each announcement) | ||
| 296 | let keys_x = Keys::generate(); | ||
| 297 | let keys_y = Keys::generate(); | ||
| 298 | |||
| 299 | // 3. Set up announcement_x on relay_b (lists all three relays: A+B+C) with git data | ||
| 300 | let domains_x = vec![relay_a.domain(), relay_b.domain(), relay_c.domain()]; | ||
| 301 | let domain_refs_x: Vec<&str> = domains_x.iter().map(|s| s.as_str()).collect(); | ||
| 302 | |||
| 303 | let (announcement_x, _git_dir_b) = | ||
| 304 | setup_announcement_on_relay(&relay_b, &keys_x, &domain_refs_x, "repo-x-all-relays").await; | ||
| 305 | let announcement_x_id = announcement_x.id; | ||
| 306 | println!("announcement_x {} set up on relay_b with git data (listing A+B+C)", announcement_x_id); | ||
| 307 | |||
| 308 | // 4. Set up announcement_y on relay_c (lists only A+C, NOT B) with git data | ||
| 309 | let domains_y = vec![relay_a.domain(), relay_c.domain()]; | ||
| 310 | let domain_refs_y: Vec<&str> = domains_y.iter().map(|s| s.as_str()).collect(); | ||
| 311 | |||
| 312 | let (announcement_y, _git_dir_c) = | ||
| 313 | setup_announcement_on_relay(&relay_c, &keys_y, &domain_refs_y, "repo-y-ac-only").await; | ||
| 314 | let announcement_y_id = announcement_y.id; | ||
| 315 | println!("announcement_y {} set up on relay_c with git data (listing A+C only)", announcement_y_id); | ||
| 316 | |||
| 317 | // 7. Wait for relay_a to: | ||
| 318 | // - Sync from bootstrap relay_b (gets announcement_x) | ||
| 319 | // - Discover relay_c from announcement_x's relays tag | ||
| 320 | // - Connect to relay_c and sync announcement_y | ||
| 321 | // With purgatory, each relay needs to: sync announcement → purgatory → sync state event → | ||
| 322 | // immediate purgatory sync → fetch git data → promote. Allow extra time for this. | ||
| 323 | println!("Waiting 12s for recursive relay discovery (with purgatory flow)..."); | ||
| 324 | tokio::time::sleep(Duration::from_secs(12)).await; | ||
| 325 | |||
| 326 | // 8. Verify announcement_x was synced to relay_a (from bootstrap relay_b) | ||
| 327 | let filter_x = Filter::new() | ||
| 328 | .kind(Kind::GitRepoAnnouncement) | ||
| 329 | .author(keys_x.public_key()); | ||
| 330 | |||
| 331 | let announcement_x_synced = | ||
| 332 | wait_for_event_on_relay(relay_a.url(), filter_x, Duration::from_secs(5)).await; | ||
| 333 | |||
| 334 | println!( | ||
| 335 | "announcement_x {} synced to relay_a: {}", | ||
| 336 | announcement_x_id, announcement_x_synced | ||
| 337 | ); | ||
| 338 | |||
| 339 | // 9. Verify announcement_y was synced to relay_a (from discovered relay_c) | ||
| 340 | let filter_y = Filter::new() | ||
| 341 | .kind(Kind::GitRepoAnnouncement) | ||
| 342 | .author(keys_y.public_key()); | ||
| 343 | |||
| 344 | let announcement_y_synced = | ||
| 345 | wait_for_event_on_relay(relay_a.url(), filter_y, Duration::from_secs(5)).await; | ||
| 346 | |||
| 347 | println!( | ||
| 348 | "announcement_y {} synced to relay_a: {}", | ||
| 349 | announcement_y_id, announcement_y_synced | ||
| 350 | ); | ||
| 351 | |||
| 352 | // 10. Cleanup | ||
| 353 | relay_a.stop().await; | ||
| 354 | relay_b.stop().await; | ||
| 355 | relay_c.stop().await; | ||
| 356 | |||
| 357 | // 11. Assertions | ||
| 358 | assert!( | ||
| 359 | announcement_x_synced, | ||
| 360 | "announcement_x {} should have synced from bootstrap relay_b to relay_a", | ||
| 361 | announcement_x_id | ||
| 362 | ); | ||
| 363 | |||
| 364 | assert!( | ||
| 365 | announcement_y_synced, | ||
| 366 | "announcement_y {} should have synced from discovered relay_c to relay_a (recursive discovery)", | ||
| 367 | announcement_y_id | ||
| 368 | ); | ||
| 369 | } | ||
diff --git a/tests/sync/mod.rs b/tests/sync/mod.rs index 400341f..70c6981 100644 --- a/tests/sync/mod.rs +++ b/tests/sync/mod.rs | |||
| @@ -82,14 +82,12 @@ | |||
| 82 | //! **Example from `discovery.rs`:** | 82 | //! **Example from `discovery.rs`:** |
| 83 | //! ```rust | 83 | //! ```rust |
| 84 | //! #[tokio::test] | 84 | //! #[tokio::test] |
| 85 | //! async fn test_recursive_relay_discovery() { | 85 | //! async fn test_discovers_layer3_via_layer2() { |
| 86 | //! // Multi-relay orchestration | 86 | //! // Multi-relay orchestration |
| 87 | //! let relay1 = TestRelay::start().await; | 87 | //! let relay_a = TestRelay::start().await; |
| 88 | //! let relay2 = TestRelay::start().await; | 88 | //! let relay_b = TestRelay::start_with_sync(None).await; |
| 89 | //! let relay3 = TestRelay::start().await; | ||
| 90 | //! | 89 | //! |
| 91 | //! // relay1 announces relay2, relay2 announces relay3 | 90 | //! // relay_b receives announcement listing relay_a, discovers and syncs from it |
| 92 | //! // Verify relay1 discovers relay3 through chain | ||
| 93 | //! } | 91 | //! } |
| 94 | //! ``` | 92 | //! ``` |
| 95 | //! | 93 | //! |