test: add tests for solver
This commit is contained in:
@@ -5,9 +5,12 @@
|
|||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@eslint/js": "^9.29.0",
|
"@eslint/js": "^9.29.0",
|
||||||
|
"@jest/globals": "^30.0.3",
|
||||||
|
"@swc/jest": "^0.2.38",
|
||||||
"@types/node": "^24.0.4",
|
"@types/node": "^24.0.4",
|
||||||
"eslint": "^9.29.0",
|
"eslint": "^9.29.0",
|
||||||
"globals": "^16.2.0",
|
"globals": "^16.2.0",
|
||||||
|
"jest": "^30.0.3",
|
||||||
"prettier": "^3.6.0",
|
"prettier": "^3.6.0",
|
||||||
"turbo": "^2.5.4",
|
"turbo": "^2.5.4",
|
||||||
"typescript": "^5.8.3",
|
"typescript": "^5.8.3",
|
||||||
|
|||||||
6
pkgs/solver/jest.config.js
Normal file
6
pkgs/solver/jest.config.js
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
/** @type {import('jest').Config} */
|
||||||
|
module.exports = {
|
||||||
|
transform: {
|
||||||
|
"^.+\\.(t|j)sx?$": "@swc/jest",
|
||||||
|
},
|
||||||
|
};
|
||||||
@@ -4,6 +4,7 @@
|
|||||||
"module": "dist/lib.js",
|
"module": "dist/lib.js",
|
||||||
"types": "dist/lib.d.ts",
|
"types": "dist/lib.d.ts",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "tsc -p tsconfig.build.json"
|
"build": "tsc -p tsconfig.build.json",
|
||||||
|
"test": "jest"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
23
pkgs/solver/src/lib.spec.ts
Normal file
23
pkgs/solver/src/lib.spec.ts
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
import { describe, it, expect } from "@jest/globals";
|
||||||
|
import * as solver from "./lib";
|
||||||
|
|
||||||
|
describe("solver", () => {
|
||||||
|
it("solveJs", async () => {
|
||||||
|
expect(
|
||||||
|
await solver.solveJs(
|
||||||
|
new Uint8Array([1, 2]),
|
||||||
|
new Uint8Array([3, 4]),
|
||||||
|
),
|
||||||
|
).toStrictEqual(new Uint8Array([45, 176, 0, 0, 0, 0, 0, 0]));
|
||||||
|
});
|
||||||
|
|
||||||
|
it("verify", async () => {
|
||||||
|
expect(
|
||||||
|
await solver.verify(
|
||||||
|
new Uint8Array([1, 2]),
|
||||||
|
new Uint8Array([3, 4]),
|
||||||
|
new Uint8Array([45, 176, 0, 0, 0, 0, 0, 0]),
|
||||||
|
),
|
||||||
|
).toStrictEqual(true);
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -12,6 +12,7 @@ export async function solveJs(
|
|||||||
true;
|
true;
|
||||||
i++
|
i++
|
||||||
) {
|
) {
|
||||||
|
// using little-endian
|
||||||
solutionView.setBigUint64(0, i, true);
|
solutionView.setBigUint64(0, i, true);
|
||||||
|
|
||||||
const hashArrayBuf = await crypto.subtle.digest("SHA-256", arr);
|
const hashArrayBuf = await crypto.subtle.digest("SHA-256", arr);
|
||||||
|
|||||||
2688
pnpm-lock.yaml
generated
2688
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user