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

Cannot read property 'getCode' of undefined mocha delay =true makes gasReporter fails #258

Closed zgorizzo69 closed 8 months ago

zgorizzo69 commented 3 years ago

Steps to reproduce: add a delayed test like described in mocha doc here add this to your hardhat config to take the delay into acount

https://mochajs.org/#delayed-root-suite

If you run hardhat test it will fail with

 UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'getCode' of undefined
    at GasData.asyncGetNameByAddress (/home/zgo/work/src/github.com/Protocol/node_modules/eth-gas-reporter/lib/gasData.js:181:38)
    at TransactionWatcher._asyncCollectMethodsData (/home/zgo/work/src/github.com/Protocol/node_modules/eth-gas-reporter/lib/transactionWatcher.js:131:40)
    at TransactionWatcher.transaction (/home/zgo/work/src/github.com/Protocol/node_modules/eth-gas-reporter/lib/transactionWatcher.js:59:20)
    at EGRDataCollectionProvider.request (/home/zgo/work/src/github.com/RProtocol/node_modules/hardhat-gas-reporter/src/providers.ts:36:44)
    at processTicksAndRejections (internal/process/task_queues.js:93:5)
    at runNextTicks (internal/process/task_queues.js:62:3)
    at listOnTimeout (internal/timers.js:523:9)
    at processTimers (internal/timers.js:497:7)
    at EthersProviderWrapper.send (/home/zgo/work/src/github.com/Protocol/node_modules/hardhat-deploy-ethers/src/internal/ethers-provider-wrapper.ts

it seems that the provider is null due to the delay

version: "chai": "4.3.4", "hardhat": "2.6.1", "hardhat-gas-reporter": "1.0.4", "mocha": "9.1.0",

cgewecke commented 8 months ago

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

In the latest version at Hardhat, the reporter has been completely decoupled from mocha and this conflict should be resolved.

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