An invariant is a predicate that must hold at any point in the stateful test. They are evaluated in full on the initial and final state and sampled at intermediate join points, unless declared always checked. The invariant function should throw when the invariant is violated.
More...
|
| | Invariant (std::string name, std::function< void(const T &)> invariant) |
| | Declare a new invariant.
|
| | Invariant (std::string name, bool always_check, std::function< void(const T &)> invariant) |
| | Declare a new invariant that can skip sampling.
|
| | Invariant (InvariantParams< T > params) |
| | Declare a new invariant from named arguments.
|
| const std::string & | name () const |
| | Returns the name of the invariant.
|
| const std::function< void(const T &)> & | invariant () const |
| | Returns the function representing the predicate of the invariant.
|
| bool | pause_faults () const |
| | Returns true if fault injection is paused while this invariant is checked.
|
| bool | always_check () const |
| | Returns whether the invariant is checked after every step or round instead of sampled.
|
template<typename T>
class hegel::stateful::Invariant< T >
An invariant is a predicate that must hold at any point in the stateful test. They are evaluated in full on the initial and final state and sampled at intermediate join points, unless declared always checked. The invariant function should throw when the invariant is violated.
An invariant declared with pause_faults asks the engine to pause fault injection for the duration of each of its checks, so that inside Antithesis no fault lands in the middle of the check. Fault injection resumes when the check returns or throws. Outside Antithesis the flag has no effect.
std::vector<hegel::stateful::Invariant<Bank>> invariants() const {
{.name = "balances_sum_to_total",
.pause_faults = true,
.invariant = [](const Bank& m) { m.verify_total(); }})};
}
An invariant is a predicate that must hold at any point in the stateful test. They are evaluated in f...
Definition stateful.h:939
- Template Parameters
-
| T | The state-machine type the invariant checks |