One of the functions of my smart contract can only be executed if three conditions are met. At the moment I have a single require
which combines all the conditions like this:
require(evalCond1() && evalCond2() && evalCond3());
But when I try to check my code coverage with solidity-coverage
it only sees two branches: the one in which the require
is met and the other, in which at least one of those conditions evaluates to false (no matter which one). I was wondering if there was any issue with breaking down the single require
in three separate ones, one for each condition:
require(evalCond1());
require(evalCond2());
require(evalCond3());
I think this improves readability (since the real function names are a bit more complex than evalCond
) and helps showing the correct coverage for branches, but I'm not sure this doesn't have any side effects regarding gas usage and performance.