tezos-checker / checker

An in-development "robocoin" system for the Tezos blockchain
24 stars 16 forks source link

Increase test coverage for checkerMain.ml #179

Closed gkaracha closed 3 years ago

gkaracha commented 3 years ago

These unit tests primarily go through different execution paths and ensure that calls to entrypoints fail/succeed, depending on whether checker is sealed/unsealed. However, the values themselves are not inspected.

At this high a level most of the actual code to be run is wrapped in {BEGIN,END}_LIGO, so I think e2e tests are much more appropriate for testing the behavior of main.

Test coverage goes from 86.40% to 88.52%.

gkaracha commented 3 years ago

Thanks for the review @dorranh! Indeed, I made two changes for coverage purposes:

Overall, since I don't expect https://github.com/aantron/bisect_ppx/issues/377 to be changed any time soon I've been thinking that we can combine @aantron's advice with using pattern matches instead of if-then-else to get accurate coverage. That is, if we convert

if <condition>
then e1
else (Ligo.failwith (...))

into

match <condition> with
| true -> e1
| false -> ((Ligo.failwith [@coverage off]) (...))        (* tricky *)

then the "tricky" line is colored green when covered by the tests and red when not covered by the tests, as we want.