Skip to content

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

Merged
thomaseizinger merged 1 commit into
masterfrom
claude/boringtun-integration-tests-723kny
Jul 14, 2026
Merged

test: replace Tunn unit tests with integration test suite#210
thomaseizinger merged 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.

@jamilbk jamilbk left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Concept ACK. Would it be a good idea to add this to our coverage reporting so we have better visibility into this change?

@thomaseizinger

Copy link
Copy Markdown
Member Author

Concept ACK. Would it be a good idea to add this to our coverage reporting so we have better visibility into this change?

Are you worried about the removed tests? Or just interested in coverage in general?

Happy to play with that in a follow-up! I don't know how Coveralls interacts with forks but I guess there is no reason why it wouldn't work.

@thomaseizinger thomaseizinger added this pull request to the merge queue Jul 14, 2026
Merged via the queue into master with commit 1beaa29 Jul 14, 2026
16 checks passed
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.

3 participants