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

Allow files to be skipped during coverage #52

Merged
merged 1 commit into from
Jun 27, 2017
Merged

Conversation

area
Copy link
Contributor

@area area commented Jun 27, 2017

While ordinarily we shouldn't want to do this, it is possible to construct valid contracts using assembly that break when the coverage events are injected.

An example of such a contract is the EtherRouter contract by Peter Borah. It repeatedly calls mload(0x40) when it needs a memory address, as it only uses one piece of memory at a time and repeatedly overwrites the memory starting at the address contained in 0x40. In Solidity, 0x40 is a special memory address that contains the address of the first empty slot. When events in solidity are compiled, they use the address contained in 0x40 and update it, and so the injected instrumentation events clobber the memory that EtherRouter is using.

This time, I've also included a test to demonstrate that skipping a contract works!

Really, this is just another sign pointing towards a huge do-over for solidity-coverage that I've been trying not to think about. Once testrpc allows debug_traceTransaction, we should really be using that functionality plus source mappings to generate coverage. We would no longer require a custom testrpc, wouldn't have to have to make our own coverage environment, no need for custom very high gas limits, or run in to these sorts of issues where instrumentation breaks contracts...

EDIT: I am a terrible collaborator. Just noticed #17 existed, and you wanted to do it a different way... I don't think that using comments is the way to go though. In some cases, I would expect the contracts that wanted to be ignored would be libraries that the user will not want to edit directly.

While ordinarily we shouldn't want to do these, it is possible to
construct valid contracts using assembly that break when the coverage
events are injected.
@codecov-io
Copy link

Codecov Report

Merging #52 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master      #52   +/-   ##
=======================================
  Coverage   97.57%   97.57%           
=======================================
  Files           6        6           
  Lines         330      330           
  Branches       78       78           
=======================================
  Hits          322      322           
  Misses          8        8

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update c0d5f2e...c500b9d. Read the comment docs.

@cgewecke
Copy link
Member

LOL no I'm completely ambivalent about the comments thing - I just saw that Istanbul's taking that approach and ESLint as well and was wondering whether that's becoming normative or something. Good point re: libs.

Your analysis of the path forward is fantastic too! It's a complete rewrite but it would be so much more robust and closer to solc / Solidity. And cooler.

(I see that while writing this note coulter merged that Too Big PR! Ha ha!)

Great. As far as V1 - I think this is very close to being finished. Shouldn't this go back over to Colony and publish it over there? Is there anything else you want to do here?

Open to anything but that seems like it makes sense to me.

@cgewecke cgewecke merged commit aa41e80 into master Jun 27, 2017
@cgewecke cgewecke mentioned this pull request Jun 27, 2017
@area
Copy link
Contributor Author

area commented Jun 27, 2017

(I see that while writing this note coulter merged that Too Big PR! Ha ha!)

ONeil

Got to dash now, but I'll get back to you tomorrow!

@cgewecke
Copy link
Member

👍

@cgewecke
Copy link
Member

cgewecke commented Jul 3, 2017

Published w/ 0.1.6

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

Successfully merging this pull request may close these issues.

None yet

3 participants