0

Let us say I am trying to fuzz simple addition b/w two 'uint' variables in Solidity using foundry, I expect one of two conditions to happen:

  1. The test passes without overflow error.
  2. The test fails with the compiler reverting because of overflow.

How do I configure my fuzz test function to expect both of those conditions at the same time? As in I want the test to pass if either of the conditions are true, but fail for anything else. enter image description here Basically, I want my test function to check for two conditions at the same time.

1 Answer 1

1

How about codes below?

function testAddition(uint256 a, uint256 b) public {
    assert(a <= (type(uint256).max - b));
}

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.