Skip to content

Add a refund-after-dispute resolution test verifying escrow refund finality and investment status alignment #1324

@Baskarayelu

Description

@Baskarayelu

📋 Description

When a dispute resolves against the business, the natural remedy is to refund the investor via refund_escrow_funds in quicklendx-contracts/src/escrow.rs, which moves the escrow Held -> Refunded, the invoice to Refunded, the accepted bid to Cancelled, and the investment to Refunded. The dispute lifecycle in dispute.rs and refund mechanics are each tested separately, but the combined path — dispute resolved then escrow refunded — has no end-to-end consistency test.

Why this matters: the dispute-to-refund path is where investor protection actually pays out, and it touches four pieces of state that must all move together. A test that opens a dispute, resolves it, refunds, and asserts every status aligns (and that no second refund/settle can follow) proves the remedy is atomic and final — exactly the property a disputing investor relies on.

🎯 Requirements & Context

Functional requirements

  • Add quicklendx-contracts/src/test_dispute_refund_flow.rs driving: fund -> create dispute -> put under review -> resolve -> refund escrow.
  • Assert post-refund: invoice Refunded, escrow Refunded, bid Cancelled, investment Refunded, dispute Resolved — all consistent.
  • Assert finality: after refund, settle_invoice and a second refund_escrow_funds both fail; no double disbursement (verify token balance delta equals one refund).
  • Assert the investor (not the business) received the refunded amount.

Context & constraints

🛠️ Suggested Execution

1. Fork & branch

git checkout -b test/dispute-refund-flow

2. Implement changes

  • Build the full path and the multi-module consistency + finality assertions.
  • Doc-comment the atomic-remedy invariant.

3. Test & commit

cargo test -p quicklendx-contracts test_dispute_refund_flow -- --nocapture
  • Edge cases: refund attempted while dispute still UnderReview; refund by admin vs business; double refund rejected; settle after refund rejected.

Example commit message

test(disputes): add end-to-end dispute-resolution-then-refund consistency and finality suite

Verifies invoice/escrow/bid/investment/dispute statuses align after refund and that the
remedy is final with no double disbursement.

✅ Acceptance Criteria & Guidelines

Requirement Target
Full dispute-to-refund path covered Required
Cross-module status alignment asserted Required
Finality + no-double-spend asserted Required
Coverage of refund/dispute branches ≥ 95%
Docs + doc comments Required
cargo test + cargo clippy clean Required
Timeframe 96 hours from assignment

💬 Community & Support

Questions, design discussion, and help getting your environment running — join the QuickLendX contributor community on Discord: https://discord.gg/VpngvTjWa

Please drop a note in the channel when you pick this up so we can avoid duplicate work and unblock you fast. Clear communication during the PR keeps the review fast and friction-free. 🚀

Metadata

Metadata

Assignees

Labels

Type

No fields configured for Task.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions