Add comprehensive protocol integration test suite
Introduce 20 integration tests in pwr-core/tests/protocol_integration.rs
that exercise the full protocol layer without network dependencies,
operating entirely on in-memory frame buffers and byte streams.
Frame encode/decode round-trips validate that ArchiveRequest,
RestoreRequest, and Handshake messages survive serialization through the
full pipeline: typed ClientMessage enum to JSON payload to framed bytes
with magic and length prefix through decode_frame back to typed enum with
correct field values.
FrameDecoder buffering tests cover two edge cases: byte-by-byte arrival
where the decoder correctly reports None for incomplete frames across
dozens of individual push_bytes calls until the full frame is available,
and multi-frame reads where two concatenated frames in a single buffer are
decoded sequentially without leftover bytes.
Error injection tests verify that bad magic bytes produce errors, truncated
frame headers (fewer than 10 bytes) return None rather than errors,
payloads exceeding the 16 MiB limit are rejected, unsupported protocol
versions are detected, and unknown message type bytes trigger framing
errors.
File chunk streaming tests cover exact 1 MiB chunks, zero-length data
(which is indistinguishable from the EOF marker by design since empty
chunks serve no purpose), EOF detection, and reassembly of 500 KB of
cyclical data across 4 KB chunks with content verification.
Serialization coverage iterates over all five ClientMessage variants and
all seven ServerMessage variants, verifying each round-trips through JSON
and preserves its message_type discriminant. Boundary tests handle empty
ProjectInfo lists, near-max-size payloads with u64::MAX size_bytes and
u32::MAX file_count, and direction-mismatch rejection where
decode_client_message and decode_server_message refuse payloads from the
wrong direction.
Comments 0
No comments yet. Be the first!
Sign in to join the conversation.