Skip to main content

fusee_sim/
lib.rs

1//! Deterministic simulation testing for Fusee.
2//!
3//! The real shard runtime, journal machines and Rust SDK run inside one
4//! thread under a seeded scheduler. The disk tears writes, loses unflushed
5//! data at crashes and fails flushes; messages between shards are delayed
6//! and lost with the process. A mock external service logs every call. A
7//! seed reproduces a run exactly.
8//!
9//! The checkers, after every recovery and at the end:
10//!
11//! - every acknowledged start and signal exists;
12//! - a result once reported never changes;
13//! - no external call was made with inputs the recovered journal
14//!   contradicts (one idempotency key, two different inputs);
15//! - once faults stop, every workflow finishes.
16//!
17//! [`scenario`] runs your own workflows the same way.
18
19pub mod disk;
20pub mod env;
21pub mod rng;
22pub mod scenario;
23pub mod world;
24
25pub use scenario::Scenario;
26pub use world::{Failure, Report, SimConfig, run_seed};
27
28/// Waits `d` of simulated time, inside a step body under the simulator.
29pub async fn sleep(d: std::time::Duration) {
30    world::sim_sleep(d.as_millis() as u64).await
31}