Skip to content
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

vm.expectRevert() does not necessarily bind to the primary function #1374

Open
timefliez1210 opened this issue Dec 21, 2024 · 1 comment
Open

Comments

@timefliez1210
Copy link

As an example the following lines:

vm.expectRevert();
stable.donate(sUSD.balanceOf(users[1]));

the stable.donate() function is indeed expected to revert, but since sUSD.balanceOf(users[1]) does succeed the expectRevert() will make the test fail, with [FAIL: next call did not revert as expected].

An easy workaround is though to simply rewrite the order:

uint256 susdToDonate = sUSD.balanceOf(users[1]);
vm.expectRevert();
stable.donate(susdToDonate);

I'm unsure if this is expected behavior, but I find it quite unintuitive.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Status: No status
Development

No branches or pull requests

2 participants
@timefliez1210 and others