Asynchronous Checks
Checks can be asynchronous when using the constructor AsyncCheck
instead of Check
. In this case the execution of the check does not
block the progression of the execution of the scenario.
This is useful to implement checks that must wait for a certain amount of time, or wait for events to perform checks. For instance, with this we can add a check that waits 10 seconds and checks that the receiving node has handled the proposal.
#![allow(unused)] fn main() { Check ("Node has handled proposal after 10s", Continue_on_fail, (fun (msg, _) -> match msg with | Proposal header -> ( let hash = Block_header.hash header in Lwt_unix.wait 10. >>= fun () -> Helpers.get_node_block b1 (`Hash (hash, 0)) >>= fun _ -> | Ok _ -> return true (* block known *) | Error _ -> return false (* block not known *) ) | _ -> return true )) }