Skip to content
This repository has been archived by the owner on Jul 9, 2021. It is now read-only.

Commit

Permalink
Fixed false positives in expectTransactionFailedAsync
Browse files Browse the repository at this point in the history
  • Loading branch information
hysz committed Jun 5, 2019
1 parent b2cf701 commit 56bc294
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
9 changes: 9 additions & 0 deletions contracts/test-utils/CHANGELOG.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
[
{
"version": "3.1.8",
"changes": [
{
"note": "Fixed false positives in `expectTransactionFailedAsync` and `expectContractCallFailedAsync`",
"pr": 1852
}
]
},
{
"timestamp": 1558712885,
"version": "3.1.7",
Expand Down
6 changes: 4 additions & 2 deletions contracts/test-utils/src/assertions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,8 @@ export async function expectTransactionFailedAsync(p: sendTransactionResult, rea
}
switch (nodeType) {
case NodeType.Ganache:
return expect(p).to.be.rejectedWith(reason);
const rejectionMessageRegex = new RegExp(`^VM Exception while processing transaction: revert ${reason}$`);
return expect(p).to.be.rejectedWith(rejectionMessageRegex);
case NodeType.Geth:
logUtils.warn(
'WARNING: Geth does not support revert reasons for sendTransaction. This test will pass if the transaction fails for any reason.',
Expand Down Expand Up @@ -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}$`);
return expect(p).to.be.rejectedWith(rejectionMessageRegex);
}

/**
Expand Down

0 comments on commit 56bc294

Please sign in to comment.