Getting 0% coverage results
GitSwarmOrg opened this issue · comments
Reproduction code is on this repository on the solidity-coverage branch: https://github.com/GitSwarmOrg/contracts/tree/solidity-coverage
There are several tests for the Delegates contract implemented that pass so result should be more than 0%.
Getting same result with and without the optimizer or viaIR enabled.
@GitSwarmOrg Hi.
The coverage plugin only works if your tests run on the default built-in Hardhat network. You're setting the provider yourself to use a stand-alone localhost client at the top of the test file.
The normal way to use hardhat is to define all networks in hardhat.config.ts and toggle between them using the --network
command line flag. If you let hardhat and hardhat-ethers manage provider instantiation and consume it from the hardhat runtime environment imported in the tests as necessary, any other other plugins you're using are more likely to work correctly.
Closing for now since this isn't a bug and should be resolved by following the conventions established in the hardhat docs.