-
Notifications
You must be signed in to change notification settings - Fork 366
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
Highlight lcov support in the readme #1081
Closed
Closed
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -81,6 +81,65 @@ Our tool signals each execution trace in the corpus with the following "line mar | |
* `o` if an execution ended with an out-of-gas error | ||
* `e` if an execution ended with any other error (zero division, assertion failure, etc) | ||
|
||
### Using lcov Support with a VSCode Plugin | ||
#### Install the lcov plugin for VSCode | ||
|
||
To visualize the coverage reports of your smart contracts in Visual Studio Code (VSCode), you need to install the lcov plugin. Here's how: | ||
|
||
1. Open the VSCode Marketplace by clicking on the square icon in the left sidebar or using the shortcut `Ctrl+Shift+X` (Windows/Linux) or `Cmd+Shift+X` (Mac). | ||
|
||
2. Search for "lcov" in the Extensions search bar. | ||
|
||
3. Look for an lcov plugin, such as "Code Coverage" by Jun Han. | ||
|
||
4. Click the "Install" button to install the plugin. | ||
|
||
Once the plugin is installed, you will need to restart VSCode for the changes to take effect. | ||
|
||
#### Run Echidna and generate a coverage report | ||
|
||
Echidna is a powerful fuzz testing tool used to discover bugs in smart contracts. Before running Echidna, ensure that you have the following prerequisites installed: | ||
|
||
- Node.js: A JavaScript runtime environment. | ||
- NPM: A package manager for Node.js. | ||
|
||
To install Echidna and generate a coverage report, follow these steps: | ||
|
||
1. Install Echidna globally by running the following command in your terminal or command prompt: | ||
|
||
```shell | ||
npm install -g echidna | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. echidna is not available on npm |
||
Note: The -g flag ensures a global installation of Echidna. | ||
|
||
2. Once Echidna is installed, execute the following command to run Echidna with coverage enabled: | ||
|
||
```shell | ||
echidna --coverage | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There is no |
||
|
||
#### Open the coverage report in VSCode | ||
|
||
To view the coverage report in VSCode, follow these steps: | ||
|
||
1. Open Visual Studio Code (VSCode). | ||
|
||
2. Locate and open the `coverage.lcov` file generated by Echidna. | ||
|
||
**Note**: You can use the File Explorer in VSCode to navigate to the file. | ||
|
||
3. The lcov plugin, already installed in the previous steps, will automatically detect the file format and display the coverage of your smart contracts within the editor. | ||
|
||
#### Use the lcov plugin to visualize the coverage of the smart contracts | ||
|
||
The lcov plugin for VSCode provides a range of features to visualize the coverage of your smart contracts. These features include: | ||
|
||
- **Coverage map**: Displays which lines of code have been executed and which ones haven't. | ||
|
||
- **Call graph**: Illustrates how different functions within your smart contracts are called and the coverage status of each. | ||
|
||
- **Function coverage summary**: Offers a summary of the coverage for individual functions, providing insights into areas that may require additional testing. | ||
|
||
Leverage these features to identify areas of your smart contracts that have not been covered by the fuzz testing, enabling you to uncover potential bugs and vulnerabilities. | ||
|
||
### Support for smart contract build systems | ||
|
||
Echidna can test contracts compiled with different smart contract build systems, including [Truffle](https://truffleframework.com/) or [hardhat](https://hardhat.org/) using [crytic-compile](https://github.com/crytic/crytic-compile). To invoke echidna with the current compilation framework, use `echidna .`. | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there is no need to explain what Echidna is here