test(api): add integration tests for transfer route handlers#41
Merged
Miracle656 merged 1 commit intoMiracle656:mainfrom Apr 23, 2026
Merged
Conversation
|
@0xDeon Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
…pagination Closes Miracle656#29 - Installs Jest, ts-jest, supertest; wires up npm test script and jest config - Adds tsconfig types for @types/jest to fix IDE resolution - 36 tests covering all 5 route handlers (incoming, outgoing, address, tx, summary) with: direction filters, fromDate/toDate, fromLedger/toLedger, contractId, eventType (single, multi, invalid → 400), limit/offset pagination, unknown address → empty array, displayAmount formatting, and edge-case stroop values (0, 1, large i128)
8c653cd to
b39105f
Compare
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.
Summary
Closes #29
npm testscript and jest config inpackage.json"types": ["node", "jest"]totsconfig.jsonso Jest globals resolve correctly in the IDEsrc/__tests__/routes/transfers.test.tswith 36 integration tests covering all transfer route handlers via HTTP (supertest), with all DB and RPC calls mockedWhat was implemented
All 5 route handlers are tested:
GET /transfers/incoming/:addresscontractId,fromDate/toDate, invalid dates → 400,eventType(valid, multi, invalid → 400),limit/offset,fromLedger/toLedger, unknown address → empty,displayAmountGET /transfers/outgoing/:addressoutgoing,displayAmountlarge i128, invalideventType→ 400GET /transfers/address/:addressdirectionfield, pagination,contractId, invalidtoDate→ 400GET /transfers/tx/:txHashGET /summary/:addressSeed data: 20 transfers covering incoming/outgoing, mint/burn/clawback/transfer event types, two token contracts, two addresses, varied timestamps and ledger numbers.
Edge cases for
toDisplayAmount: 0 stroops, 1 stroop, 1 token (10 000 000), large i128 value.How it was tested
All 36 tests pass with zero TS errors.
Manual test steps
git checkout test/transfer-route-handlers npm install npm test