Files
dex/tests
zeekay 8d77873ef4 test: DEX chaos tests (8 fault injection) + performance benchmarks
Chaos tests (Jepsen-style):
- OrderMatchingAtomicity: verify buy+sell match is atomic
- CLOBPriceTimePriority: 100 orders verify FIFO at same price
- PartitionedMatchingEngine: no phantom fills after partition
- ZMQMessageDelivery: no lost/duplicate orders under transport drops
- NATSFailover: order flow survives disconnect/reconnect
- ConcurrentCancelFill: race cancel vs fill, exactly one wins
- MarketOrderSlippage: VWAP within 10% of best ask
- GatewayLoadShedding: 10K orders, no panics, consistent book

Benchmarks:
- OrderInsert: ~773K ops/sec, 1294ns/order
- OrderMatch: ~15K matches/sec, 66us/match
- CancelOrder: ~608K ops/sec, 0 allocs
- BatchOrders: ~442K orders/sec (1000-order batches)
- ConcurrentMatching: ~16K markets/sec across 100 parallel books

Known: engine has data races in AddOrder.LastOrderID (non-atomic
write after atomic.Add) exposed by concurrent ZMQ/LoadShedding tests.
2026-04-07 01:45:42 -07:00
..