Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 68 additions & 0 deletions BOUNDARY_TESTS_SUMMARY.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
# Boundary Tests Implementation Summary

## Overview
Added comprehensive boundary tests for the POST /api/streams route validation rules, specifically for `durationSeconds` and `totalAmount` parameters.

## Tests Added

### Duration Boundary Tests
Located in: `backend/src/index.test.ts` (lines ~618-664)

1. **Test: durationSeconds = 59 (below minimum)**
- Sends request with `durationSeconds: 59`
- Expects: `400` status code
- Expects: Error message "durationSeconds must be at least 60 seconds"
- Validates the lower boundary is enforced

2. **Test: durationSeconds = 60 (minimum boundary)**
- Sends request with `durationSeconds: 60`
- Expects: `201` status code (success)
- Validates the exact minimum boundary is accepted

### Amount Precision Boundary Tests
Located in: `backend/src/index.test.ts` (lines ~666-744)

1. **Test: totalAmount = 0.0000001 (1 stroop - minimum valid)**
- Sends request with `totalAmount: 0.0000001` (7 decimal places)
- Expects: `201` status code (success)
- Validates that the smallest Stellar amount (1 stroop) is accepted

2. **Test: totalAmount = 0**
- Sends request with `totalAmount: 0`
- Expects: `400` status code
- Expects: Error message "Amount must be greater than zero"
- Validates zero amounts are rejected

3. **Test: totalAmount with 8 decimal places**
- Sends request with `totalAmount: 100.12345678` (8 decimal places)
- Expects: `400` status code
- Expects: Error message "Amount cannot have more than 7 decimal places"
- Validates precision limit is enforced

4. **Test: totalAmount with exactly 7 decimal places**
- Sends request with `totalAmount: 100.1234567` (7 decimal places)
- Expects: `201` status code (success)
- Validates the maximum precision boundary is accepted

## Validation Schema Reference
The validation logic tested here is implemented in:
- `backend/src/validation/schemas.ts`
- `durationSecondsSchema`: Enforces minimum of 60 seconds
- `totalAmountSchema`: Enforces positive values and maximum 7 decimal places

## Acceptance Criteria ✅
- ✅ Duration boundary (59 vs 60) is tested explicitly
- ✅ Stroop-level minimum amount (0.0000001) is accepted
- ✅ More than 7 decimal places is rejected with clear message "Amount cannot have more than 7 decimal places"
- ✅ Zero amount is rejected with clear message "Amount must be greater than zero"
- ✅ All tests follow the existing test pattern with proper assertions

## Test Structure
All boundary tests are organized under the existing `describe("POST /api/streams")` block with two sub-describe blocks:
1. `describe("Duration boundary tests")`
2. `describe("Amount precision boundary tests")`

This organization makes it easy to find and maintain these specific boundary test cases.

## Additional Fix
Fixed a syntax error in `backend/src/index.ts` (lines 1040-1090) where duplicate code was causing compilation failures. Removed the duplicate query parsing and filtering logic in the recipients route handler.
Loading