Add tests for progressive containers and ProgressiveMerkleHasher - #50
Merged
Conversation
Co-authored-by: michaelsproul <4452260+michaelsproul@users.noreply.github.com>
Co-authored-by: michaelsproul <4452260+michaelsproul@users.noreply.github.com>
Co-authored-by: michaelsproul <4452260+michaelsproul@users.noreply.github.com>
Co-authored-by: michaelsproul <4452260+michaelsproul@users.noreply.github.com>
… stream in Co-authored-by: michaelsproul <4452260+michaelsproul@users.noreply.github.com>
…er method Co-authored-by: michaelsproul <4452260+michaelsproul@users.noreply.github.com>
…inary tree hashing Co-authored-by: michaelsproul <4452260+michaelsproul@users.noreply.github.com>
Previously the consistency check between variant-level `tree_hash` and `ssz` attributes compared the whole parsed `VariantOpts` structs. Since both parsers tolerate unknown keys, an attribute that is present but does not set `selector` (e.g. one carrying only ssz-specific keys) would parse as `selector: None` and spuriously fail the consistency assertion against the other attribute's explicit selector. Merge the two attributes field-by-field instead, asserting consistency only when both actually set a selector. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
The variant checks in the transparent and union derive paths only
verified the field *count*, so a single named-field variant like
`A { x: u8 }` passed the check and then failed with a confusing
"expected tuple struct" error in the generated match pattern.
Check explicitly for a single unnamed field and panic with a proper
message naming the offending variant.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Regular unions already panic with "0-variant union is not permitted"
(via `compute_union_selectors`), but a 0-variant compatible union slipped
through selector validation and instead failed on the generated
`match self {}`, which is not exhaustive for `&Self` even when `Self` is
uninhabited. Panic with the same message as the regular union path.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
A `selector` attribute on a variant of a transparent enum was silently ignored, because `parse_variant_opts` was only called from the union derive path. Transparent enums never mix in a selector, so a manual one is a configuration error: reject it in the same way that the regular "union" behaviour already does. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Extend the differential property tests (sigp#47) and derive macro tests (sigp#48) to cover the new functionality in the progressive branch: - Property test ProgressiveMerkleHasher against a recursive reference implementation of EIP-7916 merkleize_progressive, with random byte lengths and random write splits to exercise the partial-chunk carry buffer, up to 128 chunks to cross all early level boundaries. - Property test ProgressiveBitList hashing against the same reference with independent bit packing, covering the empty-list workaround. - Derive tests for progressive containers: skip_hashing interaction, nesting (both directions), generics, tree_hash_type, a six-field container crossing a progressive level boundary, and active_fields spanning multiple bytes. - Hard-coded roots for the level-crossing and multi-byte cases computed independently from the EIP pseudocode, so these tests do not rely on the hasher under test. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017PpXigbebk4GAQ9D9qdFzU
Member
Author
|
@macladson was thinking of merging this into the |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #50 +/- ##
==========================================
+ Coverage 92.49% 93.64% +1.14%
==========================================
Files 8 8
Lines 626 739 +113
==========================================
+ Hits 579 692 +113
Misses 47 47 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
michaelsproul
approved these changes
Aug 18, 2026
michaelsproul
left a comment
Member
There was a problem hiding this comment.
Nice test coverage, thanks!
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.
Extend the differential property tests (#47) and derive macro tests (#48) to cover the new functionality in the progressive branch:
Claude-Session: https://claude.ai/code/session_017PpXigbebk4GAQ9D9qdFzU