Skip to content

Add tests for the dispute resolution_payouts split math in dispute.rs #465

Description

@mikewheeleer

Add tests for the dispute resolution_payouts split math in dispute.rs

Description

contracts/escrow/src/dispute.rs implements resolution_payouts for FullRefund, PartialRefund (70/30), FullPayout, and Split(client, freelancer), plus final_status_after_resolution. This pure money-splitting logic is the most security-sensitive code in the contract, yet it has no dedicated unit tests covering the 70/30 rounding, the Split total-must-equal-available rule, negative-split rejection, and the accounting-invariant guard.

This issue adds focused unit tests for the dispute payout calculations.

Requirements and context

  • Repository scope: Talenttrust/Talenttrust-Contracts only.
  • Test each DisputeResolution variant against a range of available balances, asserting (client_payout, freelancer_payout) and that the two always sum to available.
  • Cover PartialRefund rounding at odd amounts (e.g. available = 7 → 30% truncation).
  • Cover Split rejection when totals mismatch or amounts are negative (InvalidDisputeSplit).
  • Cover the AccountingInvariantViolated path when available would be negative, and verify final_status_after_resolution returns Refunded only on full refund.

Suggested execution

  • Fork the repo and create a branch
  • git checkout -b test/contracts-dispute-payouts
  • Implement changes
  • Test and commit

Test and commit

  • Run cargo fmt --all -- --check, cargo build, and cargo test.
  • Cover edge cases: zero available, odd-amount PartialRefund, mismatched Split.
  • Include full cargo test output in the PR description.

Example commit message

test: add resolution_payouts split-math coverage for dispute.rs

Guidelines

  • Minimum 95 percent test coverage for impacted modules.
  • Clear, reviewer-focused documentation.
  • Timeframe: 96 hours.

Community & contribution rewards

  • 💬 Join the TalentTrust community on Discord for questions, reviews, and faster merges: https://discord.gg/WqnGpcPx
  • ⭐ This is a GrantFox OSS / Official Campaign task and may be rewarded. When your PR is merged you'll be prompted to rate the project — if this issue and the maintainers helped you ship, we'd be grateful for a 5-star rating. Clear questions in Discord and tidy, well-tested PRs are the fastest path to a merge and a reward.

Metadata

Metadata

Assignees

Labels

Fields

No fields configured for Feature.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions