diff options
author | Leonid Logvinov <logvinov.leon@gmail.com> | 2018-03-14 02:13:37 +0800 |
---|---|---|
committer | Leonid Logvinov <logvinov.leon@gmail.com> | 2018-03-14 02:13:37 +0800 |
commit | 20985d515fd88c798dddb5e946bd4dd5fe40cd6b (patch) | |
tree | 730d196e9b176661f86e537dc350bdc6ad7a0775 /packages | |
parent | 0334004b11564d4c23dd64bcf1ee4f9c6097a466 (diff) | |
download | dexon-0x-contracts-20985d515fd88c798dddb5e946bd4dd5fe40cd6b.tar.gz dexon-0x-contracts-20985d515fd88c798dddb5e946bd4dd5fe40cd6b.tar.zst dexon-0x-contracts-20985d515fd88c798dddb5e946bd4dd5fe40cd6b.zip |
Address feedback
Diffstat (limited to 'packages')
-rw-r--r-- | packages/deployer/README.md | 2 | ||||
-rw-r--r-- | packages/sol-cov/README.md | 22 |
2 files changed, 10 insertions, 14 deletions
diff --git a/packages/deployer/README.md b/packages/deployer/README.md index 5f10b762b..9abcfa6fe 100644 --- a/packages/deployer/README.md +++ b/packages/deployer/README.md @@ -41,7 +41,7 @@ Options: You might want to write a migration scripts (similar to `truffle migrate`), that deploys multiple contracts and configures them. Below you'll find a simple example of such a script to help you get started. -``` +```typescript import { Deployer } from '@0xproject/deployer'; import * as path from 'path'; diff --git a/packages/sol-cov/README.md b/packages/sol-cov/README.md index fec087394..6a98346f9 100644 --- a/packages/sol-cov/README.md +++ b/packages/sol-cov/README.md @@ -12,31 +12,27 @@ yarn add -D @0xproject/sol-cov 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. -``` -import { CoverageSubprovider } from '@0xproject/sol-cov' +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, -); +const coverageSubprovider = new CoverageSubprovider(artifactsPath, contractsPath, networkId, defaultFromAddress); provider.addProvider(coverageSubprovider); ``` -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. - -After all your tests are run, you'll need to call: +After your test suite is complete (e.g global `after` hook), you'll need to call: -``` -await coverageSubprovider.writeCoverageAsync() +```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. |