-
Notifications
You must be signed in to change notification settings - Fork 465
Fixes false positives in expectTransactionFailedAsync
#1852
Fixes false positives in expectTransactionFailedAsync
#1852
Conversation
dcd86f1
to
56bc294
Compare
expectTransactionFailedAsync
expectTransactionFailedAsync
@@ -160,7 +161,8 @@ export async function expectTransactionFailedWithoutReasonAsync(p: sendTransacti | |||
* otherwise resolve with no value. | |||
*/ | |||
export async function expectContractCallFailedAsync<T>(p: Promise<T>, reason: RevertReason): Promise<void> { | |||
return expect(p).to.be.rejectedWith(reason); | |||
const rejectionMessageRegex = new RegExp(`^VM Exception while processing transaction: revert ${reason}$`); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this will work in Geth. We have disabled Geth tests for now (see #1754 and #1775). Going forward, instead of running all of our unit tests through Geth and relying on features that don't exist upstream, we want to have integration tests that operate at a higher level and don't rely on any extra features.
Anyways, I'm okay with this for now but if we write integration tests for Geth in the future we'll have to update it.
Oof. If this is true we should report the issue to Mocha/Chai. I can't imagine this was the intended behavior. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Like I mentioned we might have to change this in the future to support revert reasons from Geth (and maybe Parity too), but I'm okay with leaving it as is for now.
Description
The function
expectTransactionFailedAsync(transactionReceipt, expectedRevertReason)
returns a false positive when the expected revert reason is a substring of the exception message.For example, if the expected revert reason is
INVALID_DATA
and the actual reason isINVALID_DATA_OFFSET
then there will be a false positive.To go one step further, the full exception message is
VM Exception while processing transaction: revert INVALID_DATA_OFFSET
. Any substring within that message will also return a false positive, for example,processing trans
.Testing instructions
Types of changes
Checklist:
[WIP]
if necessary.