truffle-assertions
Advanced tools
Comparing version 0.9.0 to 0.9.1
16
index.js
@@ -6,2 +6,13 @@ const AssertionError = require('assertion-error'); | ||
class InvalidTxResultError extends Error {} | ||
const validateResult = (result) => { | ||
if (!result.logs) { | ||
throw new InvalidTxResultError( | ||
'First argument is not a transaction result. Did you accidentally pass a contract instance or transaction receipt?\n' | ||
+ 'If that is the case, check out truffleAssert.createTransactionResult in the documentation.', | ||
); | ||
} | ||
}; | ||
/* Creates a new assertion message, containing the passedAssertionMessage and | ||
@@ -61,2 +72,4 @@ * the defaultAssertion message when passedAssertionMessage exists, otherwise | ||
const assertEventEmittedFromTxResult = (result, eventType, filter, message) => { | ||
validateResult(result); | ||
/* Filter correct event types */ | ||
@@ -81,2 +94,4 @@ const events = result.logs.filter(entry => entry.event === eventType); | ||
const assertEventNotEmittedFromTxResult = (result, eventType, filter, message) => { | ||
validateResult(result); | ||
/* Filter correct event types */ | ||
@@ -200,2 +215,3 @@ const events = result.logs.filter(entry => entry.event === eventType); | ||
ErrorType, | ||
InvalidTxResultError, | ||
}; |
{ | ||
"name": "truffle-assertions", | ||
"version": "0.9.0", | ||
"version": "0.9.1", | ||
"description": "Additional assertions and utilities for testing Ethereum smart contracts in Truffle unit tests", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
19665
187