CRYPTO NEWS

How to assert failing require statement in Foundry

In my contract A I have a function foo which has a require statement

contract A {   bool public shouldFail;      function foo() public {      require(shouldFail, "State not set correctly for continuation");      ...   } } 

Now I want to test this with Foundry

contract ATest is Test {    function testFoo() public {         // executing function with some account         vm.prank(someAddress);         A.foo(); // <- this will fail     } } 

How should I do that?

How to assert failing require statement in Foundry

Shopping cart
There are no products in the cart!
Continue shopping
0