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/nip77_negentropy.rs | |
| 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/nip77_negentropy.rs')
| -rw-r--r-- | tests/nip77_negentropy.rs | 27 |
1 files changed, 16 insertions, 11 deletions
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() { | |||
| 45 | let keys = Keys::generate(); | 45 | let keys = Keys::generate(); |
| 46 | 46 | ||
| 47 | // Create a repository announcement that will be accepted by the relay | 47 | // Create a repository announcement that will be accepted by the relay |
| 48 | let announcement = create_repo_announcement( | 48 | let announcement = create_repo_announcement(&keys, &[&relay.domain()], "test-repo-nip77"); |
| 49 | &keys, | ||
| 50 | &[&relay.domain()], | ||
| 51 | "test-repo-nip77", | ||
| 52 | ); | ||
| 53 | let event1_id = announcement.id; | 49 | let event1_id = announcement.id; |
| 54 | println!("Created event 1: {} (kind {})", event1_id, announcement.kind.as_u16()); | 50 | println!( |
| 51 | "Created event 1: {} (kind {})", | ||
| 52 | event1_id, | ||
| 53 | announcement.kind.as_u16() | ||
| 54 | ); | ||
| 55 | 55 | ||
| 56 | // Create a second event (issue referencing the repo) | 56 | // Create a second event (issue referencing the repo) |
| 57 | let repo_coord = format!( | 57 | let repo_coord = format!( |
| @@ -63,7 +63,11 @@ async fn test_nip77_negentropy_sync_finds_events() { | |||
| 63 | let issue = build_layer2_issue_event(&keys, &repo_coord, "Test issue for NIP-77") | 63 | let issue = build_layer2_issue_event(&keys, &repo_coord, "Test issue for NIP-77") |
| 64 | .expect("Failed to build issue event"); | 64 | .expect("Failed to build issue event"); |
| 65 | let event2_id = issue.id; | 65 | let event2_id = issue.id; |
| 66 | println!("Created event 2: {} (kind {})", event2_id, issue.kind.as_u16()); | 66 | println!( |
| 67 | "Created event 2: {} (kind {})", | ||
| 68 | event2_id, | ||
| 69 | issue.kind.as_u16() | ||
| 70 | ); | ||
| 67 | 71 | ||
| 68 | // 3. Send events to relay using TestClient | 72 | // 3. Send events to relay using TestClient |
| 69 | let publish_client = TestClient::new(relay.url(), keys.clone()) | 73 | let publish_client = TestClient::new(relay.url(), keys.clone()) |
| @@ -99,9 +103,10 @@ async fn test_nip77_negentropy_sync_finds_events() { | |||
| 99 | tokio::time::sleep(Duration::from_millis(500)).await; | 103 | tokio::time::sleep(Duration::from_millis(500)).await; |
| 100 | 104 | ||
| 101 | // 6. Perform negentropy sync with filter matching our events | 105 | // 6. Perform negentropy sync with filter matching our events |
| 102 | let filter = Filter::new() | 106 | let filter = Filter::new().author(keys.public_key()).kinds(vec![ |
| 103 | .author(keys.public_key()) | 107 | Kind::Custom(KIND_REPOSITORY_STATE), |
| 104 | .kinds(vec![Kind::Custom(KIND_REPOSITORY_STATE), Kind::Custom(KIND_ISSUE)]); | 108 | Kind::Custom(KIND_ISSUE), |
| 109 | ]); | ||
| 105 | 110 | ||
| 106 | println!("Starting negentropy sync with filter: {:?}", filter); | 111 | println!("Starting negentropy sync with filter: {:?}", filter); |
| 107 | 112 | ||
| @@ -177,7 +182,7 @@ async fn test_nip77_negentropy_sync_empty_result() { | |||
| 177 | 182 | ||
| 178 | // 3. Sync with filter that won't match anything | 183 | // 3. Sync with filter that won't match anything |
| 179 | let filter = Filter::new() | 184 | let filter = Filter::new() |
| 180 | .author(keys.public_key()) // Random new key, no events exist | 185 | .author(keys.public_key()) // Random new key, no events exist |
| 181 | .kind(Kind::Custom(KIND_REPOSITORY_STATE)); | 186 | .kind(Kind::Custom(KIND_REPOSITORY_STATE)); |
| 182 | 187 | ||
| 183 | println!("Starting negentropy sync with empty filter"); | 188 | println!("Starting negentropy sync with empty filter"); |