-
Notifications
You must be signed in to change notification settings - Fork 142
Simple utils ts migration #847
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| import { describe, it, expect } from "vitest"; | ||
| import { verifyChecksum } from "../../../src/util/checksum"; | ||
|
|
||
| describe("verifyChecksum", () => { | ||
| it("returns true for identical arrays", () => { | ||
| const a = new Uint8Array([1, 2, 3]); | ||
| const b = new Uint8Array([1, 2, 3]); | ||
| expect(verifyChecksum(a, b)).toBe(true); | ||
| }); | ||
|
|
||
| it("returns false for different contents", () => { | ||
| const a = new Uint8Array([1, 2, 3]); | ||
| const b = new Uint8Array([1, 2, 4]); | ||
| expect(verifyChecksum(a, b)).toBe(false); | ||
| }); | ||
|
|
||
| it("returns false for different lengths", () => { | ||
| const a = new Uint8Array([1, 2, 3]); | ||
| const b = new Uint8Array([1, 2]); | ||
| expect(verifyChecksum(a, b)).toBe(false); | ||
| }); | ||
|
|
||
| it("returns true for two empty arrays", () => { | ||
| expect(verifyChecksum(new Uint8Array([]), new Uint8Array([]))).toBe(true); | ||
| }); | ||
|
|
||
| it("returns true for single matching byte", () => { | ||
| expect(verifyChecksum(new Uint8Array([0xff]), new Uint8Array([0xff]))).toBe( | ||
| true | ||
| ); | ||
| }); | ||
|
|
||
| it("returns false when first byte differs", () => { | ||
| const a = new Uint8Array([0, 2, 3]); | ||
| const b = new Uint8Array([1, 2, 3]); | ||
| expect(verifyChecksum(a, b)).toBe(false); | ||
| }); | ||
|
|
||
| it("returns false when last byte differs", () => { | ||
| const a = new Uint8Array([1, 2, 3]); | ||
| const b = new Uint8Array([1, 2, 0]); | ||
| expect(verifyChecksum(a, b)).toBe(false); | ||
| }); | ||
| }); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -19,7 +19,7 @@ | |
| "noUncheckedIndexedAccess": true, | ||
|
|
||
| // JavaScript support | ||
| "allowJs": true, | ||
| "allowJs": false, | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We'll have mixed JS and TS files for a while, is it OK to disable it?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I chose to disable this so that it would be easier to review the generation type declaration files. With this flag set to true the tsc compiler will generate declaration files for all js files. |
||
| "checkJs": false, | ||
|
|
||
| // Interop constraints | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| export declare function verifyChecksum(expected: Uint8Array, actual: Uint8Array): boolean; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we need to create these manually for every file we migrate?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is generated by tsc |
||
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.
Why are we removing these?
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.
The previous eslint config used a stricter rule set