mad-turmoil 0.2.1

madsim-inspired determinism for turmoil-based simulation tests
Documentation

mad-turmoil

madsim-inspired determinism for turmoil-based simulation tests

See blog post

Setup

Make sure you are only depending on this crate for simulation binaries!

fn main() -> eyre::Result<()> {
    let rng_seed = std::env::var("DST_SEED")?.parse()?;

    // Taming randomness...

    let mut rng = StdRng::seed_from_u64(rng_seed);
    mad_turmoil::rand::set_rng(rng.clone());
    assert_eq!(rng.next_u64(), mad_turmoil::rand::get_rng().next_u64());

    // Additionally, if you are using fastrand (possibly transitively!)
    fastrand::seed(rng_seed);

    // Taming time...

    let _tokio_time_guard = mad_turmoil::time::SimClocksGuard::init();

    // Go forth and create turmoil...
}