aboutsummaryrefslogtreecommitdiffstats
path: root/packages/sol-coverage
diff options
context:
space:
mode:
Diffstat (limited to 'packages/sol-coverage')
-rw-r--r--packages/sol-coverage/.npmignore6
-rw-r--r--packages/sol-coverage/CHANGELOG.json66
-rw-r--r--packages/sol-coverage/CHANGELOG.md34
-rw-r--r--packages/sol-coverage/README.md75
-rw-r--r--packages/sol-coverage/package.json52
-rw-r--r--packages/sol-coverage/src/coverage_subprovider.ts148
-rw-r--r--packages/sol-coverage/src/globals.d.ts7
-rw-r--r--packages/sol-coverage/src/index.ts25
-rw-r--r--packages/sol-coverage/tsconfig.json8
-rw-r--r--packages/sol-coverage/tslint.json3
-rw-r--r--packages/sol-coverage/typedoc-tsconfig.json7
11 files changed, 0 insertions, 431 deletions
diff --git a/packages/sol-coverage/.npmignore b/packages/sol-coverage/.npmignore
deleted file mode 100644
index 037786e46..000000000
--- a/packages/sol-coverage/.npmignore
+++ /dev/null
@@ -1,6 +0,0 @@
-.*
-yarn-error.log
-/src/
-/scripts/
-tsconfig.json
-/lib/src/monorepo_scripts/
diff --git a/packages/sol-coverage/CHANGELOG.json b/packages/sol-coverage/CHANGELOG.json
deleted file mode 100644
index dc5ae1a53..000000000
--- a/packages/sol-coverage/CHANGELOG.json
+++ /dev/null
@@ -1,66 +0,0 @@
-[
- {
- "version": "2.0.2",
- "changes": [
- {
- "note": "Dependencies updated"
- }
- ],
- "timestamp": 1549547375
- },
- {
- "timestamp": 1549452781,
- "version": "2.0.1",
- "changes": [
- {
- "note": "Dependencies updated"
- }
- ]
- },
- {
- "version": "2.0.0",
- "changes": [
- {
- "note": "Upgrade the bignumber.js to v8.0.2",
- "pr": 1517
- }
- ],
- "timestamp": 1549373905
- },
- {
- "timestamp": 1547747677,
- "version": "1.0.3",
- "changes": [
- {
- "note": "Dependencies updated"
- }
- ]
- },
- {
- "timestamp": 1547561734,
- "version": "1.0.2",
- "changes": [
- {
- "note": "Dependencies updated"
- }
- ]
- },
- {
- "timestamp": 1547225310,
- "version": "1.0.1",
- "changes": [
- {
- "note": "Dependencies updated"
- }
- ]
- },
- {
- "version": "1.0.0",
- "changes": [
- {
- "note": "Initial release as a separate package. For historical entries see @0x/sol-tracing-utils",
- "pr": 1492
- }
- ]
- }
-]
diff --git a/packages/sol-coverage/CHANGELOG.md b/packages/sol-coverage/CHANGELOG.md
deleted file mode 100644
index 1af9b9f26..000000000
--- a/packages/sol-coverage/CHANGELOG.md
+++ /dev/null
@@ -1,34 +0,0 @@
-<!--
-changelogUtils.file is auto-generated using the monorepo-scripts package. Don't edit directly.
-Edit the package's CHANGELOG.json file only.
--->
-
-CHANGELOG
-
-## v2.0.2 - _February 7, 2019_
-
- * Dependencies updated
-
-## v2.0.1 - _February 6, 2019_
-
- * Dependencies updated
-
-## v2.0.0 - _February 5, 2019_
-
- * Upgrade the bignumber.js to v8.0.2 (#1517)
-
-## v1.0.3 - _January 17, 2019_
-
- * Dependencies updated
-
-## v1.0.2 - _January 15, 2019_
-
- * Dependencies updated
-
-## v1.0.1 - _January 11, 2019_
-
- * Dependencies updated
-
-## v1.0.0 - _Invalid date_
-
- * Initial release as a separate package. For historical entries see @0x/sol-tracing-utils (#1492)
diff --git a/packages/sol-coverage/README.md b/packages/sol-coverage/README.md
deleted file mode 100644
index f8cc62eb8..000000000
--- a/packages/sol-coverage/README.md
+++ /dev/null
@@ -1,75 +0,0 @@
-## @0x/sol-coverage
-
-A Solidity code coverage tool.
-
-### Read the [Documentation](https://0xproject.com/docs/sol-coverage).
-
-## Installation
-
-```bash
-yarn add @0x/sol-coverage
-```
-
-**Import**
-
-```javascript
-import { CoverageSubprovider } from '@0x/sol-coverage';
-```
-
-or
-
-```javascript
-var CoverageSubprovider = require('@0x/sol-coverage').CoverageSubprovider;
-```
-
-## Contributing
-
-We welcome improvements and fixes from the wider community! To report bugs within this package, please create an issue in this repository.
-
-Please read our [contribution guidelines](../../CONTRIBUTING.md) before getting started.
-
-### Install dependencies
-
-If you don't have yarn workspaces enabled (Yarn < v1.0) - enable them:
-
-```bash
-yarn config set workspaces-experimental true
-```
-
-Then install dependencies
-
-```bash
-yarn install
-```
-
-### Build
-
-To build this package and all other monorepo packages that it depends on, run the following from the monorepo root directory:
-
-```bash
-PKG=@0x/sol-coverage yarn build
-```
-
-Or continuously rebuild on change:
-
-```bash
-PKG=@0x/sol-coverage yarn watch
-```
-
-### Clean
-
-```bash
-yarn clean
-```
-
-### Lint
-
-```bash
-yarn lint
-```
-
-### Run Tests
-
-```bash
-yarn test
-```
diff --git a/packages/sol-coverage/package.json b/packages/sol-coverage/package.json
deleted file mode 100644
index 6724a03df..000000000
--- a/packages/sol-coverage/package.json
+++ /dev/null
@@ -1,52 +0,0 @@
-{
- "name": "@0x/sol-coverage",
- "version": "2.0.2",
- "engines": {
- "node": ">=6.12"
- },
- "description": "Generate coverage reports for Solidity code",
- "main": "lib/src/index.js",
- "types": "lib/src/index.d.ts",
- "scripts": {
- "build": "tsc -b",
- "build:ci": "yarn build",
- "lint": "tslint --format stylish --project .",
- "clean": "shx rm -rf lib src/artifacts generated_docs",
- "docs:json": "typedoc --excludePrivate --excludeExternals --target ES5 --tsconfig typedoc-tsconfig.json --json $JSON_FILE_PATH $PROJECT_FILES"
- },
- "config": {
- "postpublish": {
- "assets": []
- }
- },
- "repository": {
- "type": "git",
- "url": "https://github.com/0xProject/0x-monorepo.git"
- },
- "license": "Apache-2.0",
- "bugs": {
- "url": "https://github.com/0xProject/0x-monorepo/issues"
- },
- "homepage": "https://github.com/0xProject/0x-monorepo/packages/sol-coverage/README.md",
- "dependencies": {
- "@0x/sol-tracing-utils": "^6.0.2",
- "@0x/subproviders": "^3.0.2",
- "@0x/typescript-typings": "^4.0.0",
- "ethereum-types": "^2.0.0",
- "lodash": "^4.17.11"
- },
- "devDependencies": {
- "@0x/tslint-config": "^3.0.0",
- "@types/node": "*",
- "npm-run-all": "^4.1.2",
- "nyc": "^11.0.1",
- "shx": "^0.2.2",
- "sinon": "^4.0.0",
- "tslint": "5.11.0",
- "typedoc": "0.13.0",
- "typescript": "3.0.1"
- },
- "publishConfig": {
- "access": "public"
- }
-}
diff --git a/packages/sol-coverage/src/coverage_subprovider.ts b/packages/sol-coverage/src/coverage_subprovider.ts
deleted file mode 100644
index 2d92b25ca..000000000
--- a/packages/sol-coverage/src/coverage_subprovider.ts
+++ /dev/null
@@ -1,148 +0,0 @@
-import {
- AbstractArtifactAdapter,
- BranchCoverage,
- collectCoverageEntries,
- ContractData,
- Coverage,
- FunctionCoverage,
- FunctionDescription,
- SingleFileSubtraceHandler,
- SourceRange,
- StatementCoverage,
- StatementDescription,
- Subtrace,
- TraceCollector,
- TraceInfo,
- TraceInfoSubprovider,
- utils,
-} from '@0x/sol-tracing-utils';
-import * as _ from 'lodash';
-
-/**
- * This class implements the [web3-provider-engine](https://github.com/MetaMask/provider-engine) subprovider interface.
- * It's used to compute your code coverage while running solidity tests.
- */
-export class CoverageSubprovider extends TraceInfoSubprovider {
- private readonly _coverageCollector: TraceCollector;
- /**
- * Instantiates a CoverageSubprovider instance
- * @param artifactAdapter Adapter for used artifacts format (0x, truffle, giveth, etc.)
- * @param defaultFromAddress default from address to use when sending transactions
- * @param isVerbose If true, we will log any unknown transactions. Otherwise we will ignore them
- */
- constructor(artifactAdapter: AbstractArtifactAdapter, defaultFromAddress: string, isVerbose: boolean = true) {
- const traceCollectionSubproviderConfig = {
- shouldCollectTransactionTraces: true,
- shouldCollectGasEstimateTraces: true,
- shouldCollectCallTraces: true,
- };
- super(defaultFromAddress, traceCollectionSubproviderConfig);
- this._coverageCollector = new TraceCollector(artifactAdapter, isVerbose, coverageHandler);
- }
- protected async _handleTraceInfoAsync(traceInfo: TraceInfo): Promise<void> {
- await this._coverageCollector.computeSingleTraceCoverageAsync(traceInfo);
- }
- /**
- * Write the test coverage results to a file in Istanbul format.
- */
- public async writeCoverageAsync(): Promise<void> {
- await this._coverageCollector.writeOutputAsync();
- }
-}
-
-const IGNORE_REGEXP = /\/\*\s*solcov\s+ignore\s+next\s*\*\/\s*/gm;
-
-/**
- * Computed partial coverage for a single file & subtrace.
- * @param contractData Contract metadata (source, srcMap, bytecode)
- * @param subtrace A subset of a transcation/call trace that was executed within that contract
- * @param pcToSourceRange A mapping from program counters to source ranges
- * @param fileIndex Index of a file to compute coverage for
- * @return Partial istanbul coverage for that file & subtrace
- */
-export const coverageHandler: SingleFileSubtraceHandler = (
- contractData: ContractData,
- subtrace: Subtrace,
- pcToSourceRange: { [programCounter: number]: SourceRange },
- fileIndex: number,
-): Coverage => {
- const absoluteFileName = contractData.sources[fileIndex];
- const coverageEntriesDescription = collectCoverageEntries(contractData.sourceCodes[fileIndex], IGNORE_REGEXP);
-
- // if the source wasn't provided for the fileIndex, we can't cover the file
- if (_.isUndefined(coverageEntriesDescription)) {
- return {};
- }
-
- let sourceRanges = _.map(subtrace, structLog => pcToSourceRange[structLog.pc]);
- sourceRanges = _.compact(sourceRanges); // Some PC's don't map to a source range and we just ignore them.
- // By default lodash does a shallow object comparison. We JSON.stringify them and compare as strings.
- sourceRanges = _.uniqBy(sourceRanges, s => JSON.stringify(s)); // We don't care if one PC was covered multiple times within a single transaction
- sourceRanges = _.filter(sourceRanges, sourceRange => sourceRange.fileName === absoluteFileName);
- const branchCoverage: BranchCoverage = {};
- const branchIds = _.keys(coverageEntriesDescription.branchMap);
- for (const branchId of branchIds) {
- const branchDescription = coverageEntriesDescription.branchMap[branchId];
- const branchIndexToIsBranchCovered = _.map(branchDescription.locations, location => {
- const isBranchCovered = _.some(sourceRanges, range => utils.isRangeInside(range.location, location));
- const timesBranchCovered = Number(isBranchCovered);
- return timesBranchCovered;
- });
- branchCoverage[branchId] = branchIndexToIsBranchCovered;
- }
- const statementCoverage: StatementCoverage = {};
- const statementIds = _.keys(coverageEntriesDescription.statementMap);
- for (const statementId of statementIds) {
- const statementDescription = coverageEntriesDescription.statementMap[statementId];
- const isStatementCovered = _.some(sourceRanges, range =>
- utils.isRangeInside(range.location, statementDescription),
- );
- const timesStatementCovered = Number(isStatementCovered);
- statementCoverage[statementId] = timesStatementCovered;
- }
- const functionCoverage: FunctionCoverage = {};
- const functionIds = _.keys(coverageEntriesDescription.fnMap);
- for (const fnId of functionIds) {
- const functionDescription = coverageEntriesDescription.fnMap[fnId];
- const isFunctionCovered = _.some(sourceRanges, range =>
- utils.isRangeInside(range.location, functionDescription.loc),
- );
- const timesFunctionCovered = Number(isFunctionCovered);
- functionCoverage[fnId] = timesFunctionCovered;
- }
- // HACK: Solidity doesn't emit any opcodes that map back to modifiers with no args, that's why we map back to the
- // function range and check if there is any covered statement within that range.
- for (const modifierStatementId of coverageEntriesDescription.modifiersStatementIds) {
- if (statementCoverage[modifierStatementId]) {
- // Already detected as covered
- continue;
- }
- const modifierDescription = coverageEntriesDescription.statementMap[modifierStatementId];
- const enclosingFunction = _.find(coverageEntriesDescription.fnMap, functionDescription =>
- utils.isRangeInside(modifierDescription, functionDescription.loc),
- ) as FunctionDescription;
- const isModifierCovered = _.some(
- coverageEntriesDescription.statementMap,
- (statementDescription: StatementDescription, statementId: number) => {
- const isInsideTheModifierEnclosingFunction = utils.isRangeInside(
- statementDescription,
- enclosingFunction.loc,
- );
- const isCovered = statementCoverage[statementId];
- return isInsideTheModifierEnclosingFunction && isCovered;
- },
- );
- const timesModifierCovered = Number(isModifierCovered);
- statementCoverage[modifierStatementId] = timesModifierCovered;
- }
- const partialCoverage = {
- [absoluteFileName]: {
- ...coverageEntriesDescription,
- path: absoluteFileName,
- f: functionCoverage,
- s: statementCoverage,
- b: branchCoverage,
- },
- };
- return partialCoverage;
-};
diff --git a/packages/sol-coverage/src/globals.d.ts b/packages/sol-coverage/src/globals.d.ts
deleted file mode 100644
index e799b3529..000000000
--- a/packages/sol-coverage/src/globals.d.ts
+++ /dev/null
@@ -1,7 +0,0 @@
-// tslint:disable:completed-docs
-declare module '*.json' {
- const json: any;
- /* tslint:disable */
- export default json;
- /* tslint:enable */
-}
diff --git a/packages/sol-coverage/src/index.ts b/packages/sol-coverage/src/index.ts
deleted file mode 100644
index 6a91a3966..000000000
--- a/packages/sol-coverage/src/index.ts
+++ /dev/null
@@ -1,25 +0,0 @@
-export { CoverageSubprovider } from './coverage_subprovider';
-export {
- SolCompilerArtifactAdapter,
- TruffleArtifactAdapter,
- AbstractArtifactAdapter,
- ContractData,
- SourceCodes,
- Sources,
-} from '@0x/sol-tracing-utils';
-
-export {
- JSONRPCRequestPayload,
- Provider,
- JSONRPCErrorCallback,
- JSONRPCResponsePayload,
- JSONRPCResponseError,
-} from 'ethereum-types';
-
-export {
- JSONRPCRequestPayloadWithMethod,
- NextCallback,
- ErrorCallback,
- OnNextCompleted,
- Callback,
-} from '@0x/subproviders';
diff --git a/packages/sol-coverage/tsconfig.json b/packages/sol-coverage/tsconfig.json
deleted file mode 100644
index 233008d61..000000000
--- a/packages/sol-coverage/tsconfig.json
+++ /dev/null
@@ -1,8 +0,0 @@
-{
- "extends": "../../tsconfig",
- "compilerOptions": {
- "outDir": "lib",
- "rootDir": "."
- },
- "include": ["./src/**/*"]
-}
diff --git a/packages/sol-coverage/tslint.json b/packages/sol-coverage/tslint.json
deleted file mode 100644
index dd9053357..000000000
--- a/packages/sol-coverage/tslint.json
+++ /dev/null
@@ -1,3 +0,0 @@
-{
- "extends": ["@0x/tslint-config"]
-}
diff --git a/packages/sol-coverage/typedoc-tsconfig.json b/packages/sol-coverage/typedoc-tsconfig.json
deleted file mode 100644
index c9b0af1ae..000000000
--- a/packages/sol-coverage/typedoc-tsconfig.json
+++ /dev/null
@@ -1,7 +0,0 @@
-{
- "extends": "../../typedoc-tsconfig",
- "compilerOptions": {
- "outDir": "lib"
- },
- "include": ["./src/**/*", "./test/**/*"]
-}