diff options
| author | DanConwayDev <DanConwayDev@protonmail.com> | 2025-12-11 16:53:03 +0000 |
|---|---|---|
| committer | DanConwayDev <DanConwayDev@protonmail.com> | 2025-12-11 16:53:03 +0000 |
| commit | 2a9160836bb87fdea3ae891563b0169c68d1c2ab (patch) | |
| tree | 583c890687beaf7f380fc0be131bdf17485f06fa /tests/sync | |
| parent | 52489d3b1a7d79e164b4cc901b53fd06c05ce1b1 (diff) | |
fix: resolve all fmt and clippy warnings
Main lib (src/):
- Add #[allow(dead_code)] for build_info field (stored to prevent Prometheus unregistration)
- Add #[allow(dead_code)] for first_seen field (reserved for future rate limiting)
- Replace .or_insert_with(RelaySyncNeeds::default) with .or_default()
- Replace manual div_ceil implementations with .div_ceil(100)
Test code (tests/):
- Replace .expect(&format!(...)) with .unwrap_or_else(|_| panic!(...))
- Remove needless borrows in fetch_metrics() calls
- Add #[allow(dead_code)] and #[allow(unused_imports)] to test helpers module
grasp-audit:
- Apply cargo fmt to fix formatting
Diffstat (limited to 'tests/sync')
| -rw-r--r-- | tests/sync/bootstrap.rs | 9 | ||||
| -rw-r--r-- | tests/sync/discovery.rs | 15 | ||||
| -rw-r--r-- | tests/sync/live_sync.rs | 7 | ||||
| -rw-r--r-- | tests/sync/metrics.rs | 6 | ||||
| -rw-r--r-- | tests/sync/tag_variations.rs | 139 |
5 files changed, 101 insertions, 75 deletions
diff --git a/tests/sync/bootstrap.rs b/tests/sync/bootstrap.rs index 8a181c9..174fe28 100644 --- a/tests/sync/bootstrap.rs +++ b/tests/sync/bootstrap.rs | |||
| @@ -167,7 +167,8 @@ async fn test_relay_replays_events_after_restart() { | |||
| 167 | .kind(Kind::Custom(KIND_REPOSITORY_STATE)) | 167 | .kind(Kind::Custom(KIND_REPOSITORY_STATE)) |
| 168 | .author(keys.public_key()); | 168 | .author(keys.public_key()); |
| 169 | 169 | ||
| 170 | let synced_first = wait_for_event_on_relay(relay_b.url(), filter.clone(), Duration::from_secs(5)).await; | 170 | let synced_first = |
| 171 | wait_for_event_on_relay(relay_b.url(), filter.clone(), Duration::from_secs(5)).await; | ||
| 171 | println!("First sync check: {}", synced_first); | 172 | println!("First sync check: {}", synced_first); |
| 172 | 173 | ||
| 173 | // 8. Stop relay_b | 174 | // 8. Stop relay_b |
| @@ -193,7 +194,8 @@ async fn test_relay_replays_events_after_restart() { | |||
| 193 | // 12. Verify announcement is available on new relay_b | 194 | // 12. Verify announcement is available on new relay_b |
| 194 | // The announcement listed the OLD relay_b domain, but since relay_a still | 195 | // The announcement listed the OLD relay_b domain, but since relay_a still |
| 195 | // has the event, new relay_b should be able to sync it via bootstrap | 196 | // has the event, new relay_b should be able to sync it via bootstrap |
| 196 | let synced_after_restart = wait_for_event_on_relay(relay_b_new.url(), filter, Duration::from_secs(5)).await; | 197 | let synced_after_restart = |
| 198 | wait_for_event_on_relay(relay_b_new.url(), filter, Duration::from_secs(5)).await; | ||
| 197 | 199 | ||
| 198 | // 13. Cleanup | 200 | // 13. Cleanup |
| 199 | relay_b_new.stop().await; | 201 | relay_b_new.stop().await; |
| @@ -384,7 +386,8 @@ async fn test_history_sync_without_negentropy() { | |||
| 384 | relay_b_port, | 386 | relay_b_port, |
| 385 | Some(relay_a.url().into()), | 387 | Some(relay_a.url().into()), |
| 386 | true, // disable_negentropy = true | 388 | true, // disable_negentropy = true |
| 387 | ).await; | 389 | ) |
| 390 | .await; | ||
| 388 | println!( | 391 | println!( |
| 389 | "relay_b started at {} (domain: {}) - negentropy DISABLED, will do HISTORY sync", | 392 | "relay_b started at {} (domain: {}) - negentropy DISABLED, will do HISTORY sync", |
| 390 | relay_b.url(), | 393 | relay_b.url(), |
diff --git a/tests/sync/discovery.rs b/tests/sync/discovery.rs index 9e27f9e..ed3e9bb 100644 --- a/tests/sync/discovery.rs +++ b/tests/sync/discovery.rs | |||
| @@ -88,7 +88,8 @@ async fn test_discovers_layer3_via_layer2() { | |||
| 88 | ); | 88 | ); |
| 89 | 89 | ||
| 90 | // 6. Create a patch event (Layer 2) that references the announcement | 90 | // 6. Create a patch event (Layer 2) that references the announcement |
| 91 | let patch = create_event_referencing_repo(&keys, &repo_coord, KIND_PATCH, "Test patch proposal"); | 91 | let patch = |
| 92 | create_event_referencing_repo(&keys, &repo_coord, KIND_PATCH, "Test patch proposal"); | ||
| 92 | let patch_id = patch.id; | 93 | let patch_id = patch.id; |
| 93 | 94 | ||
| 94 | println!("Created patch {} (kind {})", patch_id, patch.kind.as_u16()); | 95 | println!("Created patch {} (kind {})", patch_id, patch.kind.as_u16()); |
| @@ -252,7 +253,8 @@ async fn test_layer2_discovery_with_chain() { | |||
| 252 | let issue_filter = Filter::new() | 253 | let issue_filter = Filter::new() |
| 253 | .kind(Kind::Custom(KIND_ISSUE)) | 254 | .kind(Kind::Custom(KIND_ISSUE)) |
| 254 | .author(keys.public_key()); | 255 | .author(keys.public_key()); |
| 255 | let issue_synced = wait_for_event_on_relay(relay_b.url(), issue_filter, Duration::from_secs(5)).await; | 256 | let issue_synced = |
| 257 | wait_for_event_on_relay(relay_b.url(), issue_filter, Duration::from_secs(5)).await; | ||
| 256 | 258 | ||
| 257 | println!("Sync result:"); | 259 | println!("Sync result:"); |
| 258 | println!(" Issue {} synced: {}", issue_id, issue_synced); | 260 | println!(" Issue {} synced: {}", issue_id, issue_synced); |
| @@ -296,7 +298,7 @@ async fn test_layer2_discovery_with_chain() { | |||
| 296 | #[tokio::test] | 298 | #[tokio::test] |
| 297 | async fn test_recursive_relay_discovery_syncs_announcement() { | 299 | async fn test_recursive_relay_discovery_syncs_announcement() { |
| 298 | // 1. Start all three relays | 300 | // 1. Start all three relays |
| 299 | 301 | ||
| 300 | // relay_b - will be the bootstrap relay, has announcement_x | 302 | // relay_b - will be the bootstrap relay, has announcement_x |
| 301 | let relay_b = TestRelay::start().await; | 303 | let relay_b = TestRelay::start().await; |
| 302 | println!( | 304 | println!( |
| @@ -344,7 +346,10 @@ async fn test_recursive_relay_discovery_syncs_announcement() { | |||
| 344 | "repo-y-ac-only", | 346 | "repo-y-ac-only", |
| 345 | ); | 347 | ); |
| 346 | let announcement_y_id = announcement_y.id; | 348 | let announcement_y_id = announcement_y.id; |
| 347 | println!("Created announcement_y {} listing A+C only", announcement_y_id); | 349 | println!( |
| 350 | "Created announcement_y {} listing A+C only", | ||
| 351 | announcement_y_id | ||
| 352 | ); | ||
| 348 | for tag in announcement_y.tags.iter() { | 353 | for tag in announcement_y.tags.iter() { |
| 349 | println!(" Tag: {:?}", tag.as_slice()); | 354 | println!(" Tag: {:?}", tag.as_slice()); |
| 350 | } | 355 | } |
| @@ -425,4 +430,4 @@ async fn test_recursive_relay_discovery_syncs_announcement() { | |||
| 425 | "announcement_y {} should have synced from discovered relay_c to relay_a (recursive discovery)", | 430 | "announcement_y {} should have synced from discovered relay_c to relay_a (recursive discovery)", |
| 426 | announcement_y_id | 431 | announcement_y_id |
| 427 | ); | 432 | ); |
| 428 | } \ No newline at end of file | 433 | } |
diff --git a/tests/sync/live_sync.rs b/tests/sync/live_sync.rs index ebe1c0b..7fa08a0 100644 --- a/tests/sync/live_sync.rs +++ b/tests/sync/live_sync.rs | |||
| @@ -229,7 +229,10 @@ async fn test_live_sync_layer3_events() { | |||
| 229 | .send_event(&comment) | 229 | .send_event(&comment) |
| 230 | .await | 230 | .await |
| 231 | .expect("Failed to send comment"); | 231 | .expect("Failed to send comment"); |
| 232 | println!("Layer 3 comment {} sent to relay_a BEFORE Layer 3 subscription established", comment_id); | 232 | println!( |
| 233 | "Layer 3 comment {} sent to relay_a BEFORE Layer 3 subscription established", | ||
| 234 | comment_id | ||
| 235 | ); | ||
| 233 | 236 | ||
| 234 | // 6. Now wait for issue to sync to relay_b (this triggers Layer 3 filter creation) | 237 | // 6. Now wait for issue to sync to relay_b (this triggers Layer 3 filter creation) |
| 235 | tokio::time::sleep(Duration::from_secs(2)).await; | 238 | tokio::time::sleep(Duration::from_secs(2)).await; |
| @@ -394,7 +397,7 @@ async fn test_live_sync_event_ordering() { | |||
| 394 | client_a | 397 | client_a |
| 395 | .send_event(&issue) | 398 | .send_event(&issue) |
| 396 | .await | 399 | .await |
| 397 | .expect(&format!("Failed to send issue {}", i)); | 400 | .unwrap_or_else(|_| panic!("Failed to send issue {}", i)); |
| 398 | 401 | ||
| 399 | // Delay between events to ensure different timestamps | 402 | // Delay between events to ensure different timestamps |
| 400 | tokio::time::sleep(Duration::from_millis(150)).await; | 403 | tokio::time::sleep(Duration::from_millis(150)).await; |
diff --git a/tests/sync/metrics.rs b/tests/sync/metrics.rs index 26d379d..14e1dfd 100644 --- a/tests/sync/metrics.rs +++ b/tests/sync/metrics.rs | |||
| @@ -32,7 +32,7 @@ async fn test_prometheus_format_valid() { | |||
| 32 | let relay = TestRelay::start().await; | 32 | let relay = TestRelay::start().await; |
| 33 | tokio::time::sleep(Duration::from_millis(500)).await; | 33 | tokio::time::sleep(Duration::from_millis(500)).await; |
| 34 | 34 | ||
| 35 | let metrics = fetch_metrics(&relay.url()) | 35 | let metrics = fetch_metrics(relay.url()) |
| 36 | .await | 36 | .await |
| 37 | .expect("Failed to fetch metrics"); | 37 | .expect("Failed to fetch metrics"); |
| 38 | 38 | ||
| @@ -67,7 +67,7 @@ async fn test_metrics_availability_during_sync() { | |||
| 67 | 67 | ||
| 68 | // Make multiple metrics requests while sync is active | 68 | // Make multiple metrics requests while sync is active |
| 69 | for i in 0..3 { | 69 | for i in 0..3 { |
| 70 | let metrics = fetch_metrics(&sync_relay.url()).await; | 70 | let metrics = fetch_metrics(sync_relay.url()).await; |
| 71 | assert!( | 71 | assert!( |
| 72 | metrics.is_ok(), | 72 | metrics.is_ok(), |
| 73 | "Metrics request {} should succeed during sync", | 73 | "Metrics request {} should succeed during sync", |
| @@ -135,7 +135,7 @@ async fn test_metric_values_are_numeric() { | |||
| 135 | let relay = TestRelay::start().await; | 135 | let relay = TestRelay::start().await; |
| 136 | tokio::time::sleep(Duration::from_millis(500)).await; | 136 | tokio::time::sleep(Duration::from_millis(500)).await; |
| 137 | 137 | ||
| 138 | let metrics = fetch_metrics(&relay.url()) | 138 | let metrics = fetch_metrics(relay.url()) |
| 139 | .await | 139 | .await |
| 140 | .expect("Should fetch metrics"); | 140 | .expect("Should fetch metrics"); |
| 141 | 141 | ||
diff --git a/tests/sync/tag_variations.rs b/tests/sync/tag_variations.rs index 273a573..41a6611 100644 --- a/tests/sync/tag_variations.rs +++ b/tests/sync/tag_variations.rs | |||
| @@ -57,11 +57,8 @@ async fn test_layer2_sync_with_lowercase_a_tag() { | |||
| 57 | 57 | ||
| 58 | // 2. Create and send repository announcement to both relays | 58 | // 2. Create and send repository announcement to both relays |
| 59 | let repo_id = "test-repo-tag-8a"; | 59 | let repo_id = "test-repo-tag-8a"; |
| 60 | let announcement = create_repo_announcement( | 60 | let announcement = |
| 61 | &keys, | 61 | create_repo_announcement(&keys, &[&relay_a.domain(), &relay_b.domain()], repo_id); |
| 62 | &[&relay_a.domain(), &relay_b.domain()], | ||
| 63 | repo_id, | ||
| 64 | ); | ||
| 65 | 62 | ||
| 66 | let client_a = TestClient::new(relay_a.url(), keys.clone()) | 63 | let client_a = TestClient::new(relay_a.url(), keys.clone()) |
| 67 | .await | 64 | .await |
| @@ -88,11 +85,16 @@ async fn test_layer2_sync_with_lowercase_a_tag() { | |||
| 88 | 85 | ||
| 89 | // 4. Create and send Layer 2 issue with lowercase 'a' tag | 86 | // 4. Create and send Layer 2 issue with lowercase 'a' tag |
| 90 | let repo_coordinate = repo_coord(&keys, repo_id); | 87 | let repo_coordinate = repo_coord(&keys, repo_id); |
| 91 | let issue = build_layer2_issue_event(&keys, &repo_coordinate, "Test Issue with lowercase a tag") | 88 | let issue = |
| 92 | .expect("Failed to create issue event"); | 89 | build_layer2_issue_event(&keys, &repo_coordinate, "Test Issue with lowercase a tag") |
| 90 | .expect("Failed to create issue event"); | ||
| 93 | let issue_id = issue.id; | 91 | let issue_id = issue.id; |
| 94 | 92 | ||
| 95 | println!("Created issue {} (kind {}) with lowercase 'a' tag", issue_id, issue.kind.as_u16()); | 93 | println!( |
| 94 | "Created issue {} (kind {}) with lowercase 'a' tag", | ||
| 95 | issue_id, | ||
| 96 | issue.kind.as_u16() | ||
| 97 | ); | ||
| 96 | for tag in issue.tags.iter() { | 98 | for tag in issue.tags.iter() { |
| 97 | println!(" Tag: {:?}", tag.as_slice()); | 99 | println!(" Tag: {:?}", tag.as_slice()); |
| 98 | } | 100 | } |
| @@ -154,11 +156,8 @@ async fn test_layer2_sync_with_uppercase_a_tag() { | |||
| 154 | 156 | ||
| 155 | // 2. Create and send repository announcement to both relays | 157 | // 2. Create and send repository announcement to both relays |
| 156 | let repo_id = "test-repo-tag-8b"; | 158 | let repo_id = "test-repo-tag-8b"; |
| 157 | let announcement = create_repo_announcement( | 159 | let announcement = |
| 158 | &keys, | 160 | create_repo_announcement(&keys, &[&relay_a.domain(), &relay_b.domain()], repo_id); |
| 159 | &[&relay_a.domain(), &relay_b.domain()], | ||
| 160 | repo_id, | ||
| 161 | ); | ||
| 162 | 161 | ||
| 163 | let client_a = TestClient::new(relay_a.url(), keys.clone()) | 162 | let client_a = TestClient::new(relay_a.url(), keys.clone()) |
| 164 | .await | 163 | .await |
| @@ -185,11 +184,19 @@ async fn test_layer2_sync_with_uppercase_a_tag() { | |||
| 185 | 184 | ||
| 186 | // 4. Create and send Layer 2 issue with uppercase 'A' tag | 185 | // 4. Create and send Layer 2 issue with uppercase 'A' tag |
| 187 | let repo_coordinate = repo_coord(&keys, repo_id); | 186 | let repo_coordinate = repo_coord(&keys, repo_id); |
| 188 | let issue = build_layer2_issue_with_uppercase_a_tag(&keys, &repo_coordinate, "Test Issue with uppercase A tag") | 187 | let issue = build_layer2_issue_with_uppercase_a_tag( |
| 189 | .expect("Failed to create issue event"); | 188 | &keys, |
| 189 | &repo_coordinate, | ||
| 190 | "Test Issue with uppercase A tag", | ||
| 191 | ) | ||
| 192 | .expect("Failed to create issue event"); | ||
| 190 | let issue_id = issue.id; | 193 | let issue_id = issue.id; |
| 191 | 194 | ||
| 192 | println!("Created issue {} (kind {}) with uppercase 'A' tag", issue_id, issue.kind.as_u16()); | 195 | println!( |
| 196 | "Created issue {} (kind {}) with uppercase 'A' tag", | ||
| 197 | issue_id, | ||
| 198 | issue.kind.as_u16() | ||
| 199 | ); | ||
| 193 | for tag in issue.tags.iter() { | 200 | for tag in issue.tags.iter() { |
| 194 | println!(" Tag: {:?}", tag.as_slice()); | 201 | println!(" Tag: {:?}", tag.as_slice()); |
| 195 | } | 202 | } |
| @@ -250,11 +257,8 @@ async fn test_layer2_sync_with_q_tag() { | |||
| 250 | 257 | ||
| 251 | // 2. Create and send repository announcement to both relays | 258 | // 2. Create and send repository announcement to both relays |
| 252 | let repo_id = "test-repo-tag-8c"; | 259 | let repo_id = "test-repo-tag-8c"; |
| 253 | let announcement = create_repo_announcement( | 260 | let announcement = |
| 254 | &keys, | 261 | create_repo_announcement(&keys, &[&relay_a.domain(), &relay_b.domain()], repo_id); |
| 255 | &[&relay_a.domain(), &relay_b.domain()], | ||
| 256 | repo_id, | ||
| 257 | ); | ||
| 258 | 262 | ||
| 259 | let client_a = TestClient::new(relay_a.url(), keys.clone()) | 263 | let client_a = TestClient::new(relay_a.url(), keys.clone()) |
| 260 | .await | 264 | .await |
| @@ -285,7 +289,11 @@ async fn test_layer2_sync_with_q_tag() { | |||
| 285 | .expect("Failed to create issue event"); | 289 | .expect("Failed to create issue event"); |
| 286 | let issue_id = issue.id; | 290 | let issue_id = issue.id; |
| 287 | 291 | ||
| 288 | println!("Created issue {} (kind {}) with 'q' tag", issue_id, issue.kind.as_u16()); | 292 | println!( |
| 293 | "Created issue {} (kind {}) with 'q' tag", | ||
| 294 | issue_id, | ||
| 295 | issue.kind.as_u16() | ||
| 296 | ); | ||
| 289 | for tag in issue.tags.iter() { | 297 | for tag in issue.tags.iter() { |
| 290 | println!(" Tag: {:?}", tag.as_slice()); | 298 | println!(" Tag: {:?}", tag.as_slice()); |
| 291 | } | 299 | } |
| @@ -350,11 +358,8 @@ async fn test_layer3_sync_with_lowercase_e_tag() { | |||
| 350 | 358 | ||
| 351 | // 2. Create and send repository announcement to both relays | 359 | // 2. Create and send repository announcement to both relays |
| 352 | let repo_id = "test-repo-tag-9a"; | 360 | let repo_id = "test-repo-tag-9a"; |
| 353 | let announcement = create_repo_announcement( | 361 | let announcement = |
| 354 | &keys, | 362 | create_repo_announcement(&keys, &[&relay_a.domain(), &relay_b.domain()], repo_id); |
| 355 | &[&relay_a.domain(), &relay_b.domain()], | ||
| 356 | repo_id, | ||
| 357 | ); | ||
| 358 | 363 | ||
| 359 | let client_a = TestClient::new(relay_a.url(), keys.clone()) | 364 | let client_a = TestClient::new(relay_a.url(), keys.clone()) |
| 360 | .await | 365 | .await |
| @@ -392,10 +397,9 @@ async fn test_layer3_sync_with_lowercase_e_tag() { | |||
| 392 | println!("Layer 2 issue {} sent to relay_a", issue_id); | 397 | println!("Layer 2 issue {} sent to relay_a", issue_id); |
| 393 | 398 | ||
| 394 | // 5. Wait for issue to sync to relay_b | 399 | // 5. Wait for issue to sync to relay_b |
| 395 | let issue_filter = Filter::new() | 400 | let issue_filter = Filter::new().kind(Kind::Custom(KIND_ISSUE)).id(issue_id); |
| 396 | .kind(Kind::Custom(KIND_ISSUE)) | 401 | let issue_synced = |
| 397 | .id(issue_id); | 402 | wait_for_event_on_relay(relay_b.url(), issue_filter, Duration::from_secs(5)).await; |
| 398 | let issue_synced = wait_for_event_on_relay(relay_b.url(), issue_filter, Duration::from_secs(5)).await; | ||
| 399 | println!("Issue synced to relay_b: {}", issue_synced); | 403 | println!("Issue synced to relay_b: {}", issue_synced); |
| 400 | assert!(issue_synced, "Layer 2 issue should sync first"); | 404 | assert!(issue_synced, "Layer 2 issue should sync first"); |
| 401 | 405 | ||
| @@ -412,7 +416,11 @@ async fn test_layer3_sync_with_lowercase_e_tag() { | |||
| 412 | .expect("Failed to create reply"); | 416 | .expect("Failed to create reply"); |
| 413 | let reply_id = reply.id; | 417 | let reply_id = reply.id; |
| 414 | 418 | ||
| 415 | println!("Created reply {} (kind {}) with lowercase 'e' tag", reply_id, reply.kind.as_u16()); | 419 | println!( |
| 420 | "Created reply {} (kind {}) with lowercase 'e' tag", | ||
| 421 | reply_id, | ||
| 422 | reply.kind.as_u16() | ||
| 423 | ); | ||
| 416 | for tag in reply.tags.iter() { | 424 | for tag in reply.tags.iter() { |
| 417 | println!(" Tag: {:?}", tag.as_slice()); | 425 | println!(" Tag: {:?}", tag.as_slice()); |
| 418 | } | 426 | } |
| @@ -428,11 +436,12 @@ async fn test_layer3_sync_with_lowercase_e_tag() { | |||
| 428 | 436 | ||
| 429 | // 7. Wait and verify reply syncs to relay_b | 437 | // 7. Wait and verify reply syncs to relay_b |
| 430 | let reply_filter = Filter::new() | 438 | let reply_filter = Filter::new() |
| 431 | .kind(Kind::TextNote) // Kind 1 | 439 | .kind(Kind::TextNote) // Kind 1 |
| 432 | .author(keys.public_key()) | 440 | .author(keys.public_key()) |
| 433 | .id(reply_id); | 441 | .id(reply_id); |
| 434 | 442 | ||
| 435 | let reply_synced = wait_for_event_on_relay(relay_b.url(), reply_filter, Duration::from_secs(5)).await; | 443 | let reply_synced = |
| 444 | wait_for_event_on_relay(relay_b.url(), reply_filter, Duration::from_secs(5)).await; | ||
| 436 | 445 | ||
| 437 | println!("Reply {} synced to relay_b: {}", reply_id, reply_synced); | 446 | println!("Reply {} synced to relay_b: {}", reply_id, reply_synced); |
| 438 | 447 | ||
| @@ -473,11 +482,8 @@ async fn test_layer3_sync_with_uppercase_e_tag() { | |||
| 473 | 482 | ||
| 474 | // 2. Create and send repository announcement to both relays | 483 | // 2. Create and send repository announcement to both relays |
| 475 | let repo_id = "test-repo-tag-9b"; | 484 | let repo_id = "test-repo-tag-9b"; |
| 476 | let announcement = create_repo_announcement( | 485 | let announcement = |
| 477 | &keys, | 486 | create_repo_announcement(&keys, &[&relay_a.domain(), &relay_b.domain()], repo_id); |
| 478 | &[&relay_a.domain(), &relay_b.domain()], | ||
| 479 | repo_id, | ||
| 480 | ); | ||
| 481 | 487 | ||
| 482 | let client_a = TestClient::new(relay_a.url(), keys.clone()) | 488 | let client_a = TestClient::new(relay_a.url(), keys.clone()) |
| 483 | .await | 489 | .await |
| @@ -515,10 +521,9 @@ async fn test_layer3_sync_with_uppercase_e_tag() { | |||
| 515 | println!("Layer 2 issue {} sent to relay_a", issue_id); | 521 | println!("Layer 2 issue {} sent to relay_a", issue_id); |
| 516 | 522 | ||
| 517 | // 5. Wait for issue to sync to relay_b | 523 | // 5. Wait for issue to sync to relay_b |
| 518 | let issue_filter = Filter::new() | 524 | let issue_filter = Filter::new().kind(Kind::Custom(KIND_ISSUE)).id(issue_id); |
| 519 | .kind(Kind::Custom(KIND_ISSUE)) | 525 | let issue_synced = |
| 520 | .id(issue_id); | 526 | wait_for_event_on_relay(relay_b.url(), issue_filter, Duration::from_secs(5)).await; |
| 521 | let issue_synced = wait_for_event_on_relay(relay_b.url(), issue_filter, Duration::from_secs(5)).await; | ||
| 522 | println!("Issue synced to relay_b: {}", issue_synced); | 527 | println!("Issue synced to relay_b: {}", issue_synced); |
| 523 | assert!(issue_synced, "Layer 2 issue should sync first"); | 528 | assert!(issue_synced, "Layer 2 issue should sync first"); |
| 524 | 529 | ||
| @@ -531,11 +536,16 @@ async fn test_layer3_sync_with_uppercase_e_tag() { | |||
| 531 | tokio::time::sleep(Duration::from_millis(500)).await; | 536 | tokio::time::sleep(Duration::from_millis(500)).await; |
| 532 | 537 | ||
| 533 | // 6. Create and send Layer 3 comment with uppercase 'E' tag (kind 1111) | 538 | // 6. Create and send Layer 3 comment with uppercase 'E' tag (kind 1111) |
| 534 | let comment = build_layer3_comment_with_uppercase_e_tag(&keys, &issue_id, "Comment with uppercase E tag") | 539 | let comment = |
| 535 | .expect("Failed to create comment"); | 540 | build_layer3_comment_with_uppercase_e_tag(&keys, &issue_id, "Comment with uppercase E tag") |
| 541 | .expect("Failed to create comment"); | ||
| 536 | let comment_id = comment.id; | 542 | let comment_id = comment.id; |
| 537 | 543 | ||
| 538 | println!("Created comment {} (kind {}) with uppercase 'E' tag", comment_id, comment.kind.as_u16()); | 544 | println!( |
| 545 | "Created comment {} (kind {}) with uppercase 'E' tag", | ||
| 546 | comment_id, | ||
| 547 | comment.kind.as_u16() | ||
| 548 | ); | ||
| 539 | for tag in comment.tags.iter() { | 549 | for tag in comment.tags.iter() { |
| 540 | println!(" Tag: {:?}", tag.as_slice()); | 550 | println!(" Tag: {:?}", tag.as_slice()); |
| 541 | } | 551 | } |
| @@ -551,13 +561,17 @@ async fn test_layer3_sync_with_uppercase_e_tag() { | |||
| 551 | 561 | ||
| 552 | // 7. Wait and verify comment syncs to relay_b | 562 | // 7. Wait and verify comment syncs to relay_b |
| 553 | let comment_filter = Filter::new() | 563 | let comment_filter = Filter::new() |
| 554 | .kind(Kind::Custom(KIND_COMMENT)) // Kind 1111 | 564 | .kind(Kind::Custom(KIND_COMMENT)) // Kind 1111 |
| 555 | .author(keys.public_key()) | 565 | .author(keys.public_key()) |
| 556 | .id(comment_id); | 566 | .id(comment_id); |
| 557 | 567 | ||
| 558 | let comment_synced = wait_for_event_on_relay(relay_b.url(), comment_filter, Duration::from_secs(5)).await; | 568 | let comment_synced = |
| 569 | wait_for_event_on_relay(relay_b.url(), comment_filter, Duration::from_secs(5)).await; | ||
| 559 | 570 | ||
| 560 | println!("Comment {} synced to relay_b: {}", comment_id, comment_synced); | 571 | println!( |
| 572 | "Comment {} synced to relay_b: {}", | ||
| 573 | comment_id, comment_synced | ||
| 574 | ); | ||
| 561 | 575 | ||
| 562 | // 8. Cleanup | 576 | // 8. Cleanup |
| 563 | relay_b.stop().await; | 577 | relay_b.stop().await; |
| @@ -596,11 +610,8 @@ async fn test_layer3_sync_with_q_tag() { | |||
| 596 | 610 | ||
| 597 | // 2. Create and send repository announcement to both relays | 611 | // 2. Create and send repository announcement to both relays |
| 598 | let repo_id = "test-repo-tag-9c"; | 612 | let repo_id = "test-repo-tag-9c"; |
| 599 | let announcement = create_repo_announcement( | 613 | let announcement = |
| 600 | &keys, | 614 | create_repo_announcement(&keys, &[&relay_a.domain(), &relay_b.domain()], repo_id); |
| 601 | &[&relay_a.domain(), &relay_b.domain()], | ||
| 602 | repo_id, | ||
| 603 | ); | ||
| 604 | 615 | ||
| 605 | let client_a = TestClient::new(relay_a.url(), keys.clone()) | 616 | let client_a = TestClient::new(relay_a.url(), keys.clone()) |
| 606 | .await | 617 | .await |
| @@ -638,10 +649,9 @@ async fn test_layer3_sync_with_q_tag() { | |||
| 638 | println!("Layer 2 issue {} sent to relay_a", issue_id); | 649 | println!("Layer 2 issue {} sent to relay_a", issue_id); |
| 639 | 650 | ||
| 640 | // 5. Wait for issue to sync to relay_b | 651 | // 5. Wait for issue to sync to relay_b |
| 641 | let issue_filter = Filter::new() | 652 | let issue_filter = Filter::new().kind(Kind::Custom(KIND_ISSUE)).id(issue_id); |
| 642 | .kind(Kind::Custom(KIND_ISSUE)) | 653 | let issue_synced = |
| 643 | .id(issue_id); | 654 | wait_for_event_on_relay(relay_b.url(), issue_filter, Duration::from_secs(5)).await; |
| 644 | let issue_synced = wait_for_event_on_relay(relay_b.url(), issue_filter, Duration::from_secs(5)).await; | ||
| 645 | println!("Issue synced to relay_b: {}", issue_synced); | 655 | println!("Issue synced to relay_b: {}", issue_synced); |
| 646 | assert!(issue_synced, "Layer 2 issue should sync first"); | 656 | assert!(issue_synced, "Layer 2 issue should sync first"); |
| 647 | 657 | ||
| @@ -658,7 +668,11 @@ async fn test_layer3_sync_with_q_tag() { | |||
| 658 | .expect("Failed to create quote"); | 668 | .expect("Failed to create quote"); |
| 659 | let quote_id = quote.id; | 669 | let quote_id = quote.id; |
| 660 | 670 | ||
| 661 | println!("Created quote {} (kind {}) with 'q' tag", quote_id, quote.kind.as_u16()); | 671 | println!( |
| 672 | "Created quote {} (kind {}) with 'q' tag", | ||
| 673 | quote_id, | ||
| 674 | quote.kind.as_u16() | ||
| 675 | ); | ||
| 662 | for tag in quote.tags.iter() { | 676 | for tag in quote.tags.iter() { |
| 663 | println!(" Tag: {:?}", tag.as_slice()); | 677 | println!(" Tag: {:?}", tag.as_slice()); |
| 664 | } | 678 | } |
| @@ -674,11 +688,12 @@ async fn test_layer3_sync_with_q_tag() { | |||
| 674 | 688 | ||
| 675 | // 7. Wait and verify quote syncs to relay_b | 689 | // 7. Wait and verify quote syncs to relay_b |
| 676 | let quote_filter = Filter::new() | 690 | let quote_filter = Filter::new() |
| 677 | .kind(Kind::TextNote) // Kind 1 | 691 | .kind(Kind::TextNote) // Kind 1 |
| 678 | .author(keys.public_key()) | 692 | .author(keys.public_key()) |
| 679 | .id(quote_id); | 693 | .id(quote_id); |
| 680 | 694 | ||
| 681 | let quote_synced = wait_for_event_on_relay(relay_b.url(), quote_filter, Duration::from_secs(5)).await; | 695 | let quote_synced = |
| 696 | wait_for_event_on_relay(relay_b.url(), quote_filter, Duration::from_secs(5)).await; | ||
| 682 | 697 | ||
| 683 | println!("Quote {} synced to relay_b: {}", quote_id, quote_synced); | 698 | println!("Quote {} synced to relay_b: {}", quote_id, quote_synced); |
| 684 | 699 | ||
| @@ -690,4 +705,4 @@ async fn test_layer3_sync_with_q_tag() { | |||
| 690 | quote_synced, | 705 | quote_synced, |
| 691 | "Layer 3 quote with 'q' tag should have synced to relay_b" | 706 | "Layer 3 quote with 'q' tag should have synced to relay_b" |
| 692 | ); | 707 | ); |
| 693 | } \ No newline at end of file | 708 | } |