Answer binary requests in the literal-values test transport

Object replies are read through binary() since the checker objects are
resolved from their ids, so the test transport answers both forms.
This commit is contained in:
Chris Tate
2026-10-22 07:20:38 -05:00
parent 8d1ce41a16
commit 930ee4e63a
@@ -8,16 +8,15 @@ import {
function harness() {
const members = new Map<number, SemanticTypeData[]>();
const snapshot = new SemanticSnapshot(1, {
text(method, payload) {
const query = JSON.parse(payload) as { objectId: number };
if (method !== "getTypesOfType" || !members.has(query.objectId))
throw new Error(`unexpected request: ${method}`);
return JSON.stringify(members.get(query.objectId));
},
binary(method) {
const reply = (method: string, payload: string) => {
const query = JSON.parse(payload) as { objectId: number };
if (method !== "getTypesOfType" || !members.has(query.objectId))
throw new Error(`unexpected request: ${method}`);
},
return JSON.stringify(members.get(query.objectId));
};
const snapshot = new SemanticSnapshot(1, {
text: reply,
binary: (method, payload) => new TextEncoder().encode(reply(method, payload)),
});
const project = snapshot.addProject("literal-values", () => undefined);
let id = 0;