diff options
| author | DanConwayDev <DanConwayDev@protonmail.com> | 2025-11-05 07:42:36 +0000 |
|---|---|---|
| committer | DanConwayDev <DanConwayDev@protonmail.com> | 2025-11-05 07:42:36 +0000 |
| commit | 64e607dd67f3777aa596596d74ee16e1bf9f4f27 (patch) | |
| tree | a34b35f71523f4b00ff870cd0913dc6ce98ae4be /grasp-audit/src/specs | |
| parent | b5bc16daa7e70e6c8a3576be38a8beb564294804 (diff) | |
fix: NIP-01 smoke test now sends NIP-34 repo announcement for GRASP compliance
- Modified test_send_receive_event to send kind 30617 (repo announcement)
- Added required tags: d, name, description, clone, relays
- Clone and relays tags now properly reference the GRASP server
- All 6 NIP-01 smoke tests now pass (100%)
Diffstat (limited to 'grasp-audit/src/specs')
| -rw-r--r-- | grasp-audit/src/specs/nip01_smoke.rs | 34 |
1 files changed, 30 insertions, 4 deletions
diff --git a/grasp-audit/src/specs/nip01_smoke.rs b/grasp-audit/src/specs/nip01_smoke.rs index 5fddf5d..bb7c79d 100644 --- a/grasp-audit/src/specs/nip01_smoke.rs +++ b/grasp-audit/src/specs/nip01_smoke.rs | |||
| @@ -49,6 +49,9 @@ impl Nip01SmokeTests { | |||
| 49 | /// | 49 | /// |
| 50 | /// Spec: NIP-01 EVENT message | 50 | /// Spec: NIP-01 EVENT message |
| 51 | /// Requirement: Relay MUST accept valid EVENT messages | 51 | /// Requirement: Relay MUST accept valid EVENT messages |
| 52 | /// | ||
| 53 | /// For GRASP servers, we send a NIP-34 repository announcement that lists | ||
| 54 | /// the GRASP server in clone and relays tags (required for acceptance). | ||
| 52 | async fn test_send_receive_event(client: &AuditClient) -> TestResult { | 55 | async fn test_send_receive_event(client: &AuditClient) -> TestResult { |
| 53 | TestResult::new( | 56 | TestResult::new( |
| 54 | "send_receive_event", | 57 | "send_receive_event", |
| @@ -56,9 +59,32 @@ impl Nip01SmokeTests { | |||
| 56 | "Can send EVENT and receive OK response", | 59 | "Can send EVENT and receive OK response", |
| 57 | ) | 60 | ) |
| 58 | .run(|| async { | 61 | .run(|| async { |
| 59 | // Create audit event | 62 | // Get relay URL from client |
| 63 | let relay_url = client.client().relays().await | ||
| 64 | .keys() | ||
| 65 | .next() | ||
| 66 | .ok_or("No relay URL found")? | ||
| 67 | .to_string(); | ||
| 68 | |||
| 69 | // Convert ws:// to http:// for clone URL | ||
| 70 | let http_url = relay_url | ||
| 71 | .replace("ws://", "http://") | ||
| 72 | .replace("wss://", "https://"); | ||
| 73 | |||
| 74 | // Create unique repository identifier | ||
| 75 | let repo_id = format!("smoke-test-{}", uuid::Uuid::new_v4()); | ||
| 76 | let npub = client.public_key().to_bech32() | ||
| 77 | .map_err(|e| format!("Failed to encode npub: {}", e))?; | ||
| 78 | |||
| 79 | // Create NIP-34 repository announcement (kind 30617) | ||
| 80 | // This event lists the GRASP server, so it should be accepted | ||
| 60 | let event = client | 81 | let event = client |
| 61 | .event_builder(Kind::TextNote, "NIP-01 smoke test event") | 82 | .event_builder(Kind::Custom(30617), "NIP-01 smoke test repository") |
| 83 | .tag(Tag::identifier(&repo_id)) // d tag | ||
| 84 | .tag(Tag::custom(TagKind::Custom("name".into()), vec!["Smoke Test Repo"])) | ||
| 85 | .tag(Tag::custom(TagKind::Custom("description".into()), vec!["Repository for NIP-01 smoke testing"])) | ||
| 86 | .tag(Tag::custom(TagKind::Custom("clone".into()), vec![format!("{}/{}/{}.git", http_url, npub, repo_id)])) | ||
| 87 | .tag(Tag::custom(TagKind::Custom("relays".into()), vec![relay_url.clone()])) | ||
| 62 | .build(client.keys()) | 88 | .build(client.keys()) |
| 63 | .map_err(|e| format!("Failed to build event: {}", e))?; | 89 | .map_err(|e| format!("Failed to build event: {}", e))?; |
| 64 | 90 | ||
| @@ -81,7 +107,7 @@ impl Nip01SmokeTests { | |||
| 81 | 107 | ||
| 82 | // Try to query it back | 108 | // Try to query it back |
| 83 | let filter = Filter::new() | 109 | let filter = Filter::new() |
| 84 | .kind(Kind::TextNote) | 110 | .kind(Kind::Custom(30617)) |
| 85 | .id(event_id); | 111 | .id(event_id); |
| 86 | 112 | ||
| 87 | let events = client | 113 | let events = client |
| @@ -92,7 +118,7 @@ impl Nip01SmokeTests { | |||
| 92 | if events.is_empty() { | 118 | if events.is_empty() { |
| 93 | // Debug: try querying without audit client filtering | 119 | // Debug: try querying without audit client filtering |
| 94 | eprintln!("Event not found with audit client query, trying direct client query..."); | 120 | eprintln!("Event not found with audit client query, trying direct client query..."); |
| 95 | let direct_filter = Filter::new().kind(Kind::TextNote).id(event_id); | 121 | let direct_filter = Filter::new().kind(Kind::Custom(30617)).id(event_id); |
| 96 | let direct_events = client.client().fetch_events(direct_filter, std::time::Duration::from_secs(5)).await | 122 | let direct_events = client.client().fetch_events(direct_filter, std::time::Duration::from_secs(5)).await |
| 97 | .map_err(|e| format!("Direct query failed: {}", e))?; | 123 | .map_err(|e| format!("Direct query failed: {}", e))?; |
| 98 | let direct_vec: Vec<Event> = direct_events.into_iter().collect(); | 124 | let direct_vec: Vec<Event> = direct_events.into_iter().collect(); |