aboutsummaryrefslogtreecommitdiffstats
path: root/packages/website/md/docs/sol_cov
diff options
context:
space:
mode:
authorLeonid Logvinov <logvinov.leon@gmail.com>2018-03-24 02:18:31 +0800
committerGitHub <noreply@github.com>2018-03-24 02:18:31 +0800
commitf30353087f9c4ec4fa5e096a065c9749e1164984 (patch)
tree4d7968160890b5efa358593e743411c7b8652556 /packages/website/md/docs/sol_cov
parent7ef6bd4b14b7502617c6929010d4a9991e1d577d (diff)
parentbed7d87b7ff64989051e6b2115a1c77e1e72ff55 (diff)
downloaddexon-sol-tools-f30353087f9c4ec4fa5e096a065c9749e1164984.tar
dexon-sol-tools-f30353087f9c4ec4fa5e096a065c9749e1164984.tar.gz
dexon-sol-tools-f30353087f9c4ec4fa5e096a065c9749e1164984.tar.bz2
dexon-sol-tools-f30353087f9c4ec4fa5e096a065c9749e1164984.tar.lz
dexon-sol-tools-f30353087f9c4ec4fa5e096a065c9749e1164984.tar.xz
dexon-sol-tools-f30353087f9c4ec4fa5e096a065c9749e1164984.tar.zst
dexon-sol-tools-f30353087f9c4ec4fa5e096a065c9749e1164984.zip
Merge branch 'development' into feature/deployer-improvements
Diffstat (limited to 'packages/website/md/docs/sol_cov')
-rw-r--r--packages/website/md/docs/sol_cov/installation.md17
-rw-r--r--packages/website/md/docs/sol_cov/introduction.md1
-rw-r--r--packages/website/md/docs/sol_cov/usage.md26
3 files changed, 44 insertions, 0 deletions
diff --git a/packages/website/md/docs/sol_cov/installation.md b/packages/website/md/docs/sol_cov/installation.md
new file mode 100644
index 000000000..b9ce25a5f
--- /dev/null
+++ b/packages/website/md/docs/sol_cov/installation.md
@@ -0,0 +1,17 @@
+**Install**
+
+```bash
+yarn add @0xproject/sol-cov
+```
+
+**Import**
+
+```javascript
+import { CoverageSubprovider } from '@0xproject/sol-cov';
+```
+
+or
+
+```javascript
+var CoverageSubprovider = require('@0xproject/sol-cov').CoverageSubprovider;
+```
diff --git a/packages/website/md/docs/sol_cov/introduction.md b/packages/website/md/docs/sol_cov/introduction.md
new file mode 100644
index 000000000..7064a3554
--- /dev/null
+++ b/packages/website/md/docs/sol_cov/introduction.md
@@ -0,0 +1 @@
+Welcome to the [@0xproject/sol-cov](https://github.com/0xProject/0x-monorepo/tree/development/packages/sol-cov) documentation! Sol-cov is a Solidity coverage tool for your smart contract tests.
diff --git a/packages/website/md/docs/sol_cov/usage.md b/packages/website/md/docs/sol_cov/usage.md
new file mode 100644
index 000000000..ea1982d97
--- /dev/null
+++ b/packages/website/md/docs/sol_cov/usage.md
@@ -0,0 +1,26 @@
+Sol-cov uses transaction traces in order to figure out which lines of Solidity source code have been covered by your tests. In order for it to gather these traces, you must add the `CoverageSubprovider` to the [ProviderEngine](https://github.com/MetaMask/provider-engine) instance you use when running your Solidity tests. If you're unfamiliar with ProviderEngine, please read the [Web3 Provider explained](https://0xproject.com/wiki#Web3-Provider-Explained) wiki article.
+
+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.
+
+```typescript
+import { CoverageSubprovider } from '@0xproject/sol-cov';
+
+const provider = new ProviderEngine();
+
+const artifactsPath = 'src/artifacts';
+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';
+const coverageSubprovider = new CoverageSubprovider(artifactsPath, contractsPath, networkId, defaultFromAddress);
+
+provider.addProvider(coverageSubprovider);
+```
+
+After your test suite is complete (e.g 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.