From 3fc99dbad5f7f727f7474473c261a7b512045e63 Mon Sep 17 00:00:00 2001 From: Leonid Logvinov Date: Fri, 4 May 2018 12:16:11 +0200 Subject: Updated CHANGELOGS --- packages/sol-cov/CHANGELOG.json | 9 +++++++++ packages/sol-cov/CHANGELOG.md | 6 +++++- 2 files changed, 14 insertions(+), 1 deletion(-) (limited to 'packages/sol-cov') diff --git a/packages/sol-cov/CHANGELOG.json b/packages/sol-cov/CHANGELOG.json index 508b70631..64cf42f55 100644 --- a/packages/sol-cov/CHANGELOG.json +++ b/packages/sol-cov/CHANGELOG.json @@ -1,4 +1,13 @@ [ + { + "timestamp": 1525428773, + "version": "0.0.9", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, { "timestamp": 1524044013, "version": "0.0.8", diff --git a/packages/sol-cov/CHANGELOG.md b/packages/sol-cov/CHANGELOG.md index fa8039919..3dbc1d6c7 100644 --- a/packages/sol-cov/CHANGELOG.md +++ b/packages/sol-cov/CHANGELOG.md @@ -5,11 +5,15 @@ Edit the package's CHANGELOG.json file only. CHANGELOG +## v0.0.9 - _May 4, 2018_ + + * Dependencies updated + ## v0.0.8 - _April 18, 2018_ * Dependencies updated -## v0.0.7 - _April 12, 2018_ +## v0.0.7 - _April 11, 2018_ * Dependencies updated -- cgit From 8dd91248639d167d198df949d7749a93d6af5bf3 Mon Sep 17 00:00:00 2001 From: Leonid Logvinov Date: Fri, 4 May 2018 12:16:17 +0200 Subject: Publish - 0x.js@0.37.0 - @0xproject/abi-gen@0.2.12 - @0xproject/assert@0.2.8 - @0xproject/base-contract@0.3.0 - @0xproject/connect@0.6.11 - contracts@2.1.26 - @0xproject/deployer@0.4.2 - @0xproject/dev-utils@0.4.0 - @0xproject/json-schemas@0.7.22 - @0xproject/metacoin@0.0.5 - @0xproject/migrations@0.0.4 - @0xproject/monorepo-scripts@0.1.19 - @0xproject/order-utils@0.0.2 - @0xproject/react-docs-example@0.0.9 - @0xproject/react-docs@0.0.9 - @0xproject/react-shared@0.1.4 - @0xproject/sol-cov@0.0.9 - @0xproject/sol-resolver@0.0.3 - @0xproject/sra-report@0.0.12 - @0xproject/subproviders@0.10.0 - @0xproject/testnet-faucets@1.0.27 - @0xproject/tslint-config@0.4.17 - @0xproject/types@0.6.2 - @0xproject/typescript-typings@0.3.0 - @0xproject/utils@0.6.0 - @0xproject/web3-wrapper@0.6.2 - @0xproject/website@0.0.29 --- packages/sol-cov/package.json | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'packages/sol-cov') diff --git a/packages/sol-cov/package.json b/packages/sol-cov/package.json index 886ca52c2..2df56a4b7 100644 --- a/packages/sol-cov/package.json +++ b/packages/sol-cov/package.json @@ -1,6 +1,6 @@ { "name": "@0xproject/sol-cov", - "version": "0.0.8", + "version": "0.0.9", "description": "Generate coverage reports for Solidity code", "main": "lib/src/index.js", "types": "lib/src/index.d.ts", @@ -43,9 +43,9 @@ }, "homepage": "https://github.com/0xProject/0x.js/packages/sol-cov/README.md", "dependencies": { - "@0xproject/subproviders": "^0.9.0", - "@0xproject/types": "^0.6.1", - "@0xproject/typescript-typings": "^0.2.0", + "@0xproject/subproviders": "^0.10.0", + "@0xproject/types": "^0.6.2", + "@0xproject/typescript-typings": "^0.3.0", "ethereumjs-util": "^5.1.1", "glob": "^7.1.2", "istanbul": "^0.4.5", @@ -55,8 +55,8 @@ }, "devDependencies": { "@0xproject/deployer": "^0.3.5", - "@0xproject/monorepo-scripts": "^0.1.18", - "@0xproject/tslint-config": "^0.4.16", + "@0xproject/monorepo-scripts": "^0.1.19", + "@0xproject/tslint-config": "^0.4.17", "@types/istanbul": "^0.4.29", "@types/mocha": "^2.2.42", "@types/node": "^8.0.53", -- cgit From bf87b1a6af5bf6041c7051272568ff3d67ba3f9c Mon Sep 17 00:00:00 2001 From: Leonid Logvinov Date: Sat, 5 May 2018 01:55:04 +0200 Subject: Updated CHANGELOGS --- packages/sol-cov/CHANGELOG.json | 9 +++++++++ packages/sol-cov/CHANGELOG.md | 4 ++++ 2 files changed, 13 insertions(+) (limited to 'packages/sol-cov') diff --git a/packages/sol-cov/CHANGELOG.json b/packages/sol-cov/CHANGELOG.json index 64cf42f55..468957fe3 100644 --- a/packages/sol-cov/CHANGELOG.json +++ b/packages/sol-cov/CHANGELOG.json @@ -1,4 +1,13 @@ [ + { + "timestamp": 1525477860, + "version": "0.0.10", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, { "timestamp": 1525428773, "version": "0.0.9", diff --git a/packages/sol-cov/CHANGELOG.md b/packages/sol-cov/CHANGELOG.md index 3dbc1d6c7..9e2995328 100644 --- a/packages/sol-cov/CHANGELOG.md +++ b/packages/sol-cov/CHANGELOG.md @@ -5,6 +5,10 @@ Edit the package's CHANGELOG.json file only. CHANGELOG +## v0.0.10 - _May 5, 2018_ + + * Dependencies updated + ## v0.0.9 - _May 4, 2018_ * Dependencies updated -- cgit From 69a6166b6a1d39afc24b8dd950ec5d8539a03420 Mon Sep 17 00:00:00 2001 From: Leonid Logvinov Date: Sat, 5 May 2018 01:55:12 +0200 Subject: Publish - 0x.js@0.37.2 - @0xproject/abi-gen@0.2.13 - @0xproject/assert@0.2.9 - @0xproject/base-contract@0.3.1 - @0xproject/connect@0.6.12 - contracts@2.1.28 - @0xproject/deployer@0.4.3 - @0xproject/dev-utils@0.4.1 - @0xproject/json-schemas@0.7.23 - @0xproject/metacoin@0.0.6 - @0xproject/migrations@0.0.5 - @0xproject/order-utils@0.0.4 - @0xproject/react-docs-example@0.0.11 - @0xproject/react-docs@0.0.11 - @0xproject/react-shared@0.1.6 - @0xproject/sol-cov@0.0.10 - @0xproject/sol-resolver@0.0.4 - @0xproject/sra-report@0.0.14 - @0xproject/subproviders@0.10.1 - @0xproject/testnet-faucets@1.0.29 - @0xproject/types@0.6.3 - @0xproject/typescript-typings@0.3.1 - @0xproject/utils@0.6.1 - @0xproject/web3-wrapper@0.6.3 - @0xproject/website@0.0.32 --- packages/sol-cov/package.json | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'packages/sol-cov') diff --git a/packages/sol-cov/package.json b/packages/sol-cov/package.json index 2df56a4b7..4eb1147d7 100644 --- a/packages/sol-cov/package.json +++ b/packages/sol-cov/package.json @@ -1,6 +1,6 @@ { "name": "@0xproject/sol-cov", - "version": "0.0.9", + "version": "0.0.10", "description": "Generate coverage reports for Solidity code", "main": "lib/src/index.js", "types": "lib/src/index.d.ts", @@ -43,9 +43,9 @@ }, "homepage": "https://github.com/0xProject/0x.js/packages/sol-cov/README.md", "dependencies": { - "@0xproject/subproviders": "^0.10.0", - "@0xproject/types": "^0.6.2", - "@0xproject/typescript-typings": "^0.3.0", + "@0xproject/subproviders": "^0.10.1", + "@0xproject/types": "^0.6.3", + "@0xproject/typescript-typings": "^0.3.1", "ethereumjs-util": "^5.1.1", "glob": "^7.1.2", "istanbul": "^0.4.5", -- cgit From 72b2a1c66fa9fb85ea8515645b97332eee204550 Mon Sep 17 00:00:00 2001 From: Leonid Logvinov Date: Wed, 18 Apr 2018 22:22:39 +0200 Subject: Implement new artifacts format --- packages/sol-cov/src/collect_contract_data.ts | 21 +++++++++------------ packages/sol-cov/src/coverage_manager.ts | 10 ++++++++-- 2 files changed, 17 insertions(+), 14 deletions(-) (limited to 'packages/sol-cov') diff --git a/packages/sol-cov/src/collect_contract_data.ts b/packages/sol-cov/src/collect_contract_data.ts index 1d8bc7178..3d8a45cec 100644 --- a/packages/sol-cov/src/collect_contract_data.ts +++ b/packages/sol-cov/src/collect_contract_data.ts @@ -8,25 +8,22 @@ import { ContractData } from './types'; export const collectContractsData = (artifactsPath: string, sourcesPath: string, networkId: number) => { const artifactsGlob = `${artifactsPath}/**/*.json`; const artifactFileNames = glob.sync(artifactsGlob, { absolute: true }); - const contractsDataIfExists: Array = _.map(artifactFileNames, artifactFileName => { + const contractsData: ContractData[] = []; + _.forEach(artifactFileNames, artifactFileName => { const artifact = JSON.parse(fs.readFileSync(artifactFileName).toString()); - const sources = artifact.networks[networkId].sources; - const contractName = artifact.contract_name; + const sources = _.keys(artifact.sources); + const contractName = artifact.contractName; // We don't compute coverage for dependencies const sourceCodes = _.map(sources, (source: string) => fs.readFileSync(source).toString()); - if (_.isUndefined(artifact.networks[networkId])) { - throw new Error(`No ${contractName} artifacts found for networkId ${networkId}`); - } const contractData = { sourceCodes, sources, - sourceMap: artifact.networks[networkId].source_map, - sourceMapRuntime: artifact.networks[networkId].source_map_runtime, - runtimeBytecode: artifact.networks[networkId].runtime_bytecode, - bytecode: artifact.networks[networkId].bytecode, + bytecode: artifact.compilerOutput.evm.bytecode.object, + sourceMap: artifact.compilerOutput.evm.bytecode.sourceMap, + runtimeBytecode: artifact.compilerOutput.evm.deployedBytecode.object, + sourceMapRuntime: artifact.compilerOutput.evm.deployedBytecode.sourceMap, }; - return contractData; + contractsData.push(contractData); }); - const contractsData = _.filter(contractsDataIfExists, contractData => !_.isEmpty(contractData)) as ContractData[]; return contractsData; }; diff --git a/packages/sol-cov/src/coverage_manager.ts b/packages/sol-cov/src/coverage_manager.ts index 230ccc3c9..509c1cb99 100644 --- a/packages/sol-cov/src/coverage_manager.ts +++ b/packages/sol-cov/src/coverage_manager.ts @@ -130,7 +130,10 @@ export class CoverageManager { for (const traceInfo of this._traceInfos) { if (traceInfo.address !== constants.NEW_CONTRACT) { // Runtime transaction - const runtimeBytecode = (traceInfo as TraceInfoExistingContract).runtimeBytecode; + let runtimeBytecode = (traceInfo as TraceInfoExistingContract).runtimeBytecode; + if (runtimeBytecode.startsWith('0x')) { + runtimeBytecode = runtimeBytecode.slice(2); + } const contractData = _.find(this._contractsData, { runtimeBytecode }) as ContractData; if (_.isUndefined(contractData)) { throw new Error(`Transaction to an unknown address: ${traceInfo.address}`); @@ -154,7 +157,10 @@ export class CoverageManager { } } else { // Contract creation transaction - const bytecode = (traceInfo as TraceInfoNewContract).bytecode; + let bytecode = (traceInfo as TraceInfoNewContract).bytecode; + if (bytecode.startsWith('0x')) { + bytecode = bytecode.slice(2); + } const contractData = _.find(this._contractsData, contractDataCandidate => bytecode.startsWith(contractDataCandidate.bytecode), ) as ContractData; -- cgit From c9b8f2a397606f3667e5829b5a0364f9896daec5 Mon Sep 17 00:00:00 2001 From: Leonid Logvinov Date: Mon, 7 May 2018 10:52:28 +0200 Subject: Fix sol-cov to work with the new artifacts format --- packages/sol-cov/src/collect_contract_data.ts | 4 ++- packages/sol-cov/src/coverage_manager.ts | 51 ++++++++++++++------------- 2 files changed, 30 insertions(+), 25 deletions(-) (limited to 'packages/sol-cov') diff --git a/packages/sol-cov/src/collect_contract_data.ts b/packages/sol-cov/src/collect_contract_data.ts index 3d8a45cec..bb20e98be 100644 --- a/packages/sol-cov/src/collect_contract_data.ts +++ b/packages/sol-cov/src/collect_contract_data.ts @@ -14,7 +14,9 @@ export const collectContractsData = (artifactsPath: string, sourcesPath: string, const sources = _.keys(artifact.sources); const contractName = artifact.contractName; // We don't compute coverage for dependencies - const sourceCodes = _.map(sources, (source: string) => fs.readFileSync(source).toString()); + const sourceCodes = _.map(sources, (source: string) => + fs.readFileSync(path.join(sourcesPath, source)).toString(), + ); const contractData = { sourceCodes, sources, diff --git a/packages/sol-cov/src/coverage_manager.ts b/packages/sol-cov/src/coverage_manager.ts index 509c1cb99..e932ac081 100644 --- a/packages/sol-cov/src/coverage_manager.ts +++ b/packages/sol-cov/src/coverage_manager.ts @@ -29,10 +29,31 @@ import { import { utils } from './utils'; export class CoverageManager { + private _sourcesPath: string; private _traceInfos: TraceInfo[] = []; private _contractsData: ContractData[] = []; private _getContractCodeAsync: (address: string) => Promise; - private static _getSingleFileCoverageForTrace( + constructor( + artifactsPath: string, + sourcesPath: string, + networkId: number, + getContractCodeAsync: (address: string) => Promise, + ) { + this._getContractCodeAsync = getContractCodeAsync; + this._sourcesPath = sourcesPath; + this._contractsData = collectContractsData(artifactsPath, this._sourcesPath, networkId); + } + public appendTraceInfo(traceInfo: TraceInfo): void { + this._traceInfos.push(traceInfo); + } + public async writeCoverageAsync(): Promise { + const finalCoverage = await this._computeCoverageAsync(); + const jsonReplacer: null = null; + const numberOfJsonSpaces = 4; + const stringifiedCoverage = JSON.stringify(finalCoverage, jsonReplacer, numberOfJsonSpaces); + fs.writeFileSync('coverage/coverage.json', stringifiedCoverage); + } + private _getSingleFileCoverageForTrace( contractData: ContractData, coveredPcs: number[], pcToSourceRange: { [programCounter: number]: SourceRange }, @@ -94,11 +115,12 @@ export class CoverageManager { ); statementCoverage[modifierStatementId] = isModifierCovered; } + const absoluteFileName = path.join(this._sourcesPath, fileName); const partialCoverage = { - [contractData.sources[fileIndex]]: { + [absoluteFileName]: { ...coverageEntriesDescription, l: {}, // It's able to derive it from statement coverage - path: fileName, + path: absoluteFileName, f: functionCoverage, s: statementCoverage, b: branchCoverage, @@ -106,25 +128,6 @@ export class CoverageManager { }; return partialCoverage; } - constructor( - artifactsPath: string, - sourcesPath: string, - networkId: number, - getContractCodeAsync: (address: string) => Promise, - ) { - this._getContractCodeAsync = getContractCodeAsync; - this._contractsData = collectContractsData(artifactsPath, sourcesPath, networkId); - } - public appendTraceInfo(traceInfo: TraceInfo): void { - this._traceInfos.push(traceInfo); - } - public async writeCoverageAsync(): Promise { - const finalCoverage = await this._computeCoverageAsync(); - const jsonReplacer: null = null; - const numberOfJsonSpaces = 4; - const stringifiedCoverage = JSON.stringify(finalCoverage, jsonReplacer, numberOfJsonSpaces); - fs.writeFileSync('coverage/coverage.json', stringifiedCoverage); - } private async _computeCoverageAsync(): Promise { const collector = new Collector(); for (const traceInfo of this._traceInfos) { @@ -147,7 +150,7 @@ export class CoverageManager { contractData.sources, ); for (let fileIndex = 0; fileIndex < contractData.sources.length; fileIndex++) { - const singleFileCoverageForTrace = CoverageManager._getSingleFileCoverageForTrace( + const singleFileCoverageForTrace = this._getSingleFileCoverageForTrace( contractData, traceInfo.coveredPcs, pcToSourceRange, @@ -176,7 +179,7 @@ export class CoverageManager { contractData.sources, ); for (let fileIndex = 0; fileIndex < contractData.sources.length; fileIndex++) { - const singleFileCoverageForTrace = CoverageManager._getSingleFileCoverageForTrace( + const singleFileCoverageForTrace = this._getSingleFileCoverageForTrace( contractData, traceInfo.coveredPcs, pcToSourceRange, -- cgit From 9e67e12732a0fc87f0000917e6bbf21c3c2db260 Mon Sep 17 00:00:00 2001 From: Leonid Logvinov Date: Mon, 7 May 2018 14:04:58 +0200 Subject: Add removeHexPrefix util method --- packages/sol-cov/src/coverage_manager.ts | 8 ++------ packages/sol-cov/src/utils.ts | 4 ++++ 2 files changed, 6 insertions(+), 6 deletions(-) (limited to 'packages/sol-cov') diff --git a/packages/sol-cov/src/coverage_manager.ts b/packages/sol-cov/src/coverage_manager.ts index e932ac081..6a57d07c9 100644 --- a/packages/sol-cov/src/coverage_manager.ts +++ b/packages/sol-cov/src/coverage_manager.ts @@ -134,9 +134,7 @@ export class CoverageManager { if (traceInfo.address !== constants.NEW_CONTRACT) { // Runtime transaction let runtimeBytecode = (traceInfo as TraceInfoExistingContract).runtimeBytecode; - if (runtimeBytecode.startsWith('0x')) { - runtimeBytecode = runtimeBytecode.slice(2); - } + runtimeBytecode = utils.removeHexPrefix(runtimeBytecode); const contractData = _.find(this._contractsData, { runtimeBytecode }) as ContractData; if (_.isUndefined(contractData)) { throw new Error(`Transaction to an unknown address: ${traceInfo.address}`); @@ -161,9 +159,7 @@ export class CoverageManager { } else { // Contract creation transaction let bytecode = (traceInfo as TraceInfoNewContract).bytecode; - if (bytecode.startsWith('0x')) { - bytecode = bytecode.slice(2); - } + bytecode = utils.removeHexPrefix(bytecode); const contractData = _.find(this._contractsData, contractDataCandidate => bytecode.startsWith(contractDataCandidate.bytecode), ) as ContractData; diff --git a/packages/sol-cov/src/utils.ts b/packages/sol-cov/src/utils.ts index f155043a1..d970c42ee 100644 --- a/packages/sol-cov/src/utils.ts +++ b/packages/sol-cov/src/utils.ts @@ -4,6 +4,10 @@ export const utils = { compareLineColumn(lhs: LineColumn, rhs: LineColumn): number { return lhs.line !== rhs.line ? lhs.line - rhs.line : lhs.column - rhs.column; }, + removeHexPrefix(hex: string): string { + const hexPrefix = '0x'; + return hex.startsWith(hexPrefix) ? hex.slice(hexPrefix.length) : hex; + }, isRangeInside(childRange: SingleFileSourceRange, parentRange: SingleFileSourceRange): boolean { return ( utils.compareLineColumn(parentRange.start, childRange.start) <= 0 && -- cgit From c7a147f49d6e16e677eab5a9a70191720ec61963 Mon Sep 17 00:00:00 2001 From: Leonid Logvinov Date: Wed, 9 May 2018 23:14:44 +0200 Subject: Configure the compiler to generate artifacts with deployedBytecode --- packages/sol-cov/compiler.json | 18 ++++++++++++++++++ packages/sol-cov/package.json | 2 +- 2 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 packages/sol-cov/compiler.json (limited to 'packages/sol-cov') diff --git a/packages/sol-cov/compiler.json b/packages/sol-cov/compiler.json new file mode 100644 index 000000000..a6a0c6d3a --- /dev/null +++ b/packages/sol-cov/compiler.json @@ -0,0 +1,18 @@ +{ + "contracts": ["SimpleStorage"], + "contractsDir": "test/fixtures/contracts", + "artifactsDir": "test/fixtures/artifacts", + "compilerSettings": { + "outputSelection": { + "*": { + "*": [ + "abi", + "evm.bytecode.object", + "evm.bytecode.sourceMap", + "evm.deployedBytecode.object", + "evm.deployedBytecode.sourceMap" + ] + } + } + } +} diff --git a/packages/sol-cov/package.json b/packages/sol-cov/package.json index 4eb1147d7..425b561a6 100644 --- a/packages/sol-cov/package.json +++ b/packages/sol-cov/package.json @@ -14,7 +14,7 @@ "run_mocha": "mocha lib/test/**/*_test.js --exit", "clean": "shx rm -rf lib scripts", "build": "copyfiles 'test/fixtures/**/*' ./lib && tsc && copyfiles -u 3 './lib/src/monorepo_scripts/**/*' ./scripts", - "compile_test": "node ../deployer/lib/src/cli.js compile --contracts SimpleStorage --contracts-dir test/fixtures/contracts --artifacts-dir test/fixtures/artifacts", + "compile_test": "node ../deployer/lib/src/cli.js compile", "manual:postpublish": "yarn build; node ./scripts/postpublish.js", "docs:stage": "yarn build && node ./scripts/stage_docs.js", "docs:json": "typedoc --excludePrivate --excludeExternals --target ES5 --json $JSON_FILE_PATH $PROJECT_FILES", -- cgit From 28e83c21e239ff790c8a9844ee1c23542c8c6c3f Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Thu, 10 May 2018 15:22:13 +0200 Subject: Remove uneeded tslint config --- packages/sol-cov/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'packages/sol-cov') diff --git a/packages/sol-cov/package.json b/packages/sol-cov/package.json index 4eb1147d7..004cc5f54 100644 --- a/packages/sol-cov/package.json +++ b/packages/sol-cov/package.json @@ -6,7 +6,7 @@ "types": "lib/src/index.d.ts", "scripts": { "build:watch": "tsc -w", - "lint": "tslint --project . 'src/**/*.ts'", + "lint": "tslint --project ., "test": "run-s clean build compile_test run_mocha", "test:coverage": "nyc npm run test --all && yarn coverage:report:lcov", "coverage:report:lcov": "nyc report --reporter=text-lcov > coverage/lcov.info", -- cgit From 832e1e2cf7daa94c900a2f0bd37fb9a85e995f3e Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Thu, 10 May 2018 15:26:19 +0200 Subject: Add missing quote --- packages/sol-cov/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'packages/sol-cov') diff --git a/packages/sol-cov/package.json b/packages/sol-cov/package.json index 004cc5f54..4bea117de 100644 --- a/packages/sol-cov/package.json +++ b/packages/sol-cov/package.json @@ -6,7 +6,7 @@ "types": "lib/src/index.d.ts", "scripts": { "build:watch": "tsc -w", - "lint": "tslint --project ., + "lint": "tslint --project .", "test": "run-s clean build compile_test run_mocha", "test:coverage": "nyc npm run test --all && yarn coverage:report:lcov", "coverage:report:lcov": "nyc report --reporter=text-lcov > coverage/lcov.info", -- cgit From a6f72de09d7b2c9738b78d2097baa9906838fbe9 Mon Sep 17 00:00:00 2001 From: Leonid Logvinov Date: Tue, 8 May 2018 15:42:07 +0200 Subject: Rename deployer to sol-compiler --- packages/sol-cov/package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'packages/sol-cov') diff --git a/packages/sol-cov/package.json b/packages/sol-cov/package.json index 425b561a6..68937f507 100644 --- a/packages/sol-cov/package.json +++ b/packages/sol-cov/package.json @@ -14,7 +14,7 @@ "run_mocha": "mocha lib/test/**/*_test.js --exit", "clean": "shx rm -rf lib scripts", "build": "copyfiles 'test/fixtures/**/*' ./lib && tsc && copyfiles -u 3 './lib/src/monorepo_scripts/**/*' ./scripts", - "compile_test": "node ../deployer/lib/src/cli.js compile", + "compile_test": "node ../sol-compiler/lib/src/cli.js compile", "manual:postpublish": "yarn build; node ./scripts/postpublish.js", "docs:stage": "yarn build && node ./scripts/stage_docs.js", "docs:json": "typedoc --excludePrivate --excludeExternals --target ES5 --json $JSON_FILE_PATH $PROJECT_FILES", @@ -54,7 +54,7 @@ "solidity-parser-antlr": "^0.2.8" }, "devDependencies": { - "@0xproject/deployer": "^0.3.5", + "@0xproject/sol-compiler": "^0.3.5", "@0xproject/monorepo-scripts": "^0.1.19", "@0xproject/tslint-config": "^0.4.17", "@types/istanbul": "^0.4.29", -- cgit From 75d24dea0e10d098d3833488a420498410c22991 Mon Sep 17 00:00:00 2001 From: Leonid Logvinov Date: Tue, 8 May 2018 16:02:04 +0200 Subject: Fix linter issues --- packages/sol-cov/package.json | 5 ++--- packages/sol-cov/src/collect_contract_data.ts | 2 +- packages/sol-cov/src/coverage_manager.ts | 11 +++++------ packages/sol-cov/src/coverage_subprovider.ts | 10 ++-------- packages/sol-cov/test/collect_contracts_data_test.ts | 3 +-- 5 files changed, 11 insertions(+), 20 deletions(-) (limited to 'packages/sol-cov') diff --git a/packages/sol-cov/package.json b/packages/sol-cov/package.json index 68937f507..f57a317de 100644 --- a/packages/sol-cov/package.json +++ b/packages/sol-cov/package.json @@ -6,7 +6,7 @@ "types": "lib/src/index.d.ts", "scripts": { "build:watch": "tsc -w", - "lint": "tslint --project . 'src/**/*.ts'", + "lint": "tslint --project .", "test": "run-s clean build compile_test run_mocha", "test:coverage": "nyc npm run test --all && yarn coverage:report:lcov", "coverage:report:lcov": "nyc report --reporter=text-lcov > coverage/lcov.info", @@ -54,10 +54,9 @@ "solidity-parser-antlr": "^0.2.8" }, "devDependencies": { - "@0xproject/sol-compiler": "^0.3.5", "@0xproject/monorepo-scripts": "^0.1.19", "@0xproject/tslint-config": "^0.4.17", - "@types/istanbul": "^0.4.29", + "@types/istanbul": "^0.4.30", "@types/mocha": "^2.2.42", "@types/node": "^8.0.53", "chai": "^4.0.1", 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..bf580025b 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,12 +37,11 @@ export class CoverageManager { constructor( artifactsPath: string, sourcesPath: string, - networkId: number, getContractCodeAsync: (address: string) => Promise, ) { 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); @@ -134,7 +134,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 +159,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 +185,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. diff --git a/packages/sol-cov/test/collect_contracts_data_test.ts b/packages/sol-cov/test/collect_contracts_data_test.ts index 943a4a878..c7c1dfe32 100644 --- a/packages/sol-cov/test/collect_contracts_data_test.ts +++ b/packages/sol-cov/test/collect_contracts_data_test.ts @@ -12,8 +12,7 @@ describe('Collect contracts data', () => { it('correctly collects contracts data', () => { const artifactsPath = path.resolve(__dirname, 'fixtures/artifacts'); const sourcesPath = path.resolve(__dirname, 'fixtures/contracts'); - const networkId = 50; - const contractsData = collectContractsData(artifactsPath, sourcesPath, networkId); + const contractsData = collectContractsData(artifactsPath, sourcesPath); _.forEach(contractsData, contractData => { expect(contractData).to.have.keys([ 'sourceCodes', -- cgit From f854f3ee2bd74bbb61ed465099168b4d391f92c8 Mon Sep 17 00:00:00 2001 From: Leonid Logvinov Date: Thu, 10 May 2018 15:20:00 +0200 Subject: Remove unused deployer docs configs --- packages/sol-cov/src/coverage_manager.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'packages/sol-cov') diff --git a/packages/sol-cov/src/coverage_manager.ts b/packages/sol-cov/src/coverage_manager.ts index bf580025b..f50f010b9 100644 --- a/packages/sol-cov/src/coverage_manager.ts +++ b/packages/sol-cov/src/coverage_manager.ts @@ -48,9 +48,7 @@ export class CoverageManager { } public async writeCoverageAsync(): Promise { 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( -- cgit From 733fe5b3359a490a0f113ac69d3af469fb6b4729 Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Fri, 11 May 2018 12:05:32 +0200 Subject: Add artifacts to clean command --- packages/sol-cov/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'packages/sol-cov') diff --git a/packages/sol-cov/package.json b/packages/sol-cov/package.json index 536d05370..0a64af4e5 100644 --- a/packages/sol-cov/package.json +++ b/packages/sol-cov/package.json @@ -12,7 +12,7 @@ "coverage:report:lcov": "nyc report --reporter=text-lcov > coverage/lcov.info", "test:circleci": "yarn test:coverage", "run_mocha": "mocha lib/test/**/*_test.js --exit", - "clean": "shx rm -rf lib scripts", + "clean": "shx rm -rf lib scripts test/fixtures/artifacts src/artifacts", "build": "copyfiles 'test/fixtures/**/*' ./lib && tsc && copyfiles -u 3 './lib/src/monorepo_scripts/**/*' ./scripts", "compile_test": "node ../deployer/lib/src/cli.js compile", "manual:postpublish": "yarn build; node ./scripts/postpublish.js", -- cgit From fb9c7745582166143ff421253144120ed84d57ad Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Fri, 11 May 2018 17:41:25 +0200 Subject: Create coverage dir if doesn't exist --- packages/sol-cov/package.json | 3 +++ packages/sol-cov/src/coverage_manager.ts | 5 +++++ 2 files changed, 8 insertions(+) (limited to 'packages/sol-cov') diff --git a/packages/sol-cov/package.json b/packages/sol-cov/package.json index 0cef9ff87..6268df4c7 100644 --- a/packages/sol-cov/package.json +++ b/packages/sol-cov/package.json @@ -46,10 +46,12 @@ "@0xproject/subproviders": "^0.10.1", "@0xproject/types": "^0.6.3", "@0xproject/typescript-typings": "^0.3.1", + "@0xproject/utils": "^0.6.1", "ethereumjs-util": "^5.1.1", "glob": "^7.1.2", "istanbul": "^0.4.5", "lodash": "^4.17.4", + "mkdirp": "^0.5.1", "semaphore-async-await": "^1.5.1", "solidity-parser-antlr": "^0.2.8" }, @@ -57,6 +59,7 @@ "@0xproject/monorepo-scripts": "^0.1.19", "@0xproject/tslint-config": "^0.4.17", "@types/istanbul": "^0.4.30", + "@types/mkdirp": "^0.5.1", "@types/mocha": "^2.2.42", "@types/node": "^8.0.53", "chai": "^4.0.1", diff --git a/packages/sol-cov/src/coverage_manager.ts b/packages/sol-cov/src/coverage_manager.ts index f50f010b9..800ca96dd 100644 --- a/packages/sol-cov/src/coverage_manager.ts +++ b/packages/sol-cov/src/coverage_manager.ts @@ -1,7 +1,9 @@ +import { promisify } from '@0xproject/utils'; import { addHexPrefix } from 'ethereumjs-util'; import * as fs from 'fs'; import { Collector } from 'istanbul'; import * as _ from 'lodash'; +import * as mkdirp from 'mkdirp'; import * as path from 'path'; import { collectContractsData } from './collect_contract_data'; @@ -29,6 +31,8 @@ import { } from './types'; import { utils } from './utils'; +const mkdirpAsync = promisify(mkdirp); + export class CoverageManager { private _sourcesPath: string; private _traceInfos: TraceInfo[] = []; @@ -49,6 +53,7 @@ export class CoverageManager { public async writeCoverageAsync(): Promise { const finalCoverage = await this._computeCoverageAsync(); const stringifiedCoverage = JSON.stringify(finalCoverage, null, '\t'); + await mkdirpAsync('coverage'); fs.writeFileSync('coverage/coverage.json', stringifiedCoverage); } private _getSingleFileCoverageForTrace( -- cgit From 3f6876c4199353b597e1b0ebcf3907d6b8cce284 Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Fri, 11 May 2018 17:41:35 +0200 Subject: Remove gitkeeps --- packages/sol-cov/coverage/.gitkeep | 0 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 packages/sol-cov/coverage/.gitkeep (limited to 'packages/sol-cov') diff --git a/packages/sol-cov/coverage/.gitkeep b/packages/sol-cov/coverage/.gitkeep deleted file mode 100644 index e69de29bb..000000000 -- cgit From 31763a018c18106aac11d8a3d82b3ccd9676f9c8 Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Fri, 11 May 2018 18:50:50 +0200 Subject: Revert "Remove gitkeeps" This reverts commit 3f6876c4199353b597e1b0ebcf3907d6b8cce284. --- packages/sol-cov/coverage/.gitkeep | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 packages/sol-cov/coverage/.gitkeep (limited to 'packages/sol-cov') diff --git a/packages/sol-cov/coverage/.gitkeep b/packages/sol-cov/coverage/.gitkeep new file mode 100644 index 000000000..e69de29bb -- cgit