Legend:
Library
Module
Module type
Parameter
Class
Class type
This module can be used to craft an operation without using client dedicated commands.
Overview
This module aims to replace the module Operation_legacy to provide an interface which is more extensible. In other words, supporting a new operation should be easier using this interface.
An unsigned operation is represented by the datatype t. t is a wrapper around a JSON representation of an operation. Some meta information needs to be provided to sign this operation. t is not signed a priori to ease writing tests with bad signatures.
This module also provides two functions to ease the injection of an operation: inject which should be called when the injection is expected to succeed, and inject_with_error when the injection is expected to fail.
Anyone is free to add support for new operations.
Manager operations
Manager operations represent most of the operations used by the tests. Those operations contain several parameters (see Manager.make) and can be batched. Wrapper like Manager.inject and Manager.inject_with_error are provided to ease the writing of tests.
type t
The abstract representation of an unsigned operation.
The kind is necessary because it determines the watermark of an operation which is necessary for signing an operation. This type aims to be extended when other kinds of operations are added into this module.
val make :
branch:string ->?signer:Account.key->kind:kind->Tezt_wrapper.JSON.u ->t
make ~branch ?signer ~kind json client builds the representation of an unsigned operation.
json t gives the json representation of an unsigned operation.
val hex :
?protocol:Protocol.t->?signature:Tezos_crypto.Signature.t ->t->Client.t->Hex.t Lwt.t
hex ?(protocol=None) ?(signature=None) t client computes the binary representation of an operation as a hexadecimal string. If protocol is given, the binary representation is computed using the encoding of operation from the protocol. Otherwise, a call to the forge_operations RPC is done to compute the binary representation. If signature is given, the hexadecimal represents the signed version of the operation. client is used to construct the binary representation of t.
parameterprotocol
controls whether the encoding of a protocol should be used to compute the binary representation of the operation rather than calling the forge_operations RPC to compute it.
parametersignature
controls whether a signature should be attached to the operation.
val sign :
?protocol:Protocol.t->t->Client.t->Tezos_crypto.Signature.t Lwt.t
sign t client signs the raw representation of operation t by its signer (see make). client is used to construct the binary representation of t. Note that if no signer have been given to t the function returns Tezos_crypto.Signature.zero.
val hash : t->Client.t->[ `OpHash of string ]Lwt.t
hash t client returns the hash of the operation
val byte_size :
?protocol:Protocol.t->?signature:Tezos_crypto.Signature.t ->t->Client.t->int Lwt.t
Returns the size (in bytes) of the operation.
parameterprotocol
Allows using the operation encoding rather than using the forge_operations RPC to compute the hexadecimal representation of the operation.
parametersignature
Allows to manually set the signature of the operation. When omitted, the operation is correctly signed using sign.
val inject :
?request:[ `Inject | `Notify ]->?force:bool ->?protocol:Protocol.t->?signature:Tezos_crypto.Signature.t ->?error:Tezt_wrapper.Base.rex ->t->Client.t->[ `OpHash of string ]Lwt.t
inject ?(request=`Inject) ?(force=false) ?(signature=None)
?(error=None) t injects an operation into the node. The node is extracted from the Client. If a node cannot be extracted, the injection fails. If the injection succeeds, the hash of the operation is returned.
parameterrequest
If `Inject, we do not wait the prevalidator to classify the operation. This can create some flakyness in the test but is needed to test corner cases. If `Notify, the function waits for the prevalidator to classify the operation. However, the nodes need to activate the debug events for the prevalidator.
parameterforce
If true, the function succeeds even though the operation was classified with an error and was not propagated by the prevalidator. If false, the call fails if the prevalidator classified the operation with an error.
parameterprotocol
Allow using the operation encoding rather than using the forge_operations RPC to compute the hexadecimal representation of the operations.
parametersignature
Allows to give manually the signature of the operation. The operation is signed when the signature is omitted.
parametererror
If the injection is expecting to fail, allows to specify the expected error.
val spawn_inject :
?force:bool ->?protocol:Protocol.t->?signature:Tezos_crypto.Signature.t ->t->Client.t->Tezt_wrapper.JSON.t Runnable.processLwt.t
Same as inject, but do not wait for the process to exit.
val inject_and_capture2_stderr :
rex:Tezt_wrapper.Base.rex ->?force:bool ->?protocol:Protocol.t->?signature:Tezos_crypto.Signature.t ->t->Client.t->(string * string)Lwt.t
Run spawn_inject then capture two groups on stderr with rex.
val inject_operations :
?protocol:Protocol.t->?request:[ `Inject | `Notify ]->?force:bool ->?error:Tezt_wrapper.Base.rex ->?use_tmp_file:bool ->t list->Client.t->[ `OpHash of string ] listLwt.t
inject_operations ?protocol ?request ?force ?error ?use_tmp_file ops
client is similar as inject for a list of operations. This function calls the RPC RPC.post_private_injection_operations which is faster than calling the RPC used by inject several times. Note that this function should be used mainly when the time for injecting operations matters.