1

Here is the file I am working with SubscribeBySig.t.sol . You can replicate the scenario by cloning the above repo, switch to the 230-migrate-comm-unit-tests branch and run forge test.

The problem is when I use vm.expectRevert knowing that the function call is goin to revert, I get the following error, means that the function didn't revert. enter image description here

But the moment I comment out or remove the vm.expectRevert line from the test, I again get an error, this time indicating that the function call reverted, which is obviously what I expected.

enter image description here

But why didn't the expectRevert catch this error in the first place? What am I doing wrong? I have also tried to use expectRevert with the error message, but nothing changed.

UPDATE: The tests pass when I use another method which is prefixing the function name with testFail. But I want to use expectRevert, still not sure what's the issue.

2

1 Answer 1

1

Got the issue.

Actually, I was passing a function call as an argument to another function call, which would be called obviously before the actual function call, because of which the expectRevert method expected the argument to fail.enter image description here

Here is the solution if you wanna check out - Commit

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.