Skip to main content
Version: Next

state

module reset

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.

save: (_: unit) => unit

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

drop: (_: unit) => unit

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

reset: (_: nat, amounts: list<tez>) => unit

Generates a number of random bootstrapped accounts with a default amount of 4000000 tez. 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.

reset_at: (_: timestamp, _: nat, amounts: list<tez>) => unit

Generates a number of random bootstrapped accounts with a default amount of 4000000 tez. 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.

register_delegate: (_: key_hash) => unit

Registers a key_hash corresponding to an account as a delegate.

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.

set_source: (_: address) => unit

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

set_baker_policy: (_: test_baker_policy) => unit

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

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.

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.

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.

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.

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.

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.

last_events: <a, p, s>(_: typed_address<p, s>, tag: 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.

stake: (_: key_hash, amount: tez) => unit