Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Solidity Coverage returns 0% #7

Closed
jeffywu opened this issue Mar 26, 2020 · 2 comments
Closed

Solidity Coverage returns 0% #7

jeffywu opened this issue Mar 26, 2020 · 2 comments

Comments

@jeffywu
Copy link

jeffywu commented Mar 26, 2020

I've been using this as a repo for my solidity project and it's been really helpful. Saw that solidity-coverage was added here but it returns 0% for me when I run it. Getting the same issue with the setup in my project as well. Wonder if you guys got it working?

> server:            http://127.0.0.1:8555
> ganache-core:      v2.8.0
> solidity-coverage: v0.7.1

Network Info
============
> port:    8555
> network: soliditycoverage


Instrumenting for coverage...
=============================

> Counter.sol
Compiling...
Downloading compiler version 0.6.2
Compiled 2 contracts successfully
All contracts have already been compiled, skipping compilation.


  Counter
    count up
      ✓ should count up (277ms)
    count down
      ✓ should fail (1051ms)
      ✓ should count down (188ms)


  3 passing (2s)

--------------|----------|----------|----------|----------|----------------|
File          |  % Stmts | % Branch |  % Funcs |  % Lines |Uncovered Lines |
--------------|----------|----------|----------|----------|----------------|
 contracts/   |        0 |        0 |        0 |        0 |                |
  Counter.sol |        0 |        0 |        0 |        0 |... 28,30,32,33 |
--------------|----------|----------|----------|----------|----------------|
All files     |        0 |        0 |        0 |        0 |                |
--------------|----------|----------|----------|----------|----------------|

> Istanbul reports written to ./coverage/ and ./coverage.json
> solidity-coverage cleaning up, shutting down ganache server
@jeffywu
Copy link
Author

jeffywu commented Mar 26, 2020

Looking at this and maybe I've set up some things wrong:
https://github.com/rhlsthrm/typescript-solidity-dev-starter-kit/pull/6/files

Will update if I get it resolved. Thanks.

@jeffywu
Copy link
Author

jeffywu commented Mar 29, 2020

Ok, the pull request was informative but I had a lot of stuff set up already so it took a bit of work to get everything where I needed it. Some things to note:

  1. Waffle needs to be imported from @nomiclabs/buidler which this repo is doing properly but I was not.
  2. When solidity-coverage runs it deploys different bytecode that is much larger than what the regular builds create. It took me a little while to figure this out since solidity-coverage also deletes its artifacts after it runs. I added in an if block and an environment variable to switch between the two artifacts depending on if I was running tests normally or coverage.

Not sure where to properly document this for others to find out, the solidity-coverage docs and the buidler docs weren't too helpful. I'm sure others will run into the same issue. I'll ping the devs there.

@jeffywu jeffywu closed this as completed Mar 29, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant