upleb.uk

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

summaryrefslogtreecommitdiff
path: root/tests/nip01_compliance.rs
diff options
context:
space:
mode:
authorDanConwayDev <DanConwayDev@protonmail.com>2025-11-19 11:55:32 +0000
committerDanConwayDev <DanConwayDev@protonmail.com>2025-11-19 15:43:29 +0000
commitfa065ad128882755f2a988d6203b59a2ab5e38ff (patch)
treee8326de70a6e6ea56b5bf4250e0a00a3cda4afed /tests/nip01_compliance.rs
parent98c6fa4bfa897ff0b8f9c95ea698d4d065b5e9f3 (diff)
add landing page and nostr-relay-builder relay on same port
Diffstat (limited to 'tests/nip01_compliance.rs')
-rw-r--r--tests/nip01_compliance.rs50
1 files changed, 25 insertions, 25 deletions
diff --git a/tests/nip01_compliance.rs b/tests/nip01_compliance.rs
index 3e2fdd3..05957fd 100644
--- a/tests/nip01_compliance.rs
+++ b/tests/nip01_compliance.rs
@@ -39,22 +39,22 @@ use grasp_audit::*;
39async fn test_nip01_smoke() { 39async fn test_nip01_smoke() {
40 // Start test relay 40 // Start test relay
41 let relay = TestRelay::start().await; 41 let relay = TestRelay::start().await;
42 42
43 // Create audit client in CI mode (isolated, no cleanup needed) 43 // Create audit client in CI mode (isolated, no cleanup needed)
44 let config = AuditConfig::ci(); 44 let config = AuditConfig::ci();
45 let client = AuditClient::new(relay.url(), config) 45 let client = AuditClient::new(relay.url(), config)
46 .await 46 .await
47 .expect("Failed to create audit client"); 47 .expect("Failed to create audit client");
48 48
49 // Run all NIP-01 smoke tests 49 // Run all NIP-01 smoke tests
50 let results = specs::Nip01SmokeTests::run_all(&client).await; 50 let results = specs::Nip01SmokeTests::run_all(&client).await;
51 51
52 // Print detailed report 52 // Print detailed report
53 results.print_report(); 53 results.print_report();
54 54
55 // Stop relay 55 // Stop relay
56 relay.stop().await; 56 relay.stop().await;
57 57
58 // Assert all tests passed 58 // Assert all tests passed
59 assert!( 59 assert!(
60 results.all_passed(), 60 results.all_passed(),
@@ -70,20 +70,20 @@ async fn test_nip01_smoke() {
70/// for more granular testing or debugging. 70/// for more granular testing or debugging.
71#[tokio::test] 71#[tokio::test]
72async fn test_nip01_individual_tests() { 72async fn test_nip01_individual_tests() {
73 use grasp_audit::specs::nip01_smoke::Nip01SmokeTests; 73 use grasp_audit::specs::grasp01::Nip01SmokeTests;
74 74
75 let relay = TestRelay::start().await; 75 let relay = TestRelay::start().await;
76 let config = AuditConfig::ci(); 76 let config = AuditConfig::ci();
77 let client = AuditClient::new(relay.url(), config) 77 let client = AuditClient::new(relay.url(), config)
78 .await 78 .await
79 .expect("Failed to create audit client"); 79 .expect("Failed to create audit client");
80 80
81 // We can't call private methods, so we'll run the full suite 81 // We can't call private methods, so we'll run the full suite
82 // This test is mainly to show the pattern 82 // This test is mainly to show the pattern
83 let all_results = Nip01SmokeTests::run_all(&client).await; 83 let all_results = Nip01SmokeTests::run_all(&client).await;
84 84
85 relay.stop().await; 85 relay.stop().await;
86 86
87 // Verify 87 // Verify
88 assert!(all_results.all_passed()); 88 assert!(all_results.all_passed());
89} 89}
@@ -99,25 +99,25 @@ async fn test_relay_validates_events() {
99 let client = AuditClient::new(relay.url(), config) 99 let client = AuditClient::new(relay.url(), config)
100 .await 100 .await
101 .expect("Failed to create audit client"); 101 .expect("Failed to create audit client");
102 102
103 // The validation tests are part of the smoke tests 103 // The validation tests are part of the smoke tests
104 let results = specs::Nip01SmokeTests::run_all(&client).await; 104 let results = specs::Nip01SmokeTests::run_all(&client).await;
105 105
106 // Check that validation tests exist and pass 106 // Check that validation tests exist and pass
107 let validation_tests: Vec<_> = results 107 let validation_tests: Vec<_> = results
108 .results 108 .results
109 .iter() 109 .iter()
110 .filter(|t| t.spec_ref.contains("validation")) 110 .filter(|t| t.spec_ref.contains("validation"))
111 .collect(); 111 .collect();
112 112
113 relay.stop().await; 113 relay.stop().await;
114 114
115 // Should have validation tests 115 // Should have validation tests
116 assert!( 116 assert!(
117 !validation_tests.is_empty(), 117 !validation_tests.is_empty(),
118 "No validation tests found in NIP-01 smoke tests" 118 "No validation tests found in NIP-01 smoke tests"
119 ); 119 );
120 120
121 // All validation tests should pass 121 // All validation tests should pass
122 for test in validation_tests { 122 for test in validation_tests {
123 assert!( 123 assert!(
@@ -137,18 +137,18 @@ async fn test_relay_lifecycle() {
137 // Start relay 137 // Start relay
138 let relay = TestRelay::start().await; 138 let relay = TestRelay::start().await;
139 let url = relay.url().to_string(); 139 let url = relay.url().to_string();
140 140
141 // Verify we can connect 141 // Verify we can connect
142 let config = AuditConfig::ci(); 142 let config = AuditConfig::ci();
143 let client = AuditClient::new(&url, config) 143 let client = AuditClient::new(&url, config)
144 .await 144 .await
145 .expect("Failed to connect to relay"); 145 .expect("Failed to connect to relay");
146 146
147 assert!(client.is_connected().await, "Client should be connected"); 147 assert!(client.is_connected().await, "Client should be connected");
148 148
149 // Stop relay 149 // Stop relay
150 relay.stop().await; 150 relay.stop().await;
151 151
152 // Note: We can't easily verify disconnection without modifying grasp-audit 152 // Note: We can't easily verify disconnection without modifying grasp-audit
153 // to expose connection state after relay shutdown. That's okay - the 153 // to expose connection state after relay shutdown. That's okay - the
154 // important part is that the relay starts and stops cleanly. 154 // important part is that the relay starts and stops cleanly.
@@ -162,28 +162,28 @@ async fn test_parallel_relays() {
162 // Start two relays simultaneously 162 // Start two relays simultaneously
163 let relay1 = TestRelay::start().await; 163 let relay1 = TestRelay::start().await;
164 let relay2 = TestRelay::start().await; 164 let relay2 = TestRelay::start().await;
165 165
166 // Should have different URLs (different ports) 166 // Should have different URLs (different ports)
167 assert_ne!( 167 assert_ne!(
168 relay1.url(), 168 relay1.url(),
169 relay2.url(), 169 relay2.url(),
170 "Relays should use different ports" 170 "Relays should use different ports"
171 ); 171 );
172 172
173 // Both should be connectable 173 // Both should be connectable
174 let config = AuditConfig::ci(); 174 let config = AuditConfig::ci();
175 175
176 let client1 = AuditClient::new(relay1.url(), config.clone()) 176 let client1 = AuditClient::new(relay1.url(), config.clone())
177 .await 177 .await
178 .expect("Failed to connect to relay 1"); 178 .expect("Failed to connect to relay 1");
179 179
180 let client2 = AuditClient::new(relay2.url(), config) 180 let client2 = AuditClient::new(relay2.url(), config)
181 .await 181 .await
182 .expect("Failed to connect to relay 2"); 182 .expect("Failed to connect to relay 2");
183 183
184 assert!(client1.is_connected().await); 184 assert!(client1.is_connected().await);
185 assert!(client2.is_connected().await); 185 assert!(client2.is_connected().await);
186 186
187 // Clean up 187 // Clean up
188 relay1.stop().await; 188 relay1.stop().await;
189 relay2.stop().await; 189 relay2.stop().await;