Commit df426e1
committed
Add stateful property-based tests using rapid
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.1 parent df0b95b commit df426e1
6 files changed
Lines changed: 442 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
45 | 45 | | |
46 | 46 | | |
47 | 47 | | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
48 | 55 | | |
49 | 56 | | |
50 | 57 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
| 2 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| 8 | + | |
8 | 9 | | |
9 | 10 | | |
10 | 11 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
43 | 43 | | |
44 | 44 | | |
45 | 45 | | |
| 46 | + | |
| 47 | + | |
0 commit comments