aboutsummaryrefslogtreecommitdiffstats
path: root/packages/website/md/docs/sol_cov/usage.md
diff options
context:
space:
mode:
authorFabio Berger <me@fabioberger.com>2018-06-02 04:05:17 +0800
committerFabio Berger <me@fabioberger.com>2018-06-02 04:05:17 +0800
commitb7b45b69a66cfaf9c3737d1a8d95be21edccf527 (patch)
tree4337613836a8062bd73fc8ee1e4db444961df172 /packages/website/md/docs/sol_cov/usage.md
parentdf9cfe7840b99d72ed95058e47f2ffb6623d440e (diff)
parent9ca41b9536908dddfa51854abd41b7926e69bd09 (diff)
downloaddexon-sol-tools-b7b45b69a66cfaf9c3737d1a8d95be21edccf527.tar
dexon-sol-tools-b7b45b69a66cfaf9c3737d1a8d95be21edccf527.tar.gz
dexon-sol-tools-b7b45b69a66cfaf9c3737d1a8d95be21edccf527.tar.bz2
dexon-sol-tools-b7b45b69a66cfaf9c3737d1a8d95be21edccf527.tar.lz
dexon-sol-tools-b7b45b69a66cfaf9c3737d1a8d95be21edccf527.tar.xz
dexon-sol-tools-b7b45b69a66cfaf9c3737d1a8d95be21edccf527.tar.zst
dexon-sol-tools-b7b45b69a66cfaf9c3737d1a8d95be21edccf527.zip
Merge branch 'v2-prototype' into refactor/order-utils/for-v2
* v2-prototype: (33 commits) Only show ProviderDisplay in portal Improve sol-cov docs Remove old parse code Refactor order parser and add shared order support to new portal Add generate and fill order routes Address feedback Override ethereumjs-tx version Fix missing key Update placeholder param ordering Change userEtherBalanceInWei to optional so we can know if its loading Add loading state to ProviderDisplay Tweaks Add Placeholder component Add StandardIconRow Split render into loading and loaaded Fix linter errors Fix linter errors Add ethereum-types to extraFileIncludes Introduce ethereum-types package Remove merge conflicts from yarn.lock ... # Conflicts: # packages/contracts/src/utils/exchange_wrapper.ts # packages/contracts/src/utils/match_order_tester.ts # packages/contracts/src/utils/types.ts # packages/contracts/test/exchange/core.ts # packages/contracts/test/exchange/match_orders.ts # packages/contracts/test/libraries/lib_bytes.ts # packages/sol-cov/package.json
Diffstat (limited to 'packages/website/md/docs/sol_cov/usage.md')
-rw-r--r--packages/website/md/docs/sol_cov/usage.md48
1 files changed, 46 insertions, 2 deletions
diff --git a/packages/website/md/docs/sol_cov/usage.md b/packages/website/md/docs/sol_cov/usage.md
index 63a88f595..59638f611 100644
--- a/packages/website/md/docs/sol_cov/usage.md
+++ b/packages/website/md/docs/sol_cov/usage.md
@@ -2,8 +2,47 @@ Sol-cov uses transaction traces in order to figure out which lines of Solidity s
The CoverageSubprovider eavesdrops on the `eth_sendTransaction` and `eth_call` RPC calls and collects traces after each call using `debug_traceTransaction`. `eth_call`'s' don't generate traces - so we take a snapshot, re-submit it as a transaction, get the trace and then revert the snapshot.
+Coverage subprovider needs some info about your contracts (`srcMap`, `bytecode`). It gets that info from your project's artifacts. Some frameworks have their own artifact format. Some artifact formats don't actually contain all the neccessary data.
+
+In order to use `CoverageSubprovider` with your favorite framework you need to pass an `artifactsAdapter` to it.
+
+### Sol-compiler
+
+If you are generating your artifacts with [@0xproject/sol-compiler](LINK) you can use the `SolCompilerArtifactsAdapter` we've implemented for you.
+
+```typescript
+<<<<<<< HEAD
+import { CoverageSubprovider } from '@0xproject/sol-cov';
+=======
+import { SolCompilerArtifactsAdapter } from '@0xproject/sol-cov';
+const artifactsPath = 'src/artifacts';
+const contractsPath = 'src/contracts';
+const artifactsAdapter = new SolCompilerArtifactsAdapter(artifactsPath, contractsPath);
+```
+
+### Truffle
+
+If your project is using [Truffle](LINK), we've written a `TruffleArtifactsAdapter`for you.
+
+```typescript
+import { TruffleArtifactAdapter } from '@0xproject/sol-cov';
+const contractsPath = 'src/contracts';
+const artifactAdapter = new TruffleArtifactAdapter(contractsDir);
+```
+
+Because truffle artifacts don't have all the data we need - we actually will recompile your contracts under the hood. That's why you don't need to pass an `artifactsPath`.
+
+### Other framework/toolset
+
+You'll need to write your own artifacts adapter. It should extend `AbstractArtifactsAdapter`.
+Look at the code of the two adapters above for examples.
+
+### Usage
+
```typescript
import { CoverageSubprovider } from '@0xproject/sol-cov';
+import ProviderEngine = require('web3-provider-engine');
+>>>>>>> Improve sol-cov docs
const provider = new ProviderEngine();
@@ -12,15 +51,20 @@ const contractsPath = 'src/contracts';
const networkId = 50;
// Some calls might not have `from` address specified. Nevertheless - transactions need to be submitted from an address with at least some funds. defaultFromAddress is the address that will be used to submit those calls as transactions from.
const defaultFromAddress = '0x5409ed021d9299bf6814279a6a1411a7e866a631';
+<<<<<<< HEAD
const coverageSubprovider = new CoverageSubprovider(artifactsPath, contractsPath, defaultFromAddress);
+=======
+const isVerbose = true;
+const coverageSubprovider = new CoverageSubprovider(artifactsAdapter, defaultFromAddress, isVerbose);
+>>>>>>> Improve sol-cov docs
provider.addProvider(coverageSubprovider);
```
-After your test suite is complete (e.g global `after` hook), you'll need to call:
+After your test suite is complete (e.g in the Mocha global `after` hook), you'll need to call:
```typescript
await coverageSubprovider.writeCoverageAsync();
```
-This will create a `coverage.json` file in the `coverage` directory. This file has an [Istanbul format](https://github.com/gotwarlost/istanbul/blob/master/coverage.json.md) - so you can use any of the existing Instanbul reporters.
+This will create a `coverage.json` file in a `coverage` directory. This file has an [Istanbul format](https://github.com/gotwarlost/istanbul/blob/master/coverage.json.md) - so you can use it with any of the existing Istanbul reporters.