package tezt-tezos

  1. Overview
  2. Docs

Spawn Tezos accuser and control them.

type t

Tezos accuser states.

type event = {
  1. name : string;
  2. value : Tezt_wrapper.JSON.t;
  3. timestamp : float;
}

Raw events.

val create : protocol:Protocol.t -> ?name:string -> ?color:Tezt_wrapper.Log.Color.t -> ?event_pipe:string -> ?base_dir:string -> ?runner:Tezt_wrapper.Runner.t -> ?preserved_levels:int -> Node.t -> t

Create an accuser.

This function just creates the t value, it does not call run.

The path to accuser binary is chosen from the protocol.

The standard output and standard error output of the accuser will be logged with prefix name and color color.

Default event_pipe is a temporary file whose name is derived from name. It will be created as a named pipe so that accuser events can be received.

base_dir corresponds to the (useless) "--base-dir" argument of the octez-accuser command.

The Node.t parameter is the accuser's node target. The accuser will be configured to be synchronised with the given node, and will communicate with it.

If runner is specified, the accuser will be spawned on this runner using SSH.

preserved_levels is the number of effective levels kept in the accuser's memory

val name : t -> string

See Daemon.Make.name.

val node_rpc_port : t -> int

Get the RPC port of the associated node.

val terminate : ?timeout:float -> t -> unit Lwt.t

Send SIGTERM and wait for the process to terminate.

Default timeout is 30 seconds, after which SIGKILL is sent.

val kill : t -> unit Lwt.t

Send SIGKILL and wait for the process to terminate.

Commands

val run : ?event_level:Daemon.Level.default_level -> t -> unit Lwt.t

Spawn octez-accuser run.

The resulting promise is fulfilled as soon as the accuser has been spawned. It continues running in the background.

Events

exception Terminated_before_event of {
  1. daemon : string;
  2. event : string;
  3. where : string option;
}

Exception raised by wait_for functions if the node terminates before the event.

You may catch or let it propagate to cause the test to fail. daemon is the name of the accuser. event is the name of the event. where is an additional optional constraint, such as "level >= 10".

val wait_for_ready : t -> unit Lwt.t

Wait until the accuser is ready.

More precisely, wait until the node on which the accuser is connected to is bootstrapped, and then, the accuser is ready.

val wait_for : ?where:string -> t -> string -> (Tezt_wrapper.JSON.t -> 'a option) -> 'a Lwt.t

See Daemon.Make.wait_for.

val on_event : t -> (event -> unit) -> unit

See Daemon.Make.on_event.

val log_events : ?max_length:int -> t -> unit

See Daemon.Make.log_events.

High-Level Functions

val init : protocol:Protocol.t -> ?name:string -> ?color:Tezt_wrapper.Log.Color.t -> ?event_pipe:string -> ?event_level:Daemon.Level.default_level -> ?base_dir:string -> ?runner:Tezt_wrapper.Runner.t -> ?preserved_levels:int -> Node.t -> t Lwt.t

Initialize an accuser.

This creates an accuser and run, then waits for the accuser to be ready, and finally returns the accuser.

As the accuser usually needs to be connected to a node, we first wait for the node to be ready and then, run the accuser. If one does not want to wait for the node to be ready, it is necessary to use create and then run.

The path to accuser binary is chosen from the protocol.

The standard output and standard error output of the accuser will be logged with prefix name and color color.

Default event_pipe is a temporary file whose name is derived from name. It will be created as a named pipe so that accuser events can be received.

event_level specifies the verbosity of the file descriptor sink. The default value is `Info.

base_dir corresponds to the (useless) "--base-dir" argument of the octez-accuser command.

The Node.t parameter is the accuser's node target. The accuser will be configured to be synchronised with the given node, and will communicate with it.

If runner is specified, the accuser will be spawned on this runner using SSH.

preserved_levels is the number of effective levels kept in the accuser's memory

val restart : t -> unit Lwt.t

Restart an accuser.

This terminates an accuser, then runs it again and waits for it to be ready.

OCaml

Innovation. Community. Security.