First Steps

Let's give ourselves a testcase file test1.techel

{
    PUSH string "starting the test" ;
}

This testcase does not use any contract. To run it, simply run

$ techelson rsc/no_contract/okay/test1.techel
Running test `Test1`

running test script...
   timestamp: 1970-01-01 00:00:00 +00:00

Done running test `Test1`

Introspection

This is not very informative, which is why techelson provides extensions such as PRINT_STACK. This instruction prints the state of the stack in a readable way. For example, if we change the example above to test2.techel to

{
    PUSH string "starting the test" ;
    PRINT_STACK
}

the output becomes

$ techelson rsc/no_contract/okay/test2.techel
Running test `Test2`

running test script...
   timestamp: 1970-01-01 00:00:00 +00:00
stack:
|==================================================================================================|
| "starting the test"                                                                              |
| string                                                                                           |
|==================================================================================================|

running test script...
   timestamp: 1970-01-01 00:00:00 +00:00

Done running test `Test2`

Steps

When you run a complex testcase or contract, it can be useful to have break point that stop the execution. This gives you time to read a PRINT_STACK before the next step is actually performed, make one step, read the state of the stack, etc.

The STEP techelson extension allows to do just that. You can also provide a string that will be displayed when the STEP instruction is reached.

The following example (test3.techel) showcases the STEP instruction:

{
    PUSH string "starting the test" ;
    PRINT_STACK ;
    STEP "just started the test" ; # The description string is optional, see below.
    PUSH @not_important string "a string with a variable name" ;
    PRINT_STACK ;
    STEP ; # No description string.
    DROP ;
    PRINT_STACK ;
    STEP "The string should be gone. Also, we're done."
}

Techelson will stop on all STEP instructions and ask you to press enter to keep going:

$ techelson rsc/no_contract/okay/test3.techel
Running test `Test3`

running test script...
   timestamp: 1970-01-01 00:00:00 +00:00
stack:
|==================================================================================================|
| "starting the test"                                                                              |
| string                                                                                           |
|==================================================================================================|

running test script...
   timestamp: 1970-01-01 00:00:00 +00:00
stopping [just started the test] press `return` to continue


running test script...
   timestamp: 1970-01-01 00:00:00 +00:00
stack:
|==================================================================================================|
| "starting the test"                                                                              |
| string                                                                                           |
|--------------------------------------------------------------------------------------------------|
|                                                                                   @not_important |
| "a string with a variable name"                                                                  |
| string                                                                                           |
|==================================================================================================|

running test script...
   timestamp: 1970-01-01 00:00:00 +00:00
stopping [no information] press `return` to continue


running test script...
   timestamp: 1970-01-01 00:00:00 +00:00
stack:
|==================================================================================================|
| "starting the test"                                                                              |
| string                                                                                           |
|==================================================================================================|

running test script...
   timestamp: 1970-01-01 00:00:00 +00:00
stopping [The string should be gone. Also, we're done.] press `return` to continue


running test script...
   timestamp: 1970-01-01 00:00:00 +00:00

Done running test `Test3`

Pro tip 1: you can use PRINT_STACK and STEP in contracts too (see the extensions section for details). Also, techelson treats #> as a whitespace. Hence, your can have #> STEP ; and/or #> PRINT_STACK ; in your michelson contract, which lets you inspect it during tests. Your contract remains legal michelson thanks to the leading # which comments the command.

Pro tip 2: passing --skip on to techelson will skip (but still display) all the steps. The output of the commands reported in this book are all obtained by running techelson with --skip on.