diff options
| author | DanConwayDev <DanConwayDev@protonmail.com> | 2026-02-12 12:36:23 +0000 |
|---|---|---|
| committer | DanConwayDev <DanConwayDev@protonmail.com> | 2026-02-12 12:36:23 +0000 |
| commit | 3fd6ce4149d567c67009b0332ca76c0cd6f51055 (patch) | |
| tree | 2316c9a07fafcf419bea4369823ff9741c755080 /grasp-audit/src/specs/grasp01/event_acceptance_policy.rs | |
| parent | 869fd91e5c652c48a32d284eedc989a79c7afaea (diff) | |
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.
Diffstat (limited to 'grasp-audit/src/specs/grasp01/event_acceptance_policy.rs')
| -rw-r--r-- | grasp-audit/src/specs/grasp01/event_acceptance_policy.rs | 45 |
1 files changed, 23 insertions, 22 deletions
diff --git a/grasp-audit/src/specs/grasp01/event_acceptance_policy.rs b/grasp-audit/src/specs/grasp01/event_acceptance_policy.rs index 5b697d8..8259283 100644 --- a/grasp-audit/src/specs/grasp01/event_acceptance_policy.rs +++ b/grasp-audit/src/specs/grasp01/event_acceptance_policy.rs | |||
| @@ -92,6 +92,7 @@ | |||
| 92 | //! - Transitive tests verify multi-hop acceptance chains | 92 | //! - Transitive tests verify multi-hop acceptance chains |
| 93 | 93 | ||
| 94 | use crate::fixtures::{send_and_verify_accepted, send_and_verify_rejected}; | 94 | use crate::fixtures::{send_and_verify_accepted, send_and_verify_rejected}; |
| 95 | use crate::specs::grasp01::SpecRef; | ||
| 95 | use crate::{AuditClient, AuditResult, FixtureKind, TestContext, TestResult}; | 96 | use crate::{AuditClient, AuditResult, FixtureKind, TestContext, TestResult}; |
| 96 | use nostr_sdk::{Event, Filter, Kind, Tag, TagKind, Timestamp, ToBech32}; | 97 | use nostr_sdk::{Event, Filter, Kind, Tag, TagKind, Timestamp, ToBech32}; |
| 97 | use std::time::Duration; | 98 | use std::time::Duration; |
| @@ -148,8 +149,8 @@ impl EventAcceptancePolicyTests { | |||
| 148 | pub async fn test_accept_valid_repo_announcement(client: &AuditClient) -> TestResult { | 149 | pub async fn test_accept_valid_repo_announcement(client: &AuditClient) -> TestResult { |
| 149 | TestResult::new( | 150 | TestResult::new( |
| 150 | "accept_valid_repo_announcement", | 151 | "accept_valid_repo_announcement", |
| 151 | "GRASP-01:nostr-relay:7", | 152 | SpecRef::NostrRelayNip01Compliant, |
| 152 | "Accept valid repository announcements with service in clone and relays tags", | 153 | "MUST accept repo announcements listing service in clone & relays tags", |
| 153 | ) | 154 | ) |
| 154 | .run(|| async { | 155 | .run(|| async { |
| 155 | // Create TestContext for mode-aware fixture management | 156 | // Create TestContext for mode-aware fixture management |
| @@ -253,8 +254,8 @@ impl EventAcceptancePolicyTests { | |||
| 253 | ) -> TestResult { | 254 | ) -> TestResult { |
| 254 | TestResult::new( | 255 | TestResult::new( |
| 255 | "reject_repo_announcement_missing_clone_tag", | 256 | "reject_repo_announcement_missing_clone_tag", |
| 256 | "GRASP-01:nostr-relay:9", | 257 | SpecRef::NostrRelayRejectMissingCloneRelays, |
| 257 | "Reject repository announcements without service in clone tag", | 258 | "MUST reject announcements not listing service in clone tag", |
| 258 | ) | 259 | ) |
| 259 | .run(|| async { | 260 | .run(|| async { |
| 260 | // Get relay URL from client | 261 | // Get relay URL from client |
| @@ -329,8 +330,8 @@ impl EventAcceptancePolicyTests { | |||
| 329 | ) -> TestResult { | 330 | ) -> TestResult { |
| 330 | TestResult::new( | 331 | TestResult::new( |
| 331 | "reject_repo_announcement_missing_relays_tag", | 332 | "reject_repo_announcement_missing_relays_tag", |
| 332 | "GRASP-01:nostr-relay:9", | 333 | SpecRef::NostrRelayRejectMissingCloneRelays, |
| 333 | "Reject repository announcements without service in relays tag", | 334 | "MUST reject announcements not listing service in relays tag", |
| 334 | ) | 335 | ) |
| 335 | .run(|| async { | 336 | .run(|| async { |
| 336 | // Get relay URL from client | 337 | // Get relay URL from client |
| @@ -425,8 +426,8 @@ impl EventAcceptancePolicyTests { | |||
| 425 | ) -> TestResult { | 426 | ) -> TestResult { |
| 426 | TestResult::new( | 427 | TestResult::new( |
| 427 | "accept_recursive_maintainer_announcement_without_service", | 428 | "accept_recursive_maintainer_announcement_without_service", |
| 428 | "GRASP-01:nostr-relay:9", | 429 | SpecRef::NostrRelayRejectMissingCloneRelays, |
| 429 | "Accept recursive maintainer announcement for chain discovery (even without GRASP server in clone)", | 430 | "MUST accept recursive maintainer announcements for chain discovery", |
| 430 | ) | 431 | ) |
| 431 | .run(|| async { | 432 | .run(|| async { |
| 432 | // Create TestContext for mode-aware fixture management | 433 | // Create TestContext for mode-aware fixture management |
| @@ -593,7 +594,7 @@ impl EventAcceptancePolicyTests { | |||
| 593 | pub async fn test_accept_issue_via_a_tag(client: &AuditClient) -> TestResult { | 594 | pub async fn test_accept_issue_via_a_tag(client: &AuditClient) -> TestResult { |
| 594 | TestResult::new( | 595 | TestResult::new( |
| 595 | "accept_issue_via_a_tag", | 596 | "accept_issue_via_a_tag", |
| 596 | "GRASP-01:nostr-relay:13", | 597 | SpecRef::NostrRelayMustAcceptTaggedEvents, |
| 597 | "Accept issue referencing repo via 'a' tag", | 598 | "Accept issue referencing repo via 'a' tag", |
| 598 | ) | 599 | ) |
| 599 | .run(|| async { | 600 | .run(|| async { |
| @@ -628,7 +629,7 @@ impl EventAcceptancePolicyTests { | |||
| 628 | pub async fn test_accept_comment_via_capital_a_tag(client: &AuditClient) -> TestResult { | 629 | pub async fn test_accept_comment_via_capital_a_tag(client: &AuditClient) -> TestResult { |
| 629 | TestResult::new( | 630 | TestResult::new( |
| 630 | "accept_comment_via_A_tag", | 631 | "accept_comment_via_A_tag", |
| 631 | "GRASP-01:nostr-relay:13", | 632 | SpecRef::NostrRelayMustAcceptTaggedEvents, |
| 632 | "Accept NIP-22 comment with root 'A' tag referencing repo", | 633 | "Accept NIP-22 comment with root 'A' tag referencing repo", |
| 633 | ) | 634 | ) |
| 634 | .run(|| async { | 635 | .run(|| async { |
| @@ -681,8 +682,8 @@ impl EventAcceptancePolicyTests { | |||
| 681 | pub async fn test_accept_kind1_via_q_tag(client: &AuditClient) -> TestResult { | 682 | pub async fn test_accept_kind1_via_q_tag(client: &AuditClient) -> TestResult { |
| 682 | TestResult::new( | 683 | TestResult::new( |
| 683 | "accept_kind1_via_q_tag", | 684 | "accept_kind1_via_q_tag", |
| 684 | "GRASP-01:nostr-relay:13", | 685 | SpecRef::NostrRelayMustAcceptTaggedEvents, |
| 685 | "Accept kind 1 note quoting repo via 'q' tag", | 686 | "Accept kind 1 text note quoting repo via 'q' tag", |
| 686 | ) | 687 | ) |
| 687 | .run(|| async { | 688 | .run(|| async { |
| 688 | // Create TestContext | 689 | // Create TestContext |
| @@ -731,8 +732,8 @@ impl EventAcceptancePolicyTests { | |||
| 731 | pub async fn test_accept_issue_quoting_issue_via_q(client: &AuditClient) -> TestResult { | 732 | pub async fn test_accept_issue_quoting_issue_via_q(client: &AuditClient) -> TestResult { |
| 732 | TestResult::new( | 733 | TestResult::new( |
| 733 | "accept_issue_quoting_issue_via_q", | 734 | "accept_issue_quoting_issue_via_q", |
| 734 | "GRASP-01:nostr-relay:13", | 735 | SpecRef::NostrRelayMustAcceptTaggedEvents, |
| 735 | "Accept issue quoting accepted issue (transitive)", | 736 | "Accept issue quoting another accepted issue (transitive)", |
| 736 | ) | 737 | ) |
| 737 | .run(|| async { | 738 | .run(|| async { |
| 738 | // Create TestContext | 739 | // Create TestContext |
| @@ -777,7 +778,7 @@ impl EventAcceptancePolicyTests { | |||
| 777 | pub async fn test_accept_comment_via_capital_e_tag(client: &AuditClient) -> TestResult { | 778 | pub async fn test_accept_comment_via_capital_e_tag(client: &AuditClient) -> TestResult { |
| 778 | TestResult::new( | 779 | TestResult::new( |
| 779 | "accept_comment_via_E_tag", | 780 | "accept_comment_via_E_tag", |
| 780 | "GRASP-01:nostr-relay:13", | 781 | SpecRef::NostrRelayMustAcceptTaggedEvents, |
| 781 | "Accept NIP-22 comment with root 'E' tag to accepted issue", | 782 | "Accept NIP-22 comment with root 'E' tag to accepted issue", |
| 782 | ) | 783 | ) |
| 783 | .run(|| async { | 784 | .run(|| async { |
| @@ -816,7 +817,7 @@ impl EventAcceptancePolicyTests { | |||
| 816 | pub async fn test_accept_kind1_via_e_tag(client: &AuditClient) -> TestResult { | 817 | pub async fn test_accept_kind1_via_e_tag(client: &AuditClient) -> TestResult { |
| 817 | TestResult::new( | 818 | TestResult::new( |
| 818 | "accept_kind1_via_e_tag", | 819 | "accept_kind1_via_e_tag", |
| 819 | "GRASP-01:nostr-relay:13", | 820 | SpecRef::NostrRelayMustAcceptTaggedEvents, |
| 820 | "Accept kind 1 reply via 'e' tag to accepted kind 1", | 821 | "Accept kind 1 reply via 'e' tag to accepted kind 1", |
| 821 | ) | 822 | ) |
| 822 | .run(|| async { | 823 | .run(|| async { |
| @@ -872,7 +873,7 @@ impl EventAcceptancePolicyTests { | |||
| 872 | pub async fn test_accept_kind1_referenced_in_issue(client: &AuditClient) -> TestResult { | 873 | pub async fn test_accept_kind1_referenced_in_issue(client: &AuditClient) -> TestResult { |
| 873 | TestResult::new( | 874 | TestResult::new( |
| 874 | "accept_kind1_referenced_in_issue", | 875 | "accept_kind1_referenced_in_issue", |
| 875 | "GRASP-01:nostr-relay:13", | 876 | SpecRef::NostrRelayMustAcceptTaggedEvents, |
| 876 | "Accept kind 1 referenced in accepted issue (forward ref)", | 877 | "Accept kind 1 referenced in accepted issue (forward ref)", |
| 877 | ) | 878 | ) |
| 878 | .run(|| async { | 879 | .run(|| async { |
| @@ -964,7 +965,7 @@ impl EventAcceptancePolicyTests { | |||
| 964 | pub async fn test_accept_comment_referenced_in_comment(client: &AuditClient) -> TestResult { | 965 | pub async fn test_accept_comment_referenced_in_comment(client: &AuditClient) -> TestResult { |
| 965 | TestResult::new( | 966 | TestResult::new( |
| 966 | "accept_comment_referenced_in_comment", | 967 | "accept_comment_referenced_in_comment", |
| 967 | "GRASP-01:nostr-relay:13", | 968 | SpecRef::NostrRelayMustAcceptTaggedEvents, |
| 968 | "Accept comment referenced in another accepted comment (forward ref)", | 969 | "Accept comment referenced in another accepted comment (forward ref)", |
| 969 | ) | 970 | ) |
| 970 | .run(|| async { | 971 | .run(|| async { |
| @@ -1025,7 +1026,7 @@ impl EventAcceptancePolicyTests { | |||
| 1025 | pub async fn test_accept_kind1_referenced_in_kind1(client: &AuditClient) -> TestResult { | 1026 | pub async fn test_accept_kind1_referenced_in_kind1(client: &AuditClient) -> TestResult { |
| 1026 | TestResult::new( | 1027 | TestResult::new( |
| 1027 | "accept_kind1_referenced_in_kind1", | 1028 | "accept_kind1_referenced_in_kind1", |
| 1028 | "GRASP-01:nostr-relay:13", | 1029 | SpecRef::NostrRelayMustAcceptTaggedEvents, |
| 1029 | "Accept kind 1 referenced in another accepted kind 1 (forward ref)", | 1030 | "Accept kind 1 referenced in another accepted kind 1 (forward ref)", |
| 1030 | ) | 1031 | ) |
| 1031 | .run(|| async { | 1032 | .run(|| async { |
| @@ -1083,7 +1084,7 @@ impl EventAcceptancePolicyTests { | |||
| 1083 | pub async fn test_reject_orphan_issue(client: &AuditClient) -> TestResult { | 1084 | pub async fn test_reject_orphan_issue(client: &AuditClient) -> TestResult { |
| 1084 | TestResult::new( | 1085 | TestResult::new( |
| 1085 | "reject_orphan_issue", | 1086 | "reject_orphan_issue", |
| 1086 | "GRASP-01:nostr-relay:18", | 1087 | SpecRef::NostrRelayMayRejectSpamCuration, |
| 1087 | "Reject issue referencing unaccepted repo", | 1088 | "Reject issue referencing unaccepted repo", |
| 1088 | ) | 1089 | ) |
| 1089 | .run(|| async { | 1090 | .run(|| async { |
| @@ -1110,7 +1111,7 @@ impl EventAcceptancePolicyTests { | |||
| 1110 | pub async fn test_reject_orphan_kind1(client: &AuditClient) -> TestResult { | 1111 | pub async fn test_reject_orphan_kind1(client: &AuditClient) -> TestResult { |
| 1111 | TestResult::new( | 1112 | TestResult::new( |
| 1112 | "reject_orphan_kind1", | 1113 | "reject_orphan_kind1", |
| 1113 | "GRASP-01:nostr-relay:18", | 1114 | SpecRef::NostrRelayMayRejectSpamCuration, |
| 1114 | "Reject kind 1 with no repo references", | 1115 | "Reject kind 1 with no repo references", |
| 1115 | ) | 1116 | ) |
| 1116 | .run(|| async { | 1117 | .run(|| async { |
| @@ -1139,7 +1140,7 @@ impl EventAcceptancePolicyTests { | |||
| 1139 | pub async fn test_reject_comment_quoting_other_repo(client: &AuditClient) -> TestResult { | 1140 | pub async fn test_reject_comment_quoting_other_repo(client: &AuditClient) -> TestResult { |
| 1140 | TestResult::new( | 1141 | TestResult::new( |
| 1141 | "reject_comment_quoting_other_repo", | 1142 | "reject_comment_quoting_other_repo", |
| 1142 | "GRASP-01:nostr-relay:18", | 1143 | SpecRef::NostrRelayMayRejectSpamCuration, |
| 1143 | "Reject comment quoting unaccepted repo", | 1144 | "Reject comment quoting unaccepted repo", |
| 1144 | ) | 1145 | ) |
| 1145 | .run(|| async { | 1146 | .run(|| async { |