refactor(koalabear): drop tests-only Fp.__bytes__ - #749
Merged
Conversation
The dunder only enabled bytes(fp) syntactic sugar that no production code used. Fp.encode_bytes() is the canonical SSZ path. Removed test_bytes_protocol entirely; its decode_bytes error checks (wrong length and exceeds-modulus) are already covered by the dedicated tests at test_ssz_deserialize_wrong_scope, test_ssz_deserialize_short_data, and test_ssz_deserialize_exceeds_modulus. Simplified test_ssz_roundtrip and test_ssz_deterministic by dropping the bytes(fp) versus encode_bytes() cross-checks; without the dunder those comparisons are meaningless. The encode-decode roundtrip and encode determinism are still asserted. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.
Summary
Fp.__bytes__only enabledbytes(fp)syntactic sugar used by a handful of test sites. No production code calls it — the canonical SSZ path isFp.encode_bytes().src/lean_spec/subspecs/koalabear/field.py(−11 lines):Fp.__bytes__deleted.tests/lean_spec/subspecs/koalabear/test_field.py(−40 lines net):test_bytes_protocoldeleted entirely. Thedecode_byteserror paths it exercised (wrong length, exceeds modulus) are already covered by the dedicatedtest_ssz_deserialize_wrong_scope,test_ssz_deserialize_short_data, andtest_ssz_deserialize_exceeds_modulustests.test_ssz_roundtripandtest_ssz_deterministicsimplified — removed thebytes(fp)vsencode_bytes()cross-checks, which become meaningless without the dunder. The encode-decode roundtrip and encode determinism are still asserted.Test plan
ruff check— clean.uv run pytest tests/lean_spec/subspecs/koalabear/test_field.py— 11 tests pass.grep -r "bytes(.*Fp\|__bytes__"acrosssrc/,tests/,packages/— no remaining production references toFp.__bytes__.🤖 Generated with Claude Code