tests: cover the RTMP chunk layer and trace hex helper#32
Merged
Conversation
The chunk stream reader/writer was only exercised by the e2e job. Since our ChunkWriter only ever emits fmt-0 + fmt-3 continuations, the reader's fmt-1/2/3 decode paths, the extended-timestamp handling, and the in-band control messages had no direct coverage even though OBS and Twitch drive all of them on every connection. Adds 15 tests to rtmp/chunk.rs: - writer/reader round-trips (small, fragmented, extended-timestamp, and extended-timestamp across fragmentation) so the encoder and decoder are checked against each other - reader-only fmt-1/fmt-2/fmt-3 header decoding, which the writer never produces - in-band Set-Chunk-Size and Window-Ack-Size handling - basic-header CSID range encoding and u24 round-trip - malformed input (truncated header, truncated payload, zero-length message) returning an error instead of panicking Also adds 4 pure tests for trace::hex_prefix. Test count 210 -> 229. Updated both READMEs and the changelog.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds unit coverage for
rtmp/chunk.rsandtrace::hex_prefix. The chunk stream reader/writer was only exercised through the end-to-end job before this.Why
Our
ChunkWriteronly ever emits fmt-0 headers plus fmt-3 continuations. That means the reader's fmt-1, fmt-2, and fmt-3-replay decode paths, the extended-timestamp corner, and the in-band control messages had no direct test, even though OBS and Twitch use all of them on every connection. If a refactor broke one of those paths, only a live stream would have caught it.What's covered
15 new cases in
rtmp/chunk.rs:4 new pure tests for
trace::hex_prefix(formatting, boundary, truncation suffix).The socket-driving files (
client.rs,server.rs,handshake.rs,tcp.rs,sink.rs) are intentionally left to the e2e job. Unit-mocking those would add brittle tests without much signal.chunk.rswas the one file with real parsing logic on the untrusted-input path, so that's where the coverage went.Verification
cargo fmt --all -- --checkcleancargo clippy --all-targets -- -D warningscleancargo test --release: 229 passed, 0 failed, 1 ignored (the existing GitHub-hitting test)Test count went from 210 to 229. Both READMEs and the changelog are updated to match.