diff --git a/lib/modules/coverage/contract_source.js b/lib/modules/coverage/contract_source.js index c45e15be..0b91ca7d 100644 --- a/lib/modules/coverage/contract_source.js +++ b/lib/modules/coverage/contract_source.js @@ -114,6 +114,7 @@ class ContractSource { case 'Identifier': case 'Literal': case 'VariableDeclaration': + case 'PragmaDirective': // We don't need to do anything with these. Just carry on. break; @@ -190,10 +191,6 @@ class ContractSource { children = node.nodes; break; - case 'PragmaDirective': - // These nodes do nothing, so we move on. - break; - case 'FunctionDefinition': // Istanbul only wants the function definition, not the body, so we're // going to do some fun math here. @@ -243,16 +240,7 @@ class ContractSource { // Try to match the contract to the bytecode. If it doesn't, // then we bail. - trace.structLogs.forEach((step) => { - if(!contractMatches) return; - - if(!bytecode[step.pc]) { - // This contract won't match so we bail - contractMatches = false; - return; - } - }); - + contractMatches = trace.structLogs.every((step) => { return bytecode[step.pc]; }); if(!contractMatches) break; trace.structLogs.forEach((step) => { diff --git a/lib/modules/coverage/contract_sources.js b/lib/modules/coverage/contract_sources.js index 2b37a349..9c86eab8 100644 --- a/lib/modules/coverage/contract_sources.js +++ b/lib/modules/coverage/contract_sources.js @@ -50,8 +50,7 @@ class ContractSources { parseSolcOutput(output) { for(var file in output.contracts) { - var basename = path.basename(file); - var contractSource = this.files[basename]; + var contractSource = this.files[path.basename(file)]; if(!contractSource) continue; contractSource.parseSolcOutput(output.sources[file], output.contracts[file]); @@ -62,8 +61,7 @@ class ContractSources { var coverageReport = {}; for(var file in this.files) { - var contractSource = this.files[file]; - coverageReport[file] = contractSource.generateCodeCoverage(trace); + coverageReport[file] = this.files[file].generateCodeCoverage(trace); } if(!this.coverageReport) { diff --git a/lib/modules/coverage/source_map.js b/lib/modules/coverage/source_map.js index 67ba6ebf..84215d8e 100644 --- a/lib/modules/coverage/source_map.js +++ b/lib/modules/coverage/source_map.js @@ -15,8 +15,7 @@ class SourceMap { } subtract(sourceMap) { - var length = sourceMap.offset - this.offset; - return new SourceMap(this.offset, length); + return new SourceMap(this.offset, sourceMap.offset - this.offset); } toString() {