Allow files to be skipped during coverage #52
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 in0x40
. 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 in0x40
and update it, and so the injected instrumentation events clobber the memory thatEtherRouter
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. Oncetestrpc
allows debug_traceTransaction, we should really be using that functionality plus source mappings to generate coverage. We would no longer require a customtestrpc
, 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.