Skip to content

[FEATURE] Add cross-contract integration test suite #83

Description

@Josue19-08

🔖 Feature Title

Add cross-contract integration tests covering the full BNPL lifecycle


📄 Description

Each contract has its own unit tests but there are no tests that exercise the contracts together. The `tests.rs` files in CreditLine have several TODOs for wiring up mock contracts that remain unimplemented. Integration tests are essential to verify that the CreditLine → Reputation → LiquidityPool → MerchantRegistry call chain works correctly as a system.

Current TODOs in `creditline-contract/src/tests.rs`:

  • `// TODO: wire up MockMerchantRegistry/MockLiquidityPool`
  • `// TODO: assert reputation score increased for user`
  • `// TODO: assert liquidity pool received the repayment`

✅ Tasks to complete

  • Create a `tests/integration/` directory at the workspace root (or within each contract)
  • Implement integration test: Full BNPL lifecycle
    1. Deploy all 4 contracts in the test environment
    2. Register a merchant in MerchantRegistry
    3. Set user reputation score ≥ 40 in Reputation contract
    4. Fund LiquidityPool with test tokens
    5. Create a loan via CreditLine → assert loan created, liquidity pool debited, merchant funded
    6. Repay the loan → assert loan completed, liquidity pool repaid with interest, reputation increased
  • Implement integration test: Loan default path
    • Create loan → mark as defaulted → assert reputation decreased → assert guarantee received by pool
  • Implement integration test: Unauthorized access rejection
    • Non-updater calling Reputation `set_score()` should panic
    • Non-CreditLine address calling LiquidityPool `fund_loan()` should panic
  • Mock the SAC (Stellar Asset Contract) token for test environments
  • Add integration test CI job in `.github/workflows/contracts-ci.yml`

🗒️ Additional notes

  • Depends on SC-09 and SC-11 being completed
  • Use Soroban SDK's `testutils` feature: `env.register_contract()` to deploy contracts in-memory
  • Each contract's address needs to be passed to the others during initialization
  • The Reputation contract must have CreditLine registered as an updater via `set_updater()` before tests

Metadata

Metadata

Labels

GrantFox OSSIssue tracked in GrantFox OSSMaybe RewardedIssue may be eligible for a GrantFox rewardOfficial Campaign | FWC26Campaign: Official Campaign | FWC26

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions