upleb.uk

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

summaryrefslogtreecommitdiff
path: root/grasp-audit/src/client.rs
diff options
context:
space:
mode:
authorDanConwayDev <DanConwayDev@protonmail.com>2025-11-05 11:48:35 +0000
committerDanConwayDev <DanConwayDev@protonmail.com>2025-11-05 11:48:35 +0000
commitd9c9ef2ff92b687f5ff5585b08b2eead8f139a02 (patch)
treeb2b125899d6724e2f21e0b785b4844703e16722a /grasp-audit/src/client.rs
parentff00d106da0abd734a233e6445cdd81ffb5f1d9f (diff)
feat(grasp-audit): improve test infrastructure and error handling
- Fix compilation error in test setup (use .expect() instead of ?) - Add comprehensive error messages with troubleshooting guidance - Implement connection verification in AuditClient with retry logic - Update AGENTS.md with testing troubleshooting section - Verify all changes: 4/18 tests passing as expected Error messages now include: - Specific context about failures (event IDs, repo IDs, URLs) - Example commands for resolution (docker, nak verification) - References to helper scripts (test-ngit-relay.sh) Tests compile cleanly and run successfully against ngit-relay.
Diffstat (limited to 'grasp-audit/src/client.rs')
-rw-r--r--grasp-audit/src/client.rs22
1 files changed, 21 insertions, 1 deletions
diff --git a/grasp-audit/src/client.rs b/grasp-audit/src/client.rs
index 4831d3f..b80b59f 100644
--- a/grasp-audit/src/client.rs
+++ b/grasp-audit/src/client.rs
@@ -24,11 +24,12 @@ impl AuditClient {
24 24
25 // Wait for connection to establish (with retries) 25 // Wait for connection to establish (with retries)
26 let mut attempts = 0; 26 let mut attempts = 0;
27 let mut connected = false;
27 while attempts < 20 { 28 while attempts < 20 {
28 tokio::time::sleep(Duration::from_millis(100)).await; 29 tokio::time::sleep(Duration::from_millis(100)).await;
29 30
30 let relays = client.relays().await; 31 let relays = client.relays().await;
31 let connected = relays.values().any(|r| r.is_connected()); 32 connected = relays.values().any(|r| r.is_connected());
32 33
33 if connected { 34 if connected {
34 break; 35 break;
@@ -37,6 +38,25 @@ impl AuditClient {
37 attempts += 1; 38 attempts += 1;
38 } 39 }
39 40
41 // Verify we actually connected
42 if !connected {
43 return Err(anyhow!(
44 "Failed to connect to relay at '{}'\n\
45 \n\
46 Possible causes:\n\
47 • Relay is not running at this address\n\
48 • Network connectivity issues\n\
49 • Incorrect URL or port\n\
50 \n\
51 To start ngit-relay for testing:\n\
52 docker run --rm -p 18081:8081 ghcr.io/danconwaydev/ngit-relay:latest\n\
53 \n\
54 Or use the test script:\n\
55 cd grasp-audit && ./test-ngit-relay.sh",
56 relay_url
57 ));
58 }
59
40 // Give it a bit more time to stabilize 60 // Give it a bit more time to stabilize
41 tokio::time::sleep(Duration::from_millis(200)).await; 61 tokio::time::sleep(Duration::from_millis(200)).await;
42 62