aboutsummaryrefslogtreecommitdiffstats
path: root/packages/sol-cov/src
diff options
context:
space:
mode:
authorLeonid Logvinov <logvinov.leon@gmail.com>2018-05-11 18:12:39 +0800
committerGitHub <noreply@github.com>2018-05-11 18:12:39 +0800
commitf42f608f3f97a5244f09f17ae5ee184c0f775de3 (patch)
tree08fd03d69f8a7dfcc7beadcd56c5d1624928c430 /packages/sol-cov/src
parent44f17c1706e7b3208fdc0702c54a8cd943132fd3 (diff)
parentc093aab350dfbd86972d6388c3923ec60fc4501a (diff)
downloaddexon-sol-tools-f42f608f3f97a5244f09f17ae5ee184c0f775de3.tar
dexon-sol-tools-f42f608f3f97a5244f09f17ae5ee184c0f775de3.tar.gz
dexon-sol-tools-f42f608f3f97a5244f09f17ae5ee184c0f775de3.tar.bz2
dexon-sol-tools-f42f608f3f97a5244f09f17ae5ee184c0f775de3.tar.lz
dexon-sol-tools-f42f608f3f97a5244f09f17ae5ee184c0f775de3.tar.xz
dexon-sol-tools-f42f608f3f97a5244f09f17ae5ee184c0f775de3.tar.zst
dexon-sol-tools-f42f608f3f97a5244f09f17ae5ee184c0f775de3.zip
Merge pull request #574 from 0xProject/feature/rm-rf-deployer
Remove @0xproject/deployer.Deployer. Make contracts able to deploy themselves
Diffstat (limited to 'packages/sol-cov/src')
-rw-r--r--packages/sol-cov/src/collect_contract_data.ts2
-rw-r--r--packages/sol-cov/src/coverage_manager.ts15
-rw-r--r--packages/sol-cov/src/coverage_subprovider.ts10
3 files changed, 9 insertions, 18 deletions
diff --git a/packages/sol-cov/src/collect_contract_data.ts b/packages/sol-cov/src/collect_contract_data.ts
index bb20e98be..2c2a12835 100644
--- a/packages/sol-cov/src/collect_contract_data.ts
+++ b/packages/sol-cov/src/collect_contract_data.ts
@@ -5,7 +5,7 @@ import * as path from 'path';
import { ContractData } from './types';
-export const collectContractsData = (artifactsPath: string, sourcesPath: string, networkId: number) => {
+export const collectContractsData = (artifactsPath: string, sourcesPath: string) => {
const artifactsGlob = `${artifactsPath}/**/*.json`;
const artifactFileNames = glob.sync(artifactsGlob, { absolute: true });
const contractsData: ContractData[] = [];
diff --git a/packages/sol-cov/src/coverage_manager.ts b/packages/sol-cov/src/coverage_manager.ts
index 6a57d07c9..f50f010b9 100644
--- a/packages/sol-cov/src/coverage_manager.ts
+++ b/packages/sol-cov/src/coverage_manager.ts
@@ -1,3 +1,4 @@
+import { addHexPrefix } from 'ethereumjs-util';
import * as fs from 'fs';
import { Collector } from 'istanbul';
import * as _ from 'lodash';
@@ -36,21 +37,18 @@ export class CoverageManager {
constructor(
artifactsPath: string,
sourcesPath: string,
- networkId: number,
getContractCodeAsync: (address: string) => Promise<string>,
) {
this._getContractCodeAsync = getContractCodeAsync;
this._sourcesPath = sourcesPath;
- this._contractsData = collectContractsData(artifactsPath, this._sourcesPath, networkId);
+ this._contractsData = collectContractsData(artifactsPath, this._sourcesPath);
}
public appendTraceInfo(traceInfo: TraceInfo): void {
this._traceInfos.push(traceInfo);
}
public async writeCoverageAsync(): Promise<void> {
const finalCoverage = await this._computeCoverageAsync();
- const jsonReplacer: null = null;
- const numberOfJsonSpaces = 4;
- const stringifiedCoverage = JSON.stringify(finalCoverage, jsonReplacer, numberOfJsonSpaces);
+ const stringifiedCoverage = JSON.stringify(finalCoverage, null, '\t');
fs.writeFileSync('coverage/coverage.json', stringifiedCoverage);
}
private _getSingleFileCoverageForTrace(
@@ -134,7 +132,7 @@ export class CoverageManager {
if (traceInfo.address !== constants.NEW_CONTRACT) {
// Runtime transaction
let runtimeBytecode = (traceInfo as TraceInfoExistingContract).runtimeBytecode;
- runtimeBytecode = utils.removeHexPrefix(runtimeBytecode);
+ runtimeBytecode = addHexPrefix(runtimeBytecode);
const contractData = _.find(this._contractsData, { runtimeBytecode }) as ContractData;
if (_.isUndefined(contractData)) {
throw new Error(`Transaction to an unknown address: ${traceInfo.address}`);
@@ -159,7 +157,7 @@ export class CoverageManager {
} else {
// Contract creation transaction
let bytecode = (traceInfo as TraceInfoNewContract).bytecode;
- bytecode = utils.removeHexPrefix(bytecode);
+ bytecode = addHexPrefix(bytecode);
const contractData = _.find(this._contractsData, contractDataCandidate =>
bytecode.startsWith(contractDataCandidate.bytecode),
) as ContractData;
@@ -185,7 +183,6 @@ export class CoverageManager {
}
}
}
- // TODO: Remove any cast as soon as https://github.com/DefinitelyTyped/DefinitelyTyped/pull/24233 gets merged
- return (collector as any).getFinalCoverage();
+ return collector.getFinalCoverage();
}
}
diff --git a/packages/sol-cov/src/coverage_subprovider.ts b/packages/sol-cov/src/coverage_subprovider.ts
index 6504d5a46..b08291afb 100644
--- a/packages/sol-cov/src/coverage_subprovider.ts
+++ b/packages/sol-cov/src/coverage_subprovider.ts
@@ -28,19 +28,13 @@ export class CoverageSubprovider extends Subprovider {
* Instantiates a CoverageSubprovider instance
* @param artifactsPath Path to the smart contract artifacts
* @param sourcesPath Path to the smart contract source files
- * @param networkId network id
* @param defaultFromAddress default from address to use when sending transactions
*/
- constructor(artifactsPath: string, sourcesPath: string, networkId: number, defaultFromAddress: string) {
+ constructor(artifactsPath: string, sourcesPath: string, defaultFromAddress: string) {
super();
this._lock = new Lock();
this._defaultFromAddress = defaultFromAddress;
- this._coverageManager = new CoverageManager(
- artifactsPath,
- sourcesPath,
- networkId,
- this._getContractCodeAsync.bind(this),
- );
+ this._coverageManager = new CoverageManager(artifactsPath, sourcesPath, this._getContractCodeAsync.bind(this));
}
/**
* Write the test coverage results to a file in Istanbul format.