aboutsummaryrefslogtreecommitdiffstats
path: root/packages/sol-cov/src/collect_coverage_entries.ts
diff options
context:
space:
mode:
authorperissology <perissology@protonmail.com>2018-06-15 02:17:04 +0800
committerperissology <perissology@protonmail.com>2018-06-15 02:17:04 +0800
commit7a41a5249fcb8457cb8beb823ce9a1362cdbfa98 (patch)
treeb7f03fab37dde2f652984c9aef486bde23f560d6 /packages/sol-cov/src/collect_coverage_entries.ts
parent0e354e5ea1f9951088331a310999bf87c8f8f4b3 (diff)
downloaddexon-0x-contracts-7a41a5249fcb8457cb8beb823ce9a1362cdbfa98.tar.gz
dexon-0x-contracts-7a41a5249fcb8457cb8beb823ce9a1362cdbfa98.tar.zst
dexon-0x-contracts-7a41a5249fcb8457cb8beb823ce9a1362cdbfa98.zip
Collect coverage for provided sources
When solidity generates source maps during contract compilation, the contracts are referred to by an id, which corresponds to an array index. We may not want to cover all sources that were included in a compilation, but because we use array indexes (vs. the id that is provided by solidity compiler) to map the contract to the sourceMap, the provided sourceCodes array must include the code at the correct index. This can result in empty slots in the sourceCodes array. This commit allows the coverage to only be collected for the contracts with provided sourceCode.
Diffstat (limited to 'packages/sol-cov/src/collect_coverage_entries.ts')
-rw-r--r--packages/sol-cov/src/collect_coverage_entries.ts2
1 files changed, 1 insertions, 1 deletions
diff --git a/packages/sol-cov/src/collect_coverage_entries.ts b/packages/sol-cov/src/collect_coverage_entries.ts
index b145f044e..3fc85008c 100644
--- a/packages/sol-cov/src/collect_coverage_entries.ts
+++ b/packages/sol-cov/src/collect_coverage_entries.ts
@@ -10,7 +10,7 @@ const coverageEntriesBySourceHash: { [sourceHash: string]: CoverageEntriesDescri
export const collectCoverageEntries = (contractSource: string) => {
const sourceHash = ethUtil.sha3(contractSource).toString('hex');
- if (_.isUndefined(coverageEntriesBySourceHash[sourceHash])) {
+ if (_.isUndefined(coverageEntriesBySourceHash[sourceHash]) && !_.isUndefined(contractSource)) {
const ast = parser.parse(contractSource, { range: true });
const locationByOffset = getLocationByOffset(contractSource);
const visitor = new ASTVisitor(locationByOffset);