# Verification guide
How the test suites work, and how to verify a release build before shipping.
## Test layers
1. Unit tests — pure parser and validation tests with realistic fixtures.
No nmap binary required.
2. Wire-protocol tests (`tests/wire_protocol.rs`) — spawn the real compiled
server binary and speak MCP over stdio (newline-delimited JSON-RPC) like
a real client. A fake nmap shim (`tests/fixtures/fake_nmap.sh`) supplies
fixture output for `--version`, `--script-help`, and scans, so the whole
tool surface is exercised without scanning anything real. Covers the
handshake, `tools/list`, one call per scan tool, structured NSE output
parsing, input-validation error paths, unknown-tool errors, and
multi-call stability.
3. Live tests (`tests/live.rs`, `#[ignore]`) — run the server against a real
nmap scanning `127.0.0.1`. Gated on `NMAP_MCP_BIN` pointing at a real
nmap; they skip quietly when it is unset, so CI without nmap stays green.
## Running everything
```console
# unit + wire tests (no nmap required)
cargo test
# live tests against a real nmap
NMAP_MCP_BIN=/usr/bin/nmap cargo test --test live -- --ignored
```
On this machine the local nmap 7.95 needs its shared-library path:
```console
LD_LIBRARY_PATH=/data/nmap-local/usr/lib/x86_64-linux-gnu \
NMAP_MCP_BIN=/data/nmap-local/usr/bin/nmap \
cargo test --test live -- --ignored
```
## Quality gates
```console
cargo fmt --check
cargo clippy --all-targets -- -D warnings
cargo test
```
## Verifying a release build
```console
bash build/linux/build.sh
ls -la bin/nmap-mcp
```
Smoke-test the built binary directly over stdio: send an `initialize`
request, expect a JSON-RPC result back:
```console
printf '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2025-06-18","capabilities":{},"clientInfo":{"name":"smoke","version":"0.0.1"}}}\n' \
| bin/nmap-mcp
```
Then check the server registers cleanly:
```console
open-grok mcp doctor nmap-mcp
```