Skip to content

Add a consistency test asserting POST /api/v1/quote rejects a non-positive amount with the same 400 envelope shape as routes/liquidity.ts #150

Description

@Jagadeeshftw

📌 Description

QuoteService.quote, LiquidityService.addLiquidity, and SettlementService.open all funnel through the same requirePositiveNumber helper for their amount field, so their 400 responses for a non-positive amount should be identical in shape and message pattern. There doesn't appear to be a cross-route consistency test proving this — a future change to just one call site's error handling could silently diverge without any test catching it.

🧩 Requirements and context

  • Add a table-driven test issuing a non-positive (0, -1) amount to POST /api/v1/quote, POST /api/v1/liquidity, and POST /api/v1/settlements, asserting all three return 400 with the same error.code (BAD_REQUEST) and a message referencing "amount".

🛠️ Suggested execution

  • Add the cross-route test, likely as a new test file (e.g. src/routes/amountValidationConsistency.test.ts) or appended to an existing shared test setup, exercising all three routes via supertest against createApp().

✅ Acceptance criteria

  • New test passes, demonstrating consistent 400 behavior for non-positive amount across all three routes.
  • No production code changes expected unless an inconsistency is actually found, in which case the diverging call site is fixed to match.

🔒 Security notes

N/A — test-only; guards a cross-cutting validation consistency invariant relevant to defensive input handling.

📋 Guidelines

  • Minimum 95% test coverage
  • Clear documentation
  • Timeframe: 96 hours

Metadata

Metadata

Assignees

No one assigned

    Labels

    GrantFox OSSGrantFox open-source programMaybe RewardedGrantFox: potentially rewarded contributionOfficial Campaign | FWC26GrantFox official campaign issueapiHTTP/WebSocket APItestingTests and coverage

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions