feature/streak-increment-tests
#121
Three new test modules appended to contract/src/lib.rs:
Property and unit tests covering all six streak increment invariants:
| Test | Invariant | Cases |
|---|---|---|
test_streak_starts_at_zero_and_first_win_reaches_tier_1 |
I-4: fresh game starts at 0, first win → tier 1 | deterministic |
test_no_tier_is_skipped_across_all_transitions |
I-3: every tier reachable in exactly one step | deterministic |
test_streak_increments_past_tier_4_without_reset |
I-5: counter keeps going past cap, no reset | deterministic |
test_single_win_increments_by_exactly_one_deterministic |
I-1: +1 per win, spot-checked values | deterministic |
prop_single_win_increments_streak_by_exactly_one |
I-1: ∀ streak ∈ [0, u32::MAX), win → streak+1 | 500 |
prop_streak_progression_is_strictly_monotonic |
I-2: k wins from any start → start+k, no gaps | 500 |
prop_no_multiplier_tier_is_skipped |
I-3: tier advances by exactly 1 for streaks 0–3 | 500 |
prop_streak_past_tier_4_stays_capped |
I-5: multiplier stays at 10x cap for streak ≥ 4 | 500 |
prop_payout_strictly_increases_with_streak_tier |
I-6: payout(streak+1) > payout(streak) for tiers 1–3 | 500 |
prop_new_game_streak_always_initializes_to_zero |
streak=0 on every new game regardless of inputs | 500 |
prop_k_wins_from_zero_yields_streak_k_and_correct_tier |
k wins from 0 → streak k, tier min(k,4) | 500 |
Validates all pure helpers are referentially transparent:
prop_multiplier_is_deterministicprop_payout_is_deterministicprop_commitment_verification_is_deterministicprop_wrong_secret_never_verifiesprop_multiplier_tier_boundaries_are_stableprop_zero_wager_payout_is_zero
Validates the commit-reveal scheme resists unilateral manipulation:
prop_commitment_round_tripprop_distinct_secrets_produce_distinct_commitmentsprop_tampered_commitment_fails_verificationprop_tampered_secret_fails_verificationprop_commitment_verification_is_not_symmetric
I-1 A single win increments streak by exactly 1 (never 0, never 2+).
I-2 Streak progression is strictly monotonic: streak_n+1 == streak_n + 1.
I-3 No multiplier tier is skipped: every tier 1→2→3→4 is reachable in
exactly one step from the previous tier.
I-4 Streak starts at 0 on a fresh game and reaches tier 1 on the first win.
I-5 Streak saturates at tier 4+ — the multiplier is capped but the counter
continues to increment (no overflow, no reset).
I-6 Payout at streak N+1 is strictly greater than payout at streak N for
any fixed wager and fee.
The cargo check --tests pass also surfaced a pre-existing type mismatch:
env.crypto().sha256() returns Hash<32>, not BytesN<32>, in soroban-sdk 22.0.11.
Fixed in:
verify_commitment(production code)start_game—contract_randomfield assignmentdummy_commitment/dummy_commitment_proptest helperstest_verify_commitmentunit test
warning: unused import: `token` (pre-existing)
warning: associated function `delete_player_game` is never used (pre-existing)
warning: hiding a lifetime that's elided elsewhere (pre-existing)
Finished `dev` profile [unoptimized + debuginfo] target(s) in 12.18s
Zero new warnings introduced. Zero errors.
# Full suite
cargo test
# New module only
cargo test --lib streak_increment_tests::
cargo test --lib outcome_determinism_tests::
cargo test --lib randomness_regression_tests::Note: a complete native linker (
link.exeon MSVC ordlltool.exeon GNU) must be present to link the test binary. The code passescargo check --testscleanly on the current machine; runcargo testin a CI environment or after installing the missing linker component.