From b28a356cb41077ccee12a9c52f4ef2054e76cac6 Mon Sep 17 00:00:00 2001 From: DanConwayDev Date: Fri, 9 Jan 2026 19:58:41 +0000 Subject: chore: cargo fmt --- tests/common/sync_helpers.rs | 2 +- tests/state_authorization.rs | 242 +++++++++++++------------- tests/sync/maintainer_reprocessing.rs | 311 ++++++++++++++++------------------ 3 files changed, 266 insertions(+), 289 deletions(-) (limited to 'tests') diff --git a/tests/common/sync_helpers.rs b/tests/common/sync_helpers.rs index d6a6ee4..5fc2ad7 100644 --- a/tests/common/sync_helpers.rs +++ b/tests/common/sync_helpers.rs @@ -708,7 +708,7 @@ impl ParsedMetrics { /// Check if a specific relay is connected pub fn relay_connected(&self, relay: &str) -> Option { self.gauge("ngit_sync_relay_connected", &[("relay", relay)]) - .map(|v| v >= 2) // Syncing (2), Connected (3), or ConnectedHistoricSyncFailures (4) + .map(|v| v >= 2) // Syncing (2), Connected (3), or ConnectedHistoricSyncFailures (4) } /// Get total number of connected relays diff --git a/tests/state_authorization.rs b/tests/state_authorization.rs index a5dfa2d..d443005 100644 --- a/tests/state_authorization.rs +++ b/tests/state_authorization.rs @@ -13,30 +13,27 @@ use nostr_sdk::prelude::*; async fn test_reject_state_without_announcement() { // Start test relay let relay = TestRelay::start().await; - + // Create test keypair let keys = Keys::generate(); - + // Create a state event without any announcement - let state_event = EventBuilder::new( - Kind::RepoState, - "", - ) - .tags([ - Tag::custom(TagKind::custom("d"), ["test-repo"]), - Tag::custom(TagKind::custom("refs/heads/main"), ["abc123"]), - ]) - .sign_with_keys(&keys) - .unwrap(); - + let state_event = EventBuilder::new(Kind::RepoState, "") + .tags([ + Tag::custom(TagKind::custom("d"), ["test-repo"]), + Tag::custom(TagKind::custom("refs/heads/main"), ["abc123"]), + ]) + .sign_with_keys(&keys) + .unwrap(); + // Connect to relay let client = Client::default(); client.add_relay(relay.url()).await.unwrap(); client.connect().await; - + // Try to send state event let result = client.send_event(&state_event).await; - + // Should be rejected match result { Ok(output) => { @@ -45,22 +42,26 @@ async fn test_reject_state_without_announcement() { "Event should be processed" ); // Check if any relay rejected it - let rejected = output.failed.values().any(|err| { - err.to_string().contains("no announcement exists") - }); - assert!(rejected, "Event should be rejected due to missing announcement"); + let rejected = output + .failed + .values() + .any(|err| err.to_string().contains("no announcement exists")); + assert!( + rejected, + "Event should be rejected due to missing announcement" + ); } Err(e) => { // Also acceptable - relay rejected the event assert!( - e.to_string().contains("no announcement exists") || - e.to_string().contains("rejected"), + e.to_string().contains("no announcement exists") + || e.to_string().contains("rejected"), "Error should indicate missing announcement: {}", e ); } } - + relay.stop().await; } @@ -68,67 +69,67 @@ async fn test_reject_state_without_announcement() { async fn test_reject_state_from_unauthorized_author() { // Start test relay let relay = TestRelay::start().await; - + // Create two keypairs: one for announcement, one for unauthorized state let announcement_keys = Keys::generate(); let unauthorized_keys = Keys::generate(); - + // Create announcement - let announcement = EventBuilder::new( - Kind::GitRepoAnnouncement, - "", - ) - .tags([ - Tag::custom(TagKind::custom("d"), ["test-repo"]), - Tag::custom(TagKind::custom("clone"), [format!("https://{}/test.git", relay.domain())]), - Tag::custom(TagKind::custom("relays"), [relay.url()]), - ]) - .sign_with_keys(&announcement_keys) - .unwrap(); - + let announcement = EventBuilder::new(Kind::GitRepoAnnouncement, "") + .tags([ + Tag::custom(TagKind::custom("d"), ["test-repo"]), + Tag::custom( + TagKind::custom("clone"), + [format!("https://{}/test.git", relay.domain())], + ), + Tag::custom(TagKind::custom("relays"), [relay.url()]), + ]) + .sign_with_keys(&announcement_keys) + .unwrap(); + // Connect to relay let client = Client::default(); client.add_relay(relay.url()).await.unwrap(); client.connect().await; - + // Send announcement client.send_event(&announcement).await.unwrap(); - + // Wait for announcement to be processed tokio::time::sleep(tokio::time::Duration::from_millis(100)).await; - + // Try to send state event from unauthorized author - let state_event = EventBuilder::new( - Kind::RepoState, - "", - ) - .tags([ - Tag::custom(TagKind::custom("d"), ["test-repo"]), - Tag::custom(TagKind::custom("refs/heads/main"), ["abc123"]), - ]) - .sign_with_keys(&unauthorized_keys) - .unwrap(); - + let state_event = EventBuilder::new(Kind::RepoState, "") + .tags([ + Tag::custom(TagKind::custom("d"), ["test-repo"]), + Tag::custom(TagKind::custom("refs/heads/main"), ["abc123"]), + ]) + .sign_with_keys(&unauthorized_keys) + .unwrap(); + let result = client.send_event(&state_event).await; - + // Should be rejected match result { Ok(output) => { - let rejected = output.failed.values().any(|err| { - err.to_string().contains("not authorized") - }); - assert!(rejected, "Event should be rejected due to unauthorized author"); + let rejected = output + .failed + .values() + .any(|err| err.to_string().contains("not authorized")); + assert!( + rejected, + "Event should be rejected due to unauthorized author" + ); } Err(e) => { assert!( - e.to_string().contains("not authorized") || - e.to_string().contains("rejected"), + e.to_string().contains("not authorized") || e.to_string().contains("rejected"), "Error should indicate unauthorized author: {}", e ); } } - + relay.stop().await; } @@ -136,48 +137,45 @@ async fn test_reject_state_from_unauthorized_author() { async fn test_accept_state_from_announcement_author() { // Start test relay let relay = TestRelay::start().await; - + // Create keypair let keys = Keys::generate(); - + // Create announcement - let announcement = EventBuilder::new( - Kind::GitRepoAnnouncement, - "", - ) - .tags([ - Tag::custom(TagKind::custom("d"), ["test-repo"]), - Tag::custom(TagKind::custom("clone"), [format!("https://{}/test.git", relay.domain())]), - Tag::custom(TagKind::custom("relays"), [relay.url()]), - ]) - .sign_with_keys(&keys) - .unwrap(); - + let announcement = EventBuilder::new(Kind::GitRepoAnnouncement, "") + .tags([ + Tag::custom(TagKind::custom("d"), ["test-repo"]), + Tag::custom( + TagKind::custom("clone"), + [format!("https://{}/test.git", relay.domain())], + ), + Tag::custom(TagKind::custom("relays"), [relay.url()]), + ]) + .sign_with_keys(&keys) + .unwrap(); + // Connect to relay let client = Client::default(); client.add_relay(relay.url()).await.unwrap(); client.connect().await; - + // Send announcement client.send_event(&announcement).await.unwrap(); - + // Wait for announcement to be processed tokio::time::sleep(tokio::time::Duration::from_millis(100)).await; - + // Send state event from same author (should be accepted or go to purgatory) - let state_event = EventBuilder::new( - Kind::RepoState, - "", - ) - .tags([ - Tag::custom(TagKind::custom("d"), ["test-repo"]), - Tag::custom(TagKind::custom("refs/heads/main"), ["abc123"]), - ]) - .sign_with_keys(&keys) - .unwrap(); - + let state_event = EventBuilder::new(Kind::RepoState, "") + .tags([ + Tag::custom(TagKind::custom("d"), ["test-repo"]), + Tag::custom(TagKind::custom("refs/heads/main"), ["abc123"]), + ]) + .sign_with_keys(&keys) + .unwrap(); + let result = client.send_event(&state_event).await; - + // Should be accepted or go to purgatory (not permanently rejected) match result { Ok(output) => { @@ -194,14 +192,13 @@ async fn test_accept_state_from_announcement_author() { Err(e) => { // Purgatory is acceptable assert!( - e.to_string().contains("purgatory") || - e.to_string().contains("waiting for git"), + e.to_string().contains("purgatory") || e.to_string().contains("waiting for git"), "Error should be about purgatory, not authorization: {}", e ); } } - + relay.stop().await; } @@ -209,50 +206,50 @@ async fn test_accept_state_from_announcement_author() { async fn test_accept_state_from_maintainer() { // Start test relay let relay = TestRelay::start().await; - + // Create two keypairs: owner and maintainer let owner_keys = Keys::generate(); let maintainer_keys = Keys::generate(); - + // Create announcement with maintainer - let announcement = EventBuilder::new( - Kind::GitRepoAnnouncement, - "", - ) - .tags([ - Tag::custom(TagKind::custom("d"), ["test-repo"]), - Tag::custom(TagKind::custom("clone"), [format!("https://{}/test.git", relay.domain())]), - Tag::custom(TagKind::custom("relays"), [relay.url()]), - Tag::custom(TagKind::custom("maintainers"), [maintainer_keys.public_key().to_hex()]), - ]) - .sign_with_keys(&owner_keys) - .unwrap(); - + let announcement = EventBuilder::new(Kind::GitRepoAnnouncement, "") + .tags([ + Tag::custom(TagKind::custom("d"), ["test-repo"]), + Tag::custom( + TagKind::custom("clone"), + [format!("https://{}/test.git", relay.domain())], + ), + Tag::custom(TagKind::custom("relays"), [relay.url()]), + Tag::custom( + TagKind::custom("maintainers"), + [maintainer_keys.public_key().to_hex()], + ), + ]) + .sign_with_keys(&owner_keys) + .unwrap(); + // Connect to relay let client = Client::default(); client.add_relay(relay.url()).await.unwrap(); client.connect().await; - + // Send announcement client.send_event(&announcement).await.unwrap(); - + // Wait for announcement to be processed tokio::time::sleep(tokio::time::Duration::from_millis(100)).await; - + // Send state event from maintainer - let state_event = EventBuilder::new( - Kind::RepoState, - "", - ) - .tags([ - Tag::custom(TagKind::custom("d"), ["test-repo"]), - Tag::custom(TagKind::custom("refs/heads/main"), ["abc123"]), - ]) - .sign_with_keys(&maintainer_keys) - .unwrap(); - + let state_event = EventBuilder::new(Kind::RepoState, "") + .tags([ + Tag::custom(TagKind::custom("d"), ["test-repo"]), + Tag::custom(TagKind::custom("refs/heads/main"), ["abc123"]), + ]) + .sign_with_keys(&maintainer_keys) + .unwrap(); + let result = client.send_event(&state_event).await; - + // Should be accepted or go to purgatory (not permanently rejected) match result { Ok(output) => { @@ -268,13 +265,12 @@ async fn test_accept_state_from_maintainer() { Err(e) => { // Purgatory is acceptable assert!( - e.to_string().contains("purgatory") || - e.to_string().contains("waiting for git"), + e.to_string().contains("purgatory") || e.to_string().contains("waiting for git"), "Error should be about purgatory, not authorization: {}", e ); } } - + relay.stop().await; } diff --git a/tests/sync/maintainer_reprocessing.rs b/tests/sync/maintainer_reprocessing.rs index 2b7fb0f..df1bf78 100644 --- a/tests/sync/maintainer_reprocessing.rs +++ b/tests/sync/maintainer_reprocessing.rs @@ -42,23 +42,18 @@ async fn test_maintainer_announcement_reprocessed_immediately() { .await .expect("Failed to connect to relay_a"); - let maintainer_announcement = EventBuilder::new( - Kind::GitRepoAnnouncement, - "Maintainer's repository", - ) - .tags(vec![ - Tag::identifier(identifier), - Tag::custom( - TagKind::custom("clone"), - vec![format!("https://{}/{}.git", relay_a.domain(), identifier)], - ), - Tag::custom( - TagKind::custom("relays"), - vec![relay_a.url().to_string()], - ), - ]) - .sign_with_keys(&maintainer_keys) - .unwrap(); + let maintainer_announcement = + EventBuilder::new(Kind::GitRepoAnnouncement, "Maintainer's repository") + .tags(vec![ + Tag::identifier(identifier), + Tag::custom( + TagKind::custom("clone"), + vec![format!("https://{}/{}.git", relay_a.domain(), identifier)], + ), + Tag::custom(TagKind::custom("relays"), vec![relay_a.url().to_string()]), + ]) + .sign_with_keys(&maintainer_keys) + .unwrap(); client_a.send_event(&maintainer_announcement).await.unwrap(); println!("✓ Maintainer announcement sent to relay_a"); @@ -68,27 +63,24 @@ async fn test_maintainer_announcement_reprocessed_immediately() { .await .expect("Failed to connect to relay_b"); - let owner_announcement = EventBuilder::new( - Kind::GitRepoAnnouncement, - "Owner's repository", - ) - .tags(vec![ - Tag::identifier(identifier), - Tag::custom( - TagKind::custom("clone"), - vec![format!("https://{}/{}.git", relay_b.domain(), identifier)], - ), - Tag::custom( - TagKind::custom("relays"), - vec![relay_a.url().to_string(), relay_b.url().to_string()], - ), - Tag::custom( - TagKind::custom("maintainers"), - vec![maintainer_keys.public_key().to_hex()], - ), - ]) - .sign_with_keys(&owner_keys) - .unwrap(); + let owner_announcement = EventBuilder::new(Kind::GitRepoAnnouncement, "Owner's repository") + .tags(vec![ + Tag::identifier(identifier), + Tag::custom( + TagKind::custom("clone"), + vec![format!("https://{}/{}.git", relay_b.domain(), identifier)], + ), + Tag::custom( + TagKind::custom("relays"), + vec![relay_a.url().to_string(), relay_b.url().to_string()], + ), + Tag::custom( + TagKind::custom("maintainers"), + vec![maintainer_keys.public_key().to_hex()], + ), + ]) + .sign_with_keys(&owner_keys) + .unwrap(); client_b.send_event(&owner_announcement).await.unwrap(); println!("✓ Owner announcement sent to relay_b"); @@ -104,7 +96,8 @@ async fn test_maintainer_announcement_reprocessed_immediately() { .author(owner_keys.public_key()) .identifier(identifier); - let owner_found = wait_for_event_on_relay(relay_b.url(), owner_filter, Duration::from_secs(2)).await; + let owner_found = + wait_for_event_on_relay(relay_b.url(), owner_filter, Duration::from_secs(2)).await; assert!(owner_found, "Owner announcement should be in relay_b"); let maintainer_filter = Filter::new() @@ -112,8 +105,12 @@ async fn test_maintainer_announcement_reprocessed_immediately() { .author(maintainer_keys.public_key()) .identifier(identifier); - let maintainer_found = wait_for_event_on_relay(relay_b.url(), maintainer_filter, Duration::from_secs(2)).await; - assert!(maintainer_found, "Maintainer announcement should be re-processed and accepted in relay_b"); + let maintainer_found = + wait_for_event_on_relay(relay_b.url(), maintainer_filter, Duration::from_secs(2)).await; + assert!( + maintainer_found, + "Maintainer announcement should be re-processed and accepted in relay_b" + ); // Step 5: Verify it happened quickly (not 24 hours!) assert!( @@ -145,36 +142,34 @@ async fn test_maintainer_announcement_reprocessed_immediately() { #[ignore] // Skip by default due to 2+ minute duration async fn test_maintainer_announcement_cold_index_prevents_refetch() { let relay = TestRelay::start().await; - + // Create keys let owner_keys = Keys::generate(); let maintainer_keys = Keys::generate(); let identifier = "test-repo-cold"; - + // Create client using TestClient helper let client = TestClient::new(relay.url(), maintainer_keys.clone()) .await .expect("Failed to connect to relay"); // Step 1: Send maintainer announcement (will be rejected - doesn't list our relay) - let maintainer_announcement = EventBuilder::new( - Kind::GitRepoAnnouncement, - "Maintainer's repository", - ) - .tags(vec![ - Tag::identifier(identifier), - Tag::custom( - TagKind::custom("clone"), - vec![format!("https://example.com/{}.git", identifier)], - ), - Tag::custom( - TagKind::custom("relays"), - vec!["wss://example.com".to_string()], - ), - ]) - .sign_with_keys(&maintainer_keys) - .unwrap(); + let maintainer_announcement = + EventBuilder::new(Kind::GitRepoAnnouncement, "Maintainer's repository") + .tags(vec![ + Tag::identifier(identifier), + Tag::custom( + TagKind::custom("clone"), + vec![format!("https://example.com/{}.git", identifier)], + ), + Tag::custom( + TagKind::custom("relays"), + vec!["wss://example.com".to_string()], + ), + ]) + .sign_with_keys(&maintainer_keys) + .unwrap(); // Send maintainer announcement - expect it to be rejected let _ = client.send_event(&maintainer_announcement).await; @@ -185,27 +180,21 @@ async fn test_maintainer_announcement_cold_index_prevents_refetch() { tokio::time::sleep(Duration::from_secs(125)).await; // Step 3: Send owner announcement (lists maintainer) - let owner_announcement = EventBuilder::new( - Kind::GitRepoAnnouncement, - "Owner's repository", - ) - .tags(vec![ - Tag::identifier(identifier), - Tag::custom( - TagKind::custom("clone"), - vec![format!("https://{}/{}.git", relay.domain(), identifier)], - ), - Tag::custom( - TagKind::custom("relays"), - vec![relay.url().to_string()], - ), - Tag::custom( - TagKind::custom("maintainers"), - vec![maintainer_keys.public_key().to_hex()], - ), - ]) - .sign_with_keys(&owner_keys) - .unwrap(); + let owner_announcement = EventBuilder::new(Kind::GitRepoAnnouncement, "Owner's repository") + .tags(vec![ + Tag::identifier(identifier), + Tag::custom( + TagKind::custom("clone"), + vec![format!("https://{}/{}.git", relay.domain(), identifier)], + ), + Tag::custom(TagKind::custom("relays"), vec![relay.url().to_string()]), + Tag::custom( + TagKind::custom("maintainers"), + vec![maintainer_keys.public_key().to_hex()], + ), + ]) + .sign_with_keys(&owner_keys) + .unwrap(); client.send_event(&owner_announcement).await.unwrap(); tokio::time::sleep(Duration::from_millis(500)).await; @@ -215,16 +204,18 @@ async fn test_maintainer_announcement_cold_index_prevents_refetch() { .kind(Kind::GitRepoAnnouncement) .author(owner_keys.public_key()) .identifier(identifier); - - let owner_found = wait_for_event_on_relay(relay.url(), owner_filter, Duration::from_secs(2)).await; + + let owner_found = + wait_for_event_on_relay(relay.url(), owner_filter, Duration::from_secs(2)).await; assert!(owner_found, "Owner announcement should be accepted"); let maintainer_filter = Filter::new() .kind(Kind::GitRepoAnnouncement) .author(maintainer_keys.public_key()) .identifier(identifier); - - let maintainer_found = wait_for_event_on_relay(relay.url(), maintainer_filter, Duration::from_millis(500)).await; + + let maintainer_found = + wait_for_event_on_relay(relay.url(), maintainer_filter, Duration::from_millis(500)).await; assert!( !maintainer_found, "Maintainer announcement should NOT be re-processed (hot cache expired)" @@ -267,7 +258,10 @@ async fn test_multiple_maintainers_all_reprocessed() { .await .expect("Failed to connect to relay_a"); - for (idx, maintainer_keys) in [&maintainer1_keys, &maintainer2_keys, &maintainer3_keys].iter().enumerate() { + for (idx, maintainer_keys) in [&maintainer1_keys, &maintainer2_keys, &maintainer3_keys] + .iter() + .enumerate() + { let announcement = EventBuilder::new( Kind::GitRepoAnnouncement, format!("Maintainer {} repository", idx + 1), @@ -278,10 +272,7 @@ async fn test_multiple_maintainers_all_reprocessed() { TagKind::custom("clone"), vec![format!("https://{}/{}.git", relay_a.domain(), identifier)], ), - Tag::custom( - TagKind::custom("relays"), - vec![relay_a.url().to_string()], - ), + Tag::custom(TagKind::custom("relays"), vec![relay_a.url().to_string()]), ]) .sign_with_keys(maintainer_keys) .unwrap(); @@ -295,31 +286,28 @@ async fn test_multiple_maintainers_all_reprocessed() { .await .expect("Failed to connect to relay_b"); - let owner_announcement = EventBuilder::new( - Kind::GitRepoAnnouncement, - "Owner's repository", - ) - .tags(vec![ - Tag::identifier(identifier), - Tag::custom( - TagKind::custom("clone"), - vec![format!("https://{}/{}.git", relay_b.domain(), identifier)], - ), - Tag::custom( - TagKind::custom("relays"), - vec![relay_a.url().to_string(), relay_b.url().to_string()], - ), - Tag::custom( - TagKind::custom("maintainers"), - vec![ - maintainer1_keys.public_key().to_hex(), - maintainer2_keys.public_key().to_hex(), - maintainer3_keys.public_key().to_hex(), - ], - ), - ]) - .sign_with_keys(&owner_keys) - .unwrap(); + let owner_announcement = EventBuilder::new(Kind::GitRepoAnnouncement, "Owner's repository") + .tags(vec![ + Tag::identifier(identifier), + Tag::custom( + TagKind::custom("clone"), + vec![format!("https://{}/{}.git", relay_b.domain(), identifier)], + ), + Tag::custom( + TagKind::custom("relays"), + vec![relay_a.url().to_string(), relay_b.url().to_string()], + ), + Tag::custom( + TagKind::custom("maintainers"), + vec![ + maintainer1_keys.public_key().to_hex(), + maintainer2_keys.public_key().to_hex(), + maintainer3_keys.public_key().to_hex(), + ], + ), + ]) + .sign_with_keys(&owner_keys) + .unwrap(); client_b.send_event(&owner_announcement).await.unwrap(); println!("✓ Owner announcement sent to relay_b"); @@ -340,11 +328,7 @@ async fn test_multiple_maintainers_all_reprocessed() { .identifier(identifier); let found = wait_for_event_on_relay(relay_b.url(), filter, Duration::from_secs(2)).await; - assert!( - found, - "{} announcement should be in relay_b", - name - ); + assert!(found, "{} announcement should be in relay_b", name); } println!("✅ All three maintainer announcements re-processed successfully"); @@ -365,63 +349,55 @@ async fn test_multiple_maintainers_all_reprocessed() { #[tokio::test] async fn test_invalid_maintainer_pubkey_handled_gracefully() { let relay = TestRelay::start().await; - + // Create keys let owner_keys = Keys::generate(); let maintainer_keys = Keys::generate(); let identifier = "invalid-maintainer-repo"; - + // Create client using TestClient helper let client = TestClient::new(relay.url(), owner_keys.clone()) .await .expect("Failed to connect to relay"); // Step 1: Send maintainer announcement (will be rejected - doesn't list our relay) - let maintainer_announcement = EventBuilder::new( - Kind::GitRepoAnnouncement, - "Maintainer's repository", - ) - .tags(vec![ - Tag::identifier(identifier), - Tag::custom( - TagKind::custom("clone"), - vec![format!("https://example.com/{}.git", identifier)], - ), - Tag::custom( - TagKind::custom("relays"), - vec!["wss://example.com".to_string()], - ), - ]) - .sign_with_keys(&maintainer_keys) - .unwrap(); + let maintainer_announcement = + EventBuilder::new(Kind::GitRepoAnnouncement, "Maintainer's repository") + .tags(vec![ + Tag::identifier(identifier), + Tag::custom( + TagKind::custom("clone"), + vec![format!("https://example.com/{}.git", identifier)], + ), + Tag::custom( + TagKind::custom("relays"), + vec!["wss://example.com".to_string()], + ), + ]) + .sign_with_keys(&maintainer_keys) + .unwrap(); // Send maintainer announcement - expect it to be rejected let _ = client.send_event(&maintainer_announcement).await; tokio::time::sleep(Duration::from_millis(200)).await; // Step 2: Send owner announcement with INVALID maintainer hex - let owner_announcement = EventBuilder::new( - Kind::GitRepoAnnouncement, - "Owner's repository", - ) - .tags(vec![ - Tag::identifier(identifier), - Tag::custom( - TagKind::custom("clone"), - vec![format!("https://{}/{}.git", relay.domain(), identifier)], - ), - Tag::custom( - TagKind::custom("relays"), - vec![relay.url().to_string()], - ), - Tag::custom( - TagKind::custom("maintainers"), - vec!["invalid-hex-not-a-pubkey".to_string()], - ), - ]) - .sign_with_keys(&owner_keys) - .unwrap(); + let owner_announcement = EventBuilder::new(Kind::GitRepoAnnouncement, "Owner's repository") + .tags(vec![ + Tag::identifier(identifier), + Tag::custom( + TagKind::custom("clone"), + vec![format!("https://{}/{}.git", relay.domain(), identifier)], + ), + Tag::custom(TagKind::custom("relays"), vec![relay.url().to_string()]), + Tag::custom( + TagKind::custom("maintainers"), + vec!["invalid-hex-not-a-pubkey".to_string()], + ), + ]) + .sign_with_keys(&owner_keys) + .unwrap(); client.send_event(&owner_announcement).await.unwrap(); tokio::time::sleep(Duration::from_millis(500)).await; @@ -431,16 +407,21 @@ async fn test_invalid_maintainer_pubkey_handled_gracefully() { .kind(Kind::GitRepoAnnouncement) .author(owner_keys.public_key()) .identifier(identifier); - - let owner_found = wait_for_event_on_relay(relay.url(), owner_filter, Duration::from_secs(2)).await; - assert!(owner_found, "Owner announcement should be accepted despite invalid maintainer"); + + let owner_found = + wait_for_event_on_relay(relay.url(), owner_filter, Duration::from_secs(2)).await; + assert!( + owner_found, + "Owner announcement should be accepted despite invalid maintainer" + ); let maintainer_filter = Filter::new() .kind(Kind::GitRepoAnnouncement) .author(maintainer_keys.public_key()) .identifier(identifier); - - let maintainer_found = wait_for_event_on_relay(relay.url(), maintainer_filter, Duration::from_millis(500)).await; + + let maintainer_found = + wait_for_event_on_relay(relay.url(), maintainer_filter, Duration::from_millis(500)).await; assert!( !maintainer_found, "Maintainer announcement should NOT be re-processed (invalid pubkey)" -- cgit v1.2.3