diff --git a/tests/api/info/_mockInfoTransport.ts b/tests/api/info/_mockInfoTransport.ts index 890d3c37..60119dad 100644 --- a/tests/api/info/_mockInfoTransport.ts +++ b/tests/api/info/_mockInfoTransport.ts @@ -14,6 +14,7 @@ import type { IRequestTransport } from "@bloxwap/hyperliquid"; export interface MockInfoCall { endpoint: "info" | "exchange"; payload: unknown; + signal?: AbortSignal; } /** An {@linkcode IRequestTransport} that serves canned responses for offline tests. */ @@ -23,9 +24,11 @@ export class MockInfoTransport implements IRequestTransport { constructor(readonly handler: (payload: Record) => unknown) {} - request(endpoint: "info" | "exchange", payload: unknown, _signal?: AbortSignal): Promise { - this.calls.push({ endpoint, payload }); - return Promise.resolve(this.handler(payload as Record) as T); + async request(endpoint: "info" | "exchange", payload: unknown, signal?: AbortSignal): Promise { + this.calls.push({ endpoint, payload, signal }); + // `async` so a throwing handler rejects the returned promise, the way a real transport's + // failures surface — never a synchronous throw out of `request`. + return this.handler(payload as Record) as T; } } diff --git a/tests/api/info/_offlineMethodTests.ts b/tests/api/info/_offlineMethodTests.ts new file mode 100644 index 00000000..af3c9a39 --- /dev/null +++ b/tests/api/info/_offlineMethodTests.ts @@ -0,0 +1,136 @@ +/** + * Shared offline battery for Info API methods over {@linkcode MockInfoTransport}. + * + * Every Info method body is the same shape — validate params against the request schema, send one + * `info` request, return the transport's response — so each method's test file runs this battery: + * the exact wire payload for every valid-params combo, a {@linkcode ValidationError} and zero + * requests for invalid params, response/error/signal passthrough, and identical behavior through + * the {@linkcode InfoClient} wrapper. + * + * @module + */ + +import { describe, expect, test } from "bun:test"; +import { InfoClient, ValidationError } from "@bloxwap/hyperliquid"; +import { MockInfoTransport } from "./_mockInfoTransport.ts"; + +/** A valid-params case for {@linkcode runOfflineMethodTests}. */ +export interface OfflineMethodCase { + /** Params handed to the method. */ + params: Record; + /** Expected wire payload after request-schema validation; defaults to `{ type: , ...params }`. */ + payload?: Record; +} + +/** How the method (and its InfoClient wrapper) takes its arguments. */ +export type OfflineMethodSignature = + /** `(params, signal?)` */ + | "params" + /** `(signal?)` — parameterless endpoint */ + | "none" + /** `(params?, signal?)` or `(signal?)` — params optional via an overload */ + | "overloaded"; + +// The battery drives every method shape through one signature; each call site passes the right +// arguments for its declared `signature` mode. +type AnyInfoMethod = (config: { transport: MockInfoTransport }, ...args: any[]) => Promise; + +/** + * Registers the offline battery for one Info API method as `describe(" (offline request)")`. + * + * @param options.name Method name; also the request `type` and the InfoClient method name. + * @param options.method The standalone method function. + * @param options.signature How the method takes its arguments (see {@linkcode OfflineMethodSignature}). + * @param options.cases Valid-params cases; ignored for `signature: "none"` (one bare request is tested). + * @param options.invalidParams Params that must fail request-schema validation; omit when no input can be invalid. + */ +export function runOfflineMethodTests(options: { + name: string; + method: AnyInfoMethod; + signature: OfflineMethodSignature; + cases?: OfflineMethodCase[]; + invalidParams?: Record[]; +}): void { + const { name, method, signature, cases = [{ params: {} }], invalidParams = [] } = options; + const payloadOf = (c: OfflineMethodCase): Record => c.payload ?? { type: name, ...c.params }; + + const callMethod = (transport: MockInfoTransport, c: OfflineMethodCase, signal?: AbortSignal): Promise => + signature === "none" ? method({ transport }, signal) : method({ transport }, c.params, signal); + + const callClient = (client: InfoClient, c: OfflineMethodCase, signal?: AbortSignal): Promise => { + const fn = (client as unknown as Record Promise>)[name]; + return signature === "none" ? fn.call(client, signal) : fn.call(client, c.params, signal); + }; + + describe(`${name} (offline request)`, () => { + test("sends one request with the exact payload and returns the transport's response", async () => { + for (const c of cases) { + const response = { sentinel: name }; + const transport = new MockInfoTransport(() => response); + const signal = new AbortController().signal; + + const result = await callMethod(transport, c, signal); + + expect(result).toBe(response); // the method returns the transport's response untouched + expect(transport.calls).toEqual([{ endpoint: "info", payload: payloadOf(c), signal }]); + } + }); + + if (invalidParams.length > 0) { + test("rejects invalid params before any request", () => { + for (const params of invalidParams) { + const transport = new MockInfoTransport(() => ({})); + + expect(() => method({ transport }, params)).toThrow(ValidationError); + + expect(transport.calls).toHaveLength(0); // validation happens before sending + } + }); + } + + test("propagates transport errors", async () => { + const error = new Error("transport boom"); + const transport = new MockInfoTransport(() => { + throw error; + }); + + await expect(callMethod(transport, cases[0])).rejects.toBe(error); + }); + + test("is exposed on InfoClient with identical behavior", async () => { + for (const c of cases) { + const response = { sentinel: name }; + const transport = new MockInfoTransport(() => response); + const client = new InfoClient({ transport }); + const signal = new AbortController().signal; + + const result = await callClient(client, c, signal); + + expect(result).toBe(response); + expect(transport.calls).toEqual([{ endpoint: "info", payload: payloadOf(c), signal }]); + } + }); + + if (signature === "overloaded") { + test("accepts a bare AbortSignal or no argument in place of params (function and client)", async () => { + for (const viaClient of [false, true]) { + for (const arg of ["signal", "absent"] as const) { + const transport = new MockInfoTransport(() => null); + const client = new InfoClient({ transport }); + const fn = (client as unknown as Record Promise>)[name]; + const signal = new AbortController().signal; + + if (arg === "signal") { + await (viaClient ? fn.call(client, signal) : method({ transport }, signal)); + expect(transport.calls).toEqual([{ endpoint: "info", payload: { type: name }, signal }]); + } else { + await (viaClient ? fn.call(client) : method({ transport })); + expect(transport.calls).toEqual([{ endpoint: "info", payload: { type: name } }]); + expect(transport.calls[0].signal).toBeUndefined(); + } + } + } + }); + } + }); +} diff --git a/tests/api/info/activeAssetData.test.ts b/tests/api/info/activeAssetData.test.ts index d537d415..03b680b6 100644 --- a/tests/api/info/activeAssetData.test.ts +++ b/tests/api/info/activeAssetData.test.ts @@ -1,4 +1,5 @@ -import { type ActiveAssetDataParameters, ActiveAssetDataRequest } from "@bloxwap/hyperliquid/api/info"; +import { activeAssetData, type ActiveAssetDataParameters, ActiveAssetDataRequest } from "@bloxwap/hyperliquid/api/info"; +import { runOfflineMethodTests } from "./_offlineMethodTests.ts"; import * as v from "valibot"; import { schemaCoverage } from "../_utils/schemaCoverage.ts"; import { typeToJsonSchema } from "../_utils/typeToJsonSchema.ts"; @@ -23,3 +24,18 @@ runTest({ schemaCoverage(responseSchema, data); }, }); + +// ============================================================ +// Offline: request construction, passthrough, and InfoClient wrapper +// ============================================================ + +runOfflineMethodTests({ + name: "activeAssetData", + method: activeAssetData, + signature: "params", + cases: [{ params: { user: "0x0000000000000000000000000000000000000001", coin: "ETH" } }], + invalidParams: [ + { user: "0x123", coin: "ETH" }, + { user: "0x0000000000000000000000000000000000000001", coin: 123 }, + ], +}); diff --git a/tests/api/info/allBorrowLendReserveStates.test.ts b/tests/api/info/allBorrowLendReserveStates.test.ts index f1a617bf..2e0a5199 100644 --- a/tests/api/info/allBorrowLendReserveStates.test.ts +++ b/tests/api/info/allBorrowLendReserveStates.test.ts @@ -1,3 +1,5 @@ +import { allBorrowLendReserveStates } from "@bloxwap/hyperliquid/api/info"; +import { runOfflineMethodTests } from "./_offlineMethodTests.ts"; import { schemaCoverage } from "../_utils/schemaCoverage.ts"; import { typeToJsonSchema } from "../_utils/typeToJsonSchema.ts"; import { runTest } from "./_t.ts"; @@ -13,3 +15,13 @@ runTest({ schemaCoverage(responseSchema, data); }, }); + +// ============================================================ +// Offline: request construction, passthrough, and InfoClient wrapper +// ============================================================ + +runOfflineMethodTests({ + name: "allBorrowLendReserveStates", + method: allBorrowLendReserveStates, + signature: "none", +}); diff --git a/tests/api/info/allMids.test.ts b/tests/api/info/allMids.test.ts index 3f8bdce0..e970703c 100644 --- a/tests/api/info/allMids.test.ts +++ b/tests/api/info/allMids.test.ts @@ -1,4 +1,5 @@ -import { type AllMidsParameters, AllMidsRequest } from "@bloxwap/hyperliquid/api/info"; +import { allMids, type AllMidsParameters, AllMidsRequest } from "@bloxwap/hyperliquid/api/info"; +import { runOfflineMethodTests } from "./_offlineMethodTests.ts"; import * as v from "valibot"; import { schemaCoverage } from "../_utils/schemaCoverage.ts"; import { typeToJsonSchema } from "../_utils/typeToJsonSchema.ts"; @@ -20,3 +21,15 @@ runTest({ schemaCoverage(responseSchema, data); }, }); + +// ============================================================ +// Offline: request construction, passthrough, and InfoClient wrapper +// ============================================================ + +runOfflineMethodTests({ + name: "allMids", + method: allMids, + signature: "overloaded", + cases: [{ params: { dex: "test" } }], + invalidParams: [{ dex: 123 }], +}); diff --git a/tests/api/info/allPerpMetas.test.ts b/tests/api/info/allPerpMetas.test.ts index 4c6a1c48..6205039c 100644 --- a/tests/api/info/allPerpMetas.test.ts +++ b/tests/api/info/allPerpMetas.test.ts @@ -1,3 +1,5 @@ +import { allPerpMetas } from "@bloxwap/hyperliquid/api/info"; +import { runOfflineMethodTests } from "./_offlineMethodTests.ts"; import { schemaCoverage } from "../_utils/schemaCoverage.ts"; import { typeToJsonSchema } from "../_utils/typeToJsonSchema.ts"; import { runTest } from "./_t.ts"; @@ -13,3 +15,13 @@ runTest({ schemaCoverage(responseSchema, data); }, }); + +// ============================================================ +// Offline: request construction, passthrough, and InfoClient wrapper +// ============================================================ + +runOfflineMethodTests({ + name: "allPerpMetas", + method: allPerpMetas, + signature: "none", +}); diff --git a/tests/api/info/approvedBuilders.test.ts b/tests/api/info/approvedBuilders.test.ts index 717dac0c..ee30dbc7 100644 --- a/tests/api/info/approvedBuilders.test.ts +++ b/tests/api/info/approvedBuilders.test.ts @@ -1,4 +1,9 @@ -import { type ApprovedBuildersParameters, ApprovedBuildersRequest } from "@bloxwap/hyperliquid/api/info"; +import { + approvedBuilders, + type ApprovedBuildersParameters, + ApprovedBuildersRequest, +} from "@bloxwap/hyperliquid/api/info"; +import { runOfflineMethodTests } from "./_offlineMethodTests.ts"; import * as v from "valibot"; import { schemaCoverage } from "../_utils/schemaCoverage.ts"; import { typeToJsonSchema } from "../_utils/typeToJsonSchema.ts"; @@ -23,3 +28,15 @@ runTest({ schemaCoverage(responseSchema, data); }, }); + +// ============================================================ +// Offline: request construction, passthrough, and InfoClient wrapper +// ============================================================ + +runOfflineMethodTests({ + name: "approvedBuilders", + method: approvedBuilders, + signature: "params", + cases: [{ params: { user: "0x0000000000000000000000000000000000000001" } }], + invalidParams: [{ user: "0x123" }, {}], +}); diff --git a/tests/api/info/borrowLendReserveState.test.ts b/tests/api/info/borrowLendReserveState.test.ts index e127e947..94bcca79 100644 --- a/tests/api/info/borrowLendReserveState.test.ts +++ b/tests/api/info/borrowLendReserveState.test.ts @@ -1,4 +1,9 @@ -import { type BorrowLendReserveStateParameters, BorrowLendReserveStateRequest } from "@bloxwap/hyperliquid/api/info"; +import { + borrowLendReserveState, + type BorrowLendReserveStateParameters, + BorrowLendReserveStateRequest, +} from "@bloxwap/hyperliquid/api/info"; +import { runOfflineMethodTests } from "./_offlineMethodTests.ts"; import * as v from "valibot"; import { schemaCoverage } from "../_utils/schemaCoverage.ts"; import { typeToJsonSchema } from "../_utils/typeToJsonSchema.ts"; @@ -20,3 +25,15 @@ runTest({ schemaCoverage(responseSchema, data); }, }); + +// ============================================================ +// Offline: request construction, passthrough, and InfoClient wrapper +// ============================================================ + +runOfflineMethodTests({ + name: "borrowLendReserveState", + method: borrowLendReserveState, + signature: "params", + cases: [{ params: { token: 1 } }], + invalidParams: [{ token: -1 }, { token: "abc" }, {}], +}); diff --git a/tests/api/info/borrowLendUserState.test.ts b/tests/api/info/borrowLendUserState.test.ts index 9437d61d..c619cdeb 100644 --- a/tests/api/info/borrowLendUserState.test.ts +++ b/tests/api/info/borrowLendUserState.test.ts @@ -1,4 +1,9 @@ -import { type BorrowLendUserStateParameters, BorrowLendUserStateRequest } from "@bloxwap/hyperliquid/api/info"; +import { + borrowLendUserState, + type BorrowLendUserStateParameters, + BorrowLendUserStateRequest, +} from "@bloxwap/hyperliquid/api/info"; +import { runOfflineMethodTests } from "./_offlineMethodTests.ts"; import * as v from "valibot"; import { schemaCoverage } from "../_utils/schemaCoverage.ts"; import { typeToJsonSchema } from "../_utils/typeToJsonSchema.ts"; @@ -20,3 +25,15 @@ runTest({ schemaCoverage(responseSchema, data); }, }); + +// ============================================================ +// Offline: request construction, passthrough, and InfoClient wrapper +// ============================================================ + +runOfflineMethodTests({ + name: "borrowLendUserState", + method: borrowLendUserState, + signature: "params", + cases: [{ params: { user: "0x0000000000000000000000000000000000000001" } }], + invalidParams: [{ user: "0x123" }, {}], +}); diff --git a/tests/api/info/candleSnapshot.test.ts b/tests/api/info/candleSnapshot.test.ts index a790197f..e7602637 100644 --- a/tests/api/info/candleSnapshot.test.ts +++ b/tests/api/info/candleSnapshot.test.ts @@ -1,4 +1,5 @@ -import { type CandleSnapshotParameters, CandleSnapshotRequest } from "@bloxwap/hyperliquid/api/info"; +import { candleSnapshot, type CandleSnapshotParameters, CandleSnapshotRequest } from "@bloxwap/hyperliquid/api/info"; +import { runOfflineMethodTests } from "./_offlineMethodTests.ts"; import { schemaCoverage } from "../_utils/schemaCoverage.ts"; import { typeToJsonSchema } from "../_utils/typeToJsonSchema.ts"; import { valibotToJsonSchema } from "../_utils/valibotToJsonSchema.ts"; @@ -38,3 +39,27 @@ runTest({ schemaCoverage(responseSchema, data); }, }); + +// ============================================================ +// Offline: request construction, passthrough, and InfoClient wrapper +// ============================================================ + +runOfflineMethodTests({ + name: "candleSnapshot", + method: candleSnapshot, + signature: "params", + cases: [ + { + params: { coin: "ETH", interval: "1h", startTime: 1000 }, + payload: { type: "candleSnapshot", req: { coin: "ETH", interval: "1h", startTime: 1000 } }, + }, + { + params: { coin: "ETH", interval: "1h", startTime: 1000, endTime: 2000 }, + payload: { type: "candleSnapshot", req: { coin: "ETH", interval: "1h", startTime: 1000, endTime: 2000 } }, + }, + ], + invalidParams: [ + { coin: 1, interval: "1h", startTime: 1000 }, + { coin: "ETH", interval: "7m", startTime: 1000 }, + ], +}); diff --git a/tests/api/info/candleSnapshotAll.test.ts b/tests/api/info/candleSnapshotAll.test.ts index bb2c3326..89350ad8 100644 --- a/tests/api/info/candleSnapshotAll.test.ts +++ b/tests/api/info/candleSnapshotAll.test.ts @@ -5,6 +5,7 @@ */ import { describe, expect, test } from "bun:test"; +import { InfoClient } from "@bloxwap/hyperliquid"; import { candleSnapshotAll } from "@bloxwap/hyperliquid/api/info"; import { MockInfoTransport, scriptedPages } from "./_mockInfoTransport.ts"; @@ -54,4 +55,20 @@ describe("candleSnapshotAll", () => { expect(transport.calls).toHaveLength(2); expect(result).toHaveLength(PAGE); }); + + test("is exposed on InfoClient with identical behavior", async () => { + const transport = new MockInfoTransport(scriptedPages([candlePage(0, PAGE), candlePage(PAGE * 60_000, 7)])); + const client = new InfoClient({ transport }); + const signal = new AbortController().signal; + + const result = await client.candleSnapshotAll( + { coin: "ETH", interval: "1m", startTime: 0 }, + { maxPages: 5 }, + signal, + ); + + expect(result).toHaveLength(5_007); + expect(requestedStartTimes(transport)).toEqual([0, (PAGE - 1) * 60_000]); + expect(transport.calls[0].signal).toBe(signal); + }); }); diff --git a/tests/api/info/clearinghouseState.test.ts b/tests/api/info/clearinghouseState.test.ts index b25aa7b1..0d1e3067 100644 --- a/tests/api/info/clearinghouseState.test.ts +++ b/tests/api/info/clearinghouseState.test.ts @@ -1,4 +1,9 @@ -import { type ClearinghouseStateParameters, ClearinghouseStateRequest } from "@bloxwap/hyperliquid/api/info"; +import { + clearinghouseState, + type ClearinghouseStateParameters, + ClearinghouseStateRequest, +} from "@bloxwap/hyperliquid/api/info"; +import { runOfflineMethodTests } from "./_offlineMethodTests.ts"; import * as v from "valibot"; import { schemaCoverage } from "../_utils/schemaCoverage.ts"; import { typeToJsonSchema } from "../_utils/typeToJsonSchema.ts"; @@ -23,3 +28,18 @@ runTest({ schemaCoverage(responseSchema, data); }, }); + +// ============================================================ +// Offline: request construction, passthrough, and InfoClient wrapper +// ============================================================ + +runOfflineMethodTests({ + name: "clearinghouseState", + method: clearinghouseState, + signature: "params", + cases: [ + { params: { user: "0x0000000000000000000000000000000000000001" } }, + { params: { user: "0x0000000000000000000000000000000000000001", dex: "test" } }, + ], + invalidParams: [{ user: "0x123" }, { user: "0x0000000000000000000000000000000000000001", dex: 123 }], +}); diff --git a/tests/api/info/delegations.test.ts b/tests/api/info/delegations.test.ts index 00df9994..6043a212 100644 --- a/tests/api/info/delegations.test.ts +++ b/tests/api/info/delegations.test.ts @@ -1,4 +1,5 @@ -import { type DelegationsParameters, DelegationsRequest } from "@bloxwap/hyperliquid/api/info"; +import { delegations, type DelegationsParameters, DelegationsRequest } from "@bloxwap/hyperliquid/api/info"; +import { runOfflineMethodTests } from "./_offlineMethodTests.ts"; import * as v from "valibot"; import { schemaCoverage } from "../_utils/schemaCoverage.ts"; import { typeToJsonSchema } from "../_utils/typeToJsonSchema.ts"; @@ -20,3 +21,15 @@ runTest({ schemaCoverage(responseSchema, data); }, }); + +// ============================================================ +// Offline: request construction, passthrough, and InfoClient wrapper +// ============================================================ + +runOfflineMethodTests({ + name: "delegations", + method: delegations, + signature: "params", + cases: [{ params: { user: "0x0000000000000000000000000000000000000001" } }], + invalidParams: [{ user: "0x123" }, {}], +}); diff --git a/tests/api/info/delegatorHistory.test.ts b/tests/api/info/delegatorHistory.test.ts index 3f5d191b..39c69aee 100644 --- a/tests/api/info/delegatorHistory.test.ts +++ b/tests/api/info/delegatorHistory.test.ts @@ -1,4 +1,9 @@ -import { type DelegatorHistoryParameters, DelegatorHistoryRequest } from "@bloxwap/hyperliquid/api/info"; +import { + delegatorHistory, + type DelegatorHistoryParameters, + DelegatorHistoryRequest, +} from "@bloxwap/hyperliquid/api/info"; +import { runOfflineMethodTests } from "./_offlineMethodTests.ts"; import * as v from "valibot"; import { schemaCoverage } from "../_utils/schemaCoverage.ts"; import { typeToJsonSchema } from "../_utils/typeToJsonSchema.ts"; @@ -20,3 +25,15 @@ runTest({ schemaCoverage(responseSchema, data); }, }); + +// ============================================================ +// Offline: request construction, passthrough, and InfoClient wrapper +// ============================================================ + +runOfflineMethodTests({ + name: "delegatorHistory", + method: delegatorHistory, + signature: "params", + cases: [{ params: { user: "0x0000000000000000000000000000000000000001" } }], + invalidParams: [{ user: "0x123" }, {}], +}); diff --git a/tests/api/info/delegatorRewards.test.ts b/tests/api/info/delegatorRewards.test.ts index b72c5ca0..c200b73a 100644 --- a/tests/api/info/delegatorRewards.test.ts +++ b/tests/api/info/delegatorRewards.test.ts @@ -1,4 +1,9 @@ -import { type DelegatorRewardsParameters, DelegatorRewardsRequest } from "@bloxwap/hyperliquid/api/info"; +import { + delegatorRewards, + type DelegatorRewardsParameters, + DelegatorRewardsRequest, +} from "@bloxwap/hyperliquid/api/info"; +import { runOfflineMethodTests } from "./_offlineMethodTests.ts"; import * as v from "valibot"; import { schemaCoverage } from "../_utils/schemaCoverage.ts"; import { typeToJsonSchema } from "../_utils/typeToJsonSchema.ts"; @@ -23,3 +28,15 @@ runTest({ schemaCoverage(responseSchema, data); }, }); + +// ============================================================ +// Offline: request construction, passthrough, and InfoClient wrapper +// ============================================================ + +runOfflineMethodTests({ + name: "delegatorRewards", + method: delegatorRewards, + signature: "params", + cases: [{ params: { user: "0x0000000000000000000000000000000000000001" } }], + invalidParams: [{ user: "0x123" }, {}], +}); diff --git a/tests/api/info/delegatorSummary.test.ts b/tests/api/info/delegatorSummary.test.ts index b11f26a7..871cb60b 100644 --- a/tests/api/info/delegatorSummary.test.ts +++ b/tests/api/info/delegatorSummary.test.ts @@ -1,4 +1,9 @@ -import { type DelegatorSummaryParameters, DelegatorSummaryRequest } from "@bloxwap/hyperliquid/api/info"; +import { + delegatorSummary, + type DelegatorSummaryParameters, + DelegatorSummaryRequest, +} from "@bloxwap/hyperliquid/api/info"; +import { runOfflineMethodTests } from "./_offlineMethodTests.ts"; import * as v from "valibot"; import { schemaCoverage } from "../_utils/schemaCoverage.ts"; import { typeToJsonSchema } from "../_utils/typeToJsonSchema.ts"; @@ -20,3 +25,15 @@ runTest({ schemaCoverage(responseSchema, data); }, }); + +// ============================================================ +// Offline: request construction, passthrough, and InfoClient wrapper +// ============================================================ + +runOfflineMethodTests({ + name: "delegatorSummary", + method: delegatorSummary, + signature: "params", + cases: [{ params: { user: "0x0000000000000000000000000000000000000001" } }], + invalidParams: [{ user: "0x123" }, {}], +}); diff --git a/tests/api/info/exchangeStatus.test.ts b/tests/api/info/exchangeStatus.test.ts index 727925af..83c56886 100644 --- a/tests/api/info/exchangeStatus.test.ts +++ b/tests/api/info/exchangeStatus.test.ts @@ -1,3 +1,5 @@ +import { exchangeStatus } from "@bloxwap/hyperliquid/api/info"; +import { runOfflineMethodTests } from "./_offlineMethodTests.ts"; import { schemaCoverage } from "../_utils/schemaCoverage.ts"; import { typeToJsonSchema } from "../_utils/typeToJsonSchema.ts"; import { runTest } from "./_t.ts"; @@ -13,3 +15,13 @@ runTest({ schemaCoverage(responseSchema, data, ["#/properties/specialStatuses/defined"]); }, }); + +// ============================================================ +// Offline: request construction, passthrough, and InfoClient wrapper +// ============================================================ + +runOfflineMethodTests({ + name: "exchangeStatus", + method: exchangeStatus, + signature: "none", +}); diff --git a/tests/api/info/extraAgents.test.ts b/tests/api/info/extraAgents.test.ts index 2d12e4b2..49cf6414 100644 --- a/tests/api/info/extraAgents.test.ts +++ b/tests/api/info/extraAgents.test.ts @@ -1,4 +1,5 @@ -import { type ExtraAgentsParameters, ExtraAgentsRequest } from "@bloxwap/hyperliquid/api/info"; +import { extraAgents, type ExtraAgentsParameters, ExtraAgentsRequest } from "@bloxwap/hyperliquid/api/info"; +import { runOfflineMethodTests } from "./_offlineMethodTests.ts"; import * as v from "valibot"; import { schemaCoverage } from "../_utils/schemaCoverage.ts"; import { typeToJsonSchema } from "../_utils/typeToJsonSchema.ts"; @@ -22,3 +23,15 @@ runTest({ ]); }, }); + +// ============================================================ +// Offline: request construction, passthrough, and InfoClient wrapper +// ============================================================ + +runOfflineMethodTests({ + name: "extraAgents", + method: extraAgents, + signature: "params", + cases: [{ params: { user: "0x0000000000000000000000000000000000000001" } }], + invalidParams: [{ user: "0x123" }, {}], +}); diff --git a/tests/api/info/frontendOpenOrders.test.ts b/tests/api/info/frontendOpenOrders.test.ts index 073d662b..f1d40c69 100644 --- a/tests/api/info/frontendOpenOrders.test.ts +++ b/tests/api/info/frontendOpenOrders.test.ts @@ -1,4 +1,9 @@ -import { type FrontendOpenOrdersParameters, FrontendOpenOrdersRequest } from "@bloxwap/hyperliquid/api/info"; +import { + frontendOpenOrders, + type FrontendOpenOrdersParameters, + FrontendOpenOrdersRequest, +} from "@bloxwap/hyperliquid/api/info"; +import { runOfflineMethodTests } from "./_offlineMethodTests.ts"; import * as v from "valibot"; import { schemaCoverage } from "../_utils/schemaCoverage.ts"; import { typeToJsonSchema } from "../_utils/typeToJsonSchema.ts"; @@ -33,3 +38,18 @@ runTest({ ]); }, }); + +// ============================================================ +// Offline: request construction, passthrough, and InfoClient wrapper +// ============================================================ + +runOfflineMethodTests({ + name: "frontendOpenOrders", + method: frontendOpenOrders, + signature: "params", + cases: [ + { params: { user: "0x0000000000000000000000000000000000000001" } }, + { params: { user: "0x0000000000000000000000000000000000000001", dex: "test" } }, + ], + invalidParams: [{ user: "0x123" }, { user: "0x0000000000000000000000000000000000000001", dex: 123 }], +}); diff --git a/tests/api/info/fundingHistory.test.ts b/tests/api/info/fundingHistory.test.ts index 7ff0bbb6..86ad85a0 100644 --- a/tests/api/info/fundingHistory.test.ts +++ b/tests/api/info/fundingHistory.test.ts @@ -1,4 +1,5 @@ -import { type FundingHistoryParameters, FundingHistoryRequest } from "@bloxwap/hyperliquid/api/info"; +import { fundingHistory, type FundingHistoryParameters, FundingHistoryRequest } from "@bloxwap/hyperliquid/api/info"; +import { runOfflineMethodTests } from "./_offlineMethodTests.ts"; import * as v from "valibot"; import { schemaCoverage } from "../_utils/schemaCoverage.ts"; import { typeToJsonSchema } from "../_utils/typeToJsonSchema.ts"; @@ -26,3 +27,18 @@ runTest({ schemaCoverage(responseSchema, data); }, }); + +// ============================================================ +// Offline: request construction, passthrough, and InfoClient wrapper +// ============================================================ + +runOfflineMethodTests({ + name: "fundingHistory", + method: fundingHistory, + signature: "params", + cases: [{ params: { coin: "ETH", startTime: 1000 } }, { params: { coin: "ETH", startTime: 1000, endTime: 2000 } }], + invalidParams: [ + { coin: 1, startTime: 1000 }, + { coin: "ETH", startTime: -1 }, + ], +}); diff --git a/tests/api/info/fundingHistoryAll.test.ts b/tests/api/info/fundingHistoryAll.test.ts index c084ccee..0b6ae4a8 100644 --- a/tests/api/info/fundingHistoryAll.test.ts +++ b/tests/api/info/fundingHistoryAll.test.ts @@ -5,6 +5,7 @@ */ import { describe, expect, test } from "bun:test"; +import { InfoClient } from "@bloxwap/hyperliquid"; import { fundingHistoryAll } from "@bloxwap/hyperliquid/api/info"; import { MockInfoTransport, scriptedPages } from "./_mockInfoTransport.ts"; @@ -48,4 +49,16 @@ describe("fundingHistoryAll", () => { expect(payload.endTime).toBe(777); } }); + + test("is exposed on InfoClient with identical behavior", async () => { + const transport = new MockInfoTransport(scriptedPages([fundingPage(0, PAGE), fundingPage(PAGE, 7)])); + const client = new InfoClient({ transport }); + const signal = new AbortController().signal; + + const result = await client.fundingHistoryAll({ coin: "ETH", startTime: 0 }, { maxPages: 5 }, signal); + + expect(result).toHaveLength(507); + expect(transport.calls.map((c) => (c.payload as { startTime: number }).startTime)).toEqual([0, 499]); + expect(transport.calls[0].signal).toBe(signal); + }); }); diff --git a/tests/api/info/gossipPriorityAuctionStatus.test.ts b/tests/api/info/gossipPriorityAuctionStatus.test.ts index 65234317..b8a280f1 100644 --- a/tests/api/info/gossipPriorityAuctionStatus.test.ts +++ b/tests/api/info/gossipPriorityAuctionStatus.test.ts @@ -1,3 +1,5 @@ +import { gossipPriorityAuctionStatus } from "@bloxwap/hyperliquid/api/info"; +import { runOfflineMethodTests } from "./_offlineMethodTests.ts"; import { schemaCoverage } from "../_utils/schemaCoverage.ts"; import { typeToJsonSchema } from "../_utils/typeToJsonSchema.ts"; import { runTest } from "./_t.ts"; @@ -21,3 +23,13 @@ runTest({ ]); }, }); + +// ============================================================ +// Offline: request construction, passthrough, and InfoClient wrapper +// ============================================================ + +runOfflineMethodTests({ + name: "gossipPriorityAuctionStatus", + method: gossipPriorityAuctionStatus, + signature: "none", +}); diff --git a/tests/api/info/gossipRootIps.test.ts b/tests/api/info/gossipRootIps.test.ts index 0466f950..f61f2cab 100644 --- a/tests/api/info/gossipRootIps.test.ts +++ b/tests/api/info/gossipRootIps.test.ts @@ -1,3 +1,5 @@ +import { gossipRootIps } from "@bloxwap/hyperliquid/api/info"; +import { runOfflineMethodTests } from "./_offlineMethodTests.ts"; import { schemaCoverage } from "../_utils/schemaCoverage.ts"; import { typeToJsonSchema } from "../_utils/typeToJsonSchema.ts"; import { runTest } from "./_t.ts"; @@ -13,3 +15,13 @@ runTest({ schemaCoverage(responseSchema, data, ["#/array"]); }, }); + +// ============================================================ +// Offline: request construction, passthrough, and InfoClient wrapper +// ============================================================ + +runOfflineMethodTests({ + name: "gossipRootIps", + method: gossipRootIps, + signature: "none", +}); diff --git a/tests/api/info/historicalOrders.test.ts b/tests/api/info/historicalOrders.test.ts index 3edd2880..db187971 100644 --- a/tests/api/info/historicalOrders.test.ts +++ b/tests/api/info/historicalOrders.test.ts @@ -1,4 +1,9 @@ -import { type HistoricalOrdersParameters, HistoricalOrdersRequest } from "@bloxwap/hyperliquid/api/info"; +import { + historicalOrders, + type HistoricalOrdersParameters, + HistoricalOrdersRequest, +} from "@bloxwap/hyperliquid/api/info"; +import { runOfflineMethodTests } from "./_offlineMethodTests.ts"; import * as v from "valibot"; import { schemaCoverage } from "../_utils/schemaCoverage.ts"; import { typeToJsonSchema } from "../_utils/typeToJsonSchema.ts"; @@ -46,3 +51,15 @@ runTest({ ]); }, }); + +// ============================================================ +// Offline: request construction, passthrough, and InfoClient wrapper +// ============================================================ + +runOfflineMethodTests({ + name: "historicalOrders", + method: historicalOrders, + signature: "params", + cases: [{ params: { user: "0x0000000000000000000000000000000000000001" } }], + invalidParams: [{ user: "0x123" }, {}], +}); diff --git a/tests/api/info/isVip.test.ts b/tests/api/info/isVip.test.ts index 79995f8c..26086e4f 100644 --- a/tests/api/info/isVip.test.ts +++ b/tests/api/info/isVip.test.ts @@ -1,4 +1,5 @@ -import { type IsVipParameters, IsVipRequest } from "@bloxwap/hyperliquid/api/info"; +import { isVip, type IsVipParameters, IsVipRequest } from "@bloxwap/hyperliquid/api/info"; +import { runOfflineMethodTests } from "./_offlineMethodTests.ts"; import * as v from "valibot"; import { schemaCoverage } from "../_utils/schemaCoverage.ts"; import { typeToJsonSchema } from "../_utils/typeToJsonSchema.ts"; @@ -20,3 +21,15 @@ runTest({ schemaCoverage(responseSchema, data, ["#/null"]); }, }); + +// ============================================================ +// Offline: request construction, passthrough, and InfoClient wrapper +// ============================================================ + +runOfflineMethodTests({ + name: "isVip", + method: isVip, + signature: "params", + cases: [{ params: { user: "0x0000000000000000000000000000000000000001" } }], + invalidParams: [{ user: "0x123" }, {}], +}); diff --git a/tests/api/info/l2Book.test.ts b/tests/api/info/l2Book.test.ts index db8e8046..1025d010 100644 --- a/tests/api/info/l2Book.test.ts +++ b/tests/api/info/l2Book.test.ts @@ -1,4 +1,5 @@ -import { type L2BookParameters, L2BookRequest } from "@bloxwap/hyperliquid/api/info"; +import { l2Book, type L2BookParameters, L2BookRequest } from "@bloxwap/hyperliquid/api/info"; +import { runOfflineMethodTests } from "./_offlineMethodTests.ts"; import * as v from "valibot"; import { schemaCoverage } from "../_utils/schemaCoverage.ts"; import { typeToJsonSchema } from "../_utils/typeToJsonSchema.ts"; @@ -31,3 +32,15 @@ runTest({ schemaCoverage(responseSchema, data); }, }); + +// ============================================================ +// Offline: request construction, passthrough, and InfoClient wrapper +// ============================================================ + +runOfflineMethodTests({ + name: "l2Book", + method: l2Book, + signature: "params", + cases: [{ params: { coin: "ETH" } }, { params: { coin: "ETH", nSigFigs: 2, mantissa: 2 } }], + invalidParams: [{ coin: 1 }, { coin: "ETH", nSigFigs: 6 }, { coin: "ETH", mantissa: 3 }], +}); diff --git a/tests/api/info/leadingVaults.test.ts b/tests/api/info/leadingVaults.test.ts index 04deabbc..9b923cde 100644 --- a/tests/api/info/leadingVaults.test.ts +++ b/tests/api/info/leadingVaults.test.ts @@ -1,4 +1,5 @@ -import { type LeadingVaultsParameters, LeadingVaultsRequest } from "@bloxwap/hyperliquid/api/info"; +import { leadingVaults, type LeadingVaultsParameters, LeadingVaultsRequest } from "@bloxwap/hyperliquid/api/info"; +import { runOfflineMethodTests } from "./_offlineMethodTests.ts"; import * as v from "valibot"; import { schemaCoverage } from "../_utils/schemaCoverage.ts"; import { typeToJsonSchema } from "../_utils/typeToJsonSchema.ts"; @@ -20,3 +21,15 @@ runTest({ schemaCoverage(responseSchema, data); }, }); + +// ============================================================ +// Offline: request construction, passthrough, and InfoClient wrapper +// ============================================================ + +runOfflineMethodTests({ + name: "leadingVaults", + method: leadingVaults, + signature: "params", + cases: [{ params: { user: "0x0000000000000000000000000000000000000001" } }], + invalidParams: [{ user: "0x123" }, {}], +}); diff --git a/tests/api/info/legalCheck.test.ts b/tests/api/info/legalCheck.test.ts index 7cf22907..41e37d5d 100644 --- a/tests/api/info/legalCheck.test.ts +++ b/tests/api/info/legalCheck.test.ts @@ -1,4 +1,5 @@ -import { type LegalCheckParameters, LegalCheckRequest } from "@bloxwap/hyperliquid/api/info"; +import { legalCheck, type LegalCheckParameters, LegalCheckRequest } from "@bloxwap/hyperliquid/api/info"; +import { runOfflineMethodTests } from "./_offlineMethodTests.ts"; import * as v from "valibot"; import { schemaCoverage } from "../_utils/schemaCoverage.ts"; import { typeToJsonSchema } from "../_utils/typeToJsonSchema.ts"; @@ -24,3 +25,15 @@ runTest({ ]); }, }); + +// ============================================================ +// Offline: request construction, passthrough, and InfoClient wrapper +// ============================================================ + +runOfflineMethodTests({ + name: "legalCheck", + method: legalCheck, + signature: "params", + cases: [{ params: { user: "0x0000000000000000000000000000000000000001" } }], + invalidParams: [{ user: "0x123" }, {}], +}); diff --git a/tests/api/info/liquidatable.test.ts b/tests/api/info/liquidatable.test.ts index a1c4fcb5..ed7fb393 100644 --- a/tests/api/info/liquidatable.test.ts +++ b/tests/api/info/liquidatable.test.ts @@ -1,3 +1,5 @@ +import { liquidatable } from "@bloxwap/hyperliquid/api/info"; +import { runOfflineMethodTests } from "./_offlineMethodTests.ts"; import { schemaCoverage } from "../_utils/schemaCoverage.ts"; import { typeToJsonSchema } from "../_utils/typeToJsonSchema.ts"; import { runTest } from "./_t.ts"; @@ -13,3 +15,13 @@ runTest({ schemaCoverage(responseSchema, data, ["#/array"]); }, }); + +// ============================================================ +// Offline: request construction, passthrough, and InfoClient wrapper +// ============================================================ + +runOfflineMethodTests({ + name: "liquidatable", + method: liquidatable, + signature: "none", +}); diff --git a/tests/api/info/marginTable.test.ts b/tests/api/info/marginTable.test.ts index 6e7c1ba7..14501df3 100644 --- a/tests/api/info/marginTable.test.ts +++ b/tests/api/info/marginTable.test.ts @@ -1,4 +1,5 @@ -import { type MarginTableParameters, MarginTableRequest } from "@bloxwap/hyperliquid/api/info"; +import { marginTable, type MarginTableParameters, MarginTableRequest } from "@bloxwap/hyperliquid/api/info"; +import { runOfflineMethodTests } from "./_offlineMethodTests.ts"; import * as v from "valibot"; import { schemaCoverage } from "../_utils/schemaCoverage.ts"; import { typeToJsonSchema } from "../_utils/typeToJsonSchema.ts"; @@ -20,3 +21,15 @@ runTest({ schemaCoverage(responseSchema, data); }, }); + +// ============================================================ +// Offline: request construction, passthrough, and InfoClient wrapper +// ============================================================ + +runOfflineMethodTests({ + name: "marginTable", + method: marginTable, + signature: "params", + cases: [{ params: { id: 1 } }], + invalidParams: [{ id: -1 }, { id: "abc" }, {}], +}); diff --git a/tests/api/info/maxBuilderFee.test.ts b/tests/api/info/maxBuilderFee.test.ts index 8c91e9b5..2f4464f0 100644 --- a/tests/api/info/maxBuilderFee.test.ts +++ b/tests/api/info/maxBuilderFee.test.ts @@ -1,4 +1,5 @@ -import { type MaxBuilderFeeParameters, MaxBuilderFeeRequest } from "@bloxwap/hyperliquid/api/info"; +import { maxBuilderFee, type MaxBuilderFeeParameters, MaxBuilderFeeRequest } from "@bloxwap/hyperliquid/api/info"; +import { runOfflineMethodTests } from "./_offlineMethodTests.ts"; import * as v from "valibot"; import { schemaCoverage } from "../_utils/schemaCoverage.ts"; import { typeToJsonSchema } from "../_utils/typeToJsonSchema.ts"; @@ -25,3 +26,25 @@ runTest({ schemaCoverage(responseSchema, data); }, }); + +// ============================================================ +// Offline: request construction, passthrough, and InfoClient wrapper +// ============================================================ + +runOfflineMethodTests({ + name: "maxBuilderFee", + method: maxBuilderFee, + signature: "params", + cases: [ + { + params: { + user: "0x0000000000000000000000000000000000000001", + builder: "0x0000000000000000000000000000000000000002", + }, + }, + ], + invalidParams: [ + { user: "0x123", builder: "0x0000000000000000000000000000000000000002" }, + { user: "0x0000000000000000000000000000000000000001", builder: "0x456" }, + ], +}); diff --git a/tests/api/info/maxMarketOrderNtls.test.ts b/tests/api/info/maxMarketOrderNtls.test.ts index bb2a4d6f..50f2c773 100644 --- a/tests/api/info/maxMarketOrderNtls.test.ts +++ b/tests/api/info/maxMarketOrderNtls.test.ts @@ -1,3 +1,5 @@ +import { maxMarketOrderNtls } from "@bloxwap/hyperliquid/api/info"; +import { runOfflineMethodTests } from "./_offlineMethodTests.ts"; import { schemaCoverage } from "../_utils/schemaCoverage.ts"; import { typeToJsonSchema } from "../_utils/typeToJsonSchema.ts"; import { runTest } from "./_t.ts"; @@ -13,3 +15,13 @@ runTest({ schemaCoverage(responseSchema, data); }, }); + +// ============================================================ +// Offline: request construction, passthrough, and InfoClient wrapper +// ============================================================ + +runOfflineMethodTests({ + name: "maxMarketOrderNtls", + method: maxMarketOrderNtls, + signature: "none", +}); diff --git a/tests/api/info/meta.test.ts b/tests/api/info/meta.test.ts index c2eb1c0a..d095ba46 100644 --- a/tests/api/info/meta.test.ts +++ b/tests/api/info/meta.test.ts @@ -1,4 +1,5 @@ -import { type MetaParameters, MetaRequest } from "@bloxwap/hyperliquid/api/info"; +import { meta, type MetaParameters, MetaRequest } from "@bloxwap/hyperliquid/api/info"; +import { runOfflineMethodTests } from "./_offlineMethodTests.ts"; import * as v from "valibot"; import { schemaCoverage } from "../_utils/schemaCoverage.ts"; import { typeToJsonSchema } from "../_utils/typeToJsonSchema.ts"; @@ -20,3 +21,15 @@ runTest({ schemaCoverage(responseSchema, data); }, }); + +// ============================================================ +// Offline: request construction, passthrough, and InfoClient wrapper +// ============================================================ + +runOfflineMethodTests({ + name: "meta", + method: meta, + signature: "overloaded", + cases: [{ params: { dex: "test" } }], + invalidParams: [{ dex: 123 }], +}); diff --git a/tests/api/info/metaAndAssetCtxs.test.ts b/tests/api/info/metaAndAssetCtxs.test.ts index 95040a61..10bb26e6 100644 --- a/tests/api/info/metaAndAssetCtxs.test.ts +++ b/tests/api/info/metaAndAssetCtxs.test.ts @@ -1,4 +1,9 @@ -import { type MetaAndAssetCtxsParameters, MetaAndAssetCtxsRequest } from "@bloxwap/hyperliquid/api/info"; +import { + metaAndAssetCtxs, + type MetaAndAssetCtxsParameters, + MetaAndAssetCtxsRequest, +} from "@bloxwap/hyperliquid/api/info"; +import { runOfflineMethodTests } from "./_offlineMethodTests.ts"; import * as v from "valibot"; import { schemaCoverage } from "../_utils/schemaCoverage.ts"; import { typeToJsonSchema } from "../_utils/typeToJsonSchema.ts"; @@ -20,3 +25,15 @@ runTest({ schemaCoverage(responseSchema, data); }, }); + +// ============================================================ +// Offline: request construction, passthrough, and InfoClient wrapper +// ============================================================ + +runOfflineMethodTests({ + name: "metaAndAssetCtxs", + method: metaAndAssetCtxs, + signature: "overloaded", + cases: [{ params: { dex: "test" } }], + invalidParams: [{ dex: 123 }], +}); diff --git a/tests/api/info/openOrders.test.ts b/tests/api/info/openOrders.test.ts index 24301c54..76fa4b05 100644 --- a/tests/api/info/openOrders.test.ts +++ b/tests/api/info/openOrders.test.ts @@ -1,4 +1,5 @@ -import { type OpenOrdersParameters, OpenOrdersRequest } from "@bloxwap/hyperliquid/api/info"; +import { openOrders, type OpenOrdersParameters, OpenOrdersRequest } from "@bloxwap/hyperliquid/api/info"; +import { runOfflineMethodTests } from "./_offlineMethodTests.ts"; import * as v from "valibot"; import { schemaCoverage } from "../_utils/schemaCoverage.ts"; import { typeToJsonSchema } from "../_utils/typeToJsonSchema.ts"; @@ -23,3 +24,18 @@ runTest({ schemaCoverage(responseSchema, data, ["#/items/properties/cloid/present"]); }, }); + +// ============================================================ +// Offline: request construction, passthrough, and InfoClient wrapper +// ============================================================ + +runOfflineMethodTests({ + name: "openOrders", + method: openOrders, + signature: "params", + cases: [ + { params: { user: "0x0000000000000000000000000000000000000001" } }, + { params: { user: "0x0000000000000000000000000000000000000001", dex: "test" } }, + ], + invalidParams: [{ user: "0x123" }, { user: "0x0000000000000000000000000000000000000001", dex: 123 }], +}); diff --git a/tests/api/info/orderStatus.test.ts b/tests/api/info/orderStatus.test.ts index f308c835..fd6cab28 100644 --- a/tests/api/info/orderStatus.test.ts +++ b/tests/api/info/orderStatus.test.ts @@ -1,4 +1,5 @@ -import { type OrderStatusParameters, OrderStatusRequest } from "@bloxwap/hyperliquid/api/info"; +import { orderStatus, type OrderStatusParameters, OrderStatusRequest } from "@bloxwap/hyperliquid/api/info"; +import { runOfflineMethodTests } from "./_offlineMethodTests.ts"; import * as v from "valibot"; import { schemaCoverage } from "../_utils/schemaCoverage.ts"; import { typeToJsonSchema } from "../_utils/typeToJsonSchema.ts"; @@ -78,3 +79,24 @@ runTest({ ]); }, }); + +// ============================================================ +// Offline: request construction, passthrough, and InfoClient wrapper +// ============================================================ + +runOfflineMethodTests({ + name: "orderStatus", + method: orderStatus, + signature: "params", + cases: [ + { params: { user: "0x0000000000000000000000000000000000000001", oid: 12345 } }, + // A cloid beyond the safe-integer range survives the UnsignedInteger arm of the union and + // reaches the wire as a string; smaller cloids parse as numbers by design. + { params: { user: "0x0000000000000000000000000000000000000001", oid: "0xffffffffffffffffffffffffffffffff" } }, + ], + invalidParams: [ + { user: "0x0000000000000000000000000000000000000001", oid: -1 }, + { user: "0x0000000000000000000000000000000000000001", oid: "0xzz" }, + { oid: 1 }, + ], +}); diff --git a/tests/api/info/outcomeMeta.test.ts b/tests/api/info/outcomeMeta.test.ts index 2e58c82c..b68564ba 100644 --- a/tests/api/info/outcomeMeta.test.ts +++ b/tests/api/info/outcomeMeta.test.ts @@ -1,3 +1,5 @@ +import { outcomeMeta } from "@bloxwap/hyperliquid/api/info"; +import { runOfflineMethodTests } from "./_offlineMethodTests.ts"; import { schemaCoverage } from "../_utils/schemaCoverage.ts"; import { typeToJsonSchema } from "../_utils/typeToJsonSchema.ts"; import { runTest } from "./_t.ts"; @@ -16,3 +18,13 @@ runTest({ ]); }, }); + +// ============================================================ +// Offline: request construction, passthrough, and InfoClient wrapper +// ============================================================ + +runOfflineMethodTests({ + name: "outcomeMeta", + method: outcomeMeta, + signature: "none", +}); diff --git a/tests/api/info/perpAnnotation.test.ts b/tests/api/info/perpAnnotation.test.ts index edb974a3..1674c8c9 100644 --- a/tests/api/info/perpAnnotation.test.ts +++ b/tests/api/info/perpAnnotation.test.ts @@ -1,4 +1,5 @@ -import { type PerpAnnotationParameters, PerpAnnotationRequest } from "@bloxwap/hyperliquid/api/info"; +import { perpAnnotation, type PerpAnnotationParameters, PerpAnnotationRequest } from "@bloxwap/hyperliquid/api/info"; +import { runOfflineMethodTests } from "./_offlineMethodTests.ts"; import * as v from "valibot"; import { schemaCoverage } from "../_utils/schemaCoverage.ts"; import { typeToJsonSchema } from "../_utils/typeToJsonSchema.ts"; @@ -20,3 +21,15 @@ runTest({ schemaCoverage(responseSchema, data, ["#/defined"]); }, }); + +// ============================================================ +// Offline: request construction, passthrough, and InfoClient wrapper +// ============================================================ + +runOfflineMethodTests({ + name: "perpAnnotation", + method: perpAnnotation, + signature: "params", + cases: [{ params: { coin: "ETH" } }], + invalidParams: [{ coin: 123 }, {}], +}); diff --git a/tests/api/info/perpCategories.test.ts b/tests/api/info/perpCategories.test.ts index 37c727c8..78349c30 100644 --- a/tests/api/info/perpCategories.test.ts +++ b/tests/api/info/perpCategories.test.ts @@ -1,3 +1,5 @@ +import { perpCategories } from "@bloxwap/hyperliquid/api/info"; +import { runOfflineMethodTests } from "./_offlineMethodTests.ts"; import { schemaCoverage } from "../_utils/schemaCoverage.ts"; import { typeToJsonSchema } from "../_utils/typeToJsonSchema.ts"; import { runTest } from "./_t.ts"; @@ -13,3 +15,13 @@ runTest({ schemaCoverage(responseSchema, data); }, }); + +// ============================================================ +// Offline: request construction, passthrough, and InfoClient wrapper +// ============================================================ + +runOfflineMethodTests({ + name: "perpCategories", + method: perpCategories, + signature: "none", +}); diff --git a/tests/api/info/perpConciseAnnotations.test.ts b/tests/api/info/perpConciseAnnotations.test.ts index eb017673..dce6fe93 100644 --- a/tests/api/info/perpConciseAnnotations.test.ts +++ b/tests/api/info/perpConciseAnnotations.test.ts @@ -1,3 +1,5 @@ +import { perpConciseAnnotations } from "@bloxwap/hyperliquid/api/info"; +import { runOfflineMethodTests } from "./_offlineMethodTests.ts"; import { schemaCoverage } from "../_utils/schemaCoverage.ts"; import { typeToJsonSchema } from "../_utils/typeToJsonSchema.ts"; import { runTest } from "./_t.ts"; @@ -13,3 +15,13 @@ runTest({ schemaCoverage(responseSchema, data); }, }); + +// ============================================================ +// Offline: request construction, passthrough, and InfoClient wrapper +// ============================================================ + +runOfflineMethodTests({ + name: "perpConciseAnnotations", + method: perpConciseAnnotations, + signature: "none", +}); diff --git a/tests/api/info/perpDeployAuctionStatus.test.ts b/tests/api/info/perpDeployAuctionStatus.test.ts index b1e0e4ca..c496e279 100644 --- a/tests/api/info/perpDeployAuctionStatus.test.ts +++ b/tests/api/info/perpDeployAuctionStatus.test.ts @@ -1,3 +1,5 @@ +import { perpDeployAuctionStatus } from "@bloxwap/hyperliquid/api/info"; +import { runOfflineMethodTests } from "./_offlineMethodTests.ts"; import { schemaCoverage } from "../_utils/schemaCoverage.ts"; import { typeToJsonSchema } from "../_utils/typeToJsonSchema.ts"; import { runTest } from "./_t.ts"; @@ -18,3 +20,13 @@ runTest({ ]); }, }); + +// ============================================================ +// Offline: request construction, passthrough, and InfoClient wrapper +// ============================================================ + +runOfflineMethodTests({ + name: "perpDeployAuctionStatus", + method: perpDeployAuctionStatus, + signature: "none", +}); diff --git a/tests/api/info/perpDexLimits.test.ts b/tests/api/info/perpDexLimits.test.ts index 64ed9c6f..c864f525 100644 --- a/tests/api/info/perpDexLimits.test.ts +++ b/tests/api/info/perpDexLimits.test.ts @@ -1,4 +1,5 @@ -import { type PerpDexLimitsParameters, PerpDexLimitsRequest } from "@bloxwap/hyperliquid/api/info"; +import { perpDexLimits, type PerpDexLimitsParameters, PerpDexLimitsRequest } from "@bloxwap/hyperliquid/api/info"; +import { runOfflineMethodTests } from "./_offlineMethodTests.ts"; import * as v from "valibot"; import { schemaCoverage } from "../_utils/schemaCoverage.ts"; import { typeToJsonSchema } from "../_utils/typeToJsonSchema.ts"; @@ -20,3 +21,15 @@ runTest({ schemaCoverage(responseSchema, data); }, }); + +// ============================================================ +// Offline: request construction, passthrough, and InfoClient wrapper +// ============================================================ + +runOfflineMethodTests({ + name: "perpDexLimits", + method: perpDexLimits, + signature: "params", + cases: [{ params: { dex: "test" } }], + invalidParams: [{ dex: 1 }, {}], +}); diff --git a/tests/api/info/perpDexStatus.test.ts b/tests/api/info/perpDexStatus.test.ts index b10dd21c..a0c0804c 100644 --- a/tests/api/info/perpDexStatus.test.ts +++ b/tests/api/info/perpDexStatus.test.ts @@ -1,4 +1,5 @@ -import { type PerpDexStatusParameters, PerpDexStatusRequest } from "@bloxwap/hyperliquid/api/info"; +import { perpDexStatus, type PerpDexStatusParameters, PerpDexStatusRequest } from "@bloxwap/hyperliquid/api/info"; +import { runOfflineMethodTests } from "./_offlineMethodTests.ts"; import * as v from "valibot"; import { schemaCoverage } from "../_utils/schemaCoverage.ts"; import { typeToJsonSchema } from "../_utils/typeToJsonSchema.ts"; @@ -20,3 +21,15 @@ runTest({ schemaCoverage(responseSchema, data); }, }); + +// ============================================================ +// Offline: request construction, passthrough, and InfoClient wrapper +// ============================================================ + +runOfflineMethodTests({ + name: "perpDexStatus", + method: perpDexStatus, + signature: "params", + cases: [{ params: { dex: "test" } }], + invalidParams: [{ dex: 1 }, {}], +}); diff --git a/tests/api/info/perpDexs.test.ts b/tests/api/info/perpDexs.test.ts index e1245ef0..70c1441e 100644 --- a/tests/api/info/perpDexs.test.ts +++ b/tests/api/info/perpDexs.test.ts @@ -1,3 +1,5 @@ +import { perpDexs } from "@bloxwap/hyperliquid/api/info"; +import { runOfflineMethodTests } from "./_offlineMethodTests.ts"; import { schemaCoverage } from "../_utils/schemaCoverage.ts"; import { typeToJsonSchema } from "../_utils/typeToJsonSchema.ts"; import { runTest } from "./_t.ts"; @@ -13,3 +15,13 @@ runTest({ schemaCoverage(responseSchema, data); }, }); + +// ============================================================ +// Offline: request construction, passthrough, and InfoClient wrapper +// ============================================================ + +runOfflineMethodTests({ + name: "perpDexs", + method: perpDexs, + signature: "none", +}); diff --git a/tests/api/info/perpsAtOpenInterestCap.test.ts b/tests/api/info/perpsAtOpenInterestCap.test.ts index 63efe3f9..45dfba0c 100644 --- a/tests/api/info/perpsAtOpenInterestCap.test.ts +++ b/tests/api/info/perpsAtOpenInterestCap.test.ts @@ -1,4 +1,9 @@ -import { type PerpsAtOpenInterestCapParameters, PerpsAtOpenInterestCapRequest } from "@bloxwap/hyperliquid/api/info"; +import { + perpsAtOpenInterestCap, + type PerpsAtOpenInterestCapParameters, + PerpsAtOpenInterestCapRequest, +} from "@bloxwap/hyperliquid/api/info"; +import { runOfflineMethodTests } from "./_offlineMethodTests.ts"; import * as v from "valibot"; import { schemaCoverage } from "../_utils/schemaCoverage.ts"; import { typeToJsonSchema } from "../_utils/typeToJsonSchema.ts"; @@ -20,3 +25,15 @@ runTest({ schemaCoverage(responseSchema, data, ["#/array"]); }, }); + +// ============================================================ +// Offline: request construction, passthrough, and InfoClient wrapper +// ============================================================ + +runOfflineMethodTests({ + name: "perpsAtOpenInterestCap", + method: perpsAtOpenInterestCap, + signature: "overloaded", + cases: [{ params: { dex: "test" } }], + invalidParams: [{ dex: 123 }], +}); diff --git a/tests/api/info/portfolio.test.ts b/tests/api/info/portfolio.test.ts index 7d6e3c8f..b0fe59d8 100644 --- a/tests/api/info/portfolio.test.ts +++ b/tests/api/info/portfolio.test.ts @@ -1,4 +1,5 @@ -import { type PortfolioParameters, PortfolioRequest } from "@bloxwap/hyperliquid/api/info"; +import { portfolio, type PortfolioParameters, PortfolioRequest } from "@bloxwap/hyperliquid/api/info"; +import { runOfflineMethodTests } from "./_offlineMethodTests.ts"; import * as v from "valibot"; import { schemaCoverage } from "../_utils/schemaCoverage.ts"; import { typeToJsonSchema } from "../_utils/typeToJsonSchema.ts"; @@ -20,3 +21,15 @@ runTest({ schemaCoverage(responseSchema, data); }, }); + +// ============================================================ +// Offline: request construction, passthrough, and InfoClient wrapper +// ============================================================ + +runOfflineMethodTests({ + name: "portfolio", + method: portfolio, + signature: "params", + cases: [{ params: { user: "0x0000000000000000000000000000000000000001" } }], + invalidParams: [{ user: "0x123" }, {}], +}); diff --git a/tests/api/info/preTransferCheck.test.ts b/tests/api/info/preTransferCheck.test.ts index 50398f02..436284e2 100644 --- a/tests/api/info/preTransferCheck.test.ts +++ b/tests/api/info/preTransferCheck.test.ts @@ -1,4 +1,9 @@ -import { type PreTransferCheckParameters, PreTransferCheckRequest } from "@bloxwap/hyperliquid/api/info"; +import { + preTransferCheck, + type PreTransferCheckParameters, + PreTransferCheckRequest, +} from "@bloxwap/hyperliquid/api/info"; +import { runOfflineMethodTests } from "./_offlineMethodTests.ts"; import * as v from "valibot"; import { schemaCoverage } from "../_utils/schemaCoverage.ts"; import { typeToJsonSchema } from "../_utils/typeToJsonSchema.ts"; @@ -25,3 +30,25 @@ runTest({ schemaCoverage(responseSchema, data); }, }); + +// ============================================================ +// Offline: request construction, passthrough, and InfoClient wrapper +// ============================================================ + +runOfflineMethodTests({ + name: "preTransferCheck", + method: preTransferCheck, + signature: "params", + cases: [ + { + params: { + user: "0x0000000000000000000000000000000000000001", + source: "0x0000000000000000000000000000000000000002", + }, + }, + ], + invalidParams: [ + { user: "0x123", source: "0x0000000000000000000000000000000000000002" }, + { user: "0x0000000000000000000000000000000000000001", source: "0x456" }, + ], +}); diff --git a/tests/api/info/predictedFundings.test.ts b/tests/api/info/predictedFundings.test.ts index da80f831..04c1f956 100644 --- a/tests/api/info/predictedFundings.test.ts +++ b/tests/api/info/predictedFundings.test.ts @@ -1,3 +1,5 @@ +import { predictedFundings } from "@bloxwap/hyperliquid/api/info"; +import { runOfflineMethodTests } from "./_offlineMethodTests.ts"; import { schemaCoverage } from "../_utils/schemaCoverage.ts"; import { typeToJsonSchema } from "../_utils/typeToJsonSchema.ts"; import { runTest } from "./_t.ts"; @@ -13,3 +15,13 @@ runTest({ schemaCoverage(responseSchema, data); }, }); + +// ============================================================ +// Offline: request construction, passthrough, and InfoClient wrapper +// ============================================================ + +runOfflineMethodTests({ + name: "predictedFundings", + method: predictedFundings, + signature: "none", +}); diff --git a/tests/api/info/recentTrades.test.ts b/tests/api/info/recentTrades.test.ts index a2835958..b554c063 100644 --- a/tests/api/info/recentTrades.test.ts +++ b/tests/api/info/recentTrades.test.ts @@ -1,4 +1,5 @@ -import { type RecentTradesParameters, RecentTradesRequest } from "@bloxwap/hyperliquid/api/info"; +import { recentTrades, type RecentTradesParameters, RecentTradesRequest } from "@bloxwap/hyperliquid/api/info"; +import { runOfflineMethodTests } from "./_offlineMethodTests.ts"; import * as v from "valibot"; import { schemaCoverage } from "../_utils/schemaCoverage.ts"; import { typeToJsonSchema } from "../_utils/typeToJsonSchema.ts"; @@ -20,3 +21,15 @@ runTest({ schemaCoverage(responseSchema, data, ["#/items/properties/side/enum/0", "#/items/properties/side/enum/1"]); }, }); + +// ============================================================ +// Offline: request construction, passthrough, and InfoClient wrapper +// ============================================================ + +runOfflineMethodTests({ + name: "recentTrades", + method: recentTrades, + signature: "params", + cases: [{ params: { coin: "ETH" } }], + invalidParams: [{ coin: 123 }, {}], +}); diff --git a/tests/api/info/referral.test.ts b/tests/api/info/referral.test.ts index ae0231a4..6cf28bc7 100644 --- a/tests/api/info/referral.test.ts +++ b/tests/api/info/referral.test.ts @@ -1,4 +1,5 @@ -import { type ReferralParameters, ReferralRequest } from "@bloxwap/hyperliquid/api/info"; +import { referral, type ReferralParameters, ReferralRequest } from "@bloxwap/hyperliquid/api/info"; +import { runOfflineMethodTests } from "./_offlineMethodTests.ts"; import * as v from "valibot"; import { schemaCoverage } from "../_utils/schemaCoverage.ts"; import { typeToJsonSchema } from "../_utils/typeToJsonSchema.ts"; @@ -26,3 +27,15 @@ runTest({ schemaCoverage(responseSchema, data, ["#/properties/rewardHistory/array"]); }, }); + +// ============================================================ +// Offline: request construction, passthrough, and InfoClient wrapper +// ============================================================ + +runOfflineMethodTests({ + name: "referral", + method: referral, + signature: "params", + cases: [{ params: { user: "0x0000000000000000000000000000000000000001" } }], + invalidParams: [{ user: "0x123" }, {}], +}); diff --git a/tests/api/info/settledOutcome.test.ts b/tests/api/info/settledOutcome.test.ts index 467ebc62..33eef66c 100644 --- a/tests/api/info/settledOutcome.test.ts +++ b/tests/api/info/settledOutcome.test.ts @@ -1,4 +1,5 @@ -import { type SettledOutcomeParameters, SettledOutcomeRequest } from "@bloxwap/hyperliquid/api/info"; +import { settledOutcome, type SettledOutcomeParameters, SettledOutcomeRequest } from "@bloxwap/hyperliquid/api/info"; +import { runOfflineMethodTests } from "./_offlineMethodTests.ts"; import * as v from "valibot"; import { schemaCoverage } from "../_utils/schemaCoverage.ts"; import { typeToJsonSchema } from "../_utils/typeToJsonSchema.ts"; @@ -22,3 +23,15 @@ runTest({ ]); }, }); + +// ============================================================ +// Offline: request construction, passthrough, and InfoClient wrapper +// ============================================================ + +runOfflineMethodTests({ + name: "settledOutcome", + method: settledOutcome, + signature: "params", + cases: [{ params: { outcome: 1 } }], + invalidParams: [{ outcome: -1 }, { outcome: "abc" }, {}], +}); diff --git a/tests/api/info/spotClearinghouseState.test.ts b/tests/api/info/spotClearinghouseState.test.ts index f2f7b9fc..5ef11964 100644 --- a/tests/api/info/spotClearinghouseState.test.ts +++ b/tests/api/info/spotClearinghouseState.test.ts @@ -1,4 +1,9 @@ -import { type SpotClearinghouseStateParameters, SpotClearinghouseStateRequest } from "@bloxwap/hyperliquid/api/info"; +import { + spotClearinghouseState, + type SpotClearinghouseStateParameters, + SpotClearinghouseStateRequest, +} from "@bloxwap/hyperliquid/api/info"; +import { runOfflineMethodTests } from "./_offlineMethodTests.ts"; import * as v from "valibot"; import { schemaCoverage } from "../_utils/schemaCoverage.ts"; import { typeToJsonSchema } from "../_utils/typeToJsonSchema.ts"; @@ -33,3 +38,15 @@ runTest({ ]); }, }); + +// ============================================================ +// Offline: request construction, passthrough, and InfoClient wrapper +// ============================================================ + +runOfflineMethodTests({ + name: "spotClearinghouseState", + method: spotClearinghouseState, + signature: "params", + cases: [{ params: { user: "0x0000000000000000000000000000000000000001" } }], + invalidParams: [{ user: "0x123" }, {}], +}); diff --git a/tests/api/info/spotDeployState.test.ts b/tests/api/info/spotDeployState.test.ts index a9be8364..9a98e976 100644 --- a/tests/api/info/spotDeployState.test.ts +++ b/tests/api/info/spotDeployState.test.ts @@ -1,4 +1,5 @@ -import { type SpotDeployStateParameters, SpotDeployStateRequest } from "@bloxwap/hyperliquid/api/info"; +import { spotDeployState, type SpotDeployStateParameters, SpotDeployStateRequest } from "@bloxwap/hyperliquid/api/info"; +import { runOfflineMethodTests } from "./_offlineMethodTests.ts"; import * as v from "valibot"; import { schemaCoverage } from "../_utils/schemaCoverage.ts"; import { typeToJsonSchema } from "../_utils/typeToJsonSchema.ts"; @@ -29,3 +30,15 @@ runTest({ ]); }, }); + +// ============================================================ +// Offline: request construction, passthrough, and InfoClient wrapper +// ============================================================ + +runOfflineMethodTests({ + name: "spotDeployState", + method: spotDeployState, + signature: "params", + cases: [{ params: { user: "0x0000000000000000000000000000000000000001" } }], + invalidParams: [{ user: "0x123" }, {}], +}); diff --git a/tests/api/info/spotMeta.test.ts b/tests/api/info/spotMeta.test.ts index c1c55c6a..99244bf6 100644 --- a/tests/api/info/spotMeta.test.ts +++ b/tests/api/info/spotMeta.test.ts @@ -1,3 +1,5 @@ +import { spotMeta } from "@bloxwap/hyperliquid/api/info"; +import { runOfflineMethodTests } from "./_offlineMethodTests.ts"; import { schemaCoverage } from "../_utils/schemaCoverage.ts"; import { typeToJsonSchema } from "../_utils/typeToJsonSchema.ts"; import { runTest } from "./_t.ts"; @@ -13,3 +15,13 @@ runTest({ schemaCoverage(responseSchema, data); }, }); + +// ============================================================ +// Offline: request construction, passthrough, and InfoClient wrapper +// ============================================================ + +runOfflineMethodTests({ + name: "spotMeta", + method: spotMeta, + signature: "none", +}); diff --git a/tests/api/info/spotMetaAndAssetCtxs.test.ts b/tests/api/info/spotMetaAndAssetCtxs.test.ts index 2121c76e..f8a8f081 100644 --- a/tests/api/info/spotMetaAndAssetCtxs.test.ts +++ b/tests/api/info/spotMetaAndAssetCtxs.test.ts @@ -1,3 +1,5 @@ +import { spotMetaAndAssetCtxs } from "@bloxwap/hyperliquid/api/info"; +import { runOfflineMethodTests } from "./_offlineMethodTests.ts"; import { schemaCoverage } from "../_utils/schemaCoverage.ts"; import { typeToJsonSchema } from "../_utils/typeToJsonSchema.ts"; import { runTest } from "./_t.ts"; @@ -13,3 +15,13 @@ runTest({ schemaCoverage(responseSchema, data); }, }); + +// ============================================================ +// Offline: request construction, passthrough, and InfoClient wrapper +// ============================================================ + +runOfflineMethodTests({ + name: "spotMetaAndAssetCtxs", + method: spotMetaAndAssetCtxs, + signature: "none", +}); diff --git a/tests/api/info/spotPairDeployAuctionStatus.test.ts b/tests/api/info/spotPairDeployAuctionStatus.test.ts index 04de08dd..e72054e1 100644 --- a/tests/api/info/spotPairDeployAuctionStatus.test.ts +++ b/tests/api/info/spotPairDeployAuctionStatus.test.ts @@ -1,3 +1,5 @@ +import { spotPairDeployAuctionStatus } from "@bloxwap/hyperliquid/api/info"; +import { runOfflineMethodTests } from "./_offlineMethodTests.ts"; import { schemaCoverage } from "../_utils/schemaCoverage.ts"; import { typeToJsonSchema } from "../_utils/typeToJsonSchema.ts"; import { runTest } from "./_t.ts"; @@ -18,3 +20,13 @@ runTest({ ]); }, }); + +// ============================================================ +// Offline: request construction, passthrough, and InfoClient wrapper +// ============================================================ + +runOfflineMethodTests({ + name: "spotPairDeployAuctionStatus", + method: spotPairDeployAuctionStatus, + signature: "none", +}); diff --git a/tests/api/info/subAccounts.test.ts b/tests/api/info/subAccounts.test.ts index 934bf3f6..d4a00fd3 100644 --- a/tests/api/info/subAccounts.test.ts +++ b/tests/api/info/subAccounts.test.ts @@ -1,4 +1,5 @@ -import { type SubAccountsParameters, SubAccountsRequest } from "@bloxwap/hyperliquid/api/info"; +import { subAccounts, type SubAccountsParameters, SubAccountsRequest } from "@bloxwap/hyperliquid/api/info"; +import { runOfflineMethodTests } from "./_offlineMethodTests.ts"; import * as v from "valibot"; import { schemaCoverage } from "../_utils/schemaCoverage.ts"; import { typeToJsonSchema } from "../_utils/typeToJsonSchema.ts"; @@ -36,3 +37,15 @@ runTest({ ]); }, }); + +// ============================================================ +// Offline: request construction, passthrough, and InfoClient wrapper +// ============================================================ + +runOfflineMethodTests({ + name: "subAccounts", + method: subAccounts, + signature: "params", + cases: [{ params: { user: "0x0000000000000000000000000000000000000001" } }], + invalidParams: [{ user: "0x123" }, {}], +}); diff --git a/tests/api/info/subAccounts2.test.ts b/tests/api/info/subAccounts2.test.ts index b539fbdb..6d021656 100644 --- a/tests/api/info/subAccounts2.test.ts +++ b/tests/api/info/subAccounts2.test.ts @@ -1,4 +1,5 @@ -import { type SubAccounts2Parameters, SubAccounts2Request } from "@bloxwap/hyperliquid/api/info"; +import { subAccounts2, type SubAccounts2Parameters, SubAccounts2Request } from "@bloxwap/hyperliquid/api/info"; +import { runOfflineMethodTests } from "./_offlineMethodTests.ts"; import * as v from "valibot"; import { schemaCoverage } from "../_utils/schemaCoverage.ts"; import { typeToJsonSchema } from "../_utils/typeToJsonSchema.ts"; @@ -36,3 +37,15 @@ runTest({ ]); }, }); + +// ============================================================ +// Offline: request construction, passthrough, and InfoClient wrapper +// ============================================================ + +runOfflineMethodTests({ + name: "subAccounts2", + method: subAccounts2, + signature: "params", + cases: [{ params: { user: "0x0000000000000000000000000000000000000001" } }], + invalidParams: [{ user: "0x123" }, {}], +}); diff --git a/tests/api/info/tokenDetails.test.ts b/tests/api/info/tokenDetails.test.ts index 61534ef6..4a0eb09d 100644 --- a/tests/api/info/tokenDetails.test.ts +++ b/tests/api/info/tokenDetails.test.ts @@ -1,4 +1,5 @@ -import { type TokenDetailsParameters, TokenDetailsRequest } from "@bloxwap/hyperliquid/api/info"; +import { tokenDetails, type TokenDetailsParameters, TokenDetailsRequest } from "@bloxwap/hyperliquid/api/info"; +import { runOfflineMethodTests } from "./_offlineMethodTests.ts"; import * as v from "valibot"; import { schemaCoverage } from "../_utils/schemaCoverage.ts"; import { typeToJsonSchema } from "../_utils/typeToJsonSchema.ts"; @@ -24,3 +25,15 @@ runTest({ schemaCoverage(responseSchema, data, ["#/properties/genesis/anyOf/0/properties/blacklistUsers/array"]); }, }); + +// ============================================================ +// Offline: request construction, passthrough, and InfoClient wrapper +// ============================================================ + +runOfflineMethodTests({ + name: "tokenDetails", + method: tokenDetails, + signature: "params", + cases: [{ params: { tokenId: "0x00000000000000000000000000000001" } }], + invalidParams: [{ tokenId: "0x123" }, { tokenId: "not-hex" }], +}); diff --git a/tests/api/info/twapHistory.test.ts b/tests/api/info/twapHistory.test.ts index aae6cd33..10a8f3e1 100644 --- a/tests/api/info/twapHistory.test.ts +++ b/tests/api/info/twapHistory.test.ts @@ -1,4 +1,5 @@ -import { type TwapHistoryParameters, TwapHistoryRequest } from "@bloxwap/hyperliquid/api/info"; +import { twapHistory, type TwapHistoryParameters, TwapHistoryRequest } from "@bloxwap/hyperliquid/api/info"; +import { runOfflineMethodTests } from "./_offlineMethodTests.ts"; import * as v from "valibot"; import { describe, test } from "bun:test"; import { schemaCoverage } from "../_utils/schemaCoverage.ts"; @@ -119,3 +120,15 @@ describe("twapHistory (offline)", () => { schemaCoverage(responseSchema, [samples]); }); }); + +// ============================================================ +// Offline: request construction, passthrough, and InfoClient wrapper +// ============================================================ + +runOfflineMethodTests({ + name: "twapHistory", + method: twapHistory, + signature: "params", + cases: [{ params: { user: "0x0000000000000000000000000000000000000001" } }], + invalidParams: [{ user: "0x123" }, {}], +}); diff --git a/tests/api/info/userAbstraction.test.ts b/tests/api/info/userAbstraction.test.ts index 59a1603a..1f2ed792 100644 --- a/tests/api/info/userAbstraction.test.ts +++ b/tests/api/info/userAbstraction.test.ts @@ -1,4 +1,5 @@ -import { type UserAbstractionParameters, UserAbstractionRequest } from "@bloxwap/hyperliquid/api/info"; +import { userAbstraction, type UserAbstractionParameters, UserAbstractionRequest } from "@bloxwap/hyperliquid/api/info"; +import { runOfflineMethodTests } from "./_offlineMethodTests.ts"; import * as v from "valibot"; import { schemaCoverage } from "../_utils/schemaCoverage.ts"; import { typeToJsonSchema } from "../_utils/typeToJsonSchema.ts"; @@ -25,3 +26,15 @@ runTest({ schemaCoverage(responseSchema, data); }, }); + +// ============================================================ +// Offline: request construction, passthrough, and InfoClient wrapper +// ============================================================ + +runOfflineMethodTests({ + name: "userAbstraction", + method: userAbstraction, + signature: "params", + cases: [{ params: { user: "0x0000000000000000000000000000000000000001" } }], + invalidParams: [{ user: "0x123" }, {}], +}); diff --git a/tests/api/info/userBorrowLendInterest.test.ts b/tests/api/info/userBorrowLendInterest.test.ts index 7269c03d..eb205380 100644 --- a/tests/api/info/userBorrowLendInterest.test.ts +++ b/tests/api/info/userBorrowLendInterest.test.ts @@ -1,4 +1,9 @@ -import { type UserBorrowLendInterestParameters, UserBorrowLendInterestRequest } from "@bloxwap/hyperliquid/api/info"; +import { + userBorrowLendInterest, + type UserBorrowLendInterestParameters, + UserBorrowLendInterestRequest, +} from "@bloxwap/hyperliquid/api/info"; +import { runOfflineMethodTests } from "./_offlineMethodTests.ts"; import * as v from "valibot"; import { schemaCoverage } from "../_utils/schemaCoverage.ts"; import { typeToJsonSchema } from "../_utils/typeToJsonSchema.ts"; @@ -26,3 +31,22 @@ runTest({ schemaCoverage(responseSchema, data); }, }); + +// ============================================================ +// Offline: request construction, passthrough, and InfoClient wrapper +// ============================================================ + +runOfflineMethodTests({ + name: "userBorrowLendInterest", + method: userBorrowLendInterest, + signature: "params", + cases: [ + { params: { user: "0x0000000000000000000000000000000000000001", startTime: 1000 } }, + { params: { user: "0x0000000000000000000000000000000000000001", startTime: 1000, endTime: 2000 } }, + ], + invalidParams: [ + { user: "0x123", startTime: 1000 }, + { user: "0x0000000000000000000000000000000000000001", startTime: -1 }, + { user: "0x0000000000000000000000000000000000000001" }, + ], +}); diff --git a/tests/api/info/userDexAbstraction.test.ts b/tests/api/info/userDexAbstraction.test.ts index 8f5237f4..d29ecf2b 100644 --- a/tests/api/info/userDexAbstraction.test.ts +++ b/tests/api/info/userDexAbstraction.test.ts @@ -1,4 +1,9 @@ -import { type UserDexAbstractionParameters, UserDexAbstractionRequest } from "@bloxwap/hyperliquid/api/info"; +import { + userDexAbstraction, + type UserDexAbstractionParameters, + UserDexAbstractionRequest, +} from "@bloxwap/hyperliquid/api/info"; +import { runOfflineMethodTests } from "./_offlineMethodTests.ts"; import * as v from "valibot"; import { schemaCoverage } from "../_utils/schemaCoverage.ts"; import { typeToJsonSchema } from "../_utils/typeToJsonSchema.ts"; @@ -23,3 +28,15 @@ runTest({ schemaCoverage(responseSchema, data); }, }); + +// ============================================================ +// Offline: request construction, passthrough, and InfoClient wrapper +// ============================================================ + +runOfflineMethodTests({ + name: "userDexAbstraction", + method: userDexAbstraction, + signature: "params", + cases: [{ params: { user: "0x0000000000000000000000000000000000000001" } }], + invalidParams: [{ user: "0x123" }, {}], +}); diff --git a/tests/api/info/userFees.test.ts b/tests/api/info/userFees.test.ts index 26cf19bc..b99e26e9 100644 --- a/tests/api/info/userFees.test.ts +++ b/tests/api/info/userFees.test.ts @@ -1,4 +1,5 @@ -import { type UserFeesParameters, UserFeesRequest } from "@bloxwap/hyperliquid/api/info"; +import { userFees, type UserFeesParameters, UserFeesRequest } from "@bloxwap/hyperliquid/api/info"; +import { runOfflineMethodTests } from "./_offlineMethodTests.ts"; import * as v from "valibot"; import { schemaCoverage } from "../_utils/schemaCoverage.ts"; import { typeToJsonSchema } from "../_utils/typeToJsonSchema.ts"; @@ -27,3 +28,15 @@ runTest({ ]); }, }); + +// ============================================================ +// Offline: request construction, passthrough, and InfoClient wrapper +// ============================================================ + +runOfflineMethodTests({ + name: "userFees", + method: userFees, + signature: "params", + cases: [{ params: { user: "0x0000000000000000000000000000000000000001" } }], + invalidParams: [{ user: "0x123" }, {}], +}); diff --git a/tests/api/info/userFills.test.ts b/tests/api/info/userFills.test.ts index f83ef8de..83668fe2 100644 --- a/tests/api/info/userFills.test.ts +++ b/tests/api/info/userFills.test.ts @@ -1,4 +1,5 @@ -import { type UserFillsParameters, UserFillsRequest } from "@bloxwap/hyperliquid/api/info"; +import { userFills, type UserFillsParameters, UserFillsRequest } from "@bloxwap/hyperliquid/api/info"; +import { runOfflineMethodTests } from "./_offlineMethodTests.ts"; import * as v from "valibot"; import { schemaCoverage } from "../_utils/schemaCoverage.ts"; import { typeToJsonSchema } from "../_utils/typeToJsonSchema.ts"; @@ -24,3 +25,18 @@ runTest({ schemaCoverage(responseSchema, data, ["#/items/properties/twapId/defined"]); }, }); + +// ============================================================ +// Offline: request construction, passthrough, and InfoClient wrapper +// ============================================================ + +runOfflineMethodTests({ + name: "userFills", + method: userFills, + signature: "params", + cases: [ + { params: { user: "0x0000000000000000000000000000000000000001" } }, + { params: { user: "0x0000000000000000000000000000000000000001", aggregateByTime: true } }, + ], + invalidParams: [{ user: "0x123" }, { user: "0x0000000000000000000000000000000000000001", aggregateByTime: "yes" }], +}); diff --git a/tests/api/info/userFillsByTime.test.ts b/tests/api/info/userFillsByTime.test.ts index 4a7536eb..a5c725d9 100644 --- a/tests/api/info/userFillsByTime.test.ts +++ b/tests/api/info/userFillsByTime.test.ts @@ -1,4 +1,5 @@ -import { type UserFillsByTimeParameters, UserFillsByTimeRequest } from "@bloxwap/hyperliquid/api/info"; +import { userFillsByTime, type UserFillsByTimeParameters, UserFillsByTimeRequest } from "@bloxwap/hyperliquid/api/info"; +import { runOfflineMethodTests } from "./_offlineMethodTests.ts"; import * as v from "valibot"; import { schemaCoverage } from "../_utils/schemaCoverage.ts"; import { typeToJsonSchema } from "../_utils/typeToJsonSchema.ts"; @@ -31,3 +32,30 @@ runTest({ schemaCoverage(responseSchema, data, ["#/items/properties/twapId/defined"]); }, }); + +// ============================================================ +// Offline: request construction, passthrough, and InfoClient wrapper +// ============================================================ + +runOfflineMethodTests({ + name: "userFillsByTime", + method: userFillsByTime, + signature: "params", + cases: [ + { params: { user: "0x0000000000000000000000000000000000000001", startTime: 1000 } }, + { + params: { + user: "0x0000000000000000000000000000000000000001", + startTime: 1000, + endTime: 2000, + aggregateByTime: true, + reversed: false, + }, + }, + ], + invalidParams: [ + { user: "0x123", startTime: 1000 }, + { user: "0x0000000000000000000000000000000000000001", startTime: -1 }, + { user: "0x0000000000000000000000000000000000000001" }, + ], +}); diff --git a/tests/api/info/userFunding.test.ts b/tests/api/info/userFunding.test.ts index b1a567fd..d0ddd743 100644 --- a/tests/api/info/userFunding.test.ts +++ b/tests/api/info/userFunding.test.ts @@ -1,4 +1,5 @@ -import { type UserFundingParameters, UserFundingRequest } from "@bloxwap/hyperliquid/api/info"; +import { userFunding, type UserFundingParameters, UserFundingRequest } from "@bloxwap/hyperliquid/api/info"; +import { runOfflineMethodTests } from "./_offlineMethodTests.ts"; import * as v from "valibot"; import { schemaCoverage } from "../_utils/schemaCoverage.ts"; import { typeToJsonSchema } from "../_utils/typeToJsonSchema.ts"; @@ -28,3 +29,18 @@ runTest({ schemaCoverage(responseSchema, data); }, }); + +// ============================================================ +// Offline: request construction, passthrough, and InfoClient wrapper +// ============================================================ + +runOfflineMethodTests({ + name: "userFunding", + method: userFunding, + signature: "params", + cases: [ + { params: { user: "0x0000000000000000000000000000000000000001" } }, + { params: { user: "0x0000000000000000000000000000000000000001", startTime: 1000, endTime: 2000 } }, + ], + invalidParams: [{ user: "0x123" }, { user: "0x0000000000000000000000000000000000000001", startTime: -1 }], +}); diff --git a/tests/api/info/userNonFundingLedgerUpdates.test.ts b/tests/api/info/userNonFundingLedgerUpdates.test.ts index 320e38cc..dbd27c93 100644 --- a/tests/api/info/userNonFundingLedgerUpdates.test.ts +++ b/tests/api/info/userNonFundingLedgerUpdates.test.ts @@ -1,7 +1,9 @@ import { + userNonFundingLedgerUpdates, type UserNonFundingLedgerUpdatesParameters, UserNonFundingLedgerUpdatesRequest, } from "@bloxwap/hyperliquid/api/info"; +import { runOfflineMethodTests } from "./_offlineMethodTests.ts"; import * as v from "valibot"; import { schemaCoverage } from "../_utils/schemaCoverage.ts"; import { typeToJsonSchema } from "../_utils/typeToJsonSchema.ts"; @@ -34,3 +36,18 @@ runTest({ schemaCoverage(responseSchema, data, ["#/items/properties/delta/anyOf/3/properties/leverageType/enum/0"]); }, }); + +// ============================================================ +// Offline: request construction, passthrough, and InfoClient wrapper +// ============================================================ + +runOfflineMethodTests({ + name: "userNonFundingLedgerUpdates", + method: userNonFundingLedgerUpdates, + signature: "params", + cases: [ + { params: { user: "0x0000000000000000000000000000000000000001" } }, + { params: { user: "0x0000000000000000000000000000000000000001", startTime: 1000, endTime: 2000 } }, + ], + invalidParams: [{ user: "0x123" }, { user: "0x0000000000000000000000000000000000000001", startTime: -1 }], +}); diff --git a/tests/api/info/userNonFundingLedgerUpdatesAll.test.ts b/tests/api/info/userNonFundingLedgerUpdatesAll.test.ts index 9a5a7b0c..0d97a532 100644 --- a/tests/api/info/userNonFundingLedgerUpdatesAll.test.ts +++ b/tests/api/info/userNonFundingLedgerUpdatesAll.test.ts @@ -5,6 +5,7 @@ */ import { describe, expect, test } from "bun:test"; +import { InfoClient } from "@bloxwap/hyperliquid"; import { userNonFundingLedgerUpdatesAll } from "@bloxwap/hyperliquid/api/info"; import { MockInfoTransport, scriptedPages } from "./_mockInfoTransport.ts"; @@ -51,4 +52,16 @@ describe("userNonFundingLedgerUpdatesAll", () => { expect(result).toHaveLength(1_000); expect(transport.calls).toHaveLength(2); }); + + test("is exposed on InfoClient with identical behavior", async () => { + const transport = new MockInfoTransport(scriptedPages([ledgerPage(0, PAGE), ledgerPage(PAGE, 7)])); + const client = new InfoClient({ transport }); + const signal = new AbortController().signal; + + const result = await client.userNonFundingLedgerUpdatesAll({ user: USER, startTime: 0 }, { maxPages: 5 }, signal); + + expect(result).toHaveLength(507); + expect(transport.calls.map((c) => (c.payload as { startTime: number }).startTime)).toEqual([0, 499]); + expect(transport.calls[0].signal).toBe(signal); + }); }); diff --git a/tests/api/info/userRateLimit.test.ts b/tests/api/info/userRateLimit.test.ts index 0647fa37..7ab07273 100644 --- a/tests/api/info/userRateLimit.test.ts +++ b/tests/api/info/userRateLimit.test.ts @@ -1,4 +1,5 @@ -import { type UserRateLimitParameters, UserRateLimitRequest } from "@bloxwap/hyperliquid/api/info"; +import { userRateLimit, type UserRateLimitParameters, UserRateLimitRequest } from "@bloxwap/hyperliquid/api/info"; +import { runOfflineMethodTests } from "./_offlineMethodTests.ts"; import * as v from "valibot"; import { schemaCoverage } from "../_utils/schemaCoverage.ts"; import { typeToJsonSchema } from "../_utils/typeToJsonSchema.ts"; @@ -20,3 +21,15 @@ runTest({ schemaCoverage(responseSchema, data); }, }); + +// ============================================================ +// Offline: request construction, passthrough, and InfoClient wrapper +// ============================================================ + +runOfflineMethodTests({ + name: "userRateLimit", + method: userRateLimit, + signature: "params", + cases: [{ params: { user: "0x0000000000000000000000000000000000000001" } }], + invalidParams: [{ user: "0x123" }, {}], +}); diff --git a/tests/api/info/userRole.test.ts b/tests/api/info/userRole.test.ts index c7a1aac5..e4d2f964 100644 --- a/tests/api/info/userRole.test.ts +++ b/tests/api/info/userRole.test.ts @@ -1,4 +1,5 @@ -import { type UserRoleParameters, UserRoleRequest } from "@bloxwap/hyperliquid/api/info"; +import { userRole, type UserRoleParameters, UserRoleRequest } from "@bloxwap/hyperliquid/api/info"; +import { runOfflineMethodTests } from "./_offlineMethodTests.ts"; import * as v from "valibot"; import { schemaCoverage } from "../_utils/schemaCoverage.ts"; import { typeToJsonSchema } from "../_utils/typeToJsonSchema.ts"; @@ -26,3 +27,15 @@ runTest({ schemaCoverage(responseSchema, data); }, }); + +// ============================================================ +// Offline: request construction, passthrough, and InfoClient wrapper +// ============================================================ + +runOfflineMethodTests({ + name: "userRole", + method: userRole, + signature: "params", + cases: [{ params: { user: "0x0000000000000000000000000000000000000001" } }], + invalidParams: [{ user: "0x123" }, {}], +}); diff --git a/tests/api/info/userToMultiSigSigners.test.ts b/tests/api/info/userToMultiSigSigners.test.ts index 10a2f036..ba5c0cb8 100644 --- a/tests/api/info/userToMultiSigSigners.test.ts +++ b/tests/api/info/userToMultiSigSigners.test.ts @@ -1,4 +1,9 @@ -import { type UserToMultiSigSignersParameters, UserToMultiSigSignersRequest } from "@bloxwap/hyperliquid/api/info"; +import { + userToMultiSigSigners, + type UserToMultiSigSignersParameters, + UserToMultiSigSignersRequest, +} from "@bloxwap/hyperliquid/api/info"; +import { runOfflineMethodTests } from "./_offlineMethodTests.ts"; import * as v from "valibot"; import { schemaCoverage } from "../_utils/schemaCoverage.ts"; import { typeToJsonSchema } from "../_utils/typeToJsonSchema.ts"; @@ -23,3 +28,15 @@ runTest({ schemaCoverage(responseSchema, data); }, }); + +// ============================================================ +// Offline: request construction, passthrough, and InfoClient wrapper +// ============================================================ + +runOfflineMethodTests({ + name: "userToMultiSigSigners", + method: userToMultiSigSigners, + signature: "params", + cases: [{ params: { user: "0x0000000000000000000000000000000000000001" } }], + invalidParams: [{ user: "0x123" }, {}], +}); diff --git a/tests/api/info/userTwapSliceFills.test.ts b/tests/api/info/userTwapSliceFills.test.ts index da70b360..2d2cf798 100644 --- a/tests/api/info/userTwapSliceFills.test.ts +++ b/tests/api/info/userTwapSliceFills.test.ts @@ -1,4 +1,9 @@ -import { type UserTwapSliceFillsParameters, UserTwapSliceFillsRequest } from "@bloxwap/hyperliquid/api/info"; +import { + userTwapSliceFills, + type UserTwapSliceFillsParameters, + UserTwapSliceFillsRequest, +} from "@bloxwap/hyperliquid/api/info"; +import { runOfflineMethodTests } from "./_offlineMethodTests.ts"; import * as v from "valibot"; import { schemaCoverage } from "../_utils/schemaCoverage.ts"; import { typeToJsonSchema } from "../_utils/typeToJsonSchema.ts"; @@ -23,3 +28,15 @@ runTest({ ]); }, }); + +// ============================================================ +// Offline: request construction, passthrough, and InfoClient wrapper +// ============================================================ + +runOfflineMethodTests({ + name: "userTwapSliceFills", + method: userTwapSliceFills, + signature: "params", + cases: [{ params: { user: "0x0000000000000000000000000000000000000001" } }], + invalidParams: [{ user: "0x123" }, {}], +}); diff --git a/tests/api/info/userTwapSliceFillsByTime.test.ts b/tests/api/info/userTwapSliceFillsByTime.test.ts index 7b2b2a3b..73d0d9d3 100644 --- a/tests/api/info/userTwapSliceFillsByTime.test.ts +++ b/tests/api/info/userTwapSliceFillsByTime.test.ts @@ -1,7 +1,9 @@ import { + userTwapSliceFillsByTime, type UserTwapSliceFillsByTimeParameters, UserTwapSliceFillsByTimeRequest, } from "@bloxwap/hyperliquid/api/info"; +import { runOfflineMethodTests } from "./_offlineMethodTests.ts"; import * as v from "valibot"; import { schemaCoverage } from "../_utils/schemaCoverage.ts"; import { typeToJsonSchema } from "../_utils/typeToJsonSchema.ts"; @@ -32,3 +34,22 @@ runTest({ ]); }, }); + +// ============================================================ +// Offline: request construction, passthrough, and InfoClient wrapper +// ============================================================ + +runOfflineMethodTests({ + name: "userTwapSliceFillsByTime", + method: userTwapSliceFillsByTime, + signature: "params", + cases: [ + { params: { user: "0x0000000000000000000000000000000000000001", startTime: 1000 } }, + { params: { user: "0x0000000000000000000000000000000000000001", startTime: 1000, endTime: 2000 } }, + ], + invalidParams: [ + { user: "0x123", startTime: 1000 }, + { user: "0x0000000000000000000000000000000000000001", startTime: -1 }, + { user: "0x0000000000000000000000000000000000000001" }, + ], +}); diff --git a/tests/api/info/userTwapSliceFillsByTimeAll.test.ts b/tests/api/info/userTwapSliceFillsByTimeAll.test.ts index caea1ce8..a53003c4 100644 --- a/tests/api/info/userTwapSliceFillsByTimeAll.test.ts +++ b/tests/api/info/userTwapSliceFillsByTimeAll.test.ts @@ -5,6 +5,7 @@ */ import { describe, expect, test } from "bun:test"; +import { InfoClient } from "@bloxwap/hyperliquid"; import { userTwapSliceFillsByTimeAll } from "@bloxwap/hyperliquid/api/info"; import { MockInfoTransport, scriptedPages } from "./_mockInfoTransport.ts"; @@ -38,4 +39,16 @@ describe("userTwapSliceFillsByTimeAll", () => { expect(result).toEqual([]); expect(transport.calls).toHaveLength(1); }); + + test("is exposed on InfoClient with identical behavior", async () => { + const transport = new MockInfoTransport(scriptedPages([sliceFillsPage(0, PAGE), sliceFillsPage(PAGE, 7)])); + const client = new InfoClient({ transport }); + const signal = new AbortController().signal; + + const result = await client.userTwapSliceFillsByTimeAll({ user: USER, startTime: 0 }, { maxPages: 5 }, signal); + + expect(result).toHaveLength(507); + expect(transport.calls.map((c) => (c.payload as { startTime: number }).startTime)).toEqual([0, 499]); + expect(transport.calls[0].signal).toBe(signal); + }); }); diff --git a/tests/api/info/userVaultEquities.test.ts b/tests/api/info/userVaultEquities.test.ts index 366c5732..db8fd2b3 100644 --- a/tests/api/info/userVaultEquities.test.ts +++ b/tests/api/info/userVaultEquities.test.ts @@ -1,4 +1,9 @@ -import { type UserVaultEquitiesParameters, UserVaultEquitiesRequest } from "@bloxwap/hyperliquid/api/info"; +import { + userVaultEquities, + type UserVaultEquitiesParameters, + UserVaultEquitiesRequest, +} from "@bloxwap/hyperliquid/api/info"; +import { runOfflineMethodTests } from "./_offlineMethodTests.ts"; import * as v from "valibot"; import { schemaCoverage } from "../_utils/schemaCoverage.ts"; import { typeToJsonSchema } from "../_utils/typeToJsonSchema.ts"; @@ -20,3 +25,15 @@ runTest({ schemaCoverage(responseSchema, data); }, }); + +// ============================================================ +// Offline: request construction, passthrough, and InfoClient wrapper +// ============================================================ + +runOfflineMethodTests({ + name: "userVaultEquities", + method: userVaultEquities, + signature: "params", + cases: [{ params: { user: "0x0000000000000000000000000000000000000001" } }], + invalidParams: [{ user: "0x123" }, {}], +}); diff --git a/tests/api/info/validatorL1Votes.test.ts b/tests/api/info/validatorL1Votes.test.ts index eaba8583..63c9647e 100644 --- a/tests/api/info/validatorL1Votes.test.ts +++ b/tests/api/info/validatorL1Votes.test.ts @@ -1,3 +1,5 @@ +import { validatorL1Votes } from "@bloxwap/hyperliquid/api/info"; +import { runOfflineMethodTests } from "./_offlineMethodTests.ts"; import { schemaCoverage } from "../_utils/schemaCoverage.ts"; import { typeToJsonSchema } from "../_utils/typeToJsonSchema.ts"; import { runTest } from "./_t.ts"; @@ -22,3 +24,13 @@ runTest({ ]); }, }); + +// ============================================================ +// Offline: request construction, passthrough, and InfoClient wrapper +// ============================================================ + +runOfflineMethodTests({ + name: "validatorL1Votes", + method: validatorL1Votes, + signature: "none", +}); diff --git a/tests/api/info/validatorSummaries.test.ts b/tests/api/info/validatorSummaries.test.ts index cd029886..21b87090 100644 --- a/tests/api/info/validatorSummaries.test.ts +++ b/tests/api/info/validatorSummaries.test.ts @@ -1,3 +1,5 @@ +import { validatorSummaries } from "@bloxwap/hyperliquid/api/info"; +import { runOfflineMethodTests } from "./_offlineMethodTests.ts"; import { schemaCoverage } from "../_utils/schemaCoverage.ts"; import { typeToJsonSchema } from "../_utils/typeToJsonSchema.ts"; import { runTest } from "./_t.ts"; @@ -13,3 +15,13 @@ runTest({ schemaCoverage(responseSchema, data); }, }); + +// ============================================================ +// Offline: request construction, passthrough, and InfoClient wrapper +// ============================================================ + +runOfflineMethodTests({ + name: "validatorSummaries", + method: validatorSummaries, + signature: "none", +}); diff --git a/tests/api/info/vaultDetails.test.ts b/tests/api/info/vaultDetails.test.ts index 7a327268..aba75204 100644 --- a/tests/api/info/vaultDetails.test.ts +++ b/tests/api/info/vaultDetails.test.ts @@ -1,4 +1,5 @@ import { type VaultDetailsParameters, VaultDetailsRequest, vaultDetails } from "@bloxwap/hyperliquid/api/info"; +import { runOfflineMethodTests } from "./_offlineMethodTests.ts"; import * as v from "valibot"; import { describe, test } from "bun:test"; import { assertEquals } from "@jsr/std__assert"; @@ -50,3 +51,27 @@ describe("vaultDetails (offline)", () => { assertEquals(result, null); }); }); + +// ============================================================ +// Offline: request construction, passthrough, and InfoClient wrapper +// ============================================================ + +runOfflineMethodTests({ + name: "vaultDetails", + method: vaultDetails, + signature: "params", + cases: [ + { params: { vaultAddress: "0x0000000000000000000000000000000000000001" } }, + { params: { vaultAddress: "0x0000000000000000000000000000000000000001", user: null } }, + { + params: { + vaultAddress: "0x0000000000000000000000000000000000000001", + user: "0x0000000000000000000000000000000000000002", + }, + }, + ], + invalidParams: [ + { vaultAddress: "0x123" }, + { vaultAddress: "0x0000000000000000000000000000000000000001", user: "0x456" }, + ], +}); diff --git a/tests/api/info/vaultSummaries.test.ts b/tests/api/info/vaultSummaries.test.ts index d36eeb3f..d97767c9 100644 --- a/tests/api/info/vaultSummaries.test.ts +++ b/tests/api/info/vaultSummaries.test.ts @@ -1,3 +1,5 @@ +import { vaultSummaries } from "@bloxwap/hyperliquid/api/info"; +import { runOfflineMethodTests } from "./_offlineMethodTests.ts"; import { schemaCoverage } from "../_utils/schemaCoverage.ts"; import { typeToJsonSchema } from "../_utils/typeToJsonSchema.ts"; import { runTest } from "./_t.ts"; @@ -13,3 +15,13 @@ runTest({ schemaCoverage(responseSchema, data, ["#/array"]); }, }); + +// ============================================================ +// Offline: request construction, passthrough, and InfoClient wrapper +// ============================================================ + +runOfflineMethodTests({ + name: "vaultSummaries", + method: vaultSummaries, + signature: "none", +}); diff --git a/tests/api/info/webData2.test.ts b/tests/api/info/webData2.test.ts index 788050b2..b08bb6f0 100644 --- a/tests/api/info/webData2.test.ts +++ b/tests/api/info/webData2.test.ts @@ -1,4 +1,5 @@ -import { type WebData2Parameters, WebData2Request } from "@bloxwap/hyperliquid/api/info"; +import { webData2, type WebData2Parameters, WebData2Request } from "@bloxwap/hyperliquid/api/info"; +import { runOfflineMethodTests } from "./_offlineMethodTests.ts"; import * as v from "valibot"; import { schemaCoverage } from "../_utils/schemaCoverage.ts"; import { typeToJsonSchema } from "../_utils/typeToJsonSchema.ts"; @@ -55,3 +56,15 @@ runTest({ ]); }, }); + +// ============================================================ +// Offline: request construction, passthrough, and InfoClient wrapper +// ============================================================ + +runOfflineMethodTests({ + name: "webData2", + method: webData2, + signature: "params", + cases: [{ params: { user: "0x0000000000000000000000000000000000000001" } }], + invalidParams: [{ user: "0x123" }, {}], +});