mirror of
https://github.com/morluto/rea.git
synced 2026-11-21 22:15:50 +00:00
test(mcp): consolidate admission and lifecycle checks (#12833)
* test(mcp): consolidate canonical batch capacity checks * test(mcp): keep separate cold-start prompt checks * test(mcp): consolidate byte entropy request checks * test(mcp): consolidate progress checks and remove waiting sleeps
This commit is contained in:
1 parent
01895d33ef
commit
bb7bdd2fba
7 files changed
+82
-146
No files matched your search
@@ -1,37 +0,0 @@
|
||||
import { Ajv2020 } from "ajv/dist/2020.js";
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
import {
|
||||
enhancedInputSchemas,
|
||||
MAX_ENHANCED_RECORDS,
|
||||
} from "./enhancedInputs.js";
|
||||
import { advertisedInputJsonSchema } from "./toolSchemaMetadata.js";
|
||||
import { toolContract } from "./toolContracts.js";
|
||||
|
||||
describe("batch_decompile input contract", () => {
|
||||
it("bounds addresses in the canonical and advertised schemas", () => {
|
||||
const addresses = Array.from({ length: MAX_ENHANCED_RECORDS }, () => "0x0");
|
||||
const schema = enhancedInputSchemas.batch_decompile;
|
||||
expect(schema.safeParse({ addresses }).success).toBe(true);
|
||||
expect(schema.safeParse({ addresses: [...addresses, "0x1"] }).success).toBe(
|
||||
false,
|
||||
);
|
||||
|
||||
const advertised = advertisedInputJsonSchema(
|
||||
toolContract("batch_decompile"),
|
||||
);
|
||||
const advertisedAddresses = (
|
||||
advertised.properties as Record<string, unknown>
|
||||
).addresses;
|
||||
expect(advertisedAddresses).toMatchObject({
|
||||
type: "array",
|
||||
maxItems: MAX_ENHANCED_RECORDS,
|
||||
});
|
||||
|
||||
const ajv = new Ajv2020({ strict: false, validateFormats: false });
|
||||
expect(ajv.validateSchema(advertised)).toBe(true);
|
||||
const validate = ajv.compile(advertised);
|
||||
expect(validate({ addresses })).toBe(true);
|
||||
expect(validate({ addresses: [...addresses, "0x1"] })).toBe(false);
|
||||
});
|
||||
});
|
||||
@@ -1,33 +0,0 @@
|
||||
import { expect, it } from "vitest";
|
||||
|
||||
import { toolContract } from "../toolContracts.js";
|
||||
|
||||
const entropy = toolContract("inspect_byte_entropy");
|
||||
|
||||
it("warns that complete byte-entropy output can become very large", () => {
|
||||
expect(entropy.description).toMatch(
|
||||
/output.*large.*one row per selected block.*summary.*full list/iu,
|
||||
);
|
||||
expect(entropy.description).toContain(
|
||||
"Use a shorter length or a larger block_size",
|
||||
);
|
||||
});
|
||||
|
||||
it("keeps the public entropy input closed after detail is added", () => {
|
||||
expect(entropy.inputSchema.parse({ path: "/file" })).toMatchObject({
|
||||
path: "/file",
|
||||
block_size: 4096,
|
||||
offset: 0,
|
||||
detail: "complete",
|
||||
});
|
||||
expect(
|
||||
entropy.inputSchema.safeParse({
|
||||
path: "/file",
|
||||
detail: "summary",
|
||||
extra: true,
|
||||
}).success,
|
||||
).toBe(false);
|
||||
expect(
|
||||
entropy.inputSchema.safeParse({ path: "/file", block_size: 257 }).success,
|
||||
).toBe(false);
|
||||
});
|
||||
@@ -354,8 +354,9 @@ it.each(["legacy", "auto"] as const)(
|
||||
},
|
||||
);
|
||||
|
||||
it("initializes through prompt retrieval or completion without an internal client", async () => {
|
||||
it("completes a prompt argument as the first operation", async () => {
|
||||
const f = await fixture();
|
||||
expect(f.loads()).toBe(0);
|
||||
expect(
|
||||
(
|
||||
await f.client.complete({
|
||||
@@ -364,24 +365,21 @@ it("initializes through prompt retrieval or completion without an internal clien
|
||||
})
|
||||
).completion.values,
|
||||
).toEqual(["Example"]);
|
||||
expect(
|
||||
(
|
||||
await f.client.getPrompt({
|
||||
name: "explain",
|
||||
arguments: { document: "Example" },
|
||||
})
|
||||
).messages[0]?.content,
|
||||
).toEqual({ type: "text", text: "Example" });
|
||||
expect(f.loads()).toBe(1);
|
||||
});
|
||||
|
||||
it("retrieves a prompt as the first operation", async () => {
|
||||
const f = await fixture();
|
||||
expect(f.loads()).toBe(0);
|
||||
const result = await f.client.getPrompt({
|
||||
name: "explain",
|
||||
arguments: { document: "Example" },
|
||||
});
|
||||
expect(result.messages).toHaveLength(1);
|
||||
expect(result.messages[0]?.content).toEqual({
|
||||
type: "text",
|
||||
text: "Example",
|
||||
});
|
||||
expect(f.loads()).toBe(1);
|
||||
});
|
||||
|
||||
|
||||
Reference in new issue
Block a user