simulate<T> function

T simulate<T>(
  1. FutureOr<T> body(
    1. Simulation sim
    ), {
  2. int seed = 0,
  3. FaultPolicy? faults,
  4. ActorSystemConfig? config,
  5. int maxSteps = 100000,
  6. Duration maxTime = const Duration(hours: 1),
})

Runs body against a simulated actor system and returns its result.

The whole run happens inside this call: body may be asynchronous, but simulate itself is not, and virtual time costs nothing. The same seed gives the same run every time, as long as the test takes its own random choices from Simulation.random.

faults interferes with message deliveries; see randomFaults. config replaces the system's configuration (by default logging is off). The run is abandoned with SimulationLimitExceeded after maxSteps deliveries and timers, or maxTime of virtual time.

Implementation

T simulate<T>(
  FutureOr<T> Function(Simulation sim) body, {
  int seed = 0,
  FaultPolicy? faults,
  ActorSystemConfig? config,
  int maxSteps = 100000,
  Duration maxTime = const Duration(hours: 1),
}) =>
    Simulation._(seed, faults, maxSteps, maxTime)._run(body, config);