mirror of
https://github.com/morluto/rea.git
synced 2026-11-02 21:06:04 +00:00
refactor(javascript): group application workflows and verification (#896)
This commit is contained in:
1 parent
faaee693d5
commit
0804722cdf
129 files changed
+402
-367
No files matched your search
@@ -0,0 +1,41 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
import assert from "node:assert/strict";
|
||||
import { constants } from "node:buffer";
|
||||
import { createHash } from "node:crypto";
|
||||
|
||||
import { canonicalDigest } from "../../../dist/domain/comparisonSemantics.js";
|
||||
import {
|
||||
createEvidence,
|
||||
parseEvidence,
|
||||
} from "../../../dist/domain/evidence.js";
|
||||
|
||||
// This opt-in check crosses the actual engine string limit; keep it outside
|
||||
// routine source tests. Build first, then run this script with the local Node.
|
||||
const leaf = "x".repeat(1024 * 1024);
|
||||
const encodedLeaf = JSON.stringify(leaf);
|
||||
const count = Math.ceil(constants.MAX_STRING_LENGTH / encodedLeaf.length) + 1;
|
||||
const value = { payload: Array.from({ length: count }, () => leaf) };
|
||||
const expected = createHash("sha256");
|
||||
expected.update('{"payload":[');
|
||||
for (let index = 0; index < count; index += 1) {
|
||||
if (index > 0) expected.update(",");
|
||||
expected.update(encodedLeaf);
|
||||
}
|
||||
expected.update("]}");
|
||||
assert.equal(canonicalDigest(value), expected.digest("hex"));
|
||||
|
||||
const evidence = createEvidence(
|
||||
undefined,
|
||||
{ id: "large-json-fixture", name: "Large JSON fixture", version: "1" },
|
||||
{ operation: "inspect_fixture", parameters: {}, result: value },
|
||||
);
|
||||
assert.equal(parseEvidence(evidence).evidence_id, evidence.evidence_id);
|
||||
process.stdout.write(
|
||||
`${JSON.stringify({
|
||||
verified: true,
|
||||
serialized_value_bytes: count * encodedLeaf.length + count - 1 + 14,
|
||||
engine_string_limit: constants.MAX_STRING_LENGTH,
|
||||
evidence_id: evidence.evidence_id,
|
||||
})}\n`,
|
||||
);
|
||||
Reference in new issue
Block a user