-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Coverage: Library coverage #2567
Comments
Hi @onbjerg , sorry to bother you, I would like to know, if it is a developer-defined library and the functions in the library are all internal functions, the coverage rate running through forge coverage cannot be supported at present, right? |
No libraries are supported at the moment |
Will it support library coverage later? |
Also generally outside of dynamically linked libraries any and all delegatecall'd code is not being considered as covered I think. Is that right? Might be worth updating the issue with what is the current way of how coverage works. |
Libraries are currently not covered and they are somewhat non-trivial to map instructions for.
Generally, there are two types of library functions:
delegatecall
The way coverage works currently is in a few passes:
The issue with adding library coverage is that the Solidity compiler does not give us any easily digestable information about what libraries are used in contracts. This is in contrast to base contracts which are easily identified using a property of contract AST nodes called
linearizedBaseContracts
.In order to reliably find what libraries are used in contracts so we can map instructions onto coverage items present in libraries, we need to walk each node in the AST to find call expression nodes.
These call expression nodes include some crude type information, and in the case of library calls, the type information will show up as e.g.
type(library LibraryName)
.After parsing this information, we need to map the library name back onto an AST node ID so we can find what coverage items are present in the library. The rest of the analysis step in
forge coverage
uses AST node IDs to refer to contracts.Some unknowns:
The text was updated successfully, but these errors were encountered: