Files
MikrotikManager/backend/src/services/traffic-flow-batch-proof.test.ts
T

16 lines
924 B
TypeScript

import assert from "node:assert/strict"
import { readFile } from "node:fs/promises"
import { flowBatchProof } from "./traffic-flow-batch-proof.js"
const payload=[{serverId:1,bytes:10}]
const before=JSON.stringify(payload)
const proof=flowBatchProof(payload,"facts")
assert.match(proof,/^[a-f0-9]{64}$/)
assert.equal(flowBatchProof(payload,"facts"),proof)
assert.notEqual(flowBatchProof(payload,"ingest"),proof)
assert.notEqual(flowBatchProof([{serverId:1,bytes:11}],"facts"),proof)
assert.equal(JSON.stringify(payload),before)
const source=await readFile(new URL("./traffic-flow-batch-proof.ts",import.meta.url),"utf8")
assert.deepEqual([...source.matchAll(/from\s+["']([^"']+)["']/g)].map(match=>match[1]),["node:crypto"])
console.log("traffic-flow-batch-proof.test.ts: deterministic owned identity, domain/payload separation, nonmutation; sole dependency node:crypto, no MCP lifecycle/filesystem/classifier/SQL/network")