Skip to content

test(websocket): expand websocket_server.cpp coverage to 80% line / 70% branch #1067

Description

@kcenon

What

Expand unit-test coverage of src/http/websocket_server.cpp from 39.9% line / 19.7% branch to >= 80% line / >= 70% branch (per coverage.yml).

This file is a new target identified in the 2026-04-26 re-measurement; no prior narrow test-expansion sub-issue exists for it.

Why

Where

  • File: src/http/websocket_server.cpp (~308 lcov-executable lines)
  • Tests: extend tests/test_messaging_ws_server.cpp and tests/test_websocket_facade.cpp
  • Coverage workflow: .github/workflows/coverage.yml

How

Technical Approach

  1. Read websocket_server.cpp / websocket_server.h to enumerate frame handlers and error branches.
  2. Use the 2026-04-26 lcov report for uncovered lines/branches.
  3. Add tests for:
    • Handshake failures (bad Sec-WebSocket-Key, unsupported version, missing headers)
    • Frame validation errors (oversized payload, masked/unmasked policy mismatch, fragmented control frames)
    • Close-handshake state transitions and abnormal closures
    • Ping/Pong timeout handling and back-pressure on send
  4. Use the in-process loopback transport; no real network.

Acceptance Criteria

  • src/http/websocket_server.cpp line coverage >= 80%
  • src/http/websocket_server.cpp branch coverage >= 70%
  • Tests pass on Ubuntu/macOS/Windows CI
  • Sanitizer builds (ASAN, TSAN, UBSAN) pass
  • Post-merge coverage delta recorded on Expand unit test coverage from 40% to 80% #953

Part of #953

Metadata

Metadata

Assignees

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions