Skip to content

armgit / rea

Public Imported from GitHub
0

Reverse engineer anything with agents, from app behavior down to native binaries.

test(firmware): stream hashes of sparse oversize fixtures

morluto7375ab6e34e5
diff --git a/tests/fixtures/firmware/producer.mjs b/tests/fixtures/firmware/producer.mjs
index d7629073a..338c746b9 100644
--- a/tests/fixtures/firmware/producer.mjs
+++ b/tests/fixtures/firmware/producer.mjs
@@ -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,