[][src]Macro tari_test_utils::async_assert_eventually

macro_rules! async_assert_eventually {
    ($check_expr:expr, expect = $expect:expr, max_attempts = $max_attempts:expr, interval = $interval:expr $(,)?) => { ... };
    ($check_expr:expr, expect = $expect:expr, max_attempts = $max_attempts:expr, $(,)?) => { ... };
    ($check_expr:expr, expect = $expect:expr $(,)?) => { ... };
}

Periodically check if a value becomes the expected value within a maximum number of attempts. The reason this has an 'async' in the name is because this doesn't use thread::sleep, but rather tokio::timer::delay(...). Therefore, needs to be in an async context using tokio threadpool.

let some_var = 123;
async_assert_eventually!(
   some_var + 1,
   expect = 124,
   max_attempts = 10,
   interval = Duration::from_millis(500)
);