Skip to content

test(http2): expand http2_client.cpp error-branch coverage using Phase 2 substrate (round 2) #1106

Description

@kcenon

What

Round 2 of protocols/http2/http2_client.cpp test coverage expansion using the Phase 2 substrate (frame_injector + mock_h2_server_peer) merged in PR #1105 (Part of #1074). Round 1 sub-issues #991 and #1062 closed but the file still stands at 18.8% line / 9.9% branch in the 2026-05-06 coverage measurement (run 25430202846).

This sub-issue narrows scope to error-branch coverage specifically, leveraging the fault-injection infrastructure that did not exist when Round 1 was opened.

Why

http2_client.cpp is the single largest contributor to the #953 coverage gap:

  • Line gap: 576 LOC * (60% - 18.8%) = ~237 additional hit lines
  • Branch gap: 979 branches * (40% - 9.9%) = ~295 additional hit branches

Without raising it, the epic cannot meet its acceptance criteria. Phase 2 substrate (#1074) was specifically designed to enable deterministic error-path testing of the HTTP/2 client by giving tests control over server-side frame timing and integrity.

Where

Path Role
src/protocols/http2/http2_client.cpp File under test (576 LOC, 979 branches)
tests/unit/http2_client_branch_test.cpp Add new TEST_F cases
tests/support/mock_h2_server_peer.h Phase 2A/2A.2/2E substrate
tests/support/frame_injector.h Phase 2E fault-injection hook

How

Acceptance criteria

  • http2_client.cpp line coverage >= 60.0% (current 18.8%, +41.2pp)
  • http2_client.cpp branch coverage >= 40.0% (current 9.9%, +30.1pp)
  • At least 6 new TEST_F cases driving previously-unreachable error branches via frame_injector:
    • connect timeout via injection_mode::drop on first server SETTINGS
    • malformed SETTINGS-ACK via injection_mode::malform (flip type byte)
    • truncated server SETTINGS payload via injection_mode::truncate
    • slow-write byte-by-byte via injection_mode::slow_write
    • partial-response disconnect (HEADERS sent, DATA dropped)
    • WINDOW_UPDATE handling under back-pressure
  • All new tests pass under Debug and Release builds
  • No src/ changes; test-only PR

Test plan for reviewers

cmake --build build --target network_http2_client_branch_test -j 4
./build/bin/network_http2_client_branch_test
# Expect: all TEST_F PASS

Out of scope

  • HTTP/2 frame parsing (protocols/http2/frame.cpp already at 98.4%)
  • HPACK (protocols/http2/hpack.cpp already at 91.3%)
  • Performance / load testing

Related

Metadata

Metadata

Assignees

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions