Skip to content

test: add invariant proptest for betting (buffer #9)#1018

Open
Toyosi5566 wants to merge 1 commit into
Predictify-org:masterfrom
Toyosi5566:task/betting-proptest
Open

test: add invariant proptest for betting (buffer #9)#1018
Toyosi5566 wants to merge 1 commit into
Predictify-org:masterfrom
Toyosi5566:task/betting-proptest

Conversation

@Toyosi5566

Copy link
Copy Markdown

Overview

This PR adds property-based tests for betting state invariants, following the same pattern as voting_invariants.rs. Tests operate at the unit level on BetStorage and Market types, avoiding token/oracle infrastructure.

Related Issue

Closes #865

Changes

  • [ADD] src/betting_invariants.rs — proptest suite with 7 invariant tests
  • [MODIFY] src/lib.rs — register betting_invariants test module

Test Coverage

Test Invariant
prop_sequential_bets_conserve_stake Stake conservation holds after each sequential bet
prop_duplicate_user_bet_prevented Duplicate user bets don't inflate stats
prop_cancel_bet_conserves_invariants Cancel correctly decrements stats and marks bet
prop_resolve_bets_status_transition Valid status transitions: Active → Won/Lost
prop_bet_amounts_within_bounds All bet amounts respect MIN/MAX_BET_AMOUNT
prop_large_bet_set_conserves_stake Invariant holds for 50–200 bets
prop_multi_user_multi_outcome_invariants Multiple users/outcomes with correct bettor counts

Verification Results

cargo check — passes
Acceptance Criteria Status
Implementation matches description ✅ Buffer #9 betting invariant proptest added
Tests added and passing ✅ 7 proptest cases with 1000 iterations each
Docs updated ✅ N/A — no API changes

Add property-based tests for betting state invariants:
- Stake conservation across sequential bets
- Duplicate user bet prevention
- Cancel bet stat consistency
- Resolve bet status transitions
- Bet amount bounds validation
- Large bet set invariants
- Multi-user multi-outcome invariants

Closes Predictify-org#865
@drips-wave

drips-wave Bot commented Jul 26, 2026

Copy link
Copy Markdown

@Toyosi5566 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

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.

Add invariant proptest for betting (buffer #9)

1 participant