Skip to content

Add stateful property-based tests using rapid#175

Draft
pgr0ss wants to merge 1 commit intomainfrom
pgross/add-stateful-property-based-tests-using-rapid
Draft

Add stateful property-based tests using rapid#175
pgr0ss wants to merge 1 commit intomainfrom
pgross/add-stateful-property-based-tests-using-rapid

Conversation

@pgr0ss
Copy link
Copy Markdown
Owner

@pgr0ss pgr0ss commented Apr 7, 2026

Introduces two property-based tests using rapid's state machine support:

TestLedgerStateMachine generates random sequences of actions (create account, create transfer, batch transfers, constrained accounts, expected-failure transfers) and checks five invariants after every step:

  • Entry chain consistency (prev + amount = curr for each entry)
  • Zero-sum balance (sum of all balances per currency is zero)
  • Version tracking (account version matches entry count)
  • Two entries per transfer (debit + credit summing to zero)
  • Entry version monotonicity (strictly increasing, no gaps)

TestLedgerConcurrentStateMachine runs parallel goroutines performing transfers against shared accounts, then verifies the same invariants hold — stress-testing the sorted-ID locking strategy.

@pgr0ss pgr0ss force-pushed the pgross/add-stateful-property-based-tests-using-rapid branch from 3f1384a to df426e1 Compare April 7, 2026 19:26
Introduces two property-based tests using rapid's state machine support:

TestLedgerStateMachine generates random sequences of actions (create
account, create transfer, batch transfers, constrained accounts,
expected-failure transfers) and checks five invariants after every step:
- Entry chain consistency (prev + amount = curr for each entry)
- Zero-sum balance (sum of all balances per currency is zero)
- Version tracking (account version matches entry count)
- Two entries per transfer (debit + credit summing to zero)
- Entry version monotonicity (strictly increasing, no gaps)

TestLedgerConcurrentStateMachine runs parallel goroutines performing
transfers against shared accounts, then verifies the same invariants
hold — stress-testing the sorted-ID locking strategy.
@pgr0ss pgr0ss force-pushed the pgross/add-stateful-property-based-tests-using-rapid branch from df426e1 to 3bc93d2 Compare April 8, 2026 18:10
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.

1 participant