aboutsummaryrefslogtreecommitdiffstats
path: root/packages/sol-cov
diff options
context:
space:
mode:
Diffstat (limited to 'packages/sol-cov')
-rw-r--r--packages/sol-cov/CHANGELOG.json9
-rw-r--r--packages/sol-cov/CHANGELOG.md4
-rw-r--r--packages/sol-cov/README.md2
-rw-r--r--packages/sol-cov/package.json21
-rw-r--r--packages/sol-cov/src/collect_contract_data.ts28
-rw-r--r--packages/sol-cov/src/coverage_subprovider.ts4
-rw-r--r--packages/sol-cov/src/types.ts1
-rw-r--r--packages/sol-cov/test/collect_contracts_data_test.ts1
-rw-r--r--packages/sol-cov/test/collect_coverage_entries_test.ts4
-rw-r--r--packages/sol-cov/test/fixtures/artifacts/SimpleStorage.json64
-rw-r--r--packages/sol-cov/test/fixtures/artifacts/Simplest.json20
-rw-r--r--packages/sol-cov/test/fixtures/contracts/SimpleStorage.sol2
12 files changed, 40 insertions, 120 deletions
diff --git a/packages/sol-cov/CHANGELOG.json b/packages/sol-cov/CHANGELOG.json
index e24a264db..ca4c67f7e 100644
--- a/packages/sol-cov/CHANGELOG.json
+++ b/packages/sol-cov/CHANGELOG.json
@@ -1,5 +1,14 @@
[
{
+ "timestamp": 1523462196,
+ "version": "0.0.7",
+ "changes": [
+ {
+ "note": "Dependencies updated"
+ }
+ ]
+ },
+ {
"timestamp": 1522673609,
"version": "0.0.6",
"changes": [
diff --git a/packages/sol-cov/CHANGELOG.md b/packages/sol-cov/CHANGELOG.md
index e2e5d92ec..c55d751a8 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.7 - _April 11, 2018_
+
+ * Dependencies updated
+
## v0.0.6 - _April 2, 2018_
* Dependencies updated
diff --git a/packages/sol-cov/README.md b/packages/sol-cov/README.md
index 8cc7dca6c..3a0377521 100644
--- a/packages/sol-cov/README.md
+++ b/packages/sol-cov/README.md
@@ -2,7 +2,7 @@
A Solidity code coverage tool.
-### Read the [Documentation](0xproject.com/docs/sol-cov).
+### Read the [Documentation](https://0xproject.com/docs/sol-cov).
## Installation
diff --git a/packages/sol-cov/package.json b/packages/sol-cov/package.json
index 6444fb876..277f40130 100644
--- a/packages/sol-cov/package.json
+++ b/packages/sol-cov/package.json
@@ -1,19 +1,20 @@
{
"name": "@0xproject/sol-cov",
- "version": "0.0.6",
+ "version": "0.0.7",
"description": "Generate coverage reports for Solidity code",
"main": "lib/src/index.js",
"types": "lib/src/index.d.ts",
"scripts": {
"build:watch": "tsc -w",
"lint": "tslint --project . 'src/**/*.ts'",
- "test": "run-s clean build run_mocha",
+ "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",
"test:circleci": "yarn test:coverage",
- "run_mocha": "mocha lib/test/**/*_test.js",
+ "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",
"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",
@@ -24,7 +25,8 @@
"assets": [],
"docPublishConfigs": {
"extraFileIncludes": [
- "../subproviders/src/types.ts"
+ "../subproviders/src/types.ts",
+ "../types/src/index.ts"
],
"s3BucketPath": "s3://doc-jsons/sol-cov/",
"s3StagingBucketPath": "s3://staging-doc-jsons/sol-cov/"
@@ -41,9 +43,9 @@
},
"homepage": "https://github.com/0xProject/0x.js/packages/sol-cov/README.md",
"dependencies": {
- "@0xproject/subproviders": "^0.8.4",
- "@0xproject/types": "^0.5.0",
- "@0xproject/typescript-typings": "^0.0.3",
+ "@0xproject/subproviders": "^0.8.5",
+ "@0xproject/types": "^0.6.0",
+ "@0xproject/typescript-typings": "^0.1.0",
"ethereumjs-util": "^5.1.1",
"glob": "^7.1.2",
"istanbul": "^0.4.5",
@@ -52,8 +54,9 @@
"solidity-parser-antlr": "^0.2.8"
},
"devDependencies": {
- "@0xproject/monorepo-scripts": "^0.1.16",
- "@0xproject/tslint-config": "^0.4.14",
+ "@0xproject/deployer": "^0.3.5",
+ "@0xproject/monorepo-scripts": "^0.1.17",
+ "@0xproject/tslint-config": "^0.4.15",
"@types/istanbul": "^0.4.29",
"@types/mocha": "^2.2.42",
"@types/node": "^8.0.53",
diff --git a/packages/sol-cov/src/collect_contract_data.ts b/packages/sol-cov/src/collect_contract_data.ts
index a0ce2640f..1d8bc7178 100644
--- a/packages/sol-cov/src/collect_contract_data.ts
+++ b/packages/sol-cov/src/collect_contract_data.ts
@@ -6,30 +6,18 @@ import * as path from 'path';
import { ContractData } from './types';
export const collectContractsData = (artifactsPath: string, sourcesPath: string, networkId: number) => {
- const sourcesGlob = `${sourcesPath}/**/*.sol`;
- const sourceFileNames = glob.sync(sourcesGlob, { absolute: true });
- const contractsDataIfExists: Array<ContractData | {}> = _.map(sourceFileNames, sourceFileName => {
- const baseName = path.basename(sourceFileName, '.sol');
- const artifactFileName = path.join(artifactsPath, `${baseName}.json`);
- if (!fs.existsSync(artifactFileName)) {
- // If the contract isn't directly compiled, but is imported as the part of the other contract - we don't
- // have an artifact for it and therefore can't do anything useful with it
- return {};
- }
+ const artifactsGlob = `${artifactsPath}/**/*.json`;
+ const artifactFileNames = glob.sync(artifactsGlob, { absolute: true });
+ const contractsDataIfExists: Array<ContractData | {}> = _.map(artifactFileNames, artifactFileName => {
const artifact = JSON.parse(fs.readFileSync(artifactFileName).toString());
- const sources = _.map(artifact.networks[networkId].sources, source => {
- const includedFileName = glob.sync(`${sourcesPath}/**/${source}`, { absolute: true })[0];
- return includedFileName;
- });
- const sourceCodes = _.map(sources, source => {
- const includedSourceCode = fs.readFileSync(source).toString();
- return includedSourceCode;
- });
+ const sources = artifact.networks[networkId].sources;
+ const contractName = artifact.contract_name;
+ // 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 ${baseName} artifacts found for networkId ${networkId}`);
+ throw new Error(`No ${contractName} artifacts found for networkId ${networkId}`);
}
const contractData = {
- baseName,
sourceCodes,
sources,
sourceMap: artifact.networks[networkId].source_map,
diff --git a/packages/sol-cov/src/coverage_subprovider.ts b/packages/sol-cov/src/coverage_subprovider.ts
index fc8b55188..6504d5a46 100644
--- a/packages/sol-cov/src/coverage_subprovider.ts
+++ b/packages/sol-cov/src/coverage_subprovider.ts
@@ -56,8 +56,8 @@ export class CoverageSubprovider extends Subprovider {
* @param next Callback to call if this subprovider decides not to handle the request
* @param end Callback to call if subprovider handled the request and wants to pass back the request.
*/
- // tslint:disable-next-line:prefer-function-over-method
- public handleRequest(payload: JSONRPCRequestPayload, next: NextCallback, end: ErrorCallback) {
+ // tslint:disable-next-line:prefer-function-over-method async-suffix
+ public async handleRequest(payload: JSONRPCRequestPayload, next: NextCallback, end: ErrorCallback) {
switch (payload.method) {
case 'eth_sendTransaction':
const txData = payload.params[0];
diff --git a/packages/sol-cov/src/types.ts b/packages/sol-cov/src/types.ts
index d6491100b..01359d858 100644
--- a/packages/sol-cov/src/types.ts
+++ b/packages/sol-cov/src/types.ts
@@ -79,7 +79,6 @@ export interface ContractData {
runtimeBytecode: string;
sourceMapRuntime: string;
sourceCodes: string[];
- baseName: string;
sources: string[];
}
diff --git a/packages/sol-cov/test/collect_contracts_data_test.ts b/packages/sol-cov/test/collect_contracts_data_test.ts
index e793085e3..943a4a878 100644
--- a/packages/sol-cov/test/collect_contracts_data_test.ts
+++ b/packages/sol-cov/test/collect_contracts_data_test.ts
@@ -16,7 +16,6 @@ describe('Collect contracts data', () => {
const contractsData = collectContractsData(artifactsPath, sourcesPath, networkId);
_.forEach(contractsData, contractData => {
expect(contractData).to.have.keys([
- 'baseName',
'sourceCodes',
'sources',
'sourceMap',
diff --git a/packages/sol-cov/test/collect_coverage_entries_test.ts b/packages/sol-cov/test/collect_coverage_entries_test.ts
index c7bc45bbf..c7b9d44b1 100644
--- a/packages/sol-cov/test/collect_coverage_entries_test.ts
+++ b/packages/sol-cov/test/collect_coverage_entries_test.ts
@@ -39,13 +39,13 @@ describe('Collect coverage entries', () => {
const coverageEntries = collectCoverageEntries(simpleStorageContract);
const fnIds = _.keys(coverageEntries.fnMap);
expect(coverageEntries.fnMap[fnIds[0]].name).to.be.equal('set');
- expect(coverageEntries.fnMap[fnIds[0]].line).to.be.equal(3);
+ expect(coverageEntries.fnMap[fnIds[0]].line).to.be.equal(5);
const setFunction = `function set(uint x) {
storedData = x;
}`;
expect(getRange(simpleStorageContract, coverageEntries.fnMap[fnIds[0]].loc)).to.be.equal(setFunction);
expect(coverageEntries.fnMap[fnIds[1]].name).to.be.equal('get');
- expect(coverageEntries.fnMap[fnIds[1]].line).to.be.equal(6);
+ expect(coverageEntries.fnMap[fnIds[1]].line).to.be.equal(8);
const getFunction = `function get() constant returns (uint retVal) {
return storedData;
}`;
diff --git a/packages/sol-cov/test/fixtures/artifacts/SimpleStorage.json b/packages/sol-cov/test/fixtures/artifacts/SimpleStorage.json
deleted file mode 100644
index 416170ef2..000000000
--- a/packages/sol-cov/test/fixtures/artifacts/SimpleStorage.json
+++ /dev/null
@@ -1,64 +0,0 @@
-{
- "contract_name": "SimpleStorage",
- "networks": {
- "50": {
- "solc_version": "0.4.21",
- "keccak256": "0x18dc5b5a0e813c17e49936d2f2f7c07c51f050c09ba5e7206f17c855f23f4b6a",
- "source_tree_hash": "0x18dc5b5a0e813c17e49936d2f2f7c07c51f050c09ba5e7206f17c855f23f4b6a",
- "optimizer_enabled": 0,
- "abi": [
- {
- "constant": true,
- "inputs": [],
- "name": "storedData",
- "outputs": [
- {
- "name": "",
- "type": "uint256"
- }
- ],
- "payable": false,
- "stateMutability": "view",
- "type": "function"
- },
- {
- "constant": false,
- "inputs": [
- {
- "name": "x",
- "type": "uint256"
- }
- ],
- "name": "set",
- "outputs": [],
- "payable": false,
- "stateMutability": "nonpayable",
- "type": "function"
- },
- {
- "constant": true,
- "inputs": [],
- "name": "get",
- "outputs": [
- {
- "name": "retVal",
- "type": "uint256"
- }
- ],
- "payable": false,
- "stateMutability": "view",
- "type": "function"
- }
- ],
- "bytecode":
- "0x6060604052341561000f57600080fd5b6101098061001e6000396000f3006060604052600436106053576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff1680632a1afcd914605857806360fe47b114607e5780636d4ce63c14609e575b600080fd5b3415606257600080fd5b606860c4565b6040518082815260200191505060405180910390f35b3415608857600080fd5b609c600480803590602001909190505060ca565b005b341560a857600080fd5b60ae60d4565b6040518082815260200191505060405180910390f35b60005481565b8060008190555050565b600080549050905600a165627a7a723058207f743855fd0c71699620424a21a257cd197ed05032d6768eb9b874e4898f44c60029",
- "runtime_bytecode":
- "0x6060604052600436106053576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff1680632a1afcd914605857806360fe47b114607e5780636d4ce63c14609e575b600080fd5b3415606257600080fd5b606860c4565b6040518082815260200191505060405180910390f35b3415608857600080fd5b609c600480803590602001909190505060ca565b005b341560a857600080fd5b60ae60d4565b6040518082815260200191505060405180910390f35b60005481565b8060008190555050565b600080549050905600a165627a7a723058207f743855fd0c71699620424a21a257cd197ed05032d6768eb9b874e4898f44c60029",
- "updated_at": 1521118350895,
- "source_map": "26:196:0:-;;;;;;;;;;;;;;;;;",
- "source_map_runtime":
- "26:196:0:-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;55:22;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;83:52;;;;;;;;;;;;;;;;;;;;;;;;;;140:80;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;55:22;;;;:::o;83:52::-;127:1;114:10;:14;;;;83:52;:::o;140:80::-;173:11;203:10;;196:17;;140:80;:::o",
- "sources": ["SimpleStorage.sol"]
- }
- }
-}
diff --git a/packages/sol-cov/test/fixtures/artifacts/Simplest.json b/packages/sol-cov/test/fixtures/artifacts/Simplest.json
deleted file mode 100644
index 8de60e481..000000000
--- a/packages/sol-cov/test/fixtures/artifacts/Simplest.json
+++ /dev/null
@@ -1,20 +0,0 @@
-{
- "contract_name": "Simplest",
- "networks": {
- "50": {
- "solc_version": "0.4.21",
- "keccak256": "0x8e7d62e19c7c7b8bf9a4a43749e111605950cc877574fb9640a1a07d1c3749f9",
- "source_tree_hash": "0x8e7d62e19c7c7b8bf9a4a43749e111605950cc877574fb9640a1a07d1c3749f9",
- "optimizer_enabled": 0,
- "abi": [],
- "bytecode":
- "0x60606040523415600e57600080fd5b603580601b6000396000f3006060604052600080fd00a165627a7a7230582097cfe05b4d18d6ffb3a8d8fab0570cf09640d3131b9677ddb9be4e9fbcb65f010029",
- "runtime_bytecode":
- "0x6060604052600080fd00a165627a7a7230582097cfe05b4d18d6ffb3a8d8fab0570cf09640d3131b9677ddb9be4e9fbcb65f010029",
- "updated_at": 1521118525393,
- "source_map": "26:21:0:-;;;;;;;;;;;;;;;;;",
- "source_map_runtime": "26:21:0:-;;;;;",
- "sources": ["Simplest.sol"]
- }
- }
-}
diff --git a/packages/sol-cov/test/fixtures/contracts/SimpleStorage.sol b/packages/sol-cov/test/fixtures/contracts/SimpleStorage.sol
index 178a52318..e4b4ac246 100644
--- a/packages/sol-cov/test/fixtures/contracts/SimpleStorage.sol
+++ b/packages/sol-cov/test/fixtures/contracts/SimpleStorage.sol
@@ -1,3 +1,5 @@
+pragma solidity ^0.4.21;
+
contract SimpleStorage {
uint public storedData;
function set(uint x) {