test: cover the pure protocol units (Window, Codec, Protocol, ErrorCode)#1
Merged
Conversation
The standalone suite left the pure, sans-IO protocol modules thin — Window (the flow-control ledger) and Protocol.ErrorCode were at 0%, Codec 66%, Protocol 57%. These are the cross-language contract; they deserve dedicated unit tests, not just incidental coverage from the corpus run (which is excluded standalone). - window_test: new/take/grant — credit math, the never-negative take, draining, and the MAX_WINDOW ceiling clamp on both new/1 and grant/2. - protocol_test: pins the wire constants (version, control sid, default/max window, capabilities) and every frame type / signal / error-code token. - codec_test: encode/decode round-trips (incl. control sid 0 and the max signed-64 sid) and every decode rejection (non-map, corrupt msgpack, missing/empty/non-string 't', missing/non-integer/negative/out-of-range 'sid'). Also documents that bin payloads decode as Msgpax.Bin (binary: true) so a re-encode keeps the bin type. Also fixes a misleading codec doc comment (it claimed bin decodes to a plain binary; it's a Msgpax.Bin the Session unwraps). Total coverage 87% -> 92%; Window/Codec/Protocol/ErrorCode now 100%.
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.
Why
The standalone unit suite left the pure, sans-IO protocol modules thin — they were only exercised incidentally by the cross-language corpus run, which is excluded without
TERMINALWIRE_CORPUS. So this repo's ownmix test(what CI gates on) under-covered the contract:Terminalwire.Window(flow-control ledger)Terminalwire.Protocol.ErrorCodeTerminalwire.ProtocolTerminalwire.CodecWhat
window_test—new/take/grant: credit math, the never-negativetake, draining to empty and refilling, and theMAX_WINDOWceiling clamp on bothnew/1andgrant/2(the anti-DoS bound).protocol_test— pins the wire constants (version, control sid, default/max window, capability set) and every frame-type / signal / error-code token. These are the cross-language contract; a silent change here breaks interop.codec_test— encode/decode round-trips (including control sid0and the max signed-64-bit sid) and every decode rejection path: non-map, corrupt msgpack, missing/empty/non-stringt, and missing/non-integer/negative/out-of-rangesid.binpayloads decode asMsgpax.Bin— kept wrapped so a decode→re-encode preserves the MessagePackbintype; theSessionunwraps before use.All new files are
mix format-clean andcredo --strict-clean.mix test: 101 passed, 9 excluded (corpus).