Skip to content

test: add msgpack conformance vectors#17

Merged
lalinsky merged 1 commit intolalinsky:mainfrom
banteg:test/conformance-vectors
Apr 30, 2026
Merged

test: add msgpack conformance vectors#17
lalinsky merged 1 commit intolalinsky:mainfrom
banteg:test/conformance-vectors

Conversation

@banteg
Copy link
Copy Markdown
Contributor

@banteg banteg commented Apr 30, 2026

Summary

  • add a generated conformance test artifact for the supported core MessagePack types
  • cover nil, bool, integer/float encodings, strings, binary values, and array/map headers from kawanet/msgpack-test-suite
  • add one local MessagePack spec boundary vector for map16, which is not present in that suite

Notes

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 map16 boundary. These vectors would have caught the recently fixed binary header and array/map header-size bugs.

Tests

  • ./check.sh --ci

Summary by CodeRabbit

  • Tests
    • Added comprehensive conformance tests for msgpack encoding and decoding operations, covering nil, booleans, strings, binary data, numbers, arrays, and maps with validation for canonical encoding formats.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 30, 2026

Warning

Rate limit exceeded

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

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 @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: defaults

Review profile: CHILL

Plan: Pro

Run ID: 56b6d1bb-821f-42b3-a4cd-842c30c51dd2

📥 Commits

Reviewing files that changed from the base of the PR and between a132b96 and 0972e4d.

📒 Files selected for processing (2)
  • build.zig
  • tests/full_conformance_vectors.zig
📝 Walkthrough

Walkthrough

The 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

Cohort / File(s) Summary
Build System Integration
build.zig
Refactors msgpack_module creation into a reusable variable, adds a new conformance test module at tests/full_conformance_vectors.zig, wires in the msgpack import, creates and registers test artifacts, and updates the main test step to depend on conformance test execution.
Conformance Test Vectors
tests/full_conformance_vectors.zig
New test file containing reusable vector types and helper functions to validate msgpack unpacking/packing behavior for nil, booleans, ASCII/UTF-8/emoji strings, binaries, signed/unsigned/floating-point numbers with tolerance, and array/map headers with canonical encoding verification.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~15 minutes

Poem

Hippity-hop through test vectors true,
Msgpack unpacks, as rabbits do!
Bits and booleans, strings and maps,
Conformance checks in fuzzy laps,
Build system wired, all circuits hum! 🐰✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'test: add msgpack conformance vectors' directly and clearly summarizes the main change - adding a new conformance test suite with msgpack test vectors.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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
Review rate limit: 0/1 reviews remaining, refill in 50 minutes and 57 seconds.

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

@banteg
Copy link
Copy Markdown
Contributor Author

banteg commented Apr 30, 2026

this is the last one for now! thank you for a nice library!

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Nitpick comments (1)
tests/full_conformance_vectors.zig (1)

49-53: ⚡ Quick win

Header 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

📥 Commits

Reviewing files that changed from the base of the PR and between 5701d0c and a132b96.

📒 Files selected for processing (2)
  • build.zig
  • tests/full_conformance_vectors.zig

Comment thread tests/full_conformance_vectors.zig Outdated
Comment thread tests/full_conformance_vectors.zig Outdated
@lalinsky
Copy link
Copy Markdown
Owner

@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?

@banteg
Copy link
Copy Markdown
Contributor Author

banteg commented Apr 30, 2026

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.

@banteg banteg force-pushed the test/conformance-vectors branch from a132b96 to f5b1bbe Compare April 30, 2026 13:41
@lalinsky
Copy link
Copy Markdown
Owner

Ok, if it was done by a script, then it should be fine

@banteg banteg force-pushed the test/conformance-vectors branch from f5b1bbe to 0972e4d Compare April 30, 2026 13:43
@banteg
Copy link
Copy Markdown
Contributor Author

banteg commented Apr 30, 2026

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 reader.bufferedLen() is exactly encoding.len - header_len after unpacking. Local ./check.sh --ci passes with 145/145 tests.

@lalinsky lalinsky merged commit 676a088 into lalinsky:main Apr 30, 2026
2 of 3 checks passed
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