Serve TeX plugin ABI over CultNet
This commit is contained in:
parent
db53acf276
commit
ae7e2fa2a4
6 changed files with 127 additions and 15 deletions
|
|
@ -3,11 +3,19 @@ import { spawn } from "node:child_process";
|
|||
import fs from "node:fs";
|
||||
import path from "node:path";
|
||||
import readline from "node:readline";
|
||||
import { Buffer } from "node:buffer";
|
||||
import { decode, encode } from "@msgpack/msgpack";
|
||||
import { invokeCultNetOperation } from "cultnet-ts";
|
||||
|
||||
const root = path.resolve(import.meta.dirname, "..");
|
||||
const fixture = JSON.parse(fs.readFileSync(path.join(root, "plugins/eve-plugin-tex/plugin-abi-fixture.json"), "utf8"));
|
||||
const child = spawn(process.execPath, [path.join(root, "plugins/eve-plugin-tex/src/sidecar.mjs")], { cwd: root, stdio: ["pipe", "pipe", "inherit"] });
|
||||
const child = spawn(process.execPath, [path.join(root, "plugins/eve-plugin-tex/src/cultnet-sidecar.mjs")], { cwd: root, stdio: ["ignore", "pipe", "inherit"] });
|
||||
const responses = readline.createInterface({ input: child.stdout })[Symbol.asyncIterator]();
|
||||
const endpointLine = await responses.next();
|
||||
assert.equal(endpointLine.done, false);
|
||||
const endpointAdvertisement = JSON.parse(endpointLine.value);
|
||||
assert.equal(endpointAdvertisement.pluginId, fixture.pluginId);
|
||||
const endpoint = endpointAdvertisement.endpoint;
|
||||
const startedAt = performance.now();
|
||||
const operationWitnesses = [];
|
||||
|
||||
|
|
@ -16,10 +24,18 @@ try {
|
|||
const operation = fixture.operations[index];
|
||||
const requestId = `tex-witness-${index}`;
|
||||
const operationStartedAt = performance.now();
|
||||
child.stdin.write(`${JSON.stringify({ schema: fixture.requestSchema, pluginId: fixture.pluginId, operation: operation.operation, requestId, input: operation.input })}\n`);
|
||||
const next = await responses.next();
|
||||
assert.equal(next.done, false);
|
||||
const response = JSON.parse(next.value);
|
||||
const abiRequest = { schema: fixture.requestSchema, pluginId: fixture.pluginId, operation: operation.operation, requestId, input: operation.input };
|
||||
const envelope = await invokeCultNetOperation(endpoint, {
|
||||
schemaVersion: "cultnet.operation_request.v0",
|
||||
messageId: requestId,
|
||||
serviceId: fixture.pluginId,
|
||||
operation: operation.operation,
|
||||
payloadSchema: fixture.requestSchema,
|
||||
payloadEncoding: "messagepack-base64",
|
||||
payload: Buffer.from(encode(abiRequest)).toString("base64"),
|
||||
sourceRuntimeId: "eve-conformance",
|
||||
}, { runtimeId: "eve-conformance" });
|
||||
const response = decode(Buffer.from(envelope.payload, "base64"));
|
||||
assert.equal(response.schema, fixture.responseSchema);
|
||||
assert.equal(response.pluginId, fixture.pluginId);
|
||||
assert.equal(response.operation, operation.operation);
|
||||
|
|
@ -35,7 +51,6 @@ try {
|
|||
});
|
||||
}
|
||||
} finally {
|
||||
child.stdin.end();
|
||||
child.kill();
|
||||
}
|
||||
|
||||
|
|
@ -47,13 +62,13 @@ const witness = {
|
|||
pluginId: "tex.math",
|
||||
ownerRepo: "EvePlugins",
|
||||
status: "pass",
|
||||
transport: "stdio-ndjson",
|
||||
transport: "cultnet-operation-v0+rudp",
|
||||
generatedAtUtc: new Date().toISOString(),
|
||||
durationMs: Number((performance.now() - startedAt).toFixed(3)),
|
||||
operations: operationWitnesses,
|
||||
advertisementPath: "plugins/eve-plugin-tex/advertisement.json",
|
||||
fixturePath: "plugins/eve-plugin-tex/plugin-abi-fixture.json",
|
||||
executable: { artifact: "plugins/eve-plugin-tex/src/sidecar.mjs", command: "node" },
|
||||
executable: { artifact: "plugins/eve-plugin-tex/src/cultnet-sidecar.mjs", command: "node" },
|
||||
diagnostics: [],
|
||||
authority: "plugin-sidecar-owns-tex-semantics-provider-retains-source-and-command-acceptance",
|
||||
};
|
||||
|
|
|
|||
Reference in a new issue