expectEvent.js 507 B

123456789101112131415161718192021
  1. const should = require('chai').should();
  2. async function inLogs (logs, eventName, eventArgs = {}) {
  3. const event = logs.find(e => e.event === eventName);
  4. should.exist(event);
  5. for (const [k, v] of Object.entries(eventArgs)) {
  6. should.exist(event.args[k]);
  7. event.args[k].should.eq(v);
  8. }
  9. return event;
  10. }
  11. async function inTransaction (tx, eventName, eventArgs = {}) {
  12. const { logs } = await tx;
  13. return inLogs(logs, eventName, eventArgs);
  14. }
  15. module.exports = {
  16. inLogs,
  17. inTransaction,
  18. };