You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
The text was updated successfully, but these errors were encountered:
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.
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 becomingprivate
). It'd be great ifsolidity-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 variableinternal
instead ofpublic
(so that inheritance and overrides still work) with a new name (e.g. prefixed by the line number?), and adding apublic view
function with the same name as the original variable, returning it.The text was updated successfully, but these errors were encountered: