Files
reverse-engineering-anything/tests/boundary/evm/solidityMetadataWorker.test.ts
T
morluto cb4e5cfbff feat(analysis): make resource budgets recoverable across CLI and MCP (#9706)
* refactor(analysis): centralize resource budgets and recovery facts

* feat(analysis): expose ASAR and Ghidra runtime admission controls

* feat(artifacts): expose reader admission and preserve limited recognition

* feat(javascript): expose recoverable semantic precision budgets

* feat(web): add recoverable source-map budgets and compact retained views

* feat(web): make historical capture decoding budgets recoverable

* fix(desktop): enforce selected view policies across capture and export

* feat(runtime): make Frida and LLDB retention budgets selectable

* feat(native): expose diagnostic budgets and preserve exhaustion causes

* feat(managed): expose recoverable snapshot and representation budgets

* feat(metadata): make Go and Rust inspection budgets recoverable

* feat(wasm): expose representation and producer admissions

* feat(evm): expose per-call worker resource budgets

* feat(android): make resource and string-pool omissions recoverable

* feat(producers): expose command and recorded-capture budgets

* docs(analysis): record recovery contracts and integrated validation

* fix(docs): link calibration oracle from published verification pages

* fix(docs): restore desktop task anchors and receipt links

* test(analysis): align fixtures with selectable budget contracts

* fix(analysis): remove source-location projector dependency cycle

* test(analysis): refresh budget recovery and verifier regressions

* test(analysis): preserve format and publication recovery expectations

* test(windows): align conformance with owned runtime admission

* fix(desktop): preserve selected alias kinds in exported state

* test(analysis): align provider fixtures with recoverable budgets

* test(desktop): validate emitted alias metadata structurally

* fix(ghidra): classify bounded Windows endpoint refusals

* test(cli): assert selectable artifact admission recovery

* fix(cli): preserve capture provenance in environment builds
2026-11-10 05:11:20 -05:00

120 lines
4.2 KiB
TypeScript

import { execFile } from "node:child_process";
import { readFile, writeFile } from "node:fs/promises";
import { join } from "node:path";
import { fileURLToPath } from "node:url";
import { promisify } from "node:util";
import { expect, it } from "vitest";
import { selectedEvmProducerLimits } from "../../../src/domain/evm/evmInterface.js";
import { solidityMetadataSchema } from "../../../src/domain/evm/solidityMetadata.js";
import { createTestTempDirectory } from "../../fixtures/temporaryDirectory.js";
/** Real compiled worker and unchanged WASM engine; no Linux provider-admission claim. */
it.each([
["compiler", "00a164736f6c634300081e000a", "decoded"],
["integer", "00a1011bffffffffffffffff000b", "decoded"],
["BOM text", "00a1617864efbbbf610008", "decoded"],
["nested value", "00a1617881000005", "partial"],
[
"distinct nested byte keys",
"00a264736f6c634300081e6178a24101014102020013",
"partial",
],
[
"duplicate nested byte keys",
"00a264736f6c634300081e6178a24101014101020013",
"not-decoded",
],
[
"duplicate nested text keys",
"00a264736f6c634300081e6178a26161016161020013",
"not-decoded",
],
["unavailable trailer", "00", "unavailable"],
["unsupported tag", "00a16178c0000005", "not-decoded"],
["floating point", "00a16178fa3f8000000008", "not-decoded"],
["invalid UTF-8", "00a1617861ff0005", "not-decoded"],
])(
"retains independent %s metadata through the actual worker",
async (kind, hex, status) => {
const directory = await createTestTempDirectory("rea-solidity-worker-");
const snapshot = join(directory, "selected.hex");
const reply = join(directory, "reply.json");
const request = join(directory, "request.json");
await writeFile(snapshot, hex);
await writeFile(
request,
JSON.stringify({
snapshot_path: snapshot,
reply_path: reply,
failure_marker_path: join(directory, "resource.failure"),
encoding: "hex",
producer_limits: selectedEvmProducerLimits(undefined),
}),
);
await promisify(execFile)(
process.execPath,
[
"--max-old-space-size=256",
"--disable-wasm-trap-handler",
fileURLToPath(
new URL(
"../../../dist/evm/EvmoleInterfaceWorker.js",
import.meta.url,
),
),
request,
],
{ timeout: 30_000, maxBuffer: 1024 * 1024 },
);
const value = JSON.parse(await readFile(reply, "utf8"));
expect(value.ok, JSON.stringify(value)).toBe(true);
expect(value.bytecode.hex).toBe(hex);
const metadata = solidityMetadataSchema.parse(value.bytecode.metadata);
expect(metadata.status).toBe(status);
if (kind === "integer")
expect(metadata.entries[0]?.value).toEqual({
kind: "integer",
value: "18446744073709551615",
});
if (kind === "compiler")
expect(metadata.compiler_version?.value).toBe("0.8.30");
if (kind === "BOM text")
expect(metadata.entries[0]?.value).toEqual({
kind: "text",
value: "\ufeffa",
});
if (kind === "nested value")
expect(metadata.entries[0]?.value).toEqual({
kind: "uninterpreted",
container: "array",
});
if (kind === "distinct nested byte keys") {
expect(metadata.compiler_version?.value).toBe("0.8.30");
expect(metadata.bytecode_offset).toBe(1);
expect(metadata.cbor_bytes).toBe(19);
}
if (kind.startsWith("duplicate nested")) {
expect(metadata.entries).toEqual([]);
expect(metadata.compiler_version).toBeNull();
expect(metadata.diagnostic).toBe("repeated_map_key");
expect(metadata.admission).toMatchObject({ code: "repeated_map_key" });
if (kind === "duplicate nested text keys")
expect(metadata.admission?.detail).toEqual({
key: JSON.stringify({ kind: "text", value: "a" }),
});
else
expect(
metadata.admission?.detail?.key ??
metadata.admission?.detail?.key_length,
).toBeDefined();
expect(metadata.bytecode_offset).toBe(1);
expect(metadata.cbor_bytes).toBe(19);
}
if (kind === "unavailable trailer") {
expect(metadata.bytecode_offset).toBeNull();
expect(metadata.entries).toEqual([]);
expect(metadata.compiler_version).toBeNull();
}
},
);