Description
The dispute subsystem in contracts/predictify-hybrid/src/disputes.rs is substantial but several core rules lack dedicated coverage, especially the stake-weighted tally and the exact-tie rule. DisputeUtils::calculate_stake_weighted_outcome resolves by comparing total_support_stake vs total_against_stake and, per its own comment, resolves an exact tie to false (oracle result stands). This issue adds a focused test module exercising the full dispute lifecycle and its edge rules.
Requirements and context
- Functions under test:
DisputeManager::process_dispute (disputes.rs:822), vote_on_dispute (disputes.rs:1406), calculate_dispute_outcome (disputes.rs:1509), resolve_dispute (disputes.rs:984), and DisputeUtils::calculate_stake_weighted_outcome.
- Rules to verify: minimum stake (
MIN_DISPUTE_STAKE), the dispute voting window (voting_start/voting_end on DisputeVoting), stake-weighted tally, the exact-tie rule (ties resolve to false), and double-dispute prevention (Error::AlreadyDisputed via has_user_disputed).
- Verify events are emitted (
emit_dispute_created, emit_dispute_resolved, dispute vote events) for the lifecycle.
- Non-functional: use Soroban testutils and ledger time manipulation to test window boundaries; keep tests deterministic.
- Re-enable or add the module cleanly in
lib.rs (the dispute_stake_tests under tests/ is currently not wired in).
Acceptance criteria
Suggested execution
1. Fork the repo and create a branch — git checkout -b feature/dispute-resolution-tests.
2. Implement changes — none required in production code; if a testability gap is found, make a minimal, justified change in contracts/predictify-hybrid/src/disputes.rs.
3. Write/extend tests — extend contracts/predictify-hybrid/src/tests/dispute_stake_tests.rs (wire it into lib.rs) and/or resolution_delay_dispute_window_tests.rs.
4. Test and commit
cargo fmt --all -- --check
cargo clippy --all-targets --all-features -- -D warnings
cargo test -p predictify-hybrid
Example commit message
test: add comprehensive dispute lifecycle and tie-rule coverage
Guidelines
Target ≥90% line/branch coverage of the dispute resolution paths. Cross-link the documented tie rule with docs/designs/outcome_selection.md and update API_DOCUMENTATION.md (Voting & Disputes) if behavior is clarified. Timeframe: 96 hours.
Description
The dispute subsystem in
contracts/predictify-hybrid/src/disputes.rsis substantial but several core rules lack dedicated coverage, especially the stake-weighted tally and the exact-tie rule.DisputeUtils::calculate_stake_weighted_outcomeresolves by comparingtotal_support_stakevstotal_against_stakeand, per its own comment, resolves an exact tie tofalse(oracle result stands). This issue adds a focused test module exercising the full dispute lifecycle and its edge rules.Requirements and context
DisputeManager::process_dispute(disputes.rs:822),vote_on_dispute(disputes.rs:1406),calculate_dispute_outcome(disputes.rs:1509),resolve_dispute(disputes.rs:984), andDisputeUtils::calculate_stake_weighted_outcome.MIN_DISPUTE_STAKE), the dispute voting window (voting_start/voting_endonDisputeVoting), stake-weighted tally, the exact-tie rule (ties resolve tofalse), and double-dispute prevention (Error::AlreadyDisputedviahas_user_disputed).emit_dispute_created,emit_dispute_resolved, dispute vote events) for the lifecycle.lib.rs(thedispute_stake_testsundertests/is currently not wired in).Acceptance criteria
MIN_DISPUTE_STAKEand acceptance at/above it.false(oracle stands).Error::AlreadyDisputed.cargo fmt,cargo clippy, andcargo testpass with the module enabled.Suggested execution
1. Fork the repo and create a branch —
git checkout -b feature/dispute-resolution-tests.2. Implement changes — none required in production code; if a testability gap is found, make a minimal, justified change in
contracts/predictify-hybrid/src/disputes.rs.3. Write/extend tests — extend
contracts/predictify-hybrid/src/tests/dispute_stake_tests.rs(wire it intolib.rs) and/orresolution_delay_dispute_window_tests.rs.4. Test and commit
cargo fmt --all -- --check cargo clippy --all-targets --all-features -- -D warnings cargo test -p predictify-hybridExample commit message
Guidelines
Target ≥90% line/branch coverage of the dispute resolution paths. Cross-link the documented tie rule with
docs/designs/outcome_selection.mdand updateAPI_DOCUMENTATION.md(Voting & Disputes) if behavior is clarified. Timeframe: 96 hours.