Skip to content

Add multi-outcome tie-resolution tests for resolve_market_with_ties payout splitting #593

@greatest0fallt1me

Description

@greatest0fallt1me

Description

Multi-outcome markets can resolve to several winning outcomes and split the pool, but this path needs more explicit coverage. In contracts/predictify-hybrid/src/resolution.rs, ResolvedOutcomeSummary carries num_winning_outcomes (the "tie split divisor") and compute_winning_total_for_market aggregates the winning stake across winning_outcomes. There is an existing tie_resolution_tests module enabled in lib.rs, but the payout-split arithmetic for N-way ties should be verified end to end. This issue extends those tests.

Requirements and context

  • Resolution code: ResolvedOutcomeSummary and num_winning_outcomes (resolution.rs:518), compute_winning_total_for_market (resolution.rs:541), and the resolve_market_with_ties entrypoint path.
  • Payout division for ties must split the distributable pool by the number of winning outcomes/winners; verify the divisor is applied correctly and that rounding/remainder is handled deterministically.
  • The existing module contracts/predictify-hybrid/src/tie_resolution_tests.rs is wired in (lib.rs:133); extend it rather than creating a new one.
  • Non-functional: tests must be deterministic and cover both balanced and skewed stake distributions across the tied outcomes.
  • Confirm that a single-winner market still pays the full pool (no off-by-one in the divisor).

Acceptance criteria

  • A 2-way tie test asserts each winning side receives the correct split.
  • A 3+-way tie test asserts correct division by num_winning_outcomes.
  • A skewed-stake tie test asserts per-bettor payouts are proportional within the winning set.
  • A single-winner control test asserts the full distributable pool is paid (divisor == 1).
  • Rounding/remainder behavior is asserted explicitly (no value created or lost beyond documented rounding).
  • cargo fmt, cargo clippy, and cargo test pass.

Suggested execution

1. Fork the repo and create a branchgit checkout -b feature/multi-outcome-tie-tests.
2. Implement changes — none in production code unless a rounding ambiguity requires a minimal, documented fix in contracts/predictify-hybrid/src/resolution.rs.
3. Write/extend tests — extend contracts/predictify-hybrid/src/tie_resolution_tests.rs (Soroban testutils).
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: cover multi-outcome tie payout splitting in resolve_market_with_ties

Guidelines

Target ≥90% coverage of the tie payout paths. Cross-reference and, if needed, update docs/designs/outcome_selection.md and API_DOCUMENTATION.md (Resolution Management) to document the rounding rule. Timeframe: 96 hours.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions