Skip to content

Feat/savings goal#239

Merged
Baskarayelu merged 11 commits intoRemitwise-Org:mainfrom
shaaibu7:feat/savings-goal
Feb 26, 2026
Merged

Feat/savings goal#239
Baskarayelu merged 11 commits intoRemitwise-Org:mainfrom
shaaibu7:feat/savings-goal

Conversation

@shaaibu7
Copy link
Contributor

@shaaibu7 shaaibu7 commented Feb 25, 2026

Description

Implements savings goals transaction builders and API endpoints for creating, managing, and locking/unlocking savings goals. Adds comprehensive test coverage with unit, property-based, and integration tests.

Changes

Implementation

  • Transaction builders in lib/contracts/savings-goals.ts for all goal operations
  • 5 API endpoints: create, add funds, withdraw, lock, unlock
  • Input validation for amounts, dates, goal IDs, and names
  • Authentication middleware integration
  • Consistent error handling (400, 401, 500)

Testing

  • Set up Vitest + fast-check for testing
  • 27 unit tests for validation functions
  • 10 property-based tests (100 iterations each)
  • 7 integration tests for error handling
  • 44/44 tests passing

Documentation

  • Complete API documentation with examples
  • Requirements specification (EARS patterns)
  • Design document with correctness properties
  • Implementation plan

API Endpoints

  • POST /api/goals - Create goal
  • POST /api/goals/[id]/add - Add funds
  • POST /api/goals/[id]/withdraw - Withdraw funds
  • POST /api/goals/[id]/lock - Lock goal
  • POST /api/goals/[id]/unlock - Unlock goal

closes #159

- Define user stories for create, add, withdraw, lock, and unlock operations
- Specify acceptance criteria using EARS patterns
- Include authentication and validation requirements
- Document error handling requirements
- Document system architecture and data flow
- Define transaction builder interfaces and API endpoints
- Specify 10 correctness properties for property-based testing
- Include error handling strategy and security considerations
- Add testing strategy with unit, property, and integration tests
- Define 8 main tasks with subtasks for implementation
- Include property-based test tasks for each correctness property
- Mark optional test tasks to enable faster MVP delivery
- Reference specific requirements for each task
- Install vitest and fast-check for unit and property-based testing
- Configure vitest with TypeScript path aliases
- Add test setup file with environment variables
- Update package.json scripts for running tests
- Exclude e2e tests from vitest to avoid conflicts with Playwright
- Test validateAmount with positive, zero, negative, NaN, and Infinity
- Test validateFutureDate with past, present, and future dates
- Test validateGoalId with empty and whitespace strings
- Test validateGoalName with length constraints (1-100 chars)
- Test validatePublicKey with Stellar key format validation
- All 27 unit tests passing
- Property 2: Amount validation rejects non-positive values (Requirements 1.3, 2.2, 3.2)
- Property 3: Goal ID validation rejects empty strings (Requirements 2.3, 3.3, 4.2, 5.2)
- Property 4: Goal name validation enforces length constraints (Requirements 1.2)
- Property 5: Future date validation rejects past dates (Requirements 1.4)
- Property 9: Error responses have consistent structure (Requirements 8.2)
- Each property runs 100 iterations with randomly generated inputs
- All 10 property tests passing
- Property 6: Unauthenticated requests return 401 (Requirements 6.1, 6.2)
- Property 8: Invalid input returns 400 with error details (Requirements 7.1-7.4)
- Property 9: Error responses have consistent structure (Requirements 8.2)
- Test createValidationError, createAuthenticationError, handleUnexpectedError
- Verify all error responses include error field with descriptive messages
- All 7 integration tests passing
@Baskarayelu
Copy link
Contributor

@shaaibu7 please resolve the conflicts

@shaaibu7
Copy link
Contributor Author

@Baskarayelu conflicts resolved

@blessme247
Copy link
Contributor

Hi @shaaibu7 I see You're using a withAuth middleware in your route handlers which is quite different from the withAuth I setup and its currently causing merge conflicts on my end. kindly help me paste it here, as it will help me resolve the merge conflicts on my end and eliminate potential merge conflicts on your end

@Baskarayelu Baskarayelu merged commit cd8d69f into Remitwise-Org:main Feb 26, 2026
0 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Contract Write Layer — Savings Goals (Create, Add, Withdraw, Lock/Unlock)

3 participants