diff --git a/README.md b/README.md index 3e3b90339..c82826e1a 100644 --- a/README.md +++ b/README.md @@ -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 + 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 + +#### 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 .`.