Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No coverage data produced #433

Open
nicedinner02 opened this issue Feb 29, 2024 · 2 comments
Open

No coverage data produced #433

nicedinner02 opened this issue Feb 29, 2024 · 2 comments
Assignees

Comments

@nicedinner02
Copy link

The coverage.json, coverage.txt, and the JSON files in the coverage folder are either empty or only contain "{"coverage":{}}" when we run the command "timeout 20s ityfuzz evm -t './build/*'" with the following contract:

ragma solidity ^0.4.24;

/* User can add pay in and withdraw Ether.
The constructor is wrongly named, so anyone can become 'creator' and withdraw all funds.
*/

contract Wallet {
address creator;

mapping(address => uint256) balances;

function initWallet() public {
    creator = msg.sender;
}

function deposit() public payable {
	assert(balances[msg.sender] + msg.value > balances[msg.sender]);
    balances[msg.sender] += msg.value;
}

function withdraw(uint256 amount) public {
    require(amount <= balances[msg.sender]);
    msg.sender.transfer(amount);
    balances[msg.sender] -= amount;
}

}

How can i obtain the coverage data? Really lookforward to you help! thanks a lot!

@shouc shouc self-assigned this Mar 8, 2024
@shouc
Copy link
Contributor

shouc commented Mar 12, 2024

There is a bug in the coverage calculation process.

An ad-hoc way to bypass this is by making it a foundry project and adding a setup script (check https://book.getfoundry.sh/forge/invariant-testing)

Example:

contract InvariantExample1 is Test {

    ExampleContract1 foo;

    function setUp() external {
        foo = new ExampleContract1();
    }

    function invariant_A() external {
        assertEq(foo.val1() + foo.val2(), foo.val3());
    }

    function invariant_B() external {
        assertGe(foo.val1() + foo.val2(), foo.val3());
    }

}

Then run:

ityfuzz evm -m test/Invariant.sol:InvariantExample1 -- forge test

@qianqianpang
Copy link

@shouc Excuse me, has anyone been working on fixing this calculation bug?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants