From 86077d24e7cc8ff9d474a5947f0151d005f9f747 Mon Sep 17 00:00:00 2001 From: DanConwayDev Date: Wed, 5 Nov 2025 10:19:56 +0000 Subject: fix: hardcoded port --- grasp-audit/README.md | 15 ++++++++++----- grasp-audit/src/specs/grasp01_nostr_relay.rs | 6 +++++- grasp-audit/test-ngit-relay.sh | 2 +- 3 files changed, 16 insertions(+), 7 deletions(-) (limited to 'grasp-audit') diff --git a/grasp-audit/README.md b/grasp-audit/README.md index b8b452e..b73d72b 100644 --- a/grasp-audit/README.md +++ b/grasp-audit/README.md @@ -22,15 +22,15 @@ async fn main() -> Result<()> { // Create audit client for CI testing let config = AuditConfig::ci(); let client = AuditClient::new("ws://localhost:7000", config).await?; - + // Run NIP-01 smoke tests let results = specs::Nip01SmokeTests::run_all(&client).await; results.print_report(); - + if !results.all_passed() { std::process::exit(1); } - + Ok(()) } ``` @@ -85,6 +85,7 @@ All audit events include special tags: ``` This allows: + - **Isolation**: Each test run has unique ID - **Cleanup**: Events marked for cleanup after timestamp - **No deletion trails**: Direct database cleanup (no NIP-09 deletion events) @@ -146,10 +147,14 @@ Test against the reference GRASP implementation to ensure compatibility. See `test-ngit-relay.sh` for full setup/cleanup details. -**Manual One-Liner:** +**Manual Testing:** ```bash -# Start relay, then run: RELAY_URL="ws://localhost:$PORT" cargo test --lib -- --ignored --nocapture +# Start relay on a specific port (example uses 18081) +docker run --rm -p 18081:8081 -e NGIT_BIND_ADDRESS=0.0.0.0:8081 ghcr.io/danconwaydev/ngit-relay:latest + +# In another terminal, run tests with RELAY_URL +RELAY_URL="ws://localhost:18081" cargo test --lib test_grasp01_nostr_relay_against_relay -- --ignored --nocapture ``` **Note:** ngit-relay only accepts Git-related events (NIP-34). Some NIP-01 smoke tests will fail (expected). Validation tests should pass. diff --git a/grasp-audit/src/specs/grasp01_nostr_relay.rs b/grasp-audit/src/specs/grasp01_nostr_relay.rs index a18927c..ca84a4b 100644 --- a/grasp-audit/src/specs/grasp01_nostr_relay.rs +++ b/grasp-audit/src/specs/grasp01_nostr_relay.rs @@ -653,8 +653,12 @@ mod tests { #[tokio::test] #[ignore] // Requires running relay async fn test_grasp01_nostr_relay_against_relay() { + // Read relay URL from environment variable, default to localhost:8081 + let relay_url = std::env::var("RELAY_URL") + .unwrap_or_else(|_| "ws://localhost:8081".to_string()); + let config = AuditConfig::ci(); - let client = AuditClient::new("ws://localhost:18081", config) + let client = AuditClient::new(&relay_url, config) .await .expect("Failed to connect to relay"); diff --git a/grasp-audit/test-ngit-relay.sh b/grasp-audit/test-ngit-relay.sh index 2d1d7f2..356eed1 100755 --- a/grasp-audit/test-ngit-relay.sh +++ b/grasp-audit/test-ngit-relay.sh @@ -59,7 +59,7 @@ echo "Validation tests should pass." echo "" # Run the CLI tool (cleanup happens via trap even on failure) -cargo run -- audit --relay "ws://localhost:$PORT" --mode ci --spec nip01-smoke || { +RELAY_URL="ws://localhost:$PORT" cargo run -- audit --relay "ws://localhost:$PORT" --mode ci --spec nip01-smoke || { echo "⚠️ Some tests failed (expected for ngit-relay)" echo " Validation tests should have passed" } -- cgit v1.2.3