upleb.uk

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

summaryrefslogtreecommitdiff
path: root/grasp-audit/QUICK_START.md
diff options
context:
space:
mode:
authorDanConwayDev <DanConwayDev@protonmail.com>2025-11-04 06:17:55 +0000
committerDanConwayDev <DanConwayDev@protonmail.com>2025-11-04 06:17:55 +0000
commit001ca45e385c05b0eaa36d9879e051853aaff107 (patch)
tree603fb85d2563db5b7c418e9fd143d479bd09676e /grasp-audit/QUICK_START.md
parentd428baf30feec295870fadda2d335d1e7f89507b (diff)
created POC grasp-auditor
Diffstat (limited to 'grasp-audit/QUICK_START.md')
-rw-r--r--grasp-audit/QUICK_START.md222
1 files changed, 222 insertions, 0 deletions
diff --git a/grasp-audit/QUICK_START.md b/grasp-audit/QUICK_START.md
new file mode 100644
index 0000000..47e848e
--- /dev/null
+++ b/grasp-audit/QUICK_START.md
@@ -0,0 +1,222 @@
1# GRASP Audit - Quick Start Guide
2
3## Prerequisites
4
5- Rust 1.75 or later
6- C compiler (gcc or clang)
7- A Nostr relay for testing (optional for unit tests)
8
9## Setup on NixOS
10
11```bash
12# Enter development shell
13cd grasp-audit
14nix-shell
15
16# Build the project
17cargo build
18
19# Run unit tests (no relay needed)
20cargo test --lib
21```
22
23## Setup on Other Systems
24
25```bash
26cd grasp-audit
27
28# Install Rust (if needed)
29curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
30
31# Build
32cargo build
33
34# Run unit tests
35cargo test --lib
36```
37
38## Running Smoke Tests (Requires Relay)
39
40### Option 1: Use a Public Relay
41
42```bash
43# Run against a public relay
44cargo run --example simple_audit
45# Edit the example to use: wss://relay.damus.io or similar
46```
47
48### Option 2: Run Local Relay
49
50```bash
51# Terminal 1: Start a test relay
52# Option A: Using nostr-relay-builder
53git clone https://github.com/rust-nostr/nostr
54cd nostr/crates/nostr-relay-builder
55cargo run --example basic
56
57# Option B: Using docker
58docker run -p 7000:7000 scsibug/nostr-rs-relay
59
60# Terminal 2: Run smoke tests
61cd grasp-audit
62cargo run --example simple_audit
63```
64
65### Option 3: Use the CLI
66
67```bash
68# Build the CLI
69cargo build --release
70
71# Run smoke tests
72./target/release/grasp-audit audit \
73 --relay ws://localhost:7000 \
74 --mode ci \
75 --spec nip01-smoke
76```
77
78## Running Tests
79
80```bash
81# Unit tests only (no relay needed)
82cargo test --lib
83
84# Integration tests (needs relay at ws://localhost:7000)
85cargo test --ignored
86
87# All tests
88cargo test --all
89
90# With output
91cargo test -- --nocapture
92```
93
94## Using as a Library
95
96Add to your `Cargo.toml`:
97
98```toml
99[dependencies]
100grasp-audit = { path = "../grasp-audit" }
101```
102
103Example code:
104
105```rust
106use grasp_audit::*;
107
108#[tokio::main]
109async fn main() -> Result<()> {
110 // Create audit client
111 let config = AuditConfig::ci();
112 let client = AuditClient::new("ws://localhost:7000", config).await?;
113
114 // Run smoke tests
115 let results = specs::Nip01SmokeTests::run_all(&client).await;
116
117 // Print results
118 results.print_report();
119
120 // Check if passed
121 if !results.all_passed() {
122 eprintln!("Some tests failed!");
123 std::process::exit(1);
124 }
125
126 Ok(())
127}
128```
129
130## Troubleshooting
131
132### Build Errors
133
134**Error:** `linker 'cc' not found`
135
136**Solution (NixOS):**
137```bash
138nix-shell # Use the provided shell.nix
139```
140
141**Solution (Other Linux):**
142```bash
143sudo apt-get install build-essential # Debian/Ubuntu
144sudo yum install gcc # RedHat/CentOS
145```
146
147**Solution (macOS):**
148```bash
149xcode-select --install
150```
151
152### Connection Errors
153
154**Error:** `Failed to connect to relay`
155
156**Solutions:**
1571. Make sure a relay is running at the specified URL
1582. Check firewall settings
1593. Try a different relay URL
1604. Use `ws://` for local, `wss://` for remote
161
162### Test Failures
163
164**Error:** Tests fail with timeout
165
166**Solutions:**
1671. Increase timeout in test code
1682. Check relay is responding (try with `websocat`)
1693. Check network connectivity
170
171## Examples
172
173### CI Mode (Isolated Testing)
174
175```bash
176# Each run is isolated with unique ID
177./target/release/grasp-audit audit \
178 --relay ws://localhost:7000 \
179 --mode ci \
180 --spec nip01-smoke
181
182# Run ID: ci-a1b2c3d4-e5f6-7890-abcd-ef1234567890
183# Tests only see events from this run
184```
185
186### Production Mode (Audit Live Service)
187
188```bash
189# Read-only audit of production relay
190./target/release/grasp-audit audit \
191 --relay wss://relay.example.com \
192 --mode production \
193 --spec nip01-smoke
194
195# Run ID: prod-audit-1699027200
196# Tests see all events (including real ones)
197# Minimal writes (read-only by default)
198```
199
200## What's Next?
201
2021. ✅ Run unit tests
2032. ✅ Run smoke tests against a relay
2043. ✅ Check the report output
2054. 🚧 Implement GRASP-01 compliance tests
2065. 🚧 Set up CI/CD integration
2076. 🚧 Test against ngit-grasp relay
208
209## Resources
210
211- **README.md** - Full documentation
212- **SMOKE_TEST_REPORT.md** - Implementation details
213- **examples/simple_audit.rs** - Example usage
214- **GRASP_AUDIT_PLAN.md** - Original plan
215
216## Support
217
218For issues or questions:
2191. Check the documentation in this directory
2202. Review the examples
2213. Check the test code for usage patterns
2224. Open an issue on the project repository