0

Is it possible to send funds to an Echnidna fuzzing contract before the tests start? For example, if I wanted to test for address(this).balance != 0 as an invariant, how would I seed to contract with coins ahead of time?

contract MyContractFuzz is MyContract {
    function echidna_test_balance() public view returns (bool) {
        return (address(this).balance != 0);
    }
}

1 Answer 1

2

Yes, create a config file, e.g. echidna.yaml and add the following:

#balanceContract overrides balanceAddr for the contract address
balanceContract: 0

You might also want to play around with this, but I don't think it's necessary.

# #balanceAddr is default balance for addresses
# balanceAddr: 0xffffffff

Remember to change your constructor to payable, otherwise the constructor will fail, and to pass in the config, e.g. echidna-test . --config echidna.yaml.

Here's a link to the default config.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.