mad-turmoil

Crates.iomad-turmoil
lib.rsmad-turmoil
version0.1.0
created_at2025-04-04 00:48:54.746454+00
updated_at2025-04-04 00:48:54.746454+00
descriptionmadsim-inspired determinism for turmoil-based simulation tests
homepage
repository
max_upload_size
id1619210
size35,240
Shikhar Bhushan (shikhar)

documentation

README

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...
}
Commit count: 0

cargo fmt