Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

util: check that hex to byte conversion is valid in hexToBytes #3185

Merged
merged 6 commits into from
Dec 12, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
util: add test case for invalid hex
  • Loading branch information
gabrocheleau committed Dec 9, 2023
commit 796f31679c9d423cde36f5ec18b617a54961a1ff
7 changes: 7 additions & 0 deletions packages/util/test/bytes.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,13 @@ describe('hexToBytes', () => {
hexToBytes('aabbcc112233')
})
})

it('should throw on invalid hex', () => {
assert.throws(() => {
hexToBytes('0xinvalidhexstring')
})
})

it('should convert prefixed hex-strings', () => {
const converted = hexToBytes('0x1')
assert.deepEqual(converted, new Uint8Array([1]))
Expand Down
Loading