Module Mavryk_alpha_test_helpers.Scenario_base

This module gathers the basic operations used in test scenarios. This includes starting a scenario, baking, checking and manipulating the state, and various wait functions

type Mavryk_base.TzPervasives.error +=
  1. | Unexpected_error

For assert_failure, when expected error does not match the actual error.

type Mavryk_base.TzPervasives.error +=
  1. | Unexpected_success

For assert_failure, when scenario actually succeeds when expected to fail.

type t = Block.t * State.t

Usual threaded state for the tests. Contains the current block, pending operations and the known State.t

val log : ?level:Tezt_core.Cli.Logs.level -> ?color:Tezt_core.Log.Color.t -> ('a, Stdlib.Format.formatter, unit, ('b, 'b) Scenario_dsl.scenarios) Stdlib.format4 -> 'c
val set_baker : string -> (t, t) Scenario_dsl.scenarios

Sets the de facto baker for all future blocks

val exclude_bakers : string list -> (t, t) Scenario_dsl.scenarios

Exclude a list of delegates from baking

val unset_baking_policy : (t, t) Scenario_dsl.scenarios

Unsets the baking policy, it returns to default (By_round 0)

Creates a snapshot of the current balances for the given account names. Can be used to check that balances at point A and B in the execution of a test are the same (either nothing happened, or a succession of actions resulted in getting the same values as before

val check_snapshot_balances : ?f: (name:Mavryk_base.TzPervasives.String.Map.key -> old_balance:State_account.balance -> new_balance:State_account.balance -> (unit, Mavryk_base.TzPervasives.tztrace) Stdlib.result Lwt.t) -> Mavryk_base.TzPervasives.String.Map.key -> (t, t) Scenario_dsl.scenarios

Check balances against a previously defined snapshot

val save_current_rate : (t, t) Scenario_dsl.scenarios

Save the current issuance rate for future use

val check_rate_evolution : (Q.t -> Q.t -> bool) -> (t, t) Scenario_dsl.scenarios

Check that f saved_rate current_rate is true. f is typically a comparison function

val check_failure_aux : ?loc:string -> ?expected_error:('a -> Mavryk_base.TzPervasives.tztrace) -> ('a0 -> 'b Mavryk_base.TzPervasives.tzresult Lwt.t) -> 'a0 -> 'a0 Mavryk_base.TzPervasives.tzresult Lwt.t
val check_fail_and_rollback : ?loc:string -> ?expected_error:('a -> Mavryk_base.TzPervasives.tztrace) -> ('a0, 'b) Scenario_dsl.single_scenario -> 'a0 -> 'a0 Mavryk_base.TzPervasives.tzresult Lwt.t
val assert_failure : ?loc:string -> ?expected_error:('a -> Mavryk_base.TzPervasives.tztrace) -> ('a0, 'b) Scenario_dsl.scenarios -> ('a0, 'a0) Scenario_dsl.scenarios

Useful function to test expected failures: runs the given branch until it fails, then rollbacks to before execution. Fails if the given branch Succeeds

val assert_success : ?loc:string -> ('a, 'b) Scenario_dsl.scenarios -> ('a, 'a) Scenario_dsl.scenarios

Check a scenario does not fail, and rolls back to before the assert

val loop : int -> ('a, 'a) Scenario_dsl.scenarios -> ('a0, 'a1) Scenario_dsl.scenarios

Loop

val loop_action : int -> ('a -> 'a Mavryk_base.TzPervasives.tzresult Lwt.t) -> ('a0, 'a1) Scenario_dsl.scenarios
val check_balance_field : Mavryk_base.TzPervasives.String.Map.key -> [< `Bonds | `Liquid | `Staked | `Total | `Unstaked_finalizable | `Unstaked_frozen_total ] -> Mavryk_protocol_alpha.Protocol.Alpha_context.Tez.t -> (t, t) Scenario_dsl.scenarios

Check a specific balance field for a specific account is equal to a specific amount