From 2a9160836bb87fdea3ae891563b0169c68d1c2ab Mon Sep 17 00:00:00 2001 From: DanConwayDev Date: Thu, 11 Dec 2025 16:53:03 +0000 Subject: 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 --- tests/common/mod.rs | 2 + tests/common/relay.rs | 6 +- tests/common/sync_helpers.rs | 54 ++++++++--------- tests/nip77_negentropy.rs | 27 +++++---- tests/sync.rs | 2 +- tests/sync/bootstrap.rs | 9 ++- tests/sync/discovery.rs | 15 +++-- tests/sync/live_sync.rs | 7 ++- tests/sync/metrics.rs | 6 +- tests/sync/tag_variations.rs | 139 ++++++++++++++++++++++++------------------- 10 files changed, 150 insertions(+), 117 deletions(-) (limited to 'tests') diff --git a/tests/common/mod.rs b/tests/common/mod.rs index 9bbfb40..37ac3bb 100644 --- a/tests/common/mod.rs +++ b/tests/common/mod.rs @@ -1,4 +1,6 @@ //! Common test utilities +#![allow(dead_code)] // Test helpers may not be used in all test configurations +#![allow(unused_imports)] // Re-exports may not be used in all test configurations pub mod relay; pub mod sync_helpers; diff --git a/tests/common/relay.rs b/tests/common/relay.rs index 2dd526b..55cc18e 100644 --- a/tests/common/relay.rs +++ b/tests/common/relay.rs @@ -104,7 +104,11 @@ impl TestRelay { } /// Start relay with full options - async fn start_with_full_options(port: u16, bootstrap_relay_url: Option, disable_negentropy: bool) -> Self { + async fn start_with_full_options( + port: u16, + bootstrap_relay_url: Option, + disable_negentropy: bool, + ) -> Self { let bind_address = format!("127.0.0.1:{}", port); let url = format!("ws://127.0.0.1:{}", port); diff --git a/tests/common/sync_helpers.rs b/tests/common/sync_helpers.rs index 531ebe1..7fa0393 100644 --- a/tests/common/sync_helpers.rs +++ b/tests/common/sync_helpers.rs @@ -173,7 +173,11 @@ impl TestClient { /// # Returns /// * `Ok(Event)` - Signed event ready to send /// * `Err(String)` - If signing fails -pub fn build_layer2_issue_event(keys: &Keys, repo_coord: &str, title: &str) -> Result { +pub fn build_layer2_issue_event( + keys: &Keys, + repo_coord: &str, + title: &str, +) -> Result { build_layer2_issue_with_tag(keys, repo_coord, title, TagVariant::LowercaseA) } @@ -256,10 +260,7 @@ pub fn build_layer3_comment_event( // Choose tag based on kind (NIP-22 uses E, NIP-10 style uses e) let tag = if kind_num == KIND_COMMENT { // NIP-22 comment: uppercase 'E' tag - Tag::custom( - TagKind::custom("E"), - vec![parent_event_id.to_hex()], - ) + Tag::custom(TagKind::custom("E"), vec![parent_event_id.to_hex()]) } else { // Kind 1 reply: lowercase 'e' tag with root marker (NIP-10) Tag::custom( @@ -299,10 +300,7 @@ pub fn build_layer3_comment_with_uppercase_e_tag( parent_event_id: &EventId, content: &str, ) -> Result { - let tag = Tag::custom( - TagKind::custom("E"), - vec![parent_event_id.to_hex()], - ); + let tag = Tag::custom(TagKind::custom("E"), vec![parent_event_id.to_hex()]); EventBuilder::new(Kind::Custom(KIND_COMMENT), content) .tags(vec![tag]) @@ -316,10 +314,7 @@ pub fn build_layer3_quote_with_q_tag( parent_event_id: &EventId, content: &str, ) -> Result { - let tag = Tag::custom( - TagKind::custom("q"), - vec![parent_event_id.to_hex()], - ); + let tag = Tag::custom(TagKind::custom("q"), vec![parent_event_id.to_hex()]); EventBuilder::new(Kind::Custom(1), content) .tags(vec![tag]) @@ -587,10 +582,7 @@ pub fn repo_coord(keys: &Keys, identifier: &str) -> String { /// ``` pub async fn fetch_metrics(relay_url: &str) -> Result { // Convert ws:// URL to http:// for metrics endpoint - let http_url = relay_url - .replace("ws://", "http://") - .replace("/", "") - + "/metrics"; + let http_url = relay_url.replace("ws://", "http://").replace("/", "") + "/metrics"; reqwest::get(&http_url).await?.text().await } @@ -888,8 +880,8 @@ mod tests { let keys = Keys::generate(); let coord = repo_coord(&keys, "my-repo"); - let event = build_layer2_issue_event(&keys, &coord, "Test Issue") - .expect("Should create event"); + let event = + build_layer2_issue_event(&keys, &coord, "Test Issue").expect("Should create event"); // nostr-sdk 0.43: use field access assert_eq!(event.kind.as_u16(), KIND_ISSUE); @@ -937,8 +929,13 @@ mod tests { let keys = Keys::generate(); let parent_id = EventId::all_zeros(); - let event = build_layer3_comment_event(&keys, &parent_id, "Test comment", Kind::Custom(KIND_COMMENT)) - .expect("Should create event"); + let event = build_layer3_comment_event( + &keys, + &parent_id, + "Test comment", + Kind::Custom(KIND_COMMENT), + ) + .expect("Should create event"); assert_eq!(event.kind.as_u16(), KIND_COMMENT); @@ -980,8 +977,7 @@ mod tests { let has_e_tag = event.tags.iter().any(|tag| { let slice = tag.as_slice(); - slice.first().is_some_and(|t| t == "e") && - slice.get(3).is_some_and(|m| m == "root") + slice.first().is_some_and(|t| t == "e") && slice.get(3).is_some_and(|m| m == "root") }); assert!(has_e_tag, "Should have 'e' tag with root marker"); } @@ -1038,7 +1034,10 @@ mod tests { fn test_parse_gauge_without_labels() { let text = r#"ngit_sync_relays_tracked_total 3"#; let metrics = ParsedMetrics::parse(text); - assert_eq!(metrics.gauge("ngit_sync_relays_tracked_total", &[]), Some(3)); + assert_eq!( + metrics.gauge("ngit_sync_relays_tracked_total", &[]), + Some(3) + ); } #[test] @@ -1051,9 +1050,6 @@ mod tests { fn test_parse_metric_with_relay_url_label() { let text = r#"ngit_sync_relay_connected{relay="ws://127.0.0.1:12345"} 1"#; let metrics = ParsedMetrics::parse(text); - assert_eq!( - metrics.relay_connected("ws://127.0.0.1:12345"), - Some(true) - ); + assert_eq!(metrics.relay_connected("ws://127.0.0.1:12345"), Some(true)); } -} \ No newline at end of file +} diff --git a/tests/nip77_negentropy.rs b/tests/nip77_negentropy.rs index c8e0b50..5293754 100644 --- a/tests/nip77_negentropy.rs +++ b/tests/nip77_negentropy.rs @@ -45,13 +45,13 @@ async fn test_nip77_negentropy_sync_finds_events() { let keys = Keys::generate(); // Create a repository announcement that will be accepted by the relay - let announcement = create_repo_announcement( - &keys, - &[&relay.domain()], - "test-repo-nip77", - ); + let announcement = create_repo_announcement(&keys, &[&relay.domain()], "test-repo-nip77"); let event1_id = announcement.id; - println!("Created event 1: {} (kind {})", event1_id, announcement.kind.as_u16()); + println!( + "Created event 1: {} (kind {})", + event1_id, + announcement.kind.as_u16() + ); // Create a second event (issue referencing the repo) let repo_coord = format!( @@ -63,7 +63,11 @@ async fn test_nip77_negentropy_sync_finds_events() { let issue = build_layer2_issue_event(&keys, &repo_coord, "Test issue for NIP-77") .expect("Failed to build issue event"); let event2_id = issue.id; - println!("Created event 2: {} (kind {})", event2_id, issue.kind.as_u16()); + println!( + "Created event 2: {} (kind {})", + event2_id, + issue.kind.as_u16() + ); // 3. Send events to relay using TestClient let publish_client = TestClient::new(relay.url(), keys.clone()) @@ -99,9 +103,10 @@ async fn test_nip77_negentropy_sync_finds_events() { tokio::time::sleep(Duration::from_millis(500)).await; // 6. Perform negentropy sync with filter matching our events - let filter = Filter::new() - .author(keys.public_key()) - .kinds(vec![Kind::Custom(KIND_REPOSITORY_STATE), Kind::Custom(KIND_ISSUE)]); + let filter = Filter::new().author(keys.public_key()).kinds(vec![ + Kind::Custom(KIND_REPOSITORY_STATE), + Kind::Custom(KIND_ISSUE), + ]); println!("Starting negentropy sync with filter: {:?}", filter); @@ -177,7 +182,7 @@ async fn test_nip77_negentropy_sync_empty_result() { // 3. Sync with filter that won't match anything let filter = Filter::new() - .author(keys.public_key()) // Random new key, no events exist + .author(keys.public_key()) // Random new key, no events exist .kind(Kind::Custom(KIND_REPOSITORY_STATE)); println!("Starting negentropy sync with empty filter"); diff --git a/tests/sync.rs b/tests/sync.rs index 5b6b752..2e09fb8 100644 --- a/tests/sync.rs +++ b/tests/sync.rs @@ -37,4 +37,4 @@ mod sync { pub mod live_sync; pub mod metrics; pub mod tag_variations; -} \ No newline at end of file +} 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() { .kind(Kind::Custom(KIND_REPOSITORY_STATE)) .author(keys.public_key()); - let synced_first = wait_for_event_on_relay(relay_b.url(), filter.clone(), Duration::from_secs(5)).await; + let synced_first = + wait_for_event_on_relay(relay_b.url(), filter.clone(), Duration::from_secs(5)).await; println!("First sync check: {}", synced_first); // 8. Stop relay_b @@ -193,7 +194,8 @@ async fn test_relay_replays_events_after_restart() { // 12. Verify announcement is available on new relay_b // The announcement listed the OLD relay_b domain, but since relay_a still // has the event, new relay_b should be able to sync it via bootstrap - let synced_after_restart = wait_for_event_on_relay(relay_b_new.url(), filter, Duration::from_secs(5)).await; + let synced_after_restart = + wait_for_event_on_relay(relay_b_new.url(), filter, Duration::from_secs(5)).await; // 13. Cleanup relay_b_new.stop().await; @@ -384,7 +386,8 @@ async fn test_history_sync_without_negentropy() { relay_b_port, Some(relay_a.url().into()), true, // disable_negentropy = true - ).await; + ) + .await; println!( "relay_b started at {} (domain: {}) - negentropy DISABLED, will do HISTORY sync", 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() { ); // 6. Create a patch event (Layer 2) that references the announcement - let patch = create_event_referencing_repo(&keys, &repo_coord, KIND_PATCH, "Test patch proposal"); + let patch = + create_event_referencing_repo(&keys, &repo_coord, KIND_PATCH, "Test patch proposal"); let patch_id = patch.id; println!("Created patch {} (kind {})", patch_id, patch.kind.as_u16()); @@ -252,7 +253,8 @@ async fn test_layer2_discovery_with_chain() { let issue_filter = Filter::new() .kind(Kind::Custom(KIND_ISSUE)) .author(keys.public_key()); - let issue_synced = wait_for_event_on_relay(relay_b.url(), issue_filter, Duration::from_secs(5)).await; + let issue_synced = + wait_for_event_on_relay(relay_b.url(), issue_filter, Duration::from_secs(5)).await; println!("Sync result:"); println!(" Issue {} synced: {}", issue_id, issue_synced); @@ -296,7 +298,7 @@ async fn test_layer2_discovery_with_chain() { #[tokio::test] async fn test_recursive_relay_discovery_syncs_announcement() { // 1. Start all three relays - + // relay_b - will be the bootstrap relay, has announcement_x let relay_b = TestRelay::start().await; println!( @@ -344,7 +346,10 @@ async fn test_recursive_relay_discovery_syncs_announcement() { "repo-y-ac-only", ); let announcement_y_id = announcement_y.id; - println!("Created announcement_y {} listing A+C only", announcement_y_id); + println!( + "Created announcement_y {} listing A+C only", + announcement_y_id + ); for tag in announcement_y.tags.iter() { println!(" Tag: {:?}", tag.as_slice()); } @@ -425,4 +430,4 @@ async fn test_recursive_relay_discovery_syncs_announcement() { "announcement_y {} should have synced from discovered relay_c to relay_a (recursive discovery)", announcement_y_id ); -} \ No newline at end of file +} 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() { .send_event(&comment) .await .expect("Failed to send comment"); - println!("Layer 3 comment {} sent to relay_a BEFORE Layer 3 subscription established", comment_id); + println!( + "Layer 3 comment {} sent to relay_a BEFORE Layer 3 subscription established", + comment_id + ); // 6. Now wait for issue to sync to relay_b (this triggers Layer 3 filter creation) tokio::time::sleep(Duration::from_secs(2)).await; @@ -394,7 +397,7 @@ async fn test_live_sync_event_ordering() { client_a .send_event(&issue) .await - .expect(&format!("Failed to send issue {}", i)); + .unwrap_or_else(|_| panic!("Failed to send issue {}", i)); // Delay between events to ensure different timestamps 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() { let relay = TestRelay::start().await; tokio::time::sleep(Duration::from_millis(500)).await; - let metrics = fetch_metrics(&relay.url()) + let metrics = fetch_metrics(relay.url()) .await .expect("Failed to fetch metrics"); @@ -67,7 +67,7 @@ async fn test_metrics_availability_during_sync() { // Make multiple metrics requests while sync is active for i in 0..3 { - let metrics = fetch_metrics(&sync_relay.url()).await; + let metrics = fetch_metrics(sync_relay.url()).await; assert!( metrics.is_ok(), "Metrics request {} should succeed during sync", @@ -135,7 +135,7 @@ async fn test_metric_values_are_numeric() { let relay = TestRelay::start().await; tokio::time::sleep(Duration::from_millis(500)).await; - let metrics = fetch_metrics(&relay.url()) + let metrics = fetch_metrics(relay.url()) .await .expect("Should fetch metrics"); 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() { // 2. Create and send repository announcement to both relays let repo_id = "test-repo-tag-8a"; - let announcement = create_repo_announcement( - &keys, - &[&relay_a.domain(), &relay_b.domain()], - repo_id, - ); + let announcement = + create_repo_announcement(&keys, &[&relay_a.domain(), &relay_b.domain()], repo_id); let client_a = TestClient::new(relay_a.url(), keys.clone()) .await @@ -88,11 +85,16 @@ async fn test_layer2_sync_with_lowercase_a_tag() { // 4. Create and send Layer 2 issue with lowercase 'a' tag let repo_coordinate = repo_coord(&keys, repo_id); - let issue = build_layer2_issue_event(&keys, &repo_coordinate, "Test Issue with lowercase a tag") - .expect("Failed to create issue event"); + let issue = + build_layer2_issue_event(&keys, &repo_coordinate, "Test Issue with lowercase a tag") + .expect("Failed to create issue event"); let issue_id = issue.id; - println!("Created issue {} (kind {}) with lowercase 'a' tag", issue_id, issue.kind.as_u16()); + println!( + "Created issue {} (kind {}) with lowercase 'a' tag", + issue_id, + issue.kind.as_u16() + ); for tag in issue.tags.iter() { println!(" Tag: {:?}", tag.as_slice()); } @@ -154,11 +156,8 @@ async fn test_layer2_sync_with_uppercase_a_tag() { // 2. Create and send repository announcement to both relays let repo_id = "test-repo-tag-8b"; - let announcement = create_repo_announcement( - &keys, - &[&relay_a.domain(), &relay_b.domain()], - repo_id, - ); + let announcement = + create_repo_announcement(&keys, &[&relay_a.domain(), &relay_b.domain()], repo_id); let client_a = TestClient::new(relay_a.url(), keys.clone()) .await @@ -185,11 +184,19 @@ async fn test_layer2_sync_with_uppercase_a_tag() { // 4. Create and send Layer 2 issue with uppercase 'A' tag let repo_coordinate = repo_coord(&keys, repo_id); - let issue = build_layer2_issue_with_uppercase_a_tag(&keys, &repo_coordinate, "Test Issue with uppercase A tag") - .expect("Failed to create issue event"); + let issue = build_layer2_issue_with_uppercase_a_tag( + &keys, + &repo_coordinate, + "Test Issue with uppercase A tag", + ) + .expect("Failed to create issue event"); let issue_id = issue.id; - println!("Created issue {} (kind {}) with uppercase 'A' tag", issue_id, issue.kind.as_u16()); + println!( + "Created issue {} (kind {}) with uppercase 'A' tag", + issue_id, + issue.kind.as_u16() + ); for tag in issue.tags.iter() { println!(" Tag: {:?}", tag.as_slice()); } @@ -250,11 +257,8 @@ async fn test_layer2_sync_with_q_tag() { // 2. Create and send repository announcement to both relays let repo_id = "test-repo-tag-8c"; - let announcement = create_repo_announcement( - &keys, - &[&relay_a.domain(), &relay_b.domain()], - repo_id, - ); + let announcement = + create_repo_announcement(&keys, &[&relay_a.domain(), &relay_b.domain()], repo_id); let client_a = TestClient::new(relay_a.url(), keys.clone()) .await @@ -285,7 +289,11 @@ async fn test_layer2_sync_with_q_tag() { .expect("Failed to create issue event"); let issue_id = issue.id; - println!("Created issue {} (kind {}) with 'q' tag", issue_id, issue.kind.as_u16()); + println!( + "Created issue {} (kind {}) with 'q' tag", + issue_id, + issue.kind.as_u16() + ); for tag in issue.tags.iter() { println!(" Tag: {:?}", tag.as_slice()); } @@ -350,11 +358,8 @@ async fn test_layer3_sync_with_lowercase_e_tag() { // 2. Create and send repository announcement to both relays let repo_id = "test-repo-tag-9a"; - let announcement = create_repo_announcement( - &keys, - &[&relay_a.domain(), &relay_b.domain()], - repo_id, - ); + let announcement = + create_repo_announcement(&keys, &[&relay_a.domain(), &relay_b.domain()], repo_id); let client_a = TestClient::new(relay_a.url(), keys.clone()) .await @@ -392,10 +397,9 @@ async fn test_layer3_sync_with_lowercase_e_tag() { println!("Layer 2 issue {} sent to relay_a", issue_id); // 5. Wait for issue to sync to relay_b - let issue_filter = Filter::new() - .kind(Kind::Custom(KIND_ISSUE)) - .id(issue_id); - let issue_synced = wait_for_event_on_relay(relay_b.url(), issue_filter, Duration::from_secs(5)).await; + let issue_filter = Filter::new().kind(Kind::Custom(KIND_ISSUE)).id(issue_id); + let issue_synced = + wait_for_event_on_relay(relay_b.url(), issue_filter, Duration::from_secs(5)).await; println!("Issue synced to relay_b: {}", issue_synced); assert!(issue_synced, "Layer 2 issue should sync first"); @@ -412,7 +416,11 @@ async fn test_layer3_sync_with_lowercase_e_tag() { .expect("Failed to create reply"); let reply_id = reply.id; - println!("Created reply {} (kind {}) with lowercase 'e' tag", reply_id, reply.kind.as_u16()); + println!( + "Created reply {} (kind {}) with lowercase 'e' tag", + reply_id, + reply.kind.as_u16() + ); for tag in reply.tags.iter() { println!(" Tag: {:?}", tag.as_slice()); } @@ -428,11 +436,12 @@ async fn test_layer3_sync_with_lowercase_e_tag() { // 7. Wait and verify reply syncs to relay_b let reply_filter = Filter::new() - .kind(Kind::TextNote) // Kind 1 + .kind(Kind::TextNote) // Kind 1 .author(keys.public_key()) .id(reply_id); - let reply_synced = wait_for_event_on_relay(relay_b.url(), reply_filter, Duration::from_secs(5)).await; + let reply_synced = + wait_for_event_on_relay(relay_b.url(), reply_filter, Duration::from_secs(5)).await; println!("Reply {} synced to relay_b: {}", reply_id, reply_synced); @@ -473,11 +482,8 @@ async fn test_layer3_sync_with_uppercase_e_tag() { // 2. Create and send repository announcement to both relays let repo_id = "test-repo-tag-9b"; - let announcement = create_repo_announcement( - &keys, - &[&relay_a.domain(), &relay_b.domain()], - repo_id, - ); + let announcement = + create_repo_announcement(&keys, &[&relay_a.domain(), &relay_b.domain()], repo_id); let client_a = TestClient::new(relay_a.url(), keys.clone()) .await @@ -515,10 +521,9 @@ async fn test_layer3_sync_with_uppercase_e_tag() { println!("Layer 2 issue {} sent to relay_a", issue_id); // 5. Wait for issue to sync to relay_b - let issue_filter = Filter::new() - .kind(Kind::Custom(KIND_ISSUE)) - .id(issue_id); - let issue_synced = wait_for_event_on_relay(relay_b.url(), issue_filter, Duration::from_secs(5)).await; + let issue_filter = Filter::new().kind(Kind::Custom(KIND_ISSUE)).id(issue_id); + let issue_synced = + wait_for_event_on_relay(relay_b.url(), issue_filter, Duration::from_secs(5)).await; println!("Issue synced to relay_b: {}", issue_synced); assert!(issue_synced, "Layer 2 issue should sync first"); @@ -531,11 +536,16 @@ async fn test_layer3_sync_with_uppercase_e_tag() { tokio::time::sleep(Duration::from_millis(500)).await; // 6. Create and send Layer 3 comment with uppercase 'E' tag (kind 1111) - let comment = build_layer3_comment_with_uppercase_e_tag(&keys, &issue_id, "Comment with uppercase E tag") - .expect("Failed to create comment"); + let comment = + build_layer3_comment_with_uppercase_e_tag(&keys, &issue_id, "Comment with uppercase E tag") + .expect("Failed to create comment"); let comment_id = comment.id; - println!("Created comment {} (kind {}) with uppercase 'E' tag", comment_id, comment.kind.as_u16()); + println!( + "Created comment {} (kind {}) with uppercase 'E' tag", + comment_id, + comment.kind.as_u16() + ); for tag in comment.tags.iter() { println!(" Tag: {:?}", tag.as_slice()); } @@ -551,13 +561,17 @@ async fn test_layer3_sync_with_uppercase_e_tag() { // 7. Wait and verify comment syncs to relay_b let comment_filter = Filter::new() - .kind(Kind::Custom(KIND_COMMENT)) // Kind 1111 + .kind(Kind::Custom(KIND_COMMENT)) // Kind 1111 .author(keys.public_key()) .id(comment_id); - let comment_synced = wait_for_event_on_relay(relay_b.url(), comment_filter, Duration::from_secs(5)).await; + let comment_synced = + wait_for_event_on_relay(relay_b.url(), comment_filter, Duration::from_secs(5)).await; - println!("Comment {} synced to relay_b: {}", comment_id, comment_synced); + println!( + "Comment {} synced to relay_b: {}", + comment_id, comment_synced + ); // 8. Cleanup relay_b.stop().await; @@ -596,11 +610,8 @@ async fn test_layer3_sync_with_q_tag() { // 2. Create and send repository announcement to both relays let repo_id = "test-repo-tag-9c"; - let announcement = create_repo_announcement( - &keys, - &[&relay_a.domain(), &relay_b.domain()], - repo_id, - ); + let announcement = + create_repo_announcement(&keys, &[&relay_a.domain(), &relay_b.domain()], repo_id); let client_a = TestClient::new(relay_a.url(), keys.clone()) .await @@ -638,10 +649,9 @@ async fn test_layer3_sync_with_q_tag() { println!("Layer 2 issue {} sent to relay_a", issue_id); // 5. Wait for issue to sync to relay_b - let issue_filter = Filter::new() - .kind(Kind::Custom(KIND_ISSUE)) - .id(issue_id); - let issue_synced = wait_for_event_on_relay(relay_b.url(), issue_filter, Duration::from_secs(5)).await; + let issue_filter = Filter::new().kind(Kind::Custom(KIND_ISSUE)).id(issue_id); + let issue_synced = + wait_for_event_on_relay(relay_b.url(), issue_filter, Duration::from_secs(5)).await; println!("Issue synced to relay_b: {}", issue_synced); assert!(issue_synced, "Layer 2 issue should sync first"); @@ -658,7 +668,11 @@ async fn test_layer3_sync_with_q_tag() { .expect("Failed to create quote"); let quote_id = quote.id; - println!("Created quote {} (kind {}) with 'q' tag", quote_id, quote.kind.as_u16()); + println!( + "Created quote {} (kind {}) with 'q' tag", + quote_id, + quote.kind.as_u16() + ); for tag in quote.tags.iter() { println!(" Tag: {:?}", tag.as_slice()); } @@ -674,11 +688,12 @@ async fn test_layer3_sync_with_q_tag() { // 7. Wait and verify quote syncs to relay_b let quote_filter = Filter::new() - .kind(Kind::TextNote) // Kind 1 + .kind(Kind::TextNote) // Kind 1 .author(keys.public_key()) .id(quote_id); - let quote_synced = wait_for_event_on_relay(relay_b.url(), quote_filter, Duration::from_secs(5)).await; + let quote_synced = + wait_for_event_on_relay(relay_b.url(), quote_filter, Duration::from_secs(5)).await; println!("Quote {} synced to relay_b: {}", quote_id, quote_synced); @@ -690,4 +705,4 @@ async fn test_layer3_sync_with_q_tag() { quote_synced, "Layer 3 quote with 'q' tag should have synced to relay_b" ); -} \ No newline at end of file +} -- cgit v1.2.3