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

Highlight lcov support in the readme #1081

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 59 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Copy link
Member

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


- 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
Copy link
Member

Choose a reason for hiding this comment

The 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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no --coverage flag


#### 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 .`.
Expand Down