From bf7f4d5381203d5c27b2811d62c5b1781533aa2b Mon Sep 17 00:00:00 2001 From: DanConwayDev Date: Wed, 19 Nov 2025 17:01:36 +0000 Subject: fix some clippy fmt warnings --- grasp-audit/src/specs/grasp01/nip11_document.rs | 71 +++++++++++++------------ 1 file changed, 36 insertions(+), 35 deletions(-) (limited to 'grasp-audit/src/specs/grasp01/nip11_document.rs') diff --git a/grasp-audit/src/specs/grasp01/nip11_document.rs b/grasp-audit/src/specs/grasp01/nip11_document.rs index 3f9c04a..be04777 100644 --- a/grasp-audit/src/specs/grasp01/nip11_document.rs +++ b/grasp-audit/src/specs/grasp01/nip11_document.rs @@ -9,7 +9,6 @@ //! - Handles curation field correctly (present if curated, absent otherwise) use crate::{AuditClient, AuditResult, TestResult}; -use nostr_sdk::prelude::*; pub struct Nip11DocumentTests; @@ -17,25 +16,25 @@ impl Nip11DocumentTests { /// Run all NIP-11 document tests pub async fn run_all(client: &AuditClient) -> AuditResult { let mut results = AuditResult::new("GRASP-01 NIP-11 Document Tests"); - + // NIP-11 relay information tests results.add(Self::test_nip11_document_exists(client).await); results.add(Self::test_nip11_supported_grasps_field(client).await); results.add(Self::test_nip11_repo_acceptance_criteria_field(client).await); results.add(Self::test_nip11_curation_field(client).await); - + results } - + // ========================================================================= // NIP-11 Relay Information Tests // ========================================================================= - + /// Test: Serve NIP-11 document /// /// Spec: Line 11 of ../grasp/01.md /// Requirement: MUST serve NIP-11 document - async fn test_nip11_document_exists(client: &AuditClient) -> TestResult { + async fn test_nip11_document_exists(_client: &AuditClient) -> TestResult { TestResult::new( "nip11_document_exists", "GRASP-01:nostr-relay:11", @@ -52,17 +51,17 @@ impl Nip11DocumentTests { // 4. Verify response is valid JSON // 5. Parse as NIP-11 document // 6. Verify has required fields (name, description, etc.) - + Err("Not implemented yet".to_string()) }) .await } - + /// Test: NIP-11 includes supported_grasps field /// /// Spec: Line 12 of ../grasp/01.md /// Requirement: MUST list supported GRASPs as string array - async fn test_nip11_supported_grasps_field(client: &AuditClient) -> TestResult { + async fn test_nip11_supported_grasps_field(_client: &AuditClient) -> TestResult { TestResult::new( "nip11_supported_grasps_field", "GRASP-01:nostr-relay:12", @@ -76,17 +75,17 @@ impl Nip11DocumentTests { // 4. Verify array includes "GRASP-01" // 5. Verify format: each entry matches pattern "GRASP-\d{2}" // 6. Document other GRASPs found (for info) - + Err("Not implemented yet".to_string()) }) .await } - + /// Test: NIP-11 includes repo_acceptance_criteria field /// /// Spec: Line 13 of ../grasp/01.md /// Requirement: MUST list repository acceptance criteria - async fn test_nip11_repo_acceptance_criteria_field(client: &AuditClient) -> TestResult { + async fn test_nip11_repo_acceptance_criteria_field(_client: &AuditClient) -> TestResult { TestResult::new( "nip11_repo_acceptance_criteria_field", "GRASP-01:nostr-relay:13", @@ -101,17 +100,17 @@ impl Nip11DocumentTests { // 5. Document the criteria (for info) // Examples: "Must list this relay in clone and relays tags" // "Pre-payment required via Lightning invoice" - + Err("Not implemented yet".to_string()) }) .await } - + /// Test: NIP-11 curation field handling /// /// Spec: Line 14 of ../grasp/01.md /// Requirement: MUST include curation if curated, omit otherwise - async fn test_nip11_curation_field(client: &AuditClient) -> TestResult { + async fn test_nip11_curation_field(_client: &AuditClient) -> TestResult { TestResult::new( "nip11_curation_field", "GRASP-01:nostr-relay:14", @@ -127,39 +126,41 @@ impl Nip11DocumentTests { // 4. If absent: // - Document that no curation beyond SPAM prevention // 5. Both cases are valid per spec - + Err("Not implemented yet".to_string()) }) .await } - } #[cfg(test)] mod tests { use super::*; use crate::AuditConfig; - -#[tokio::test] -#[ignore] // Requires running relay -async fn test_grasp01_nip11_document_against_relay() { - // Read relay URL from environment variable - must be supplied - let relay_url = std::env::var("RELAY_URL") - .expect("RELAY_URL environment variable must be set. Example: RELAY_URL=ws://localhost:18081"); - - let config = AuditConfig::ci(); - let client = AuditClient::new(&relay_url, config) - .await - .expect(&format!( - "Failed to connect to relay at {}. Ensure relay is running and accessible. \ + + #[tokio::test] + #[ignore] // Requires running relay + async fn test_grasp01_nip11_document_against_relay() { + // Read relay URL from environment variable - must be supplied + let relay_url = std::env::var("RELAY_URL").expect( + "RELAY_URL environment variable must be set. Example: RELAY_URL=ws://localhost:18081", + ); + + let config = AuditConfig::ci(); + let client = AuditClient::new(&relay_url, config) + .await + .unwrap_or_else(|_| { + panic!( + "Failed to connect to relay at {}. Ensure relay is running and accessible. \ Try: docker run --rm -p 18081:8081 ghcr.io/danconwaydev/ngit-relay:latest", - relay_url - )); - + relay_url + ) + }); + let results = Nip11DocumentTests::run_all(&client).await; results.print_report(); - + // Don't assert all passed yet - tests not implemented // assert!(results.all_passed(), "Some GRASP-01 NIP-11 document tests failed"); } -} \ No newline at end of file +} -- cgit v1.2.3