test: add missing reassembly engine test coverage#25
Merged
Conversation
For issue #13 — 7 new reassembly engine integration tests covering SYN+ACK bidirectional data, flow eviction, FIN teardown, anomaly findings, and max_segments limit.
Adds test_max_flows_eviction and test_memcap_eviction to cover the evict_flows() code path. Both tests use out-of-order segments so data stays buffered, driving total_memory above memcap and ensuring the eviction loop does not short-circuit on its break condition (total_memory <= memcap && flows.len() <= max_flows).
- Verify eviction order by FlowKey in test_max_flows_eviction - Add CloseReason::MemoryPressure assertion to test_memcap_eviction - Assert confidence, verdict, MITRE technique on overlap anomaly finding - Verify buffered segments survive max_segments rejection via memory accounting
There was a problem hiding this comment.
Pull request overview
Adds missing integration coverage for the TCP reassembly engine and updates the shared test packet helper to support ACK flagging, addressing the test gaps called out in issue #13 / PR #10 review.
Changes:
- Extend
make_tcp_packettest helper with anack: boolparameter and update all call sites. - Add 7 new integration tests for SYN+ACK direction assignment, FIN teardown, eviction (max_flows/memcap), anomaly findings, and max segment limits.
- Add accompanying design/spec and implementation plan docs for the test coverage work.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 6 comments.
| File | Description |
|---|---|
tests/reassembly_engine_tests.rs |
Adds ack to make_tcp_packet and introduces 7 new engine integration tests covering handshake, teardown, eviction, findings, and segment limits. |
docs/superpowers/specs/2026-04-06-reassembly-test-coverage-design.md |
Documents intended coverage areas and test scenarios for issue #13. |
docs/superpowers/plans/2026-04-06-reassembly-test-coverage.md |
Implementation plan describing step-by-step test additions and helper changes. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Replace "3-way handshake" with "SYN + SYN+ACK handshake" in test comments (engine transitions to Established on SYN+ACK, no third ACK needed) - Update spec: max_flows test uses memcap=5 and out-of-order data, not flow_timeout_secs - Update spec: memcap test uses two flows, not single-flow self-eviction - Update spec: overlap test uses seq 1002 (offset 2) not seq 1001, and 53 total packets not 52 - Update spec: max_segments test verifies via total_memory + finalize, not gap-fill flush
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #13. Adds 7 integration tests covering gaps identified during PR #10 review:
Directionassignment andflows_partial == 0CloseReason::Fin,flows_finstat,total_memory == 0max_flows=2, exceed with 3rd flow, verify LRU eviction order by FlowKey andCloseReason::MemoryPressurememcap=10, exceed with out-of-order buffered data, verify eviction andCloseReason::MemoryPressureOVERLAP_ALERT_THRESHOLD(50), verify finding fields (category, confidence, verdict, MITRE technique)Confidence::HighfindingAlso adds
ack: boolparameter tomake_tcp_packettest helper (acceptance criteria from issue).Test plan
cargo test --test reassembly_engine_tests)cargo clippy --all-targetscleancargo fmtclean