Skip to content

Feat(contracts): implement subscription contract invariant testing suite#320

Merged
Smartdevs17 merged 3 commits intomainfrom
feat-invariant-fixed
Apr 25, 2026
Merged

Feat(contracts): implement subscription contract invariant testing suite#320
Smartdevs17 merged 3 commits intomainfrom
feat-invariant-fixed

Conversation

@Smartdevs17
Copy link
Copy Markdown
Owner

Closes #292

morelucks and others added 3 commits April 23, 2026 01:10
Closes #221

- Define 10 key invariants covering plan/subscription count monotonicity,
  total_paid conservation, plan subscriber count accuracy, paused_at
  consistency, refund amount bounds, total_collected non-negativity, and
  user subscription index consistency
- Implement deterministic scenario tests for all lifecycle transitions:
  basic flow, multi-plan/subscriber, cancel, pause/resume, auto-resume,
  refund approve/reject, subscription transfer, plan deactivation,
  multiple charges, all billing intervals, and authorization rules
- Add property-based fuzz tests using proptest (50 cases each):
  random action sequences, plan count equals create_plan calls,
  subscription count equals subscribe calls, total_paid equals
  price x charge_count
- Add state-machine invariant tests (30 cases) covering the full
  lifecycle with weighted random actions including pause, resume,
  cancel, refund, and time advancement
- Register real Stellar asset token contracts in ContractHandler so
  charge_subscription token transfers succeed in tests
- Add [[test]] entries in Cargo.toml for invariants and integration_soroban
- Add .github/workflows/invariant-tests.yml CI job running invariant
  tests on every contracts/ change, with an extended 1000-case fuzz
  run on pushes to main/dev
- Update contracts/.gitignore to exclude generated test_snapshots/ and
  *.proptest-regressions files
@Smartdevs17 Smartdevs17 merged commit 2fe107d into main Apr 25, 2026
2 of 17 checks passed
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.

2 participants