diff --git a/lib/tests/reporter.js b/lib/tests/reporter.js index 75d8ff01..13bfcdfd 100644 --- a/lib/tests/reporter.js +++ b/lib/tests/reporter.js @@ -25,6 +25,10 @@ class EmbarkSpec extends Base { console.log(fmt, receipt.className, receipt.gasUsed); } + function onBlockHeader(blockHeader) { + self.stats.totalGasCost += blockHeader.gasUsed; + self.stats.test.gasUsed += blockHeader.gasUsed; + } function onBlockHeader(blockHeader) { self.stats.totalGasCost += blockHeader.gasUsed; diff --git a/lib/tests/test.js b/lib/tests/test.js index ea8443b4..275b2dad 100644 --- a/lib/tests/test.js +++ b/lib/tests/test.js @@ -94,9 +94,22 @@ class Test { this.sim = getSimulator(); } this.web3.setProvider(this.sim.provider(this.simOptions)); + this.subscribeToPendingTransactions(); callback(); } + subscribeToPendingTransactions() { + const self = this; + if (self.logsSubscription) { + self.logsSubscription.unsubscribe(); + } + self.logsSubscription = self.web3.eth + .subscribe('newBlockHeaders') + .on("data", function (blockHeader) { + self.engine.events.emit('block:header', blockHeader); + }); + } + initDeployServices() { this.engine.startService("web3", { web3: this.web3