From 86077d24e7cc8ff9d474a5947f0151d005f9f747 Mon Sep 17 00:00:00 2001 From: DanConwayDev Date: Wed, 5 Nov 2025 10:19:56 +0000 Subject: fix: hardcoded port --- AGENTS.md | 25 ++++++++++++++++--------- grasp-audit/README.md | 15 ++++++++++----- grasp-audit/src/specs/grasp01_nostr_relay.rs | 6 +++++- grasp-audit/test-ngit-relay.sh | 2 +- 4 files changed, 32 insertions(+), 16 deletions(-) diff --git a/AGENTS.md b/AGENTS.md index e25299c..ed9c97d 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -5,6 +5,7 @@ This file provides guidance to agents when working with code in this repository. ## Project Structure **Workspace with Two Rust Projects:** + - Root: `ngit-grasp` (main GRASP relay implementation) - `grasp-audit/`: Separate subproject with own `Cargo.toml` and `flake.nix` @@ -32,11 +33,11 @@ nix-shell --run "cargo build" **Integration tests require relay running:** ```bash -# Start ngit-relay first (tests run on port 18081) -docker run --rm -p 18081:8081 -e NGIT_BIND_ADDRESS=0.0.0.0:8081 ghcr.io/decentralizedclimate/ngit-relay:latest +# Start ngit-relay first (choose any available 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 -# From grasp-audit directory -nix develop -c cargo test --lib test_grasp01_nostr_relay_against_relay -- --ignored --nocapture +# From grasp-audit directory, set RELAY_URL to match your port +RELAY_URL="ws://localhost:18081" nix develop -c cargo test --lib test_grasp01_nostr_relay_against_relay -- --ignored --nocapture ``` Tests marked `#[ignore]` need relay - unit tests don't. @@ -60,13 +61,14 @@ event.id() event.tags() for tag in &event.tags { } -// ✅ CORRECT (0.43 API) +// ✅ CORRECT (0.43 API) event.id // Direct field access event.tags // Direct field access event.tags.iter() // Iterator method ``` **Tag API changed:** + ```rust // ❌ WRONG (0.35) Tag::Generic(TagKind::Custom("clone".into()), vec![...]) @@ -76,6 +78,7 @@ Tag::custom(TagKind::custom("clone"), vec![...]) ``` **EventBuilder signature changed:** + ```rust // ❌ WRONG (0.35) EventBuilder::new(kind, content, &[tags]) @@ -89,12 +92,14 @@ See `docs/archive/2025-11-04-nostr-sdk-upgrade.md` for full migration. ## Documentation **Diátaxis Framework Used:** + - `docs/tutorials/` - Learning-oriented -- `docs/how-to/` - Task-oriented +- `docs/how-to/` - Task-oriented - `docs/reference/` - Information-oriented - `docs/explanation/` - Understanding-oriented **Session files go in `work/` (gitignored except README.md)** + - Archive valuable content to `docs/archive/YYYY-MM-DD-*.md` at session end - Delete temporary files - Keep root clean (only README.md, AGENTS.md) @@ -111,6 +116,7 @@ See `docs/archive/2025-11-04-nostr-sdk-upgrade.md` for full migration. ## File Restrictions by Mode Code mode can only edit files matching specific patterns (enforced by system): + - Example: Architect mode restricted to `\.md$` files only - Attempting to edit restricted files causes FileRestrictionError - Check mode configuration if edit attempts fail unexpectedly @@ -121,11 +127,12 @@ Code mode can only edit files matching specific patterns (enforced by system): # Build grasp-audit cd grasp-audit && nix develop -c cargo build -# Run all tests (requires relay on 18081) -cd grasp-audit && nix develop -c cargo test --ignored +# Run all tests (requires relay running, set RELAY_URL to match your port) +cd grasp-audit && RELAY_URL="ws://localhost:18081" nix develop -c cargo test --ignored # Run single test cd grasp-audit && nix develop -c cargo test --lib test_name -- --nocapture # Check session files -ls work/ # Should only have README.md when clean \ No newline at end of file +ls work/ # Should only have README.md when clean +``` 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