Skip to content

Unit Tests for LoanService #71

@Josue19-08

Description

@Josue19-08

🔖 Title

Unit Tests for LoanService


📄 Description

Write comprehensive unit tests for the LoanService covering loan quote calculation, loan creation transaction building, and repayment logic. Mock blockchain RPC calls and database operations. This issue can be completed independently once issues #55, #56, #57, #58, and #59 are implemented.

Related to: Meta-issue #67


✅ Tasks to complete

  • Test loan quote calculation with different reputation tiers
  • Test interest rate mapping from reputation score
  • Test payment schedule generation
  • Test loan creation transaction building (XDR construction)
  • Test guarantee amount calculation (20% of purchase)
  • Test repayment transaction building
  • Test remaining balance calculations
  • Test validation of merchant existence and active status
  • Test credit limit enforcement
  • Mock Soroban contract calls
  • Mock database queries for loans and merchants
  • Test error scenarios (inactive merchant, insufficient credit)
  • Achieve 80%+ coverage for LoanService

📚 Documentation/context for AI

(This link never should removed)
https://github.com/TrustUp-app/TrustUp-API/tree/main/docs

Relevant documentation:

Dependencies:


🗒️ Additional notes

Acceptance Criteria:

  • All test cases pass
  • Code coverage for LoanService is at least 80%
  • Blockchain calls are properly mocked
  • XDR construction is validated
  • Complex calculations (interest, schedules) are tested with edge cases

Metadata

Metadata

Assignees

No one assigned

    Labels

    Stellar WaveIssues in the Stellar wave programblockchainBlockchain/Stellar integrationdatabaseDatabase relatedenhancementNew feature or requestmedium-priorityMedium priority issuetestingTesting related

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions