Skip to content

test(pidff-common): cover padding bytes and parser boundaries#509

Draft
EffortlessSteven wants to merge 1 commit into
mainfrom
claude/improve-code-coverage-xaNsj-pidff
Draft

test(pidff-common): cover padding bytes and parser boundaries#509
EffortlessSteven wants to merge 1 commit into
mainfrom
claude/improve-code-coverage-xaNsj-pidff

Conversation

@EffortlessSteven

Copy link
Copy Markdown
Member

Summary

Adds 21 new tests for openracing-pidff-common, pinning behaviour that the existing suite did not exercise.

The crate sits in the HID device protocol layer — every Moza, Simucube, AccuForce, FFBeast, etc. crate re-uses its encoders — so a regression that, for example, shifted a padding byte would propagate silently to every vendor. These tests turn the layout into an executable contract.

What the new tests cover

  • Set Effect padding — bytes 5–8 (trigger repeat interval / sample period), byte 10 (0xFF no-trigger-button marker), and byte 13 are now pinned to expected values in both a unit test and a 256-case proptest.
  • Set Effect block index extremes — exercises 0, 127, 200, 255.
  • Infinite-duration literal bytes — asserts that DURATION_INFINITE produces 0xFF, 0xFF at byte positions 3 and 4, not just the u16 view.
  • Device Gain reserved bytebuf[1] must stay 0; covered by both a direct test and a proptest over all u16 values.
  • Device Gain clamp boundary — explicit tests at 10000 (kept) and 10001 (clamped).
  • Device Control report-id byte — every named flag and several bitwise unions assert buf[0] == DEVICE_CONTROL.
  • Derived-trait coverageBlockLoadReport, EffectType, EffectOp, BlockLoadStatus all get Clone, Eq/Ne, and Debug-format assertions, so removing a derive cannot pass CI.
  • parse_block_load boundary cases — 4-byte (rejected), oversized 8-byte (accepted), status ∈ 4..=255 (rejected, brute-forced), and empty buffer.
  • Encoder length matches *_LEN constants — sanity check on every public encoder.
  • PID_POOL constant — pinned to 0x13 even though no encoder uses it yet.

Verification

cargo test -p openracing-pidff-common
running 37 tests   ...  ok
running 21 tests   ...  ok  ← new
running 64 tests   ...  ok

cargo clippy -p openracing-pidff-common --tests is clean.

Test plan

  • cargo test -p openracing-pidff-common
  • cargo clippy -p openracing-pidff-common --tests
  • Coverage CI confirms a bump for openracing-pidff-common

https://claude.ai/code/session_01NZ5jzdE2H3bbuPuYqbjCnh


Generated by Claude Code

Adds 21 tests that pin previously uncovered behavior in the shared
PIDFF encoder/parser crate:

- Set Effect padding (bytes 5-8, trigger marker at 10, trailing 13)
  is now asserted to be zero across both a unit test and a 256-case
  proptest, so a future encoder change cannot silently shift the
  layout.
- Device Gain byte 1 is pinned to zero, the clamp boundary is
  asserted at both 10000 and 10001, and the report-id byte is
  asserted on every device-control flag combination.
- BlockLoadReport, EffectType, EffectOp, and BlockLoadStatus now have
  Debug/Clone/PartialEq coverage so derived traits don't silently
  regress.
- parse_block_load gains tests for 4-byte (rejected), oversized
  (accepted), all status bytes 4..=255 (rejected), and an
  empty-buffer case, plus a proptest that pins the relationship
  between the first byte and parse success.
- Adds an "encoder length matches LEN constant" sanity check across
  every public encoder.
@gemini-code-assist

Copy link
Copy Markdown

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

@coderabbitai

coderabbitai Bot commented May 16, 2026

Copy link
Copy Markdown

Warning

Rate limit exceeded

@EffortlessSteven has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 18 minutes and 44 seconds before requesting another review.

You’ve run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: a1e5af26-0a4d-4a4e-9e2e-b879f8239670

📥 Commits

Reviewing files that changed from the base of the PR and between d151081 and a6b8fc6.

📒 Files selected for processing (1)
  • crates/pidff-common/tests/coverage_gaps.rs
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch claude/improve-code-coverage-xaNsj-pidff

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions

Copy link
Copy Markdown

Compatibility Layer Usage Report

Current usage count: 193
Baseline usage count: 193
ℹ️ Usage unchanged

📈 Usage Trend (Last 30 Days)

  • Peak usage: 193
  • Current trend: insufficient_data (0%)
  • Projected removal: unknown

Usage Details

  • /home/runner/work/OpenRacing/OpenRacing/crates/engine/src/compat_impl.rs:69 - temp_c
  • /home/runner/work/OpenRacing/OpenRacing/crates/engine/src/hid/linux.rs:1253 - temp_c
  • /home/runner/work/OpenRacing/OpenRacing/crates/engine/src/hid/linux.rs:1282 - temp_c
  • /home/runner/work/OpenRacing/OpenRacing/crates/engine/src/hid/mod.rs:230 - temp_c
  • /home/runner/work/OpenRacing/OpenRacing/crates/engine/src/protocol.rs:290 - temp_c
  • /home/runner/work/OpenRacing/OpenRacing/crates/engine/src/protocol.rs:742 - temp_c
  • /home/runner/work/OpenRacing/OpenRacing/crates/engine/src/protocol.rs:749 - temp_c
  • /home/runner/work/OpenRacing/OpenRacing/crates/schemas/src/service_example.rs:189 - temp_c
  • /home/runner/work/OpenRacing/OpenRacing/crates/schemas/src/service_example.rs:218 - temp_c
  • /home/runner/work/OpenRacing/OpenRacing/crates/schemas/src/integration_test.rs:79 - temp_c

... and 183 more occurrences

Migration Guide

To migrate these usages, replace:

  • .temp_c().temperature_c
  • .faults().fault_flags
  • .wheel_angle_mdeg().wheel_angle_deg
  • .wheel_speed_mrad_s().wheel_speed_rad_s

See Migration Patterns for detailed examples.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants