Add test coverage for slashing mechanics (#20)#31
Merged
meshackyaro merged 1 commit intoJun 23, 2026
Merged
Conversation
Implements a new `trustflow` Soroban contract crate that introduces juror staking and a dispute-resolution system where minority voters are penalised via stake slashing. Adds 13 unit tests that simulate multiple dispute rounds with a malicious juror and verify their balance decreases monotonically after each round.
meshackyaro
approved these changes
Jun 23, 2026
meshackyaro
left a comment
Contributor
There was a problem hiding this comment.
Good job and well done
10 tasks
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
Closes #20
contracts/trustflowSoroban contract crate implementing juror staking and a dispute-resolution system with stake slashingslash_bps / 10_000of their current stake (default 10%)stake * 0.9^3 ≈ 7 290(verified numerically)Test plan
test_stake_and_unstake– basic staking lifecycletest_stake_zero_rejected– invalid amount guardtest_unstake_insufficient_funds– overdraw guardtest_cast_vote_requires_stake– voting gatetest_cast_vote_duplicate_rejected– double-vote guardtest_single_round_malicious_juror_slashed– single-round 10% slashtest_honest_jurors_not_slashed– majority voters unaffectedtest_multiple_rounds_malicious_juror_balance_decreases– core acceptance criterion: 3 rounds, stake decreases each roundtest_four_rounds_progressive_slashing– 4 rounds at 20% slash ratetest_tie_favours_depositor– tie-breaking rule and minority slashtest_resolve_dispute_no_votes_fails– edge case: no votes casttest_resolve_already_resolved_fails– double-resolve guardtest_slash_cannot_exceed_stake– 100% slash rate floors at zero, not negativeAll 13 tests pass.
cargo fmtandcargo clippy --workspace --libboth clean.