cgewecke / eth-gas-reporter

Gas usage per unit test. Average gas usage per method. A mocha reporter.
MIT License
603 stars 94 forks source link

Not working properly when tests are written using Waffle #267

Closed Bolee95 closed 6 months ago

Bolee95 commented 2 years ago

Hi everyone,

I'm working on a project using the Truffle framework for development, Ganache as a local network and Waffle for testing. The reason I don't use native testing for Truffle is that I find creating mocks easily a really convenient tool, and with Waffle, it doesn't require creating new contracts with almost copied logic as the original one.

I was trying to get gas usage of the methods called during unit testing using eth-gas-reporter, but I cannot generate a report with methods gas usage. However, I do get contacts deployment gas usage.

Something that I think is causing this is that I do not use artefacts generated during truffle deploy command. I use files with generated ABI and bytecode, as I couldn't use artefacts in combination with Waffle, which operates with Ethers.js in the background.

Screenshot 2021-12-01 at 14 15 39 Screenshot 2021-12-01 at 14 15 34

This is a report generated after running tests:

Screenshot 2021-12-01 at 14 17 43

Does this ring any bell? Do I need to somehow configure the reporter differently? As you can see, the reporter is running during tests, so that's not an issue.

Would be really grateful if anyone got an answer. If you need more information, please ping me, I will provide it.

cgewecke commented 6 months ago

Hi! eth-gas-reporter is being deprecated in favor of hardhat-gas-reporter.

In the latest version at Hardhat, waffle should work as expected using the hardhat-waffle plugin

https://github.com/cgewecke/hardhat-gas-reporter/releases/tag/v2.0.0