Fixed false positives in expectTransactionFailedAsync

This commit is contained in:
Greg Hysen 2019-06-04 17:58:34 -07:00
parent b2cf701e30
commit 56bc2944d0
2 changed files with 13 additions and 2 deletions

View File

@ -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",

View File

@ -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.',
@ -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);
}
/**