diff --git a/src/hopper/HopperNameInventory.test.ts b/src/hopper/HopperNameInventory.test.ts index 286d7987755..a7c3ef39e5f 100644 --- a/src/hopper/HopperNameInventory.test.ts +++ b/src/hopper/HopperNameInventory.test.ts @@ -6,32 +6,7 @@ import { HopperClient } from "./HopperClient.js"; import { HopperProvider } from "./HopperProvider.js"; import { projectHopperNameInventory } from "./HopperNameInventory.js"; -import { - hopperReplySchemas, - parseHopperReply as parseHopperReplyWith, - type HopperReplyMethod, -} from "./HopperReplyContracts.js"; -import type { JsonValue } from "../domain/jsonValue.js"; - -/** - * Stand in for the client's own reply check: `HopperClient.callTool` validates - * each reply against its method contract before the provider reads it. - */ -const validatedReply = - (reply: JsonValue) => - ( - method: HopperReplyMethod, - _arguments?: unknown, - options?: { readonly operation?: string }, - ) => - Promise.resolve( - parseHopperReplyWith( - hopperReplySchemas, - method, - reply, - options?.operation ?? method, - ), - ); +import { validatedReply } from "./HopperReplyContracts.fixture.js"; describe("Hopper name inventory labels", () => { it("tags stripped class-object labels without rewriting source values", () => { diff --git a/src/hopper/HopperReplyContracts.fixture.ts b/src/hopper/HopperReplyContracts.fixture.ts new file mode 100644 index 00000000000..a5a924900b2 --- /dev/null +++ b/src/hopper/HopperReplyContracts.fixture.ts @@ -0,0 +1,26 @@ +import type { JsonValue } from "../domain/jsonValue.js"; +import { + hopperReplySchemas, + parseHopperReply, + type HopperReplyMethod, +} from "./HopperReplyContracts.js"; + +/** + * Stand in for the client's own reply check: `HopperClient.callTool` validates + * each reply against its method contract before the provider reads it. + */ +export const validatedReply = + (reply: JsonValue) => + ( + method: HopperReplyMethod, + _arguments?: unknown, + options?: { readonly operation?: string }, + ) => + Promise.resolve( + parseHopperReply( + hopperReplySchemas, + method, + reply, + options?.operation ?? method, + ), + ); diff --git a/src/hopper/HopperReplyContracts.test.ts b/src/hopper/HopperReplyContracts.test.ts index 56b62dec2bd..a3a19894c77 100644 --- a/src/hopper/HopperReplyContracts.test.ts +++ b/src/hopper/HopperReplyContracts.test.ts @@ -9,6 +9,7 @@ import { silentLogger } from "../logger.js"; import { HopperClient } from "./HopperClient.js"; import { HopperProvider } from "./HopperProvider.js"; import { HOPPER_OPERATIONS } from "./HopperProviderMetadata.js"; +import { validatedReply } from "./HopperReplyContracts.fixture.js"; import { hopperBridgeMethod, parseHopperReply as parseHopperReplyWith, @@ -19,26 +20,6 @@ import { parseHopperShutdownReply, } from "./HopperReplyContracts.js"; -/** - * Stand in for the client's own reply check: `HopperClient.callTool` validates - * each reply against its method contract before the provider reads it. - */ -const validatedReply = - (reply: JsonValue) => - ( - method: HopperReplyMethod, - _arguments?: unknown, - options?: { readonly operation?: string }, - ) => - Promise.resolve( - parseHopperReplyWith( - hopperReplySchemas, - method, - reply, - options?.operation ?? method, - ), - ); - const parseHopperReply = ( method: M, value: JsonValue,