-
Notifications
You must be signed in to change notification settings - Fork 12k
A logical error in assertRevert.js #938
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
Comments
Thanks for the detailed report @barakman. I understand your reasoning and it made me quite concerned. However, in practice it doesn't seem to be like this. If you try to trigger the bug by, for example, removing a
Thus, I still haven't looked deeper into why this is so. The I'm going to keep looking into this later. I've wanted to improve this helper for a while now. Suggestions are appreciated! |
@frangio: BTW, I've implemented this as a single helper for all "VM exception" errors:
Perhaps it will inspire you to do something similar.... |
So is my analysis wrong then? |
@barakman I think I would phrase this - luckily it works!! :) Really think the issue in that thread at |
I completely lost you on this one. Any chance you're talking about the other thread, where I originally posted this issue? (I went into that thread while looking for a remedy on the infamous ganache issue BTW, and from there I "accidentally" continued to the I'm asking strictly with regards to Zeppelin's So I am asking if my analysis of a problem in Zeppelin's Thanks |
A(nother) good reason to change the implementation there if you ask me :) |
Uh oh!
There was an error while loading. Please reload this page.
🎉 Description
💻 Environment
Agnostic (platform-independent)
📝 Details
If the
promise
is completed successfully, then you throw an exception with an error message containing"revert"
.You then immediately catch this exception, and since its error message contains
"revert"
, theassert
completes successfully and no exception is thrown.The thing to understand is that the Mocha framework reports a failure only when the tested scenario (
it
) throws an exception.When that happens, the Mocha framework catches this exception and reports failure on the specific test at hand.
When you throw an exception and immediately catch it, the Mocha framework is not even aware of it.
For example, let's analyze a scenario in which the
promise
completes successfully, hence the test should fail:try
part, thepromise
completes successfullytry
part, you throw an exception with"revert"
in its error messagecatch
part, you immediately catch that exceptioncatch
part, theassert
completes successfully because the error message contains"revert"
In order to understand the logical confusion, keep in mind that there are two different failure scenarios which you need to detect and handle:
promise
has completed successfully)"revert"
has occurred (thepromise
has failed but not because ofrequire
)In your code, I believe that you detect the first scenario correctly, but you handle it incorrectly.
I therefore suggest the following alternative:
The text was updated successfully, but these errors were encountered: