Files
openzeppelin-contracts/test/helpers/expectEvent.js
Facundo Spagnuolo 92133be7ea Add ERC20 opt-in migration contract (#1054)
* Extract standard token behaviuor to reuse it in other tests

* Add opt in ERC20 migration contract

* Make migration contract not to depend from standard token

* Changes based on feedback

* Improve MigratableERC20 inline documentation

* move behaviors to behaviors directory

* refactor MigratableERC20 into ERC20Migrator

* fix errors

* change expectEvent to support multiple events with same name

* fix tests

* update documentation

* rename MigratableERC20 files to ERC20Migrator

* move to drafts

* test beginMigration

* rename to ERC20Migrator

* missing semicolon  (╯°□°)╯︵ ┻━┻

* add non-zero check

* improve documentation based on review comments

* improve test descriptions

* improve docs

* add getters

* fix contract

* improve tests
2018-09-07 14:13:23 -03:00

34 lines
623 B
JavaScript

const should = require('chai').should();
function inLogs (logs, eventName, eventArgs = {}) {
const event = logs.find(function (e) {
if (e.event === eventName) {
let matches = true;
for (const [k, v] of Object.entries(eventArgs)) {
if (e.args[k] !== v) {
matches = false;
}
}
if (matches) {
return true;
}
}
});
should.exist(event);
return event;
}
async function inTransaction (tx, eventName, eventArgs = {}) {
const { logs } = await tx;
return inLogs(logs, eventName, eventArgs);
}
module.exports = {
inLogs,
inTransaction,
};