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:
1 parent
e62e92526c
commit
7375ab6e34
1 file changed
+5
-3
Vendored
+5
-3
@@ -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,
|
||||
|
||||
Reference in new issue
Block a user