update deps, cleanup

This commit is contained in:
2026-06-01 01:05:14 +02:00
parent 4c61c067e6
commit 51c3e3d05f
22 changed files with 1590 additions and 2542 deletions
+16 -16
View File
@@ -1,26 +1,26 @@
import { describe, expect, it } from 'vitest'
import { Bytes, Hash, Hashes, Hex } from '../dist/index.js'
import { Precomputed } from './values.js'
import { describe, expect, it } from "vitest";
import { Bytes, Hash, Hashes, Hex } from "../src/index.js";
import { Precomputed } from "./values.js";
describe('Hash', () => {
describe("Hash", () => {
for (const type of Object.keys(Hashes)) {
describe(type, () => {
const values = Precomputed.Hash[type]
const values = Precomputed.Hash[type];
for (const [input, output] of Object.entries(values)) {
if (typeof output !== 'string') throw new Error('Bad test data')
if (typeof output !== "string") throw new Error("Bad test data");
it(`Should hash "${input}" to "${output.slice(0, 8)}..."`, async () => {
const hashed = await Hash.hash(input, Hashes[type])
expect(hashed).toEqual(output)
})
const hashed = await Hash.hash(input, Hashes[type]);
expect(hashed).toEqual(output);
});
it(`Should hash "${input}" to "${output.slice(0, 8)}..." as buffer`, async () => {
const outputBuffer = Hex.decode(output)
const inputBuffer = Bytes.encode(input)
const hashed = await Hash.hash(inputBuffer, Hashes[type])
expect(hashed).toEqual(outputBuffer)
})
const outputBuffer = Hex.decode(output);
const inputBuffer = Bytes.encode(input);
const hashed = await Hash.hash(inputBuffer, Hashes[type]);
expect(hashed).toEqual(outputBuffer);
});
}
})
});
}
})
});