Skip to content

test: add proptest coverage to tholos-v2 - #111

Merged
collinsezedike merged 1 commit into
drydocs:mainfrom
Christopherdominic:feat/106-proptest-coverage-tholos-v2
Aug 24, 2026
Merged

test: add proptest coverage to tholos-v2#111
collinsezedike merged 1 commit into
drydocs:mainfrom
Christopherdominic:feat/106-proptest-coverage-tholos-v2

Conversation

@Christopherdominic

Copy link
Copy Markdown
Contributor

Summary

Adds a proptest! suite to contracts/tholos-v2/src/test.rs, mirroring the structure and in-process (fork: false) configuration contracts/tholos/src/test.rs already uses for its proptest_vote_counting/proptest_initialize_bounds modules.

What's covered

A new proptest_settlement module generates a random number (0-6) of third-party voters with random weights (realistic range: min_resolution_bond..=500_000, well under max_position/max_total_weight), random sides, and random reveal participation, runs the dispute through to Resolved (whichever terminal cause the reveal pattern actually produces), then checks:

  • prop_settlement_payouts_conserve_pool_and_match_formula — settlement pro-rata forfeiture splitting: settle()'s own return value matches the documented formula (amount + floor(amount * forfeited_pool / recipient_weight)) exactly for every position, no payout ever exceeds principal plus the entire forfeited pool, and the sum of every final credited balance (via get_credit) exactly equals eligible_total — payouts sum correctly and never exceed the pool, regardless of position weight distribution.
  • prop_dust_credited_to_exactly_one_recipient — dust routing: the floor-division remainder from pro-rata splitting is credited to exactly one address (the deterministic dust recipient settle documents), never split across recipients, never dropped, and never paid to more than one address.

Anti-snipe deadline extension (the issue's optional secondary target) isn't included — the two required properties above turned out to need a fair amount of scaffolding on their own (see the module's doc comment for one non-obvious wrinkle: resolve_outcome can't lazily open the Reveal phase and then fail to fully close it in the same call without Soroban rolling back that phase transition too, so the harness has to guarantee at least one real reveal() call happens before it can force-close a round with unrevealed weight outstanding).

Testing

  • cargo fmt --check
  • cargo clippy --workspace --all-targets --locked -- -D warnings
  • cargo test --workspace --locked (100/100 passing in tholos-v2, including the 2 new proptest functions each running 96 generated cases)
  • cargo build --workspace --lib --target wasm32v1-none --release --locked

Closes #106

Adds a proptest_settlement module to contracts/tholos-v2/src/test.rs,
mirroring the in-process (fork: false) proptest harness structure
contracts/tholos/src/test.rs already uses for its
proptest_vote_counting/proptest_initialize_bounds modules.

Two properties, generated over a random number of third-party voters
with random weights, sides, and reveal participation:

- prop_settlement_payouts_conserve_pool_and_match_formula: settle()'s
  own return value matches the documented pro-rata formula
  (amount + floor(amount * forfeited_pool / recipient_weight)) exactly
  for every position, no payout exceeds principal plus the entire
  forfeited pool, and the sum of every final credited balance equals
  eligible_total exactly.
- prop_dust_credited_to_exactly_one_recipient: the floor-division
  remainder lands entirely on the deterministic dust recipient (the
  winning asserter or disputer) and nowhere else, regardless of the
  weight distribution.

Closes drydocs#106

@collinsezedike collinsezedike left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Christopherdominic thank you for the contribution. This looks good, there is nothing to flag.
If you're looking for another issue to pick up, #72 is open and unassigned.
Merging now.

@collinsezedike
collinsezedike merged commit 4976bf3 into drydocs:main Aug 24, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature] Add proptest coverage to tholos-v2

2 participants