Summary
apps/api has zero HTTP-layer tests. The Fastify route handlers (positions, deposit, withdraw, health) are only exercised end-to-end against a live network. Unit tests exist for SDK helpers, but nothing verifies that the route layer parses requests correctly, validates inputs, serialises responses, or returns the right HTTP status codes.
Motivation
Without HTTP-layer tests, a change to a route handler (wrong status code on error, missing field in response, broken input validation) ships silently. Fastify's inject API makes it possible to test routes without a real network -- the suite can run in CI with mocked SDK helpers.
Proposed Solution
Add a Vitest test file at apps/api/src/__tests__/routes.test.ts using fastify.inject to test each route:
GET /health -- 200 with expected body shape
GET /positions -- 200 with mocked SDK response; 400 on missing wallet param; 500 when SDK throws
POST /deposit -- 200 with mocked prepareSorobanTx; 400 on invalid body; 422 on simulation failure
POST /withdraw -- same shape as deposit
Mock @meridian/stellar-sdk-helpers at the module level so no Soroban RPC calls are made.
Scope
| Field |
Value |
| Area |
api, testing |
| Protocol affected |
none (mocked) |
| Network |
n/a |
| Breaking change? |
No |
Acceptance Criteria
Summary
apps/apihas zero HTTP-layer tests. The Fastify route handlers (positions, deposit, withdraw, health) are only exercised end-to-end against a live network. Unit tests exist for SDK helpers, but nothing verifies that the route layer parses requests correctly, validates inputs, serialises responses, or returns the right HTTP status codes.Motivation
Without HTTP-layer tests, a change to a route handler (wrong status code on error, missing field in response, broken input validation) ships silently. Fastify's
injectAPI makes it possible to test routes without a real network -- the suite can run in CI with mocked SDK helpers.Proposed Solution
Add a Vitest test file at
apps/api/src/__tests__/routes.test.tsusingfastify.injectto test each route:GET /health-- 200 with expected body shapeGET /positions-- 200 with mocked SDK response; 400 on missing wallet param; 500 when SDK throwsPOST /deposit-- 200 with mockedprepareSorobanTx; 400 on invalid body; 422 on simulation failurePOST /withdraw-- same shape as depositMock
@meridian/stellar-sdk-helpersat the module level so no Soroban RPC calls are made.Scope
Acceptance Criteria
apps/api/src/__tests__/routes.test.tscovers all four route groupspnpm testpasses from the repo root