UNPKG

locklift

Version:

Node JS framework for working with Ever contracts. Inspired by Truffle and Hardhat. Helps you to build, test, run and maintain your smart contracts.

39 lines (38 loc) 1.72 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.supportEmitAndCall = void 0; const types_1 = require("../../internal/tracing/types"); const withNamedArgs_1 = require("./withNamedArgs"); const count_1 = require("./count"); const utils_1 = require("../utils"); const supportEmitAndCall = (Assertion, utils) => { Assertion.addMethod("emit", function (eventName, contract) { const rewriteThis = this; const viewTracingTree = rewriteThis.__flags.object; const events = (0, utils_1.getMessage)({ contract, viewTracingTree, msgName: eventName, msgType: types_1.TraceType.EVENT, }); this.assert(events.length > 0, `Expected event "${eventName}" to be emitted, but it wasn't`, `Expected event "${eventName}" NOT to be emitted, but it was`, true); utils.flag(this, "messages", events); return this; }); Assertion.addMethod("call", function (methodName, contract) { const rewriteThis = this; const viewTracingTree = rewriteThis.__flags.object; const calls = (0, utils_1.getMessage)({ contract, viewTracingTree, msgName: methodName, msgType: types_1.TraceType.FUNCTION_CALL, }); this.assert(calls.length > 0, `Expected method "${methodName}" to be called, but it wasn't`, `Expected method "${methodName}" NOT to be called, but it was`, true); utils.flag(this, "messages", calls); return this; }); (0, withNamedArgs_1.supportWithNamedArgs)(Assertion, utils); (0, count_1.supportWithCount)(Assertion, utils); }; exports.supportEmitAndCall = supportEmitAndCall;