-
Notifications
You must be signed in to change notification settings - Fork 12
Expand decoder tests and improve handling of variable-sized uints #227
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
Conversation
- test: increase decoding coverage for all types
- fix: correct handling of large uints
This should cover all the major edge cases when decoding the data section.
Previously, we were not correctly handling variable-sized uints.
5b32d92
to
293091e
Compare
Looking good, left a comment which is more of a nit - feel free to ignore it if you like |
@@ -277,7 +277,7 @@ export default class Decoder { | |||
return this.db.readUIntBE(offset, size); | |||
} | |||
if (size == 8) { | |||
return this.db.readBigInt64BE(offset).toString(); | |||
return this.db.readBigUInt64BE(offset).toString(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
src/decoder.test.ts
Outdated
]; | ||
|
||
for (const tc of testCases) { | ||
const inputStr = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is used a bunch of times - maybe a worthwhile making a small helper fn for it. Same for expectedStr
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks. I did that for the three inputStr
uses. For expectedStr
, the two uses are different as one is for a string
and the other is for a Buffer
.
🎉 This PR is included in version 2.2.1 🎉 The release is available on: Your semantic-release bot 📦🚀 |