test(firmware): stream hashes of sparse oversize fixtures

Hash the complete oversize fixture through a read stream rather than allocating the entire 128 MiB file. Preserve the digest and oversize admission test semantics.

Validation: node --check and full static checks pass. The capacity fixture was not rerun locally to avoid heavy work.

Based on #1892.

Co-authored-by: GRAB Racem <racem.grab@etu.univ-lyon1.fr>
This commit is contained in:
morlutoandGRAB Racem committed 2026-10-14 13:58:18 +08:00
1 parent e62e92526c
commit 7375ab6e34
1 file changed
+5 -3
+5 -3
View File
@@ -1,4 +1,5 @@
import { createHash } from "node:crypto";
import { createReadStream } from "node:fs";
import {
chmod,
mkdir,
@@ -140,9 +141,10 @@ if (args.includes("--version")) {
// accept it even though the unknown chunk's range is small.
const oversized = 128 * 1024 * 1024 + 1;
await truncate(child, oversized);
const oversizedHash = createHash("sha256")
.update(await readFile(child))
.digest("hex");
const oversizedDigest = createHash("sha256");
for await (const chunk of createReadStream(child))
oversizedDigest.update(chunk);
const oversizedHash = oversizedDigest.digest("hex");
const nestedUnknownRecords = [
{
task: childTask,