test(info): cover every Info API method body and InfoClient wrapper offline - #74
Merged
Conversation
…ffline Each method's test file now runs a shared offline battery over a mock transport: exact wire payload for every valid-params combo, ValidationError with zero requests for invalid params, response/error/signal passthrough, and identical behavior through the InfoClient wrapper (including the params-or-AbortSignal overloads and the paginated *All helpers). src/api/info line coverage: 63.8% -> 100% (offline run).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What & why
Tests only — no
src/changes. Bringssrc/api/infoto 100% line coverage in the offline test run (HL_OFFLINE=1 bun test tests/), closing the gap where every method body (parse(params)+config.transport.request("info", …)) and everyInfoClientwrapper was previously exercised only by the skipped-when-offline live tests.How:
tests/api/info/_mockInfoTransport.ts(existing mock): now also records theAbortSignalof each call, and isasyncso a throwing handler surfaces as a rejection the way a real transport's failures do.tests/api/info/_offlineMethodTests.ts: a shared battery each method's test file runs — exact wire payload for every valid-params combo (defaults, optionals,nulls, picklists,orderStatusoid-as-number vs cloid),ValidationErrorwith zero requests for invalid params, response/error/signal passthrough, and identical behavior through theInfoClientwrapper. Covers theparams-or-AbortSignaloverloads (allMids,meta,metaAndAssetCtxs,perpsAtOpenInterestCap) in both directions.*Allhelpers whoseInfoClientwrappers were uncovered (candleSnapshotAll,fundingHistoryAll,userNonFundingLedgerUpdatesAll,userTwapSliceFillsByTimeAll) get the same "is exposed on InfoClient with identical behavior" test asuserFillsByTimeAll, including signal threading through the pagination loop.One behavior worth noting:
orderStatuswith a small numeric-looking cloid (e.g.0x000…01) sendsoidas a number — theUnsignedIntegerarm of the union matches first. The new tests pin that and use an out-of-safe-integer-range cloid (0xffff…) to cover the string arm.Coverage (
HL_OFFLINE=1 bun test tests/ --coverage --coverage-reporter=lcov, DA lines)src/api/info/_methodssrc/api/info/client.tssrc/api/infototalNo BRDA (branch) misses remain in
src/api/info. Per-file before/after:Details
Verification
bun run check— all stages pass (format, lint, docs, types, ts7, jsdoc, export).HL_OFFLINE=1 bun test tests/— 1309 pass, 236 skip (live tests), 0 fail.Type of change