#[test]
fn test_madsim(){
for _ in 0..2{
println!("check");
madsim::runtime::Runtime::check_determinism(32, madsim::Config::default(),||async move {
println!("{:?}", (1..5).collect::<HashSet<u64>>());
});
}
for _ in 0..2{
println!("simulation");
madsim::runtime::Runtime::with_seed_and_config(32, madsim::Config::default()).block_on(async move {
println!("{:?}", (1..5).collect::<HashSet<u64>>());
});
}
}
All invocations in check_determinism produce the same ordering of elements. The first call to block_on also produces this same ordering. The second call, however, produces a different order:
check
{2, 3, 4, 1}
{2, 3, 4, 1}
check
{2, 3, 4, 1}
{2, 3, 4, 1}
simulation
{2, 3, 4, 1}
simulation
{3, 1, 2, 4}
All invocations in
check_determinismproduce the same ordering of elements. The first call toblock_onalso produces this same ordering. The second call, however, produces a different order: