a16z / halmos

A symbolic testing tool for EVM smart contracts

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Weird issue testing Huff ERC20

eugenioclrc opened this issue · comments

Describe the bug
Im trying to do some simple test on a ERC20 huff token. But its given me a weird error:

setUp() trace #1:
    CALL 0xaaaa0001::0x0a9254e4
        CREATE 0xaaaa0002::<1717 bytes of initcode>
        ↩ RETURN <1707 bytes of code>
    ↩ STOP 0x

Executing check_allowance
[ERROR] check_allowance(address,address,uint256) (paths: 3, time: 0.02s, bounds: [])
WARNING:Halmos:Encountered symbolic storage base slot: Concat(0, Extract(159, 0, p_owner_address))
(see https://github.com/a16z/halmos/wiki/warnings#internal-error)

To Reproduce

TestERC20.halmos.t.sol

contract TokenHalmosTest is Test {
    IToken token;

    function setUp() public {
        bytes memory bytecode = hex"6106a...............05260206000f3";
        /// @solidity memory-safe-assembly
        IToken _token;
        assembly {
            _token := create(0, add(bytecode, 0x20), mload(bytecode))
        }
        token = _token;
        require(token != IToken(address(0)), "Token creation failed");
    }
    function check_allowance(address owner, address spender, uint256 amount) public {
        assert(token.allowance(owner, spender) == 0);

        //vm.expectEmit(true, true, true, true);
        //emit IToken.Approval(owner, spender, amount);
        vm.prank(owner);
        assert(token.approve(spender, amount));

        assert(token.allowance(owner, spender)== amount);
    }

Environment:

  • macOS
  • Python version: Python 3.9.12
  • Halmos and other dependency versions:
  • z3-solver 4.10.1.0
  • halmos 0.1.13

Additional context
Output

 git:(main) ✗  halmos --mc TokenHalmosTest --mt allowance -vvv
[⠢] Compiling...
[⠆] Compiling 1 files with Solc 0.8.25
[⠔] Solc 0.8.25 finished in 1.09s
Compiler run successful!
Skipped Deploy.json due to parsing failure: KeyError: 'metadata'

Running 1 tests for test/halmos/Token.t.sol:TokenHalmosTest
setUp() trace #1:
    CALL 0xaaaa0001::0x0a9254e4
        CREATE 0xaaaa0002::<1717 bytes of initcode>
        ↩ RETURN <1707 bytes of code>
    ↩ STOP 0x

Executing check_allowance
[ERROR] check_allowance(address,address,uint256) (paths: 3, time: 0.02s, bounds: [])
WARNING:Halmos:Encountered symbolic storage base slot: Concat(0, Extract(159, 0, p_owner_address))
(see https://github.com/a16z/halmos/wiki/warnings#internal-error)
Symbolic test result: 0 passed; 1 failed; time: 0.09s