Sleep in Turmoil

I am trying to use turmoilto test my application and encountered some unexpected behavior. I have reduced it to this example:

use std::time::Duration;
use tokio::time::sleep;

fn main() {
    let mut sim = turmoil::Builder::new()
        .simulation_duration(Duration::from_secs(10))
        .build();
    sim.host("sleeper", move || async move {
        println!("before sleep");
        sleep(Duration::from_secs(1)).await;
        println!(" after sleep");
        Ok(())
    });
    sim.run().unwrap();
}

I would expect it to print both lines, but I only get "before sleep". This is my first time using turmoil, so I am assuming I am doing something wrong here.

It looks like turmoil shuts down the simulation once there are no clients left. Since I don't create any, it shuts down right away.

2 Likes