upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/grasp-audit/src/specs/grasp01/nip01_smoke.rs
diff options
context:
space:
mode:
Diffstat (limited to 'grasp-audit/src/specs/grasp01/nip01_smoke.rs')
-rw-r--r--grasp-audit/src/specs/grasp01/nip01_smoke.rs39
1 files changed, 20 insertions, 19 deletions
diff --git a/grasp-audit/src/specs/grasp01/nip01_smoke.rs b/grasp-audit/src/specs/grasp01/nip01_smoke.rs
index 4d0b8a4..e3206fc 100644
--- a/grasp-audit/src/specs/grasp01/nip01_smoke.rs
+++ b/grasp-audit/src/specs/grasp01/nip01_smoke.rs
@@ -4,6 +4,7 @@
4//! We don't comprehensively test NIP-01 because rust-nostr already has 1000+ tests. 4//! We don't comprehensively test NIP-01 because rust-nostr already has 1000+ tests.
5//! These are just smoke tests to ensure the relay is working at all. 5//! These are just smoke tests to ensure the relay is working at all.
6 6
7use crate::specs::grasp01::SpecRef;
7use crate::{AuditClient, AuditResult, FixtureKind, TestContext, TestResult}; 8use crate::{AuditClient, AuditResult, FixtureKind, TestContext, TestResult};
8use nostr_sdk::prelude::*; 9use nostr_sdk::prelude::*;
9 10
@@ -32,8 +33,8 @@ impl Nip01SmokeTests {
32 pub async fn test_websocket_connection(client: &AuditClient) -> TestResult { 33 pub async fn test_websocket_connection(client: &AuditClient) -> TestResult {
33 TestResult::new( 34 TestResult::new(
34 "websocket_connection", 35 "websocket_connection",
35 "GRASP-01:nostr-relay:7", 36 SpecRef::NostrRelayNip01Compliant,
36 "Can establish WebSocket connection to /", 37 "MUST serve a relay at / via WebSocket",
37 ) 38 )
38 .run(|| async { 39 .run(|| async {
39 if !client.is_connected().await { 40 if !client.is_connected().await {
@@ -61,16 +62,16 @@ impl Nip01SmokeTests {
61 pub async fn test_send_receive_event(client: &AuditClient) -> TestResult { 62 pub async fn test_send_receive_event(client: &AuditClient) -> TestResult {
62 TestResult::new( 63 TestResult::new(
63 "send_receive_event", 64 "send_receive_event",
64 "GRASP-01:nostr-relay:7", 65 SpecRef::NostrRelayNip01Compliant,
65 "Can send EVENT and receive OK response", 66 "MUST accept valid EVENT messages",
66 ) 67 )
67 .run(|| async { 68 .run(|| async {
68 // Step 1: GENERATE - Create TestContext and get ValidRepo fixture 69 // Step 1: GENERATE - Create TestContext and get ValidRepoServed fixture
69 let ctx = TestContext::new(client); 70 let ctx = TestContext::new(client);
70 let event = ctx 71 let event = ctx
71 .get_fixture(FixtureKind::ValidRepo) 72 .get_fixture(FixtureKind::ValidRepoServed)
72 .await 73 .await
73 .map_err(|e| format!("Failed to create ValidRepo fixture: {}", e))?; 74 .map_err(|e| format!("Failed to create ValidRepoServed fixture: {}", e))?;
74 75
75 let event_id = event.id; 76 let event_id = event.id;
76 77
@@ -121,22 +122,22 @@ impl Nip01SmokeTests {
121 /// 122 ///
122 /// ## Fixture-First Pattern 123 /// ## Fixture-First Pattern
123 /// 124 ///
124 /// 1. **Generate**: Create TestContext and get ValidRepo fixture 125 /// 1. **Generate**: Create TestContext and get ValidRepoServed fixture
125 /// 2. **Send**: Fixture already sends the event to relay 126 /// 2. **Send**: Fixture already sends the event to relay
126 /// 3. **Verify**: Subscribe and verify we receive the event 127 /// 3. **Verify**: Subscribe and verify we receive the event
127 pub async fn test_create_subscription(client: &AuditClient) -> TestResult { 128 pub async fn test_create_subscription(client: &AuditClient) -> TestResult {
128 TestResult::new( 129 TestResult::new(
129 "create_subscription", 130 "create_subscription",
130 "GRASP-01:nostr-relay:7", 131 SpecRef::NostrRelayNip01Compliant,
131 "Can create subscription with REQ and receive EOSE", 132 "MUST support REQ subscriptions",
132 ) 133 )
133 .run(|| async { 134 .run(|| async {
134 // Step 1: GENERATE - Create TestContext and get ValidRepo fixture 135 // Step 1: GENERATE - Create TestContext and get ValidRepoServed fixture
135 let ctx = TestContext::new(client); 136 let ctx = TestContext::new(client);
136 let _event = ctx 137 let _event = ctx
137 .get_fixture(FixtureKind::ValidRepo) 138 .get_fixture(FixtureKind::ValidRepoServed)
138 .await 139 .await
139 .map_err(|e| format!("Failed to create ValidRepo fixture: {}", e))?; 140 .map_err(|e| format!("Failed to create ValidRepoServed fixture: {}", e))?;
140 141
141 // Step 2: VERIFY - Subscribe to NIP-34 announcements from this author 142 // Step 2: VERIFY - Subscribe to NIP-34 announcements from this author
142 let filter = Filter::new() 143 let filter = Filter::new()
@@ -165,8 +166,8 @@ impl Nip01SmokeTests {
165 pub async fn test_close_subscription(client: &AuditClient) -> TestResult { 166 pub async fn test_close_subscription(client: &AuditClient) -> TestResult {
166 TestResult::new( 167 TestResult::new(
167 "close_subscription", 168 "close_subscription",
168 "GRASP-01:nostr-relay:7", 169 SpecRef::NostrRelayNip01Compliant,
169 "Can close subscriptions", 170 "MUST support CLOSE to end subscriptions",
170 ) 171 )
171 .run(|| async { 172 .run(|| async {
172 // For now, we just verify we can query events 173 // For now, we just verify we can query events
@@ -193,8 +194,8 @@ impl Nip01SmokeTests {
193 pub async fn test_reject_invalid_signature(client: &AuditClient) -> TestResult { 194 pub async fn test_reject_invalid_signature(client: &AuditClient) -> TestResult {
194 TestResult::new( 195 TestResult::new(
195 "reject_invalid_signature", 196 "reject_invalid_signature",
196 "GRASP-01:nostr-relay:7", 197 SpecRef::NostrRelayNip01Compliant,
197 "Rejects events with invalid signatures", 198 "MUST reject events with invalid signatures",
198 ) 199 )
199 .run(|| async { 200 .run(|| async {
200 // Create a valid event 201 // Create a valid event
@@ -247,8 +248,8 @@ impl Nip01SmokeTests {
247 pub async fn test_reject_invalid_event_id(client: &AuditClient) -> TestResult { 248 pub async fn test_reject_invalid_event_id(client: &AuditClient) -> TestResult {
248 TestResult::new( 249 TestResult::new(
249 "reject_invalid_event_id", 250 "reject_invalid_event_id",
250 "GRASP-01:nostr-relay:7", 251 SpecRef::NostrRelayNip01Compliant,
251 "Rejects events with invalid event IDs", 252 "MUST reject events where ID doesn't match hash",
252 ) 253 )
253 .run(|| async { 254 .run(|| async {
254 // Create a valid event 255 // Create a valid event