test: add comprehensive roundtrip tests and fix leading zeros bug#55
Open
sumanjeet0012 wants to merge 3 commits into
Open
test: add comprehensive roundtrip tests and fix leading zeros bug#55sumanjeet0012 wants to merge 3 commits into
sumanjeet0012 wants to merge 3 commits into
Conversation
sumanjeet0012
force-pushed
the
fix-issue-40
branch
from
July 13, 2026 13:40
f2bf2f3 to
4033614
Compare
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.
Fixes #40
Description
This pull request adds comprehensive round-trip tests with random data to verify that all encodings in
py-multibasecorrectly handle various data shapes, including leading zero bytes and extreme sizes. In addition, it fixes a bug whereBaseStringConverterwas incorrectly dropping leading zeros upon encoding/decoding.Changes
tests/test_roundtrip.pywith random data generators covering all 24 supported encodings (e.g.base2,base8,base10,base16,base32z,base36,base58btc, etc.).b'\x00\x00'), all ones (b'\xff\xff'), and leading zeroes (b'\x00hello').BaseStringConverter.encodeanddecodeinmultibase/converters.pyto correctly preserve leading zero bytes manually, asint.from_bytesnaturally truncates them.Base16StringConverter.decodeinmultibase/converters.pyto usebytes.fromhex()instead of relying on the integer representation decoding.