test: add proptest coverage to tholos-v2 - #111
Merged
collinsezedike merged 1 commit intoAug 24, 2026
Merged
Conversation
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
approved these changes
Aug 24, 2026
collinsezedike
left a comment
Collaborator
There was a problem hiding this comment.
@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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a
proptest!suite tocontracts/tholos-v2/src/test.rs, mirroring the structure and in-process (fork: false) configurationcontracts/tholos/src/test.rsalready uses for itsproptest_vote_counting/proptest_initialize_boundsmodules.What's covered
A new
proptest_settlementmodule generates a random number (0-6) of third-party voters with random weights (realistic range:min_resolution_bond..=500_000, well undermax_position/max_total_weight), random sides, and random reveal participation, runs the dispute through toResolved(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 (viaget_credit) exactly equalseligible_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 recipientsettledocuments), 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_outcomecan't lazily open theRevealphase 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 realreveal()call happens before it can force-close a round with unrevealed weight outstanding).Testing
cargo fmt --checkcargo clippy --workspace --all-targets --locked -- -D warningscargo test --workspace --locked(100/100 passing intholos-v2, including the 2 new proptest functions each running 96 generated cases)cargo build --workspace --lib --target wasm32v1-none --release --lockedCloses #106