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.
Add tests for the dispute resolution_payouts split math in dispute.rs
Description
contracts/escrow/src/dispute.rsimplementsresolution_payoutsforFullRefund,PartialRefund(70/30),FullPayout, andSplit(client, freelancer), plusfinal_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, theSplittotal-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
DisputeResolutionvariant against a range ofavailablebalances, asserting(client_payout, freelancer_payout)and that the two always sum toavailable.PartialRefundrounding at odd amounts (e.g. available = 7 → 30% truncation).Splitrejection when totals mismatch or amounts are negative (InvalidDisputeSplit).AccountingInvariantViolatedpath whenavailablewould be negative, and verifyfinal_status_after_resolutionreturnsRefundedonly on full refund.Suggested execution
git checkout -b test/contracts-dispute-payoutscontracts/escrow/src/dispute.rs— no logic change expected; only add a#[cfg(test)]module if needed.contracts/escrow/src/test/dispute.rs— table-driven assertions over all variants.docs/escrow/README.md.///) where helpful.Test and commit
cargo fmt --all -- --check,cargo build, andcargo test.cargo testoutput in the PR description.Example commit message
test: add resolution_payouts split-math coverage for dispute.rsGuidelines
Community & contribution rewards