huff-language / huffmate

A library of modern, hyper-optimized, and extensible Huff contracts with extensive testing and documentation built by Huff maintainers.

Home Page:https://github.com/pentagonxyz/huffmate

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

`testOnlyContract` is failing

MathisGD opened this issue · comments

https://github.com/pentagonxyz/huffmate/blob/6798bcc97026e69ff0c4bb3e0c914d2bbcb8ba7c/test/auth/OnlyContract.t.sol

    /// @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.