Skip to content

test(grpc): expand client.cpp error-branch coverage using Phase 2 substrate (round 2) #1107

@kcenon

Description

@kcenon

What

Round 2 of protocols/grpc/client.cpp test coverage expansion using the Phase 2 substrate (frame_injector + mock_grpc_server_peer) merged in PR #1105 (Part of #1074). Round 1 sub-issues #994 and #1063 closed but the file still stands at 22.6% line / 9.5% branch in the 2026-05-06 coverage measurement (run 25430202846).

Why

grpc/client.cpp is the second-largest single-file contributor to the #953 coverage gap:

  • Line gap: 482 LOC * (60% - 22.6%) = ~180 additional hit lines
  • Branch gap: 926 branches * (35% - 9.5%) = ~236 additional hit branches

Phase 2 substrate (#1074) provides a mock_grpc_server_peer whose per-frame writes are routed through frame_injector, enabling deterministic error-path coverage on the gRPC client.

Where

Path Role
src/protocols/grpc/client.cpp File under test (482 LOC, 926 branches)
tests/unit/grpc_client_branch_test.cpp Add new TEST_F cases
tests/support/mock_grpc_server_peer.h Phase 2B/2E substrate
tests/support/frame_injector.h Phase 2E fault-injection hook

How

Acceptance criteria

  • grpc/client.cpp line coverage >= 60.0% (current 22.6%, +37.4pp)
  • grpc/client.cpp branch coverage >= 35.0% (current 9.5%, +25.5pp)
  • At least 5 new TEST_F cases driving previously-unreachable error branches via frame_injector:
    • connect timeout via injection_mode::drop on server SETTINGS
    • malformed SETTINGS-ACK via injection_mode::malform (flip type byte)
    • truncated response HEADERS via injection_mode::truncate
    • non-OK gRPC-Status trailer dispatched (drives client error-handling branches)
    • slow-write of DATA frame via injection_mode::slow_write
  • No src/ changes; test-only PR

Test plan for reviewers

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

Out of scope

  • gRPC frame parsing (protocols/grpc/frame.cpp already at 95.8%)
  • gRPC server (protocols/grpc/server.cpp already at 85.4%)
  • Service registry (protocols/grpc/service_registry.cpp already at 84.3%)

Related

Metadata

Metadata

Assignees

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions