package tezt-tezos
val encoding : t Data_encoding.t
Protocol parameters.
These values denote which file to use from the "parameters"
directory.
val constants_to_string : constants -> string
val default_constants : constants
The default constants used by tests: Constants_sandbox
.
val name : t -> string
Get the name of a protocol, capitalized (e.g. "Edo"
).
val number : t -> int
Get the number of a protocol, e.g. 012 for Ithaca.
The number for Alpha
is the number it will have once snapshotted.
Use this to specify constraints that should not change once Alpha is snapshotted. For instance, number protocol >= 012
meant "at least Ithaca" even when Ithaca was still Alpha, while number protocol >= number Alpha
stopped being true for Ithaca after it was snapshotted.
val directory : t -> string
Get the directory of a protocol (e.g. "proto_012_Psithaca"
).
val tag : t -> string
Get the name of a protocol as a tag, for use when registering tests (e.g. "edo"
).
val hash : t -> string
Get the full hash of a protocol.
Get the location of the parameter file.
This returns the path to one of the parameter files of the "parameters"
directory of the protocol, relative to the root of the repository.
val accuser : t -> Tezt_wrapper.Uses.t
Get the path of the accuser of a protocol, such as "./octez-accuser-alpha"
.
val baker : t -> Tezt_wrapper.Uses.t
Get the path of the baker of a protocol, such as "./octez-baker-alpha"
.
val daemon_name : t -> string
Get the part of the daemon name that is specific to a protocol (e.g. "PtEdo2Zk"
).
This should not be used for anything except to compute the name of executables.
val encoding_prefix : t -> string
Get the part which is added at the beginning of all encoding names.
type parameter_overrides =
(string list
* [ `None | `Int of int | `String_of_int of int | Tezt_wrapper.JSON.u ])
list
Values to override in protocol parameters.
They are pairs of JSON paths and optional values that can be used to override or remove (when the value is `None
) the default parameters when activating a protocol.
`Int i
is a short-hand for `Float (float i)
and `String_of_int i
is a short-hand for `String (string_of_int i)
.
type bootstrap_smart_rollup = {
address : string;
pvm_kind : string;
boot_sector : string;
parameters_ty : Ezjsonm.value;
whitelist : string list option;
}
type bootstrap_contract = {
delegate : string option;
amount : Tez.t;
script : Ezjsonm.value;
hash : string option;
}
The value is the same as the one in src/proto_alpha/lib_parameters/default_parameters.ml.
val write_parameter_file :
?bootstrap_accounts:(Account.key * int option) list ->
?additional_bootstrap_accounts:(Account.key * int option * bool) list ->
?bootstrap_smart_rollups:bootstrap_smart_rollup list ->
?bootstrap_contracts:bootstrap_contract list ->
?output_file:string ->
base:(string, t * constants option) Either.t ->
parameter_overrides ->
string Lwt.t
Write a protocol parameter file.
This function first builds a default parameter file from the base
parameter. If base
is a string
Either.t.Left
, the string denotes a path to a parameter file like "src/proto_alpha/parameters/sandbox-parameters.json"
, which is taken as the base parameters. If base
is a t*constantsoption
Either.t.Right
, the default parameters of the given protocol are the base parameters.
Then, the base parameters are tweaked with:
bootstrap_accounts
, when given these accounts are used instead ofAccount.Bootstrap.keys
parameters_overrides
additional_bootstrap_accounts
is a list of bootstrap accounts to add to activation parameters. Each account is a triplet(key, balance, revealed)
. Ifrevealed
the public key is added, else the public key hash is added. Revealed keys are expected to bake from the start. Defaultbalance
is 4000000 tez.bootstrap_smart_rollups
when given.bootstrap_contracts
when given.output_file
the path where to write the protocol parameter file, aTemp.file
temporary file "parameters.json" by default.
Get the predecessor of a protocol.
WARNING: use of this function is discouraged, because it prevents the type-checker from telling you that your test can no longer run when removing a protocol.
val all : t list
Get the list of all protocols.
WARNING: use of this function is discouraged, because:
- if we add protocols such as demo-noop or demo-counter to type
t
, it would be awkward to add them toall
ifall
only contained "real" protocols up to now, and it would also be awkward not to add them toall
; - it is easier for maintainers if the list of protocols a test runs on is clearly defined where the test is registered.
type supported_protocols =
| Any_protocol
| From_protocol of int
| Until_protocol of int
| Between_protocols of int * int
| Has_predecessor
| And of supported_protocols list
| Or of supported_protocols list
| Not of supported_protocols
Constraints on the set protocols that a test supports.
Do not use this to decide which protocols the test should run on, this is the role of the last argument of register_test
and register_regression_test
. Instead, declare what the test *could* run on.
Any_protocol
: the test can run on all active protocols. This is the default.From_protocol n
: the test can run on protocolsp
such thatnumber p >= n
.Until_protocol n
: the test can run on protocolsp
such thatnumber p <= n
.Between_protocols (a, b)
: the test can run on protocolsp
such thata <= number p <= b
.Has_predecessor
: the test can run on protocols which have a predecessor according toprevious_protocol
.And l
: all predicates ofl
hold.Or l
: at least one predicate ofl
hold.Not p
: predicatep
does not hold.
Always write the number itself, do not compute it. For instance, writing Until_protocol (number Alpha)
would make your test not support the snapshotted version Alpha after Alpha is snapshotted, even though it actually does.
It is recommended to write protocol numbers with leading zeros. For instance, write From_protocol 008
instead of From_protocol 8
.
val register_test :
__FILE__:string ->
title:string ->
tags:string list ->
?uses:(t -> Tezt_wrapper.Uses.t list) ->
?uses_node:bool ->
?uses_client:bool ->
?uses_admin_client:bool ->
?supports:supported_protocols ->
(t -> unit Lwt.t) ->
t list ->
unit
Register a test that uses the protocol.
This is the same as Test.register
except that:
- the name of the protocol is automatically added at the beginning of
title
; - the name of the protocol is automatically added as a tag in
tags
; - the function that implements the test takes a protocol as parameter;
- an additional parameter gives the list of protocols to run the test on.
The list of protocol is the last parameter because this function is intended to be applied partially, without this list; the test function being the parameter of type t -> unit Lwt.t
before the list. The list of protocols is specified in main.ml
, next to the registration of all other tests, so that it is easy to see at a glance which tests run on which protocols.
If your test involves several protocols (for instance to test migration), use Test.register
directly.
val register_long_test :
__FILE__:string ->
title:string ->
tags:string list ->
?uses:(t -> Tezt_wrapper.Uses.t list) ->
?uses_node:bool ->
?uses_client:bool ->
?uses_admin_client:bool ->
?supports:supported_protocols ->
?team:string ->
executors:Tezt_tezos_tezt_performance_regression.Long_test.executor list ->
timeout:Tezt_tezos_tezt_performance_regression.Long_test.timeout ->
(t -> unit Lwt.t) ->
t list ->
unit
Register a long-test that uses the propocol.
This is the same as Long_test.register
, with the same differences as Protocol.register_test
compared to Test.register
.
val register_regression_test :
__FILE__:string ->
title:string ->
tags:string list ->
?uses:(t -> Tezt_wrapper.Uses.t list) ->
?uses_node:bool ->
?uses_client:bool ->
?uses_admin_client:bool ->
?supports:supported_protocols ->
(t -> unit Lwt.t) ->
t list ->
unit
Register a regression test that uses the protocol.
This is the same as Regression.register
, with the same differences as Protocol.register_test
compared to Test.register
, and where output_file
is parameterized by the protocol.
Convert a function that expects two successive protocols into a function that expects only one.
The resulting function causes the test to fail if called on a protocol which does not have a predecessor. Use ~supports:Has_predecessor
to prevent this.
Typical usage:
Protocol.register_test ...
~supports:Has_predecessor
@@ Protocol.with_predecessor
@@ fun ~previous_protocol ~protocol ->
...