defi-wonderland / smock

The Solidity mocking library
MIT License
319 stars 40 forks source link

Calls to a mocked contract function are inaccurate #99

Closed Remscar closed 2 years ago

Remscar commented 2 years ago

Describe the bug I am using a mock to track how many times the transferFrom function on an ERC20 token is called. Even though the function only gets called once, the mock says it is called 13 times.

I am using .reset() on the mock right before the call.

Expected behavior The mock should say it has only been called once.

Additional context I have discovered that by setting a gasLimit on the transaction, the mock returns the proper number of calls. My suspicion is that when Hardhat is attempting to estimate the gas of the transaction, it is calling the mock many times.

0xGorilla commented 2 years ago

Hey @Remscar , sorry for the late reply!

Could you please provide some code in order to reproduce this issue?

smartcontracts commented 2 years ago

I believe that hardhat might be using a binary search for gas estimation which results in a significant number of calls. Going to try to reproduce locally. Which version of hardhat are you using?

wei3erHase commented 2 years ago

closing this issue for inactivity for now, please reopen with further details on how to reproduce the bug 🥕