livepeer / protocol

Livepeer protocol
MIT License
152 stars 45 forks source link

Update GenericMock.sol to return revert reasons when forwarding calls #333

Closed kyriediculous closed 5 years ago

kyriediculous commented 5 years ago

Currently GenerickMock.sol uses a high-level version of the CALL opcode, which returns only whether the external call succeeded before solidity 0.5.0 , therefore we are currently not returning revert reasons to test for in the unit tests.

We could use a low-level inline assembly-snippet to make the external call, but since we'll be upgrading to solidity 0.5.0 we can make this change after the compiler upgrade. After that high-level implementation of CALL does return the return data as a second return value and we can change the GenericMock.execute function to:

    function execute(address _target, bytes _data) external payable {
       (bool ok, bytes memory r) = _target.call.value(msg.value)(_data);
        require(ok, r);
    }
yondonfu commented 5 years ago

Closed by #354