-
Notifications
You must be signed in to change notification settings - Fork 279
Description
Solidity public
state variables have getter functions automatically generated for them, making them part of the public API of a contract. Testing that they exist and can be used is therefore important, since it helps prevent regression bugs (e.g. the variable becoming private
). It'd be great if solidity-coverage
reported which of these getters are being called during testing, so that the ones without them can be quickly identified and the test suite improved.
I'm not too familiar with how code is instrumented, but my basic understanding is that the source is mutated and events are added between statements. If solidity-coverage
indeed works on auto-modified code, then this feature could probably be supported by making the original state variable internal
instead of public
(so that inheritance and overrides still work) with a new name (e.g. prefixed by the line number?), and adding a public view
function with the same name as the original variable, returning it.
Activity
cgewecke commentedon Sep 3, 2018
Hi @nventuro 🙂
This is a great idea and captures something important about how solidity is different than other languages - similar to the way
require
has to be treated as a branch in the code instead of a simple statement. Essentially we would be saying that public state variables should be treated as measurable lines. Your implementation idea also LGTM.Am going to focus work on this tool in October and will circle back to this then. Should be straightforward.