tesser-test-utils
tesser-test-utils provides a programmable Bybit v5 mock exchange that can be used to drive
end-to-end tests for the Tesser runtime. It spins up lightweight REST and WebSocket servers that
emulate the portions of the API exercised by tesser-cli live run, allowing strategies, execution
clients, and portfolio persistence to be verified without touching the real exchange.
Features
- Stateful mock exchange — Seed accounts with balances and positions, inspect fills and
open orders, and mutate shared state from tests via
MockExchangeState. - Bybit-compatible REST — Implements
/v5/order/create,/v5/order/cancel,/v5/position/list,/v5/account/wallet-balance,/v5/execution/list, and/v5/order/realtimewith header-based HMAC verification identical to the real API. - Scriptable WebSocket streams — Public subscriptions stream canned trades, candles, and order books, while the private stream echoes order/execution events pushed via the shared state.
- Scenario engine — Queue deterministic behaviors (delays, failures, staged fills, custom private events) that are consumed when REST calls or WebSocket events fire.
Quick start
use Result;
use Utc;
use Decimal;
use ;
use ;
async
In integration tests you can combine the mock with tesser_cli::live::run_live_with_shutdown to
execute strategies end-to-end. Use the ScenarioManager to queue how the mock should respond to
order placements (delays, failures, custom JSON payloads, or multi-step fills). You can also query
the shared state after the run to assert on balances, positions, or order history without touching
SQLite.
When to use it
- Exercising
tesser-cli live runcontrol-plane logic (bootstrap, reconciliation, signal routing). - Verifying new execution algorithms or strategy behaviors with deterministic fills.
- Reproducing edge cases such as WebSocket drops, reconciliation mismatches, or staged fills.
Because the mock exchange runs entirely inside the test process, it is fast enough to run in CI and
does not require external secrets or network connectivity. Add tesser-test-utils as a
dev-dependency and start scripting your own scenarios.