test: add msgpack conformance vectors#17
Conversation
|
Warning Rate limit exceeded
To keep reviews running without waiting, you can enable usage-based add-on for your organization. This allows additional reviews beyond the hourly cap. Account admins can enable it under billing. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the 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 configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughThe changes introduce a new conformance test module to the build system and create a comprehensive test file that validates msgpack unpacking and packing behavior against hardcoded test vectors covering various data types including nil, booleans, strings, binaries, numbers, and arrays/maps. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~15 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Review rate limit: 0/1 reviews remaining, refill in 50 minutes and 57 seconds.Comment |
|
this is the last one for now! thank you for a nice library! |
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (1)
tests/full_conformance_vectors.zig (1)
49-53: ⚡ Quick winHeader tests should assert no accidental payload consumption.
Both header helpers only assert decoded length; they don’t verify the reader stayed at the payload boundary. Adding a post-unpack reader-position/remaining-bytes check would catch over-read bugs in header parsers.
Also applies to: 62-65
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@tests/full_conformance_vectors.zig` around lines 49 - 53, The tests only assert the decoded header length but not that the reader didn't advance into payload; update expectArrayHeaderVector and the similar expectMapHeaderVector to, after calling msgpack.unpackArrayHeader/msgpack.unpackMapHeader, assert the reader's remaining bytes (or current cursor) equals the original encoding slice length minus the number of bytes consumed by unpack* (i.e., ensure the reader stayed at the payload boundary). Locate the reader created from std.Io.Reader.fixed(encoding) in both functions and add an expectation that the reader position/remaining count is unchanged beyond the header bytes to catch any over-read by the header parser.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@tests/full_conformance_vectors.zig`:
- Around line 275-276: The test "full msgpack-test-suite: unsupported fixture
summary" currently contains a tautological expectEqual(30, 30) and should be
replaced with a real assertion against the generated skipped-fixture metadata
(or removed until that metadata exists). Locate the test block named "full
msgpack-test-suite: unsupported fixture summary" in
tests/full_conformance_vectors.zig and change the body to compare the expected
skipped count to the actual skipped count produced by your test-suite metadata
(e.g., a variable or function such as skippedFixturesCount,
getSkippedFixtures(), or skippedFixtures.summary.count) or remove the test
entirely until that metadata is implemented; ensure you reference the actual
metadata symbol used by your test generator and use std.testing.expectEqual to
assert the value.
- Around line 43-44: The current tolerance calculation (tol) based on
`@max`(`@abs`(vector.float) * 0.000001, 0.000001) is too loose for the conformance
vectors and can mask regressions; update the check in the test that computes tol
(used with std.testing.expectApproxEqAbs(vector.float, actual, tol)) to use a
much tighter relative factor (e.g., 1e-12) and/or a smaller absolute floor
(e.g., 1e-12), or replace the approximate assertion with an exact equality
assertion (std.testing.expectEqual) for vectors that must match exactly; adjust
the tol computation or assertion in the same scope where tol, vector.float,
actual, and std.testing.expectApproxEqAbs are used.
---
Nitpick comments:
In `@tests/full_conformance_vectors.zig`:
- Around line 49-53: The tests only assert the decoded header length but not
that the reader didn't advance into payload; update expectArrayHeaderVector and
the similar expectMapHeaderVector to, after calling
msgpack.unpackArrayHeader/msgpack.unpackMapHeader, assert the reader's remaining
bytes (or current cursor) equals the original encoding slice length minus the
number of bytes consumed by unpack* (i.e., ensure the reader stayed at the
payload boundary). Locate the reader created from std.Io.Reader.fixed(encoding)
in both functions and add an expectation that the reader position/remaining
count is unchanged beyond the header bytes to catch any over-read by the header
parser.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 43e18d50-2855-4c3a-afba-89b8eac82234
📒 Files selected for processing (2)
build.zigtests/full_conformance_vectors.zig
|
@banteg This is really excellent, I've been wanting to integrate some external test suite. How was the conversion of the test data done? AI or some deterministic method? |
|
i think codex wrote some script. it could really be one off, this test suite was the most comprehensive i found, but it hasn't been touched in 8 years, so it's not likely to be updated. |
a132b96 to
f5b1bbe
Compare
|
Ok, if it was done by a script, then it should be fine |
f5b1bbe to
0972e4d
Compare
|
Addressed the header-boundary nit in 0972e4d: the array/map header helpers now derive the expected header length from the MessagePack marker and assert that |
Summary
kawanet/msgpack-test-suitemap16, which is not present in that suiteNotes
The upstream fixture suite includes timestamp and extension values, but this library does not currently expose ext/timestamp APIs. Those fixtures are intentionally not represented here yet.
The generated vectors cover 203 upstream fixture encodings plus the local
map16boundary. These vectors would have caught the recently fixed binary header and array/map header-size bugs.Tests
./check.sh --ciSummary by CodeRabbit