From 3fd6ce4149d567c67009b0332ca76c0cd6f51055 Mon Sep 17 00:00:00 2001 From: DanConwayDev Date: Thu, 12 Feb 2026 12:36:23 +0000 Subject: refactor(grasp-audit): introduce SpecRef enum for type-safe spec references Replace string-based spec references with typed SpecRef enum for compile-time validation and better IDE support. TestResult::new() now accepts SpecRef enum plus a requirement description string for test-specific context. --- grasp-audit/src/specs/grasp01/nip11_document.rs | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 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 19ceace..5bf53bd 100644 --- a/grasp-audit/src/specs/grasp01/nip11_document.rs +++ b/grasp-audit/src/specs/grasp01/nip11_document.rs @@ -8,6 +8,7 @@ //! - Includes repo_acceptance_criteria field describing acceptance policy //! - Handles curation field correctly (present if curated, absent otherwise) +use crate::specs::grasp01::SpecRef; use crate::{AuditClient, AuditResult, TestResult}; pub struct Nip11DocumentTests; @@ -37,8 +38,8 @@ impl Nip11DocumentTests { pub async fn test_nip11_document_exists(client: &AuditClient) -> TestResult { TestResult::new( "nip11_document_exists", - "GRASP-01:nostr-relay:26", - "Serve NIP-11 relay information document", + SpecRef::Nip11ServeDocument, + "MUST serve NIP-11 document", ) .run(|| async { // 1. Extract HTTP(S) URL from client's WebSocket URL @@ -96,8 +97,8 @@ impl Nip11DocumentTests { pub async fn test_nip11_supported_grasps_field(client: &AuditClient) -> TestResult { TestResult::new( "nip11_supported_grasps_field", - "GRASP-01:nostr-relay:28", - "NIP-11 document includes supported_grasps field with GRASP-01", + SpecRef::Nip11ListSupportedGrasps, + "MUST list supported GRASPs as string array", ) .run(|| async { // 1. Fetch NIP-11 document @@ -172,8 +173,8 @@ impl Nip11DocumentTests { pub async fn test_nip11_repo_acceptance_criteria_field(client: &AuditClient) -> TestResult { TestResult::new( "nip11_repo_acceptance_criteria_field", - "GRASP-01:nostr-relay:29", - "NIP-11 document includes repo_acceptance_criteria field", + SpecRef::Nip11ListRepoAcceptanceCriteria, + "MUST list repository acceptance criteria", ) .run(|| async { // 1. Fetch NIP-11 document @@ -227,8 +228,8 @@ impl Nip11DocumentTests { pub async fn test_nip11_curation_field(client: &AuditClient) -> TestResult { TestResult::new( "nip11_curation_field", - "GRASP-01:nostr-relay:30", - "NIP-11 curation field present if curated, absent otherwise", + SpecRef::Nip11ListCurationPolicy, + "MUST include curation if curated, omit otherwise", ) .run(|| async { // 1. Fetch NIP-11 document -- cgit v1.2.3