mirror of
https://github.com/morluto/rea.git
synced 2026-11-19 13:12:26 +00:00
56 lines
2.1 KiB
TypeScript
56 lines
2.1 KiB
TypeScript
import { expect, it } from "vitest";
|
|
import { AnalysisResourceConstraintError } from "../domain/analysisErrorCore.js";
|
|
import { projectAnalysisError } from "../domain/analysisErrorProjection.js";
|
|
import {
|
|
DEFAULT_WASM_INTERFACE_REPRESENTATION_BYTES,
|
|
MAX_WASM_INTERFACE_REPRESENTATION_BYTES,
|
|
} from "../domain/wasm/wasmInterface.js";
|
|
import { WasmInterfaceBudget } from "../domain/wasm/wasmInterfaceBudget.js";
|
|
|
|
it("refuses typed WASM interface growth without asking the caller to wait", () => {
|
|
const budget = new WasmInterfaceBudget();
|
|
try {
|
|
budget.reserve(DEFAULT_WASM_INTERFACE_REPRESENTATION_BYTES + 1);
|
|
throw new Error("Expected a representation refusal");
|
|
} catch (error) {
|
|
if (!(error instanceof AnalysisResourceConstraintError)) throw error;
|
|
const projected = projectAnalysisError(error);
|
|
expect(projected).toMatchObject({
|
|
retryable: false,
|
|
details: {
|
|
resource: "capacity",
|
|
reported_limits: {
|
|
maximum_bytes: DEFAULT_WASM_INTERFACE_REPRESENTATION_BYTES,
|
|
},
|
|
},
|
|
});
|
|
expect(projected.remediation.action).toContain("max_interface_bytes");
|
|
expect(projected.remediation.action).not.toContain("fixed count");
|
|
expect(projected.remediation.action).not.toMatch(
|
|
/Wait for an active analysis/u,
|
|
);
|
|
}
|
|
});
|
|
|
|
it("does not suggest an impossible increase at the runtime representation maximum", () => {
|
|
const budget = new WasmInterfaceBudget(
|
|
MAX_WASM_INTERFACE_REPRESENTATION_BYTES,
|
|
);
|
|
try {
|
|
budget.reserve(MAX_WASM_INTERFACE_REPRESENTATION_BYTES + 1);
|
|
throw new Error("Expected serialization capacity refusal");
|
|
} catch (error) {
|
|
if (!(error instanceof AnalysisResourceConstraintError)) throw error;
|
|
const projected = projectAnalysisError(error);
|
|
expect(projected).toMatchObject({
|
|
details: { reported_limits: { source: "request" } },
|
|
});
|
|
expect(projected.remediation.action).toContain(
|
|
"already at the runtime representation maximum",
|
|
);
|
|
expect(projected.remediation.action).not.toContain(
|
|
"Raise max_interface_bytes",
|
|
);
|
|
}
|
|
});
|