fuzzland / ityfuzz

Blazing Fast Bytecode-Level Hybrid Fuzzer for Smart Contracts
https://docs.ityfuzz.rs
MIT License
735 stars 116 forks source link

forge test error #439

Closed nicedinner02 closed 3 months ago

nicedinner02 commented 3 months ago

An error occurs when I use the command 'ityfuzz evm -m test/Counter.t.sol:CounterTest -- forge test' for this contract:

// SPDX-License-Identifier: UNLICENSED pragma solidity ^0.8.13;

import {Test, console} from "forge-std/Test.sol"; import {Counter} from "../src/Counter.sol";

contract CounterTest is Test { Counter public counter;

function setUp() public {
    counter = new Counter();
    counter.setNumber(0);
}

function test_Increment() public {
    counter.increment();
    assertEq(counter.number(), 1);
}

function testFuzz_SetNumber(uint256 x) public {
    counter.setNumber(x);
    assertEq(counter.number(), x);
}

}

This contract is obtained by using the 'forge init' command." Here are the details of the error:

[⠊] Compiling... [⠘] Compiling 30 files with 0.8.24 [⠢] Solc 0.8.24 finished in 3.66s Compiler run successful with warnings: Warning (2018): Function state mutability can be restricted to view --> test/InvariantExample1.t.sol:15:5: | 15 | function invariant_A() external { | ^ (Relevant source part starts here and spans across multiple lines).

Warning (2018): Function state mutability can be restricted to view --> test/InvariantExample1.t.sol:19:5: | 19 | function invariant_B() external { | ^ (Relevant source part starts here and spans across multiple lines).

Ran 2 tests for test/Counter.t.sol:CounterTest [PASS] testFuzz_SetNumber(uint256) (runs: 256, μ: 30143, ~: 31310) [PASS] test_Increment() (gas: 31325) Suite result: ok. 2 passed; 0 failed; 0 skipped; finished in 13.29ms (18.41ms CPU time)

Ran 2 tests for test/InvariantExample1.t.sol:InvariantExample1 [PASS] invariant_A() (runs: 256, calls: 3840, reverts: 1227) [PASS] invariant_B() (runs: 256, calls: 3840, reverts: 1021) Suite result: ok. 2 passed; 0 failed; 0 skipped; finished in 349.03ms (681.32ms CPU time)

Ran 2 test suites in 349.95ms (362.33ms CPU time): 4 tests passed, 0 failed, 0 skipped (4 total tests) INFO

================ EVM Fuzzer Start ===================

INFO Deploying contract: src/Counter.sol:Counter INFO Contract src/Counter.sol:Counter deployed to: 0x358e00564d898b1eb5140f1cf513b80cf9258b59 INFO Deploying contract: lib/forge-std/src/Script.sol:Script INFO Contract lib/forge-std/src/Script.sol:Script deployed to: 0x7109709ecfa91a80626ff3989d68f67f5b1dd12d INFO Deploying contract: test/Counter.t.sol:CounterTest INFO Contract test/Counter.t.sol:CounterTest deployed to: 0x7fa9385be102ac3eac297483dd6233d62b3e1496 INFO Deployed all contracts

INFO [Stats #0] run time: 0h-0m-0s, clients: 1, corpus: 0, objectives: 0, executions: 0, exec/sec: 0.000 INFO ============= New Corpus Item ============= INFO Reverted? false Txn: [Sender] 0x35c9dfd76bf02107ff4f7128Bd69716612d31dDb └─[1] 0x358E00564d898b1eb5140f1CF513B80Cf9258b59.increment()

INFO ========================================== INFO [Testcase #0] run time: 0h-0m-0s, clients: 1, corpus: 5, objectives: 0, executions: 1, exec/sec: 0.000 INFO ============= Coverage Summary ============= INFO src/Counter.sol:Counter(0x358e00564d898b1eb5140f1cf513b80cf9258b59): 60.87% Instruction Covered, NaN% Branch Covered INFO test/Counter.t.sol:CounterTest(0x7fa9385be102ac3eac297483dd6233d62b3e1496): 4.78% Instruction Covered, 1.79% Branch Covered INFO [Stats #0] run time: 0h-0m-0s, clients: 1, corpus: 5, objectives: 0, executions: 1, exec/sec: 0.000 INFO ============= New Corpus Item ============= INFO Reverted? false Txn: [Sender] 0xe1A425f1AC34A8a441566f93c82dD730639c8510 └─[1] 0x358E00564d898b1eb5140f1CF513B80Cf9258b59.setNumber(0)

INFO ========================================== INFO [Testcase #0] run time: 0h-0m-0s, clients: 1, corpus: 6, objectives: 0, executions: 27, exec/sec: 0.000 INFO [Stats #0] run time: 0h-0m-0s, clients: 1, corpus: 6, objectives: 0, executions: 27, exec/sec: 0.000 INFO ============= New Corpus Item ============= INFO Reverted? false Txn: [Sender] 0x35c9dfd76bf02107ff4f7128Bd69716612d31dDb └─[1] 0x358E00564d898b1eb5140f1CF513B80Cf9258b59.increment() [Sender] 0xe1A425f1AC34A8a441566f93c82dD730639c8510 └─[1] 0x358E00564d898b1eb5140f1CF513B80Cf9258b59.setNumber(766247770432944430461670837633257016.5640 ether)

INFO ========================================== INFO [Testcase #0] run time: 0h-0m-0s, clients: 1, corpus: 7, objectives: 0, executions: 28, exec/sec: 0.000 INFO ============= Coverage Summary ============= INFO src/Counter.sol:Counter(0x358e00564d898b1eb5140f1cf513b80cf9258b59): 60.87% Instruction Covered, NaN% Branch Covered INFO test/Counter.t.sol:CounterTest(0x7fa9385be102ac3eac297483dd6233d62b3e1496): 4.78% Instruction Covered, 1.79% Branch Covered thread 'main' panicked at src/evm/middlewares/cheatcode.rs:227:58: decode cheatcode failed: UnknownSelector { name: "VmCalls", selector: 0x98296c54 } note: run with RUST_BACKTRACE=1 environment variable to display a backtrace

nicedinner02 commented 3 months ago

I really look forward to your help. Thanks.

shouc commented 3 months ago

This is due to the Foundry upgrade. Will fix ASAP.

Ref: https://t.me/c/1815219512/1622