diff options
| author | DanConwayDev <DanConwayDev@protonmail.com> | 2025-11-05 11:48:35 +0000 |
|---|---|---|
| committer | DanConwayDev <DanConwayDev@protonmail.com> | 2025-11-05 11:48:35 +0000 |
| commit | d9c9ef2ff92b687f5ff5585b08b2eead8f139a02 (patch) | |
| tree | b2b125899d6724e2f21e0b785b4844703e16722a /AGENTS.md | |
| parent | ff00d106da0abd734a233e6445cdd81ffb5f1d9f (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 'AGENTS.md')
| -rw-r--r-- | AGENTS.md | 35 |
1 files changed, 33 insertions, 2 deletions
| @@ -33,8 +33,8 @@ nix-shell --run "cargo build" | |||
| 33 | **Integration tests require relay running:** | 33 | **Integration tests require relay running:** |
| 34 | 34 | ||
| 35 | ```bash | 35 | ```bash |
| 36 | # Start ngit-relay first (choose any available port, example uses 18081) | 36 | # Start ngit-relay first (use any available port to avoid conflicts) |
| 37 | docker run --rm -p 18081:8081 -e NGIT_BIND_ADDRESS=0.0.0.0:8081 ghcr.io/danconwaydev/ngit-relay:latest | 37 | docker run --rm -p 18081:8081 ghcr.io/danconwaydev/ngit-relay:latest |
| 38 | 38 | ||
| 39 | # From grasp-audit directory, set RELAY_URL to match your port | 39 | # From grasp-audit directory, set RELAY_URL to match your port |
| 40 | RELAY_URL="ws://localhost:18081" nix develop -c cargo test --lib test_grasp01_nostr_relay_against_relay -- --ignored --nocapture | 40 | 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 | |||
| 42 | 42 | ||
| 43 | Tests marked `#[ignore]` need relay - unit tests don't. | 43 | Tests marked `#[ignore]` need relay - unit tests don't. |
| 44 | 44 | ||
| 45 | **Note:** Always use a random available port for the relay to avoid conflicts with existing services. | ||
| 46 | |||
| 45 | ### Running Single Test | 47 | ### Running Single Test |
| 46 | 48 | ||
| 47 | ```bash | 49 | ```bash |
| @@ -49,6 +51,32 @@ Tests marked `#[ignore]` need relay - unit tests don't. | |||
| 49 | nix develop -c cargo test --lib specific_test_name -- --nocapture | 51 | nix develop -c cargo test --lib specific_test_name -- --nocapture |
| 50 | ``` | 52 | ``` |
| 51 | 53 | ||
| 54 | ### Quick Test Verification | ||
| 55 | |||
| 56 | To verify GRASP-01 compliance tests are working correctly: | ||
| 57 | |||
| 58 | ```bash | ||
| 59 | 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 | ||
| 60 | ``` | ||
| 61 | |||
| 62 | **Expected Output:** | ||
| 63 | - 2-3 tests passing | ||
| 64 | - 15 tests showing "Not implemented yet" | ||
| 65 | |||
| 66 | ### Troubleshooting | ||
| 67 | |||
| 68 | **Buffer Size Errors:** | ||
| 69 | If you see mpsc channel buffer size panics on first test run, this is usually transient. Simply run the tests again. | ||
| 70 | |||
| 71 | **Verify Relay is Running:** | ||
| 72 | Check if relay is accessible before running tests: | ||
| 73 | ```bash | ||
| 74 | nak req -l 1 ws://localhost:18081 # Replace port with your chosen port | ||
| 75 | ``` | ||
| 76 | |||
| 77 | **Port Conflicts:** | ||
| 78 | Always use a random available port to avoid conflicts with existing services. If a port is busy, choose a different one for docker. | ||
| 79 | |||
| 52 | ## Code Patterns | 80 | ## Code Patterns |
| 53 | 81 | ||
| 54 | ### nostr-sdk 0.43 Breaking Changes (vs 0.35) | 82 | ### 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 | |||
| 133 | # Run single test | 161 | # Run single test |
| 134 | cd grasp-audit && nix develop -c cargo test --lib test_name -- --nocapture | 162 | cd grasp-audit && nix develop -c cargo test --lib test_name -- --nocapture |
| 135 | 163 | ||
| 164 | # Verify GRASP-01 tests (cleaner output) | ||
| 165 | 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 | ||
| 166 | |||
| 136 | # Check session files | 167 | # Check session files |
| 137 | ls work/ # Should only have README.md when clean | 168 | ls work/ # Should only have README.md when clean |
| 138 | ``` | 169 | ``` |