Skip to main content
Version: 1.4.0

State

module Reset

let restore: (_: unit) => unit

Pops a testing framework context from the stack of contexts, and sets it up as the new current context. In case the stack was empty, the current context is kept.

let save: (_: unit) => unit

Takes current testing framework context and saves it, pushing it into a stack of contexts.

let drop: (_: unit) => unit

Drops a testing framework context from the stack of contexts. In case the stack was empty, nothing is done.

let reset: (_: nat) => (_: list<mav>) => unit

Generates a number of random bootstrapped accounts with a default amount of `4000000` mav. The passed list can be used to overwrite the amount. By default, the state only has two bootstrapped accounts. Notice that since Ithaca, a percentage of an account's balance is frozen (5% in testing mode) in case the account can be taken to be a validator, and thus getting balance can show a different amount to the one being set with `Test.State.reset`.

let reset_at: (_: timestamp) => (_: nat) => (_: list<mav>) => unit

Generates a number of random bootstrapped accounts with a default amount of `4000000` mav. The passed list can be used to overwrite the amount. By default, the state only has two bootstrapped accounts. Notice that since Ithaca, a percentage of an account's balance is frozen (5% in testing mode) in case the account can be taken to be a validator, and thus getting balance can show a different amount to the one being set with `Test.State.reset`. It also takes a starting timestamp for the genesis block.

let register_delegate: (_: key_hash) => unit

Registers a `key_hash` corresponding to an account as a delegate.

let register_constant: (_: michelson_program) => string

Registers a global constant, returns its hash as a string. See the documentation for global constants for an example of usage.

let set_source: (_: address) => unit

Sets the source for `Test.transfer` and `Test.originate`.

let set_baker_policy: (_: test_baker_policy) => unit

Forces the baking policy for `Test.transfer` and `Test.originate`. By default, the first bootstrapped account.

let set_baker: (_: address) => unit

Forces the baker for `Test.transfer` and `Test.originate`, implemented using `Test.set_baker_policy` with `By_account`. By default, the first bootstrapped account.

let bake_until: (_: nat) => unit

It bakes until a number of cycles pass, so that an account registered as delegate can effectively act as a baker. Note: It can be used in tests to manually advance time.

let set_big_map: <k, v>(_: int) => (_: big_map<k, v>) => unit

The testing framework keeps an internal reference to the values corresponding to big map identifiers. This function allows to override the value of a particular big map identifier. It should not be normally needed, except in particular circumstances such as using custom bootstrap contracts that initialize big maps.

let get_voting_power: (_: key_hash) => nat

Return the voting power of a given contract. This voting power coincides with the weight of the contract in the voting listings (i.e., the rolls count) which is calculated at the beginning of every voting period.

let get_total_voting_power: (_: unit) => nat

Returns the total voting power of all contracts. The total voting power coincides with the sum of the rolls count of every contract in the voting listings. The voting listings is calculated at the beginning of every voting period.

let last_originations: (_: unit) => map<address, list<address>>

Returns addresses of orginated accounts in the last transfer. It is given in the form of a map binding the address of the source of the origination operation to the addresses of newly originated accounts.

let last_events: <a, p, s>(_: typed_address<p, s>) => (_: string) => list<a>

Returns the list of all the event payloads emited with a given tag by a given address. Any call to this function must be annotated with the expected payload type.

let stake: (_: key_hash) => (_: mav) => unit