test: characterize the hidpp v20 matcher and cover the CLI#406
Conversation
Greptile SummaryThis PR is purely additive test coverage — zero production lines are modified. It adds characterization tests for the HID++ 2.0 send/response matcher in
Confidence Score: 5/5All changes are additive test-only code; no production lines are touched, so there is no risk of regression. The PR adds only crates/openlogi-hidpp/src/channel.rs — the decoy set in Important Files Changed
Sequence Diagram%%{init: {'theme': 'neutral'}}%%
sequenceDiagram
participant Test
participant HidppChannel
participant ReadThread
participant Listener
Test->>HidppChannel: send_v20(request)
Note over HidppChannel: registers oneshot waiter
HidppChannel-->>ReadThread: (background loop)
Test->>ReadThread: feed decoys (wrong_device / wrong_feature / wrong_sw_id)
ReadThread->>ReadThread: predicate false - skip waiter
ReadThread->>Listener: "notify(decoy, matched=false)"
Test->>ReadThread: feed response (header matches)
ReadThread->>HidppChannel: resolve oneshot
ReadThread->>Listener: "notify(response, matched=true)"
Note over Test: wait_for_event_count before asserting listener events
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
sequenceDiagram
participant Test
participant HidppChannel
participant ReadThread
participant Listener
Test->>HidppChannel: send_v20(request)
Note over HidppChannel: registers oneshot waiter
HidppChannel-->>ReadThread: (background loop)
Test->>ReadThread: feed decoys (wrong_device / wrong_feature / wrong_sw_id)
ReadThread->>ReadThread: predicate false - skip waiter
ReadThread->>Listener: "notify(decoy, matched=false)"
Test->>ReadThread: feed response (header matches)
ReadThread->>HidppChannel: resolve oneshot
ReadThread->>Listener: "notify(response, matched=true)"
Note over Test: wait_for_event_count before asserting listener events
Reviews (2): Last reviewed commit: "test(hidpp): wait for listener delivery ..." | Re-trigger Greptile |
Summary
Closes the two long-standing test gaps flagged in the engineering audit: the HID++ 2.0 send/response-matcher path in the vendored hidpp fork had no characterization tests, and openlogi-cli had 2 tests for ~965 lines. All changes are purely additive
#[cfg(test)]modules — zero production lines modified.Changes
protocol/v20.rs::send_v20over the predicate-basedHidppChannel::send), reusing the existingMockRawHidChannelharness: header-field correlation against interleaved decoys, broadcast events not consuming pending requests, 0xFF error-frame decoding (mapped code →Hidpp20Error::Feature, unmapped code →UnsupportedResponse), and the width-agnostic matching quirk (a Long reply to a Short request is accepted) pinned as current behavior.debug_assert, arg conflicts,NonZeroU8bounds, value-enum mapping),diagmessage selection, DPI list-vs-range summarization, lighting color validation (rejects before any device I/O), optional-asset classification incl. two pinned quirks, andlistoutput formatting. Pure dispatch glue and hardware-seam functions were deliberately left untested (tautological or requiring prod changes).Found while writing tests, recorded here rather than fixed (test-only PR): the unreachable
map_errindiag/lighting.rscolor parsing, andis_optional_asset's loosefront_ext*prefix match.Testing
cargo test -p openlogi-hidpp -p openlogi-cli— 157 + 30 passed, 0 failedcargo clippy -p openlogi-cli --all-targets -- -D warnings— clean