Skip to content

test: add missing reassembly engine test coverage#25

Merged
Zious11 merged 7 commits intodevelopfrom
worktree-test-coverage
Apr 7, 2026
Merged

test: add missing reassembly engine test coverage#25
Zious11 merged 7 commits intodevelopfrom
worktree-test-coverage

Conversation

@Zious11
Copy link
Copy Markdown
Owner

@Zious11 Zious11 commented Apr 7, 2026

Summary

Closes #13. Adds 7 integration tests covering gaps identified during PR #10 review:

  • SYN+ACK / bidirectional data — Full 3-way handshake, data both directions, verify Direction assignment and flows_partial == 0
  • FIN teardown — Full lifecycle (handshake → bidirectional data → dual FIN), verify CloseReason::Fin, flows_fin stat, total_memory == 0
  • max_flows evictionmax_flows=2, exceed with 3rd flow, verify LRU eviction order by FlowKey and CloseReason::MemoryPressure
  • memcap evictionmemcap=10, exceed with out-of-order buffered data, verify eviction and CloseReason::MemoryPressure
  • Overlap anomaly finding — 51 duplicate segments trigger OVERLAP_ALERT_THRESHOLD(50), verify finding fields (category, confidence, verdict, MITRE technique)
  • Conflicting overlap finding — Retransmit with different data, verify Confidence::High finding
  • max_segments_per_direction — 5 non-contiguous segments fill limit, 6th rejected, verify existing segments survive (non-destructive rejection)

Also adds ack: bool parameter to make_tcp_packet test helper (acceptance criteria from issue).

Test plan

  • All 15 engine tests pass (cargo test --test reassembly_engine_tests)
  • Full suite passes (91 tests)
  • cargo clippy --all-targets clean
  • cargo fmt clean
  • No production code changes — test-only PR

Zious11 added 6 commits April 6, 2026 22:12
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
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

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_packet test helper with an ack: bool parameter 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.

Comment thread tests/reassembly_engine_tests.rs Outdated
Comment thread tests/reassembly_engine_tests.rs Outdated
Comment thread docs/superpowers/specs/2026-04-06-reassembly-test-coverage-design.md Outdated
Comment thread docs/superpowers/specs/2026-04-06-reassembly-test-coverage-design.md Outdated
Comment thread docs/superpowers/specs/2026-04-06-reassembly-test-coverage-design.md Outdated
- 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
@Zious11 Zious11 merged commit d67fd34 into develop Apr 7, 2026
4 checks passed
@Zious11 Zious11 deleted the worktree-test-coverage branch April 7, 2026 03:48
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.

test: add missing reassembly engine test coverage

2 participants