test: add tests for solver
This commit is contained in:
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",
|
||||
"types": "dist/lib.d.ts",
|
||||
"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;
|
||||
i++
|
||||
) {
|
||||
// using little-endian
|
||||
solutionView.setBigUint64(0, i, true);
|
||||
|
||||
const hashArrayBuf = await crypto.subtle.digest("SHA-256", arr);
|
||||
|
||||
Reference in New Issue
Block a user