assertRevert.js passes when no revert occurred #775
Labels
bug
good first issue
Low hanging fruit for new contributors to get involved!
tests
Test suite and helpers.
Milestone
🎉 Description
https://github.com/OpenZeppelin/zeppelin-solidity/blob/b3a86029286569ac5656381be2398d5e3af7e92b/test/helpers/assertRevert.js
In assertRevert, the desired behavior is to fail the test if the provided promise does not throw an error containing the substring
revert
. As-written it will pass even if the promise does not throw any error. This is becauseassert.fail()
throws an error, which is caught in the catch, and in the error message is the stringExpected revert not received
, which contains the substringrevert
.assert.fail()
does not magically fail a test, it just throws an error (but regardless of itsexpected
/actual
content) like any otherassert
. Because the error message contains the substringrevert
, revertFound will betrue
even if the promise never threw anything.🔢 Code To Reproduce Issue [ Good To Have ]
Then in the test directory add this as a file:
Then run
./node_modules/mocha/bin/mocha
You will see this test fails.
revertFound
is true, but no EVM revert happened here.👍 Other Information
The
assert.fail()
should go after (outside) the catch block, and there should be areturn;
at the end of (inside) the catch block.@maurelian helped to discover this.
The text was updated successfully, but these errors were encountered: