Skip to content

[FEATURE] Add cross-contract integration tests for full savings flow #14

Description

@derbydaniels9-cpu

Summary

There is no cross-contract integration test that verifies the full end-to-end flow: user deposits via savings lock contract, interest accrues, KYC oracle is checked, fee goes to treasury, and event is indexed. Each contract is tested in isolation but their interactions are untested.

Impact

  • A breaking change in the KYC registry contract interface silently breaks the savings lock contract.
  • Fee routing to the treasury contract may fail if the savings lock holds a stale treasury address.
  • Integration bugs only surface in production when real funds are at risk.

Proposed integration test suite

// tests/integration_test.rs
#[test]
fn test_full_savings_flow_with_kyc_and_fee_collection() {
    let env = Env::default();

    // Deploy all contracts
    let kyc_id = env.register_contract(None, KycRegistryContract);
    let treasury_id = env.register_contract(None, FeeTreasuryContract);
    let savings_id = env.register_contract(None, SavingsLockContract);

    // Initialize savings lock with kyc and treasury references
    // Attest user KYC via kyc contract
    // Deposit via savings lock — should pass KYC check
    // Attempt early withdrawal — should deduct 10% fee to treasury
    // Verify treasury received correct fee amount
    // Verify user received correct net payout
}

#[test]
fn test_unverified_user_cannot_deposit() {
    // User without KYC attestation attempts deposit
    // Should panic with "KYC verification required"
}

Files affected:

  • New: tests/integration_test.rs

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions