Version: 0.15.0

Test

Important: The Test module is only available inside the ligo test command. See also Testing LIGO.

type michelson_program
A type for code that's compiled to Michelson.
type ligo_program
A type for code insertions in the test file.
type test_exec_error = Rejected of (michelson_program * address) | Other
A test error.
type test_exec_result = Success | Fail of test_exec_error
A test execution result.
function originate : string -> string -> michelson_program -> (address * michelson_program * int)

Originate a contract with an entrypoint and initial storage.

const originated = Test.originate(testme_test, "main", init_storage);
const addr = originated.0;
const program = originated.1;
const size = originated.2;
function set_now : timestamp -> unit
Set the timestamp of the predecessor block.
function set_source : address -> unit
Set the source for `Test.transfer` and `Test.originate`.
function set_baker : address -> unit
Force the baker for `Test.transfer` and `Test.originate`. By default, the first bootstrapped account.
function transfer : address -> michelson_program -> nat -> test_exec_result
Bake a transaction by sending an amount of tez with a parameter from the current source to another account.
function transfer_exn : address -> michelson_program -> nat -> unit
Similar as `Test.transfer`, but fails when anything goes wrong.
function get_storage : address -> michelson_program
Get the storage of an account.
function get_balance : address -> michelson_program
Get the balance of an account.
function michelson_equal : michelson_program -> michelson_program -> bool
Compare two Michelson values.
function log : 'a -> unit
Log a value.
function reset_state : nat -> list(nat) -> unit
Generate a number of random bootstrapped accounts with a default amount of 4000000 tez. The passed list can be used to overwrite the amount.
function nth_bootstrap_account : int -> address
Returns the address of the nth bootstrapped account.
function last_originations : unit -> map (address * list(address))
Returns the address of the nth bootstrapped account.
function compile_expression : option(string) -> ligo_program -> michelson_program
Compile an expression to Michelson and evaluate it.
const expr = Test.compile_expression(Some("filename"), [%pascaligo ({| (42: int) |} : ligo_program)]);
function compile_expression_subst : option(string) -> ligo_program -> list (string * michelson_program) -> michelson_program
const example = Test.compile_expression_subst (Some(under_test),
[%pascaligo ({| {one = $one ; two = $two ; three = $three ; four = $four ; five = $five} |} : ligo_program)],
list [
("one", d_one );
("two", Test.compile_value (1n + 2n)) ;
("three", Test.compile_value ("a"^"b")) ;
("four", Test.compile_value (0xFF00)) ;
("five", Test.compile_value ()) ;
]);
function compile_value : 'a -> michelson_program
Compile a LIGO value to Michelson.