From d9c9ef2ff92b687f5ff5585b08b2eead8f139a02 Mon Sep 17 00:00:00 2001 From: DanConwayDev Date: Wed, 5 Nov 2025 11:48:35 +0000 Subject: 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. --- AGENTS.md | 35 +++++++++++++++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) (limited to 'AGENTS.md') diff --git a/AGENTS.md b/AGENTS.md index ed9c97d..ec1ec60 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -33,8 +33,8 @@ nix-shell --run "cargo build" **Integration tests require relay running:** ```bash -# 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 +# Start ngit-relay first (use any available port to avoid conflicts) +docker run --rm -p 18081:8081 ghcr.io/danconwaydev/ngit-relay:latest # 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 @@ -42,6 +42,8 @@ RELAY_URL="ws://localhost:18081" nix develop -c cargo test --lib test_grasp01_no Tests marked `#[ignore]` need relay - unit tests don't. +**Note:** Always use a random available port for the relay to avoid conflicts with existing services. + ### Running Single Test ```bash @@ -49,6 +51,32 @@ Tests marked `#[ignore]` need relay - unit tests don't. nix develop -c cargo test --lib specific_test_name -- --nocapture ``` +### Quick Test Verification + +To verify GRASP-01 compliance tests are working correctly: + +```bash +cd grasp-audit && RELAY_URL="ws://localhost:18081" nix develop -c cargo test --lib test_grasp01_nostr_relay_against_relay -- --ignored --nocapture 2>&1 | tail -60 +``` + +**Expected Output:** +- 2-3 tests passing +- 15 tests showing "Not implemented yet" + +### Troubleshooting + +**Buffer Size Errors:** +If you see mpsc channel buffer size panics on first test run, this is usually transient. Simply run the tests again. + +**Verify Relay is Running:** +Check if relay is accessible before running tests: +```bash +nak req -l 1 ws://localhost:18081 # Replace port with your chosen port +``` + +**Port Conflicts:** +Always use a random available port to avoid conflicts with existing services. If a port is busy, choose a different one for docker. + ## Code Patterns ### nostr-sdk 0.43 Breaking Changes (vs 0.35) @@ -133,6 +161,9 @@ cd grasp-audit && RELAY_URL="ws://localhost:18081" nix develop -c cargo test --i # Run single test cd grasp-audit && nix develop -c cargo test --lib test_name -- --nocapture +# Verify GRASP-01 tests (cleaner output) +cd grasp-audit && RELAY_URL="ws://localhost:18081" nix develop -c cargo test --lib test_grasp01_nostr_relay_against_relay -- --ignored --nocapture 2>&1 | tail -60 + # Check session files ls work/ # Should only have README.md when clean ``` -- cgit v1.2.3