A check can be executed in a pre/post condition, when it is constructed with Check. It must be given a descriptive name and whether or not the scenario should abort if the check fails.

The function which is executed by the check takes as argument the actual message and the step that was matched. This allows to extract information from the message (for instance we can fail a check if we see a proposal of round > 10).

The function must return either true, if the check succeeded, or false if the check failed. The check itself can also fail in the error monad or with an exception, for unforeseen executions.

Check execution results are gathered by Mitten while executing the scenario and reported at the end. Failures are also reported while they happen. Mitten differentiates failed checks from the ones that errored or raised an exception.

For instance, the following scenario check ensures that a baker that proposes has a node whose head is on the same level, and continues even if the test fails:

fn main() {
let scenario_code =
  wait @@
  add_spec ~pre:[ 
    Check ("Node has same level as proposal", Continue_on_fail, (fun _ -> 
     Helpers.get_node_head_level b1 >|=? fun l -> 
     l = 5l
    )) ] @@
  proposal b1 (level 5) __ __ [__]