mirror of
https://github.com/morluto/rea.git
synced 2026-12-05 02:24:58 +00:00
refactor(verifiers): share whole-file SHA-256 hashing (#14475)
* refactor(verifiers): share whole-file SHA-256 hashing * fix(verifiers): type the streamed digest input
This commit is contained in:
1 parent
a0390ba877
commit
60af9ef6b3
12 files changed
+41
-68
No files matched your search
@@ -1,3 +1,4 @@
|
||||
import { sha256File } from "../../lib/verifier-file-sha256.mjs";
|
||||
import assert from "node:assert/strict";
|
||||
import { constants } from "node:buffer";
|
||||
import { createHash } from "node:crypto";
|
||||
@@ -157,9 +158,7 @@ await withVerifierFixture(fixture, async () => {
|
||||
assert.equal(output.error, undefined);
|
||||
assert.equal(unexpectedOutputBytes, 0);
|
||||
|
||||
const actualHash = createHash("sha256");
|
||||
for await (const chunk of createReadStream(path)) actualHash.update(chunk);
|
||||
const digest = actualHash.digest("hex");
|
||||
const digest = await sha256File(path);
|
||||
assert.equal(digest, expectedHash.digest("hex"));
|
||||
assert.equal((await stat(path)).size, expectedBytes);
|
||||
let verifiedTokenCount;
|
||||
|
||||
Reference in new issue
Block a user