package octez-protocol-alpha-libs

  1. Overview
  2. Docs
Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source

Module Tezos_alpha_test_helpers.Scenario_dslSource

Sourceexception Test_failed
Sourcetype ('input, 'output) scenarios =
  1. | Action : ('input -> 'output Tezos_base.TzPervasives.tzresult Lwt.t) -> ('input, 'output) scenarios
  2. | Empty : ('t, 't) scenarios
  3. | Concat : (('a, 'b) scenarios * ('b, 'c) scenarios) -> ('a, 'c) scenarios
  4. | Branch : (('a, 'b) scenarios * ('a, 'b) scenarios) -> ('a, 'b) scenarios
  5. | Tag : string -> ('t, 't) scenarios
  6. | Slow : ('t, 't) scenarios

A scenario is a succession of actions. We define a branching path as a way to create multiple tests from the same point. This allows easy compositionality of behaviors with minimal code sharing. The Tag allows to give meaningful identifiers to the branches. It is good practice to tag each case in a branch (it's not necessary, but since test names must be unique, at most one branch can remain unnamed, and even then it can create conflicting names.)

Sourcetype ('input, 'output) single_scenario =
  1. | End_scenario : ('t, 't) single_scenario
  2. | Cons : (('input -> 't Tezos_base.TzPervasives.tzresult Lwt.t) * ('t, 'output) single_scenario) -> ('input, 'output) single_scenario

Unfolded scenario type

Sourceval cat_ss : 'a 'b 'c. ('a, 'b) single_scenario -> ('b, 'c) single_scenario -> ('a, 'c) single_scenario
Sourceval combine : ('a -> 'b -> 'c) -> 'a list -> 'b list -> 'c list
Sourceval unfold_scenarios : 'input 'output. ('input, 'output) scenarios -> (('input, 'output) single_scenario * string list * bool) list
Sourceval run_scenario : 'input 'output. ('input, 'output) single_scenario -> 'input -> 'output Tezos_base.TzPervasives.tzresult Lwt.t
Sourcetype test_closure = string * bool * (Tezt_tezos.Protocol.t -> unit Lwt.t)
Sourceval unfolded_to_test : ((unit, unit) single_scenario * string list * bool) -> test_closure
Sourceval register_test : __FILE__:string -> tags:string list -> test_closure -> unit
Sourceval register_tests : __FILE__:string -> tags:string list -> test_closure list -> unit

Useful aliases and operators

Sourceval noop : ('a, 'a) scenarios
Sourceval no_tag : ('a, 'a) scenarios
Sourceval concat : 'a 'b 'c. ('a, 'b) scenarios -> ('b, 'c) scenarios -> ('a, 'c) scenarios
Sourceval branch : 'a 'b. ('a, 'b) scenarios -> ('a, 'b) scenarios -> ('a, 'b) scenarios
Sourceval (-->) : ('a, 'b) scenarios -> ('b, 'c) scenarios -> ('a, 'c) scenarios

Continuation connector: execute a then b

Sourceval (|+) : ('a, 'b) scenarios -> ('a, 'b) scenarios -> ('a, 'b) scenarios

Branching connector: creates two tests with different execution paths

Sourceval end_test : ('a, unit) scenarios

Ends the test. Dump the state, returns unit

Sourceval tests_of_scenarios : (string * (unit, 't) scenarios) list -> test_closure list

Transforms scenarios into tests

Sourceval exec : ('a -> 'b Tezos_base.TzPervasives.tzresult Lwt.t) -> ('a, 'b) scenarios

Arbitrary execution

Sourceval exec_state : (('a * 'b) -> ('c, Tezos_base.TzPervasives.tztrace) result Lwt.t) -> ('a * 'b, 'a * 'c) scenarios

Execute a function that does not modify the block, only the state

Sourceval exec_unit : ('a -> (unit, Tezos_base.TzPervasives.tztrace) result Lwt.t) -> ('a, 'a) scenarios

Execute a function that does not modify neither the block nor the state. Usually used for checks/asserts

Sourceval fold : ('a -> ('b, 'c) scenarios) -> 'a list -> ('b, 'c) scenarios

fold f l folds f over l, fails on empty list

Sourceval fold_tag : ('a -> ('b, 'c) scenarios) -> (string * 'a) list -> ('b, 'c) scenarios

fold_tag f l folds f over l, l has a tag for each of its elements. Fails on empty list.

Sourceval fold_tag_f : ('a -> ('b, 'c) scenarios) -> ('a -> string) -> 'a list -> ('b, 'c) scenarios

fold_tag_f f tag l folds f over l, tag returns a tag for each element of l. Fails on empty list.

Sourceval unfold : ('a -> ('b, 'b) scenarios) -> 'a list -> ('b, 'b) scenarios

unfold f l maps f over l, and runs them in order

OCaml

Innovation. Community. Security.