Merge pull request #29 from sc-forks/filter-events

Add topic logging to coverageMap
pull/32/head
c-g-e-w-e-k-e- 8 years ago committed by GitHub
commit 7ac9a10971
  1. 1
      .gitignore
  2. 1
      bin/exec.js
  3. 19
      lib/coverageMap.js

1
.gitignore vendored

@ -1,4 +1,5 @@
allFiredEvents allFiredEvents
scTopics
coverage.json coverage.json
coverage/ coverage/
node_modules/ node_modules/

@ -41,6 +41,7 @@ function cleanUp(err) {
shell.config.silent = true; shell.config.silent = true;
shell.rm('-Rf', `${coverageDir}`); shell.rm('-Rf', `${coverageDir}`);
shell.rm('./allFiredEvents'); shell.rm('./allFiredEvents');
shell.rm('./scTopics');
if (testrpcProcess) { testrpcProcess.kill(); } if (testrpcProcess) { testrpcProcess.kill(); }
if (err) { if (err) {

@ -6,6 +6,7 @@
const SolidityCoder = require('web3/lib/solidity/coder.js'); const SolidityCoder = require('web3/lib/solidity/coder.js');
const path = require('path'); const path = require('path');
const keccak = require('keccakjs'); const keccak = require('keccakjs');
const fs = require('fs');
/** /**
* Converts solcover event data into an object that can be * Converts solcover event data into an object that can be
@ -64,10 +65,20 @@ module.exports = class CoverageMap {
return hash.digest('hex'); return hash.digest('hex');
}); });
this.lineTopics.push(keccakhex('__Coverage' + info.contractName + '(string,uint256)')); const lineHash = keccakhex('__Coverage' + info.contractName + '(string,uint256)');
this.functionTopics.push(keccakhex('__FunctionCoverage' + info.contractName + '(string,uint256)')); const fnHash = keccakhex('__FunctionCoverage' + info.contractName + '(string,uint256)');
this.branchTopics.push(keccakhex('__BranchCoverage' + info.contractName + '(string,uint256,uint256)')); const branchHash = keccakhex('__BranchCoverage' + info.contractName + '(string,uint256,uint256)');
this.statementTopics.push(keccakhex('__StatementCoverage' + info.contractName + '(string,uint256)')); const statementHash = keccakhex('__StatementCoverage' + info.contractName + '(string,uint256)');
this.lineTopics.push(lineHash);
this.functionTopics.push(fnHash);
this.branchTopics.push(branchHash);
this.statementTopics.push(statementHash);
fs.appendFileSync('./scTopics', `${lineHash}\n`);
fs.appendFileSync('./scTopics', `${fnHash}\n`);
fs.appendFileSync('./scTopics', `${branchHash}\n`);
fs.appendFileSync('./scTopics', `${statementHash}\n`);
} }
/** /**

Loading…
Cancel
Save