Description
I am trying to execute a transaction in which a contract function transfers ether to another contract, thus invoking the other contract's fallback function:
function() external payable {
require(someInternalViewFuncWhichReturnsTrue());
}
When running truffle test
, the transaction completes successfully.
When running solidity-coverage
, the transaction reverts at the fallback function.
As you can imagine, it took me a very long time to formulate this conclusion.
And how did I formulate that conclusion?
First, I changed the fallback function to this:
function() external payable {
revert("7777777");
}
Where the transaction has reverted with a revert 7777777
message in both Truffle and SC.
Then, I changed it to this:
function() external payable {
require(someInternalViewFuncWhichReturnsTrue(), "7777777");
}
Where the transaction has reverted with a revert
message only in SC.
Finally, I changed it to this:
function() external payable {
}
Where the transaction has completed successfully in both Truffle and SC.
My guess is that it exceeds the gas stipend (2300) because of the event-emitting that SC injects to it:
function() external payable {
emit __FunctionCoverageMyContract('C:/Users/.../MyContract.sol',7);
emit __CoverageMyContract('C:/Users/.../MyContract.sol',168);
emit __AssertPreCoverageMyContract('C:/Users/.../MyContract.sol',8);
emit __StatementCoverageMyContract('C:/Users/.../MyContract.sol',12);
require(someInternalViewFuncWhichReturnsTrue(), "7777777");
emit __AssertPostCoverageMyContract('C:/Users/.../MyContract.sol',8);
}
I am using:
- Windows 10
- node v10.16.0
- npm v6.9.0
- solidity-coverage v0.6.7
- truffle v4.1.16 (relying on solc 0.4.26)
Any thoughts or ideas how to workaround this?
Thanks