Skip to content

test(subscription_renewal): property-test the renewal state machine with proptest - #1379

Merged
Calebux merged 2 commits into
Calebux:mainfrom
Classictowo:fix/1238-proptest-renewal-state-machine
Sep 1, 2026
Merged

test(subscription_renewal): property-test the renewal state machine with proptest#1379
Calebux merged 2 commits into
Calebux:mainfrom
Classictowo:fix/1238-proptest-renewal-state-machine

Conversation

@Classictowo

Copy link
Copy Markdown

Summary

Closes #1238. Implements the acceptance criteria for property-testing the subscription renewal state machine with \proptest.

Changes

  • **\subscription_renewal/src/fuzz.rs**: added \ uzz_renewal_state_machine, a proptest state-machine harness that generates random sequences of \init_sub, \�pprove_renewal,
    enew, \cancel_sub, \set_window\ and \set_user_cap, and asserts every documented invariant after each generated operation:
    1. every accepted renewal respects the per-subscription spending cap
    2. cumulative \UserSpent\ never exceeds the global \UserCap\ as a result of a renewal
    3. at most one successful renewal per billing window (cycle guard)
    4. \SubscriptionState\ transitions follow the declared graph
    5. the renewal lock is never held after a completed call
  • **\subscription_renewal/src/lib.rs**: added a crate-level doc comment documenting the invariant list (required by the acceptance criteria).
  • **.github/workflows/contracts.yml**: wired the suite into CI with a fixed \PROPTEST_SEED\ and a bounded \PROPTEST_CASES=8\ on PRs, added a nightly \ uzz-nightly\ job running an extended \PROPTEST_CASES=512, and fixed the \PROPTYST_CASES\ typo.
  • **\contracts/FUZZING_EDGE_CASES.md**: documented the new state-machine test and invariants.

Verification

  • Locally verified by careful review against the contract API and existing test patterns.
  • CI runs the fuzz/state-machine suite on this PR (bounded, fixed-seed) and nightly (extended).

…Calebux#1238)

Add a proptest state-machine harness that drives random sequences of
init_sub, approve_renewal, renew, cancel_sub, set_window and set_user_cap,
asserting the documented renewal invariants after every generated operation:

1. every accepted renewal respects the per-subscription spending cap
2. cumulative UserSpent never exceeds the global UserCap from a renewal
3. at most one successful renewal per billing window (cycle guard)
4. SubscriptionState transitions follow the declared graph
5. the renewal lock is never held after a completed call

The invariant list is documented in a crate-level doc comment (lib.rs) and
mirrored in fuzz.rs. Wire the suite into CI with a fixed PROPTEST_SEED and a
bounded PROPTEST_CASES on PRs, plus a nightly extended-run job; document the
suite in FUZZING_EDGE_CASES.md and fix the PROPTYST_CASES typo.
@Classictowo
Classictowo requested a review from Calebux as a code owner August 31, 2026 11:01
@drips-wave

drips-wave Bot commented Aug 31, 2026

Copy link
Copy Markdown

@Classictowo 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

Repair pre-existing corruption in contracts.yml (from an earlier bad merge)
that made the file invalid YAML, so GitHub Actions never registered or ran
the workflow:

- remove duplicate top-level 'name:' key (invalid duplicate-key YAML)
- fix concurrency.group expression spaces (${{ ... }})
- fix mangled shell: wasm glob ${#wasm_files[@]} and size=$(wc -c < ...)

This unblocks CI for the contracts, so the proptest renewal state-machine
harness (and its fixed-seed PR run + nightly extended run) can actually
execute and verify the Calebux#1238 fix.
@Calebux
Calebux merged commit ac58bf9 into Calebux:main Sep 1, 2026
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.

[v2][subscription_renewal] Property-test the renewal state machine with proptest

3 participants