Example of using func tests could be founded here.
But how it works and how to run it without toncli if needed?
To compile test func code we use this mini library.
To run run_tests.fif
we use special AsmTests.fif
from here
Let's start with a point where contract code and tests code successfully compiled into Fift ASM.
Toncli gets paths to those files and paste them to run_tests.fif
here and here
Also, it parse verbose level and pass it here
run_test.fif
parse function declaration from compiled Fift ASM and invoke running VM 3 times.
- First time run: run get_data function and collect
gas-limit
/c7
/c4
/stack
/function selector
- Second time run: run contract
code
with all needed params from step (1) - Third time run: get
c4
/c5
/gas-used
/stack
/exit-code
params from step (2) and pass them to actual test
- If you want to create working functions in tests code, please use
inline method_id
- If you want to get
c4
/c5
from previous tests - useget_prev_c4
/get_prev_c5
- You may use
dump_stack();
for debugging - You may use
-v 1
/-v 2
for debugging when running tests- If
-v 2
is used - stack will be dumped, but it's buggy function, so do not panic if something go wrong, just try to use-v 1
-v 3
/-v 4
used for debugging tests functions (tvm op / stack dump)
- If
- You can use special
get_prev_c4
/get_prev_c5
functions to getc4
/c5
cells from prev tests - Last gas parameter can be tuple or int. If int - just set gas limit. If tuple of 2 ints - will set gas limit and hard gas limit
- This can help when you debug
accept_message()
for example
- This can help when you debug