Skip to content

Instrument public storage variable getters #281

Open
@nventuro

Description

@nventuro

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions