Module Tezos_alpha_test_helpers.Op

The operation representation handled most often in test helpers.

Assemble the given signature and contents_list into a packed_operation.

The context argument is used to retrieve the branch.

If the signature option argument is None, then the resulting operation is unsigned.

This function is mainly useful to craft an operation with a missing or invalid signatue. Otherwise, it is often better to use one of the helpers below: they handle the signature internally to directly return well-signed operations.

Create an unpacked attestation that is expected for given Block.t.

Optional parameters allow to specify the attested values: level, round, block_payload_hash, and/or dal_content.

They also allow to specify the attester (delegate), and/or the slot. These default to the first slot and its delegate.

Finally, the operation branch can be specified. It defaults to the predecessor of the attested block.

Create an unpacked preattestation that is expected for a given Block.t.

Optional parameters are the same than raw_attestation.

Create a packed attestation that is expected for a given Block.t by packing the result of raw_attestation.

Create a packed attestations_aggregate that is expected for a given Block.t. Block context is expected to include at least one delegate with a BLS key (or a registered consensus keys).

Aggregate a list of attestations in a single Attestations_aggregate. Attestations signed by non-bls delegates are ignored. Evaluates to None if no bls-signed attestations are found or if signature_aggregation failed (due to unreadable signature representation).

Same as raw_aggregate but returns the packed operation.

Create a packed preattestation that is expected for a given Block.t by packing the result of raw_preattestation.

Create a packed preattestations_aggregate that is expected for a given Block.t. Block context is expected to include at least one delegate with a BLS key (or a registered consensus keys).

Same as raw_preattestations_aggregate but returns the packed operation.

Aggregate a list of preattestations in a single Preattestations_aggregate. Preattestations signed by non-bls delegates are ignored. Evaluates to None if no bls-signed attestations are found or if signature_aggregation failed.

Same as raw_aggregate_preattestations but returns the packed operation.

type gas_limit =
  1. | Max
    (*

    Max corresponds to the max_gas_limit_per_operation constant.

    *)
  2. | High
    (*

    High corresponds to 50_000 gas unit which should cover a majority of use-cases. This is the default used when forging manager operations.

    *)
  3. | Low
    (*

    Low corresponds to the gas entry cost of a manager operation

    *)
  4. | Zero
  5. | Custom_gas of Tezos_protocol_alpha.Protocol.Alpha_context.Gas.Arith.integral
val pp_gas_limit : Stdlib.Format.formatter -> gas_limit -> unit

Pretty printer for gas_limit type.

Packs a manager operation into a contents list.

  • parameter force_reveal

    Prepends the operation to reveal source's public key if the latter has not been revealed yet. Disabled by default (i.e., set to false).

  • parameter counter

    Specifies the expected current counter, meaning that the operation's counter will actually be counter + 1. Defaults to the correct current counter for source in the context.

  • parameter fee

    Specifies the fee. Defaults to Tez.zero.

  • parameter gas_limit

    Specifies the gas limit. Defaults to a high limit of around 50_000 gas units.

  • parameter storage_limit

    Specifies the storage limit. Defaults to Z.of_int 60_000.

  • parameter public_key

    The actual source written in the operation will be the hash of public_key. Defaults to the public key that corresponds to the source argument.

  • parameter source

    Used to retrieve defaults values of counter and public_key.

Same as transaction, but with a more generic destination parameter. It is said unsafe because it can construct transactions that will always fail, such as

  • Transaction to the deposit entrypoint of a transaction rollup, as these transactions are necessarily internals.

Optional arguments allow to override defaults:

  • ?force_reveal:bool: prepend the operation to reveal source's public key if the latter has not been revealed yet. Disabled (set to false) by default.

revelation ?fee ?gas_limit ?forge_pkh ?forge_proof ctxt pkh Creates a new Reveal manager_operation to reveal a public key pkh applying to current context ctxt.

Optional arguments allow to override defaults:

  • ?fee:Tez.t: specify a fee, otherwise set to Tez.zero.
  • ?gas_limit:Gas.Arith.integral: force a gas limit, otherwise set to 10000 gas units.
  • ?forge_pkh: use a provided pkh as source, instead of hashing pkh. Useful for forging non-honest reveal operations
  • ?forge_proof: use a provided proof instead of creating a correct proof for pkh. Useful for forging non-honest reveal operations
  • ?storage_limit:Z.t: forces a storage limit, otherwise set to Z.zero

contract_origination ctxt source Create a new contract origination operation, sign it with source and returns it alongside the contract address. The contract address is using the initial origination nonce with the hash of the operation. If this operation is combined with combine_operations then the contract address is false as the nonce is not based on the correct operation hash.

Optional arguments allow to override defaults:

  • ?force_reveal:bool: prepend the operation to reveal source's public key if the latter has not been revealed yet. Disabled (set to false) by default.

Batch a list of (already signed) operations and (re-)sign with the source. No revelation is inserted and the counters are kept as they are unless recompute_counters is set to true (defaults false).

