`testOnlyContract` is failing
MathisGD opened this issue · comments
/// @notice Tests that ONLY_CONTRACT macro reverts when tx.origin == msg.sender
function testOnlyContract(address caller) public {
vm.assume(caller != address(this));
// Should revert when tx.origin == msg.sender
// vm.startPrank(address,address) sets msg.sender and tx.origin
vm.startPrank(caller, caller);
vm.expectRevert();
only_contract.call("");
vm.stopPrank();
// Only setting the msg.sender and not tx.origin should succeed, so long as caller != address(this)
vm.startPrank(caller);
(bool success,) = only_contract.call("");
assert(success);
vm.stopPrank();
}
The default tx.origin
of forge is 0x00a329c0648769A73afAc7F9381E08FB43dBEA72
which is different from address(this)
. So when the fuzzing tries with caller = 0x00a329c0648769A73afAc7F9381E08FB43dBEA72
, the test fails.