You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
**NB:**for most projects you'll also need to configure a 'coverage' network in
30
-
truffle-config.js. See the Network Configuration guide below.
29
+
**NB:**Most projects will also need to set a `coverage` network in
30
+
truffle-config.js. See [Network Configuration](#network-configuration).
31
31
32
32
### Usage notes:
33
-
+Requires Solidity pragmas >= `0.5.0`.
33
+
+For solidity pragma >= `0.5.0`.
34
34
+ Tests run more slowly while coverage is being generated.
35
-
+ Your contracts will be double-compiled and a delay between compilation and
35
+
+ Your contracts will be double-compiled and a (long) delay between compilation and
36
36
the beginning of test execution is possible if your contracts are large.
37
-
+ solidity-coverage expects a globally installed truffle in your environment / on CI. If you
38
-
prefer to control which Truffle version your tests are run with, please see the FAQ for
39
-
[running truffle as a local dependency](https://github.com/sc-forks/solidity-coverage/blob/master/docs/faq.md#running-truffle-as-a-local-dependency).
40
-
+ Solidity fixtures / mocks stored in the `tests/` directory are no longer supported. If your suite uses native Solidity testing or accesses contracts via mocks stored in `tests/` (a la Zeppelin), coverage will trigger test errors because it's unable to rewrite your contract ABIs appropriately. Mocks should be relocated to the root folder's `contracts` directory. More on why this is necessary at issue [146](https://github.com/sc-forks/solidity-coverage/issues/146)
37
+
+ Truffle should be globallly installed in your environment.. If you prefer running truffle as
38
+
a local dependency, please see [this section](https://github.com/sc-forks/solidity-coverage/blob/master/docs/faq.md#running-truffle-as-a-local-dependency) of the FAQ.
39
+
+ If your suite uses native Solidity testing or accesses contracts via mocks stored in `tests/` (a la Zeppelin), coverage will trigger test errors because it's unable to control truffle's compilation of that folder. Mocks should be relocated to the root `contracts` directory. More on why this is necessary at issue [146](https://github.com/sc-forks/solidity-coverage/issues/146)
41
40
42
41
### Network Configuration
43
42
44
-
By default, solidity-coverage connects to a coverage-enabled fork of the ganache-cli client
45
-
called **testrpc-sc** on port 8555. (It ships with `solidity-coverage` -
46
-
there's nothing extra to download.)
43
+
By default, this tool connects to a coverage-enabled fork of ganache-cli
44
+
called **testrpc-sc** on port 8555. (It's a dependency - there's nothing extra to download.)
47
45
48
46
In `truffle-config.js`, add a coverage network following the example below.
49
47
@@ -69,8 +67,8 @@ module.exports = {
69
67
```
70
68
### Options
71
69
72
-
You can also create a `.solcover.js` config file in the root directory of your project and specify
73
-
additional options if necessary:
70
+
Additional options can be specified in a `.solcover.js` config file located in
71
+
the root directory of your project.
74
72
75
73
**Example:**
76
74
```javascript
@@ -102,15 +100,14 @@ module.exports = {
102
100
103
101
### FAQ
104
102
105
-
Solutions to common issues people run into using this tool:
103
+
Solutions to common problems people run into:
106
104
107
105
+[Running out of gas](https://github.com/sc-forks/solidity-coverage/blob/master/docs/faq.md#running-out-of-gas)
108
106
+[Running out of memory (locally and in CI)](https://github.com/sc-forks/solidity-coverage/blob/master/docs/faq.md#running-out-of-memory-locally-and-in-ci)
109
107
+[Running out of time (in mocha)](https://github.com/sc-forks/solidity-coverage/blob/master/docs/faq.md#running-out-of-time-in-mocha)
110
108
+[Running on windows](https://github.com/sc-forks/solidity-coverage/blob/master/docs/faq.md#running-on-windows)
111
109
+[Running testrpc-sc on its own](https://github.com/sc-forks/solidity-coverage/blob/master/docs/faq.md#running-testrpc-sc-on-its-own)
112
110
+[Running truffle as a local dependency](https://github.com/sc-forks/solidity-coverage/blob/master/docs/faq.md#running-truffle-as-a-local-dependency)
+[Integrating into CI](https://github.com/sc-forks/solidity-coverage/blob/master/docs/faq.md#continuous-integration-installing-metacoin-on-travisci-with-coveralls)
115
112
+[Why are asserts and requires highlighted as branch points?](https://github.com/sc-forks/solidity-coverage/blob/master/docs/faq.md#why-has-my-branch-coverage-decreased-why-is-assert-being-shown-as-a-branch-point)
116
113
+[Why are `send` and `transfer` throwing in my tests?](https://github.com/sc-forks/solidity-coverage/blob/master/docs/faq.md#why-are-send-and-transfer-throwing)
@@ -119,14 +116,12 @@ Solutions to common issues people run into using this tool:
- npm run coverage && cat coverage/lcov.info | coveralls
45
46
```
46
-
**NB:** It's probably best practice to run coverage in CI as an `after_script` or in a [parallel build](https://github.com/OpenZeppelin/zeppelin-solidity/blob/master/.travis.yml) rather than assume its equivalence to `truffle test`. Solidity-coverage's `testrpc` uses gasLimits far above the current blocklimit and rewrites your contracts in ways that might affect their behavior. It's also less robust than Truffle and may fail more frequently.
47
+
**NB:** It's best practice to run coverage in a [parallel CI build](https://github.com/OpenZeppelin/zeppelin-solidity/blob/master/.travis.yml) rather than assume its equivalence to `truffle test`. Coverage's `testrpc-sc` uses gasLimits far above the current blocklimit and rewrites your contracts in ways that might affect their behavior. It's also less robust than Truffle and may fail more frequently.
47
48
48
49
**Step 4: Toggle the project on at Travis and Coveralls and push.**
49
50
@@ -57,33 +58,12 @@ after_script:
57
58
58
59
59
60
60
-
61
61
### Running out of gas
62
62
If you have hardcoded gas costs into your tests some of them may fail when using solidity-coverage.
63
63
This is because the instrumentation process increases the gas costs for using the contracts, due to
64
64
the extra events. If this is the case, then the coverage may be incomplete. To avoid this, using
65
65
`estimateGas`to estimate your gas costs should be more resilient in most cases.
(See [issue #59](https://github.com/sc-forks/solidity-coverage/issues/59)).
@@ -104,55 +84,20 @@ limit to 7.5MB (ProTip courtesy of [@federicobond](https://github.com/federicobo
104
84
Truffle sets a default mocha timeout of 5 minutes. Because tests run slower under coverage, it's possible to hit this limit with a test that iterates hundreds of times before producing a result. Timeouts can be disabled by configuring the mocha option in `truffle.js` as below: (ProTip courtesy of [@cag](https://github.com/cag))
### Why has my branch coverage decreased? Why is assert being shown as a branch point?
157
102
158
103
`assert`and `require` check whether a condition is true or not. If it is, they allow execution to proceed. If not, they throw, and all changes are reverted. Indeed, prior to [Solidity 0.4.10](https://github.com/ethereum/solidity/releases/tag/v0.4.10), when `assert` and `require` were introduced, this functionality was achieved by code that looked like
@@ -174,8 +119,8 @@ If an `assert` or `require` is marked with an `I` in the coverage report, then d
174
119
175
120
If you include contracts that have fallback function in the list of files to instrument and attempt to `send` or `transfer` to them,
176
121
the methods will throw because the instrumentation consumes more gas than these methods allow. See the `skipFiles` option in the
177
-
README to exclude these files and [issue 118](https://github.com/sc-forks/solidity-coverage/issues/118) for a more detailed discussion of
178
-
this problem.
122
+
README to exclude these files and [issue 118](https://github.com/sc-forks/solidity-coverage/issues/118) for a more detailed discussion. This problem persists in v0.6.x even though the vm is set to emit free logs.
123
+
(Under investigation).
179
124
180
125
### Running on windows
181
126
@@ -190,15 +135,8 @@ launching `testrpc-sc` on its own from the command line before running `solidity
190
135
Sometimes its useful to launch `testrpc-sc` separately at the command line or with a script, after
191
136
setting the `norpc` config option in `.solcover.js` to true:
192
137
193
-
If you installed using npm
194
-
```
195
-
$ ./node_modules/.bin/testrpc-sc <options>
196
-
```
197
-
198
-
If you installed using yarn
199
138
```
200
-
$ ./node_modules/ethereumjs-testrpc-sc/bin/testrpc // v0.1.10 and below (testrpc v3.0.3)
201
-
$ ./node_modules/ethereumjs-testrpc-sc/build/cli.node.js // All others (testrpc v4.0.1 +)
0 commit comments