Skip to content

test(fix): expecting revert call to succeed #102

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

0xChin
Copy link
Member

@0xChin 0xChin commented Mar 27, 2025

🐧 🐧 🐧

The test check_validState_greeterNeverEmpty was breaking because in the second call address(targetContract).call(abi.encodeCall(Greeter.setGreeting, (''))); we expect the call to revert due to empty string being passed, but the vm.assume check the call was successful

🐧 🐧 🐧

@0xChin 0xChin requested a review from simon-something March 27, 2025 16:05
@@ -35,7 +35,7 @@ contract SymbolicGreeter is SymTest, Test {
(_success,) = address(targetContract).call(abi.encodeCall(Greeter.setGreeting, ('')));

// Output condition check
vm.assume(_success); // discard failing calls
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there a reason we exclude instead of testing in the post-condition state? This should rather be if(success) assert(string != '') else assert(string=='') no?

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

Successfully merging this pull request may close these issues.

2 participants