Part of #953
What
Raise line coverage of src/protocols/grpc/client.cpp from 22.2% to >= 70%, and branch coverage from 8.7% to >= 60%.
Current state (2026-04-17 measurement, source PR #989):
- Instrumented lines: 482 / ~1702 LOC
- Lines hit: 107 / 482 (22.2%)
- Branches: 81 / 926 (8.7%)
- No dedicated unit test file found for this translation unit. Related tests exist only at the integration level (
tests/test_grpc_integration.cpp, tests/test_grpc_client_server.cpp).
This is the largest file in the top-5 (~1702 LOC) and the only one without a unit test file. Coverage likely comes incidentally from integration tests.
Why
- Lack of a unit test file means the gRPC client implementation has zero guard-rails for isolated-unit regressions. Integration tests catch end-to-end breakage but give poor signal on internal branches.
- gRPC is an optional ecosystem integration (
NETWORK_ENABLE_GRPC_OFFICIAL=OFF by default) but still shipped; untested branches will break downstream consumers that opt in.
Where
- Source:
src/protocols/grpc/client.cpp
- New file to create:
tests/unit/grpc_client_test.cpp
- Existing integration tests (do not modify in this issue):
tests/test_grpc_integration.cpp, tests/test_grpc_client_server.cpp, tests/test_grpc_service_registry.cpp
How
Approach
- Create
tests/unit/grpc_client_test.cpp as the primary unit test file.
- Mock or stub transport layer so tests don't require a running server.
- Cover:
- Channel setup (valid URI, invalid URI, TLS config variants)
- Unary call lifecycle (success, deadline exceeded, cancelled, server returns error status)
- Streaming-call state transitions (client-streaming, server-streaming, bidi)
- Metadata handling (initial, trailing, custom keys)
- Error status code mapping (all gRPC status codes)
- Wire up via the existing
add_executable + gtest_discover_tests pattern used by other tests/unit/*.cpp.
Acceptance Criteria
Out of Scope
- Enabling
NETWORK_ENABLE_GRPC_OFFICIAL by default.
- gRPC server-side coverage (separate follow-up).
Dependencies
Part of #953
What
Raise line coverage of
src/protocols/grpc/client.cppfrom 22.2% to >= 70%, and branch coverage from 8.7% to >= 60%.Current state (2026-04-17 measurement, source PR #989):
tests/test_grpc_integration.cpp,tests/test_grpc_client_server.cpp).This is the largest file in the top-5 (~1702 LOC) and the only one without a unit test file. Coverage likely comes incidentally from integration tests.
Why
NETWORK_ENABLE_GRPC_OFFICIAL=OFFby default) but still shipped; untested branches will break downstream consumers that opt in.Where
src/protocols/grpc/client.cpptests/unit/grpc_client_test.cpptests/test_grpc_integration.cpp,tests/test_grpc_client_server.cpp,tests/test_grpc_service_registry.cppHow
Approach
tests/unit/grpc_client_test.cppas the primary unit test file.add_executable+gtest_discover_testspattern used by othertests/unit/*.cpp.Acceptance Criteria
tests/unit/grpc_client_test.cppcreated and registered in CMakesrc/protocols/grpc/client.cppline coverage >= 70%src/protocols/grpc/client.cppbranch coverage >= 60%Out of Scope
NETWORK_ENABLE_GRPC_OFFICIALby default.Dependencies