Reveals a seed_nonce that was previously committed at a certain level

Reveals a VDF with a proof of correctness

Craft the contents_list for a Proposals operation.

Invocation: proposals_contents ctxt source ?period proposals.

  • parameter period

    defaults to the index of the current voting period in ctxt.

Craft a Proposals operation.

Invocation: proposals ctxt source ?period proposals.

  • parameter period

    defaults to the index of the current voting period in ctxt.

Craft the contents_list for a Ballot operation.

Invocation: ballot_contents ctxt source ?period proposal ballot.

  • parameter period

    defaults to the index of the current voting period in ctxt.

Craft a Ballot operation.

Invocation: ballot ctxt source ?period proposal ballot.

  • parameter period

    defaults to the index of the current voting period in ctxt.

transfer_ticket allows an implicit account to transfer tickets they owned.

The arguments are:

  • Context.t: the context on which to apply the operation
  • source:Contract.t: the source contract of the operation
  • Tx_rollup.t: the rollup to which the withdrawal pertains
  • Tx_rollup_level.t: the level on which the withdrawal was commited
  • contents:Script.lazy_expr: the contents of the ticket of the withdrawal
  • ty:Script.lazy_expr: the type of the ticket of the withdrawal
  • ticketer:Contract.t: the ticketer of the ticket of the withdrawal
  • Z.t: the quantity of the ticket of the withdrawal
  • destination:Contract.t: the destination contract that should receive the ticket of the withdrawal
  • Entrypoint_repr.t: the entrypoint of the destination contract to which the ticket should be sent

Optional arguments allow to override defaults:

  • ?force_reveal:bool: prepend the operation to reveal source's public key if the latter has not been revealed yet. Disabled (set to false) by default.

sc_rollup_origination ctxt source kind boot_sector originates a new smart contract rollup of some given kind booting using boot_sector.

Optional arguments allow to override defaults:

  • ?force_reveal:bool: prepend the operation to reveal source's public key if the latter has not been revealed yet. Disabled (set to false) by default.

sc_rollup_publish ctxt source rollup commitment tries to publish a commitment to the SCORU. Optional arguments allow to override defaults:

Optional arguments allow to override defaults:

  • ?force_reveal:bool: prepend the operation to reveal source's public key if the latter has not been revealed yet. Disabled (set to false) by default.

sc_rollup_cement ctxt source rollup tries to cement a commitment.

Optional arguments allow to override defaults:

  • ?force_reveal:bool: prepend the operation to reveal source's public key if the latter has not been revealed yet. Disabled (set to false) by default.

sc_rollup_recover_bond ctxt source sc_rollup staker recovers the commitment bond of staker.

zk_rollup_origination ctxt source ~public_parameters ~circuits_info ~init_state ~nb_ops tries to originate a ZK Rollup.

zk_rollup_publish ctxt source ~zk_rollup ~op tries to add an operation to the pending list of a ZK Rollup.

zk_rollup_update ctxt source ~zk_rollup ~update tries to apply an update to a ZK Rollup.

module Micheline = Tezos_micheline.Micheline

Protocol.mode-related helpers

type tested_mode =
  1. | Application
  2. | Construction
  3. | Mempool

Which Protocol.mode to test.

val check_validation_and_application : loc:string -> ?error:(Tezos_protocol_alpha.Environment.Error_monad.error -> bool) -> predecessor:Block.t -> tested_mode -> t -> unit Tezos_base.TzPervasives.tzresult Lwt.t

check_validation_and_application ~loc ?error ~predecessor tested_mode operation tests the validation and application of operation in tested_mode.

  • When tested_mode is Application or Construction, a block containing operation is baked on top of predecessor in the specified mode.
  • When tested_mode is Mempool, a mempool is initialized using predecessor as head, then Incremental.add_operation is called on operation.

When error is None, we check that everything succeeds, otherwise we check that the error identified by error is returned.

val check_validation_and_application_all_modes_different_outcomes : loc:string -> ?application_error: (Tezos_protocol_alpha.Environment.Error_monad.error -> bool) -> ?construction_error: (Tezos_protocol_alpha.Environment.Error_monad.error -> bool) -> ?mempool_error:(Tezos_protocol_alpha.Environment.Error_monad.error -> bool) -> predecessor:Block.t -> t -> unit Tezos_base.TzPervasives.tzresult Lwt.t

Calls check_validation_and_application on all tested_modes successively, with respective errors.

val check_validation_and_application_all_modes : loc:string -> ?error:(Tezos_protocol_alpha.Environment.Error_monad.error -> bool) -> predecessor:Block.t -> t -> unit Tezos_base.TzPervasives.tzresult Lwt.t

Calls check_validation_and_application on all tested_modes successively, with the same error provided for each mode.

val set_op_signature : t -> Tezos_protocol_alpha.Protocol.Alpha_context.signature option -> t
val copy_op_signature : src:t -> dst:t -> t