Skip to content

test: replace Tunn unit tests with integration test suite#210

Open
thomaseizinger wants to merge 1 commit into
masterfrom
claude/boringtun-integration-tests-723kny
Open

test: replace Tunn unit tests with integration test suite#210
thomaseizinger wants to merge 1 commit into
masterfrom
claude/boringtun-integration-tests-723kny

Conversation

@thomaseizinger

@thomaseizinger thomaseizinger commented Jul 13, 2026

Copy link
Copy Markdown
Member

The behavioural unit tests in noise/mod.rs and the replay-counter test in session.rs reached into private state, duplicated handshake plumbing per test and left notable gaps: no coverage for the cookie/DoS mechanism, wire-level replay, rekey/session rotation, tampered or malformed input, or the next_timer_update contract.

This replaces them with an integration test suite (tests/it) that drives two Tunn instances against each other through the public sans-IO API on a virtual clock. A harness provides an in-memory network with fault injection and a timestamped packet log, so each test reads as a short scenario. Protocol constants are redefined from the WireGuard whitepaper and each test cites the section it exercises, so the suite asserts conformance to the paper rather than to the implementation. Sans-IO-specific behaviour (jittered handshake scheduling, next_timer_update accuracy, tolerance to coarse polling, seed determinism, the internal packet queue) is covered separately in tests/it/sans_io.rs.

The suite is deterministic (fixed jitter seeds), runs in ~0.2s and passes under every feature combination with -Dwarnings. The crypto test vectors, the Index unit tests and the docker-based device tests are kept as-is.

Replace the behavioural unit tests in noise/mod.rs and the replay
counter test in session.rs with an integration test suite that drives
two Tunn instances against each other through the public sans-IO API
only.

A harness (tests/it/harness.rs) provides a virtual clock, an in-memory
network with fault injection and a timestamped packet log, so each test
reads as a short scenario. The protocol constants are redefined from
the WireGuard whitepaper so the tests assert conformance to the paper
rather than to the implementation.

The suite covers the handshake (incl. PSK, replay and simultaneous
initiation), data transfer, replay protection at the wire level, the
cookie/DoS mechanism, all whitepaper timers, and the sans-IO-specific
contracts around next_timer_update, jitter and determinism.

The crypto test vectors, the Index unit tests and the docker-based
device tests are kept as-is.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SsK9EkMSKVDctKeasSW4sS
@thomaseizinger thomaseizinger requested a review from jamilbk July 13, 2026 00:55
@thomaseizinger thomaseizinger enabled auto-merge July 13, 2026 00:55
@thomaseizinger

Copy link
Copy Markdown
Member Author

I reviewed these tests. They are all sound and the harness is quite well written. Should enable us to update and merge #94 with confidence.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants