update tests with additional tests and snapshots using v4 #274
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.
Adds tests for encoded data types of hexadecimal strings that convert to numbers equal to or greater than Javascript's
MAX_SAFE_INTEGER
. The following additional test cases are added to each encoded field "type":0x1fffffffffffff
- The hex string equal toNumber.MAX_SAFE_INTEGER
, which contains an even number (16) of characters0x1fffffffffffff1
a hex string that contains an odd number of characters (17) and is greater thanNumber.MAX_SAFE_INTEGER
.0x101
a hex string that contains an odd number of characters and is less thanNumber.MAX_SAFE_INTEGER
We test both even and odd length hex values because Node's
Buffer.from()
method does not buffer hex numbers correctlyso we must conditionally prepend hexstrings with a zero before buffering them depending on whether the string contains an
even or odd number of characters.
The added snapshots were taken by adding the additional test values to 219511e, the commit of the last release before v5 caused regressions to encoding of buffered hex strings.
You can manually test this by adding the new tests to a previous release (4.0.0 or 4.0.1), update the snapshots (
yarn jest -u
). Copy the updated snapshot file to this branch and run the tests to ensure thatv5
matches the expected output for encoding these values.