foundry
foundry copied to clipboard
[`expectRevert v1 changes`] expectRevert seems to cause a revert to not happen rather than asserting that it does
Component
Forge
Have you ensured that all of these are up to date?
- [X] Foundry
- [ ] Foundryup
What version of Foundry are you on?
forge 0.2.0 (e488e2b 2023-07-10T15:17:42.605282000Z)
What command(s) is the bug in?
forge test
Operating System
macOS (Apple Silicon)
Describe the bug
I wrote this test
function testEmptyOracleSimple() external {
vm.expectRevert(bytes(""));
uint256 price = LibChainlink.price(address(0), type(uint256).max, 0);
(price);
}
for this function
function price(address feed, uint256 staleAfter, uint256 scalingFlags) internal view returns (uint256) {
(uint80 roundId, int256 answer, uint256 startedAt, uint256 updatedAt, uint80 answeredInRound) =
AggregatorV3Interface(feed).latestRoundData();
(roundId);
(startedAt);
(answeredInRound);
return roundDataToPrice(
block.timestamp, staleAfter, scalingFlags, answer, updatedAt, AggregatorV3Interface(feed).decimals()
);
}
so that AggregatorV3Interface(feed).latestRoundData()
is called on address(0)
which should revert.
but i get this
Encountered 1 failing test in test/lib/LibChainlink.badOracle.t.sol:LibChainlinkBadOracleTest
[FAIL. Reason: Call did not revert as expected] testEmptyOracleSimple() (gas: 6186)
I get the same thing with vm.expectRevert()
(without the bytes argument).
then removing vm.expectRevert()
entirely gives
Encountered 1 failing test in test/lib/LibChainlink.badOracle.t.sol:LibChainlinkBadOracleTest
[FAIL. Reason: EvmError: Revert] testEmptyOracleSimple() (gas: 3018)
So it does revert, and the debugger shows REVERT opcode.
Somehow the expectRevert is not seeing the REVERT.
here is it reverting https://github.com/rainprotocol/rain.chainlink/actions/runs/5530236425/jobs/10089379218?pr=1
here it is failing to revert https://github.com/rainprotocol/rain.chainlink/actions/runs/5530261812/jobs/10089440012