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

Instrument public storage variable getters #281

Open
nventuro opened this issue Aug 31, 2018 · 1 comment
Open

Instrument public storage variable getters #281

nventuro opened this issue Aug 31, 2018 · 1 comment

Comments

@nventuro
Copy link

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.

@cgewecke
Copy link
Member

cgewecke commented 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants