The LIGO command-line interpreter provides sub-commands to test directly your LIGO code. The three main sub-commands we currently support are:
We will show how to use the first two, while an example on how to use the third one was already explained in the here.
interpret allows to interpret an expression in a
context initialised by a source file. The interpretation is done using
Let's see how it works on an example. Suppose we write the following contract which we want to test.
This contract keeps an integer as storage, and has three entry-points:
one for incrementing the storage, one for decrementing the storage,
and one for resetting the storage to
As a simple property, we check whether starting with an storage of
10, if we execute the entry-point for incrementing
32, then we get
a resulting storage of
42. For checking it, we can interpret the
With the argument
--init-file we pass the contract we want to test,
and the sub-command requires also the expression to evaluate in that
context, in this case, a call to our contract (
main) with parameter
Increment (32) and storage
10. As a result, we can check that the
resulting storage is
42 (the second component of the pair), and
there are no further operations to execute (the first component).
We can tune certain parameters of the execution by passing them as arguments:
test can be used to test a contract using LIGO. It
interpret as in this case we can describe the test
internally using LIGO code, and no Michelson code is actually
⚠️ Please keep in mind that this sub-command is still BETA, and that there are features that are work in progress and are subject to change. No real test procedure should rely on this sub-command alone.
To test the contract we need to create a testing file. This file has
access to an additional
Test module. The test file is interpreted,
and implicitly updates a global state (the tezos context). To do that,
the LIGO interpreter uses the same library that Tezos internally uses for
Here we will simulate that the contract is actually deployed to an address, and
check that the resulting storage is
42 after executing a call to
Note: the types present in the context of the testing file differ from the ones when writing a contract.
Notice that now we wrote the test property inside LIGO, using:
Test.compile_expressionto compile an expression.
Test.originateto deploy a contract.
Test.transferto simulate an external call.
Test.get_storageto check the storage from a contract.
Test.logto log variables.
Test.michelson_equalto check if the Michelson results are equal.
A property like
testme is a definition of a boolean value. The
test evaluates a test, and returns whether it was
successful or not (i.e. returned