defi-wonderland / smock

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

mock function is executing contract logic despite mocked instructions #159

Open aazhou1 opened 2 years ago

aazhou1 commented 2 years ago

Describe the bug A stubbed function of a mock contract is reverting on something in the contract logic. This doesn't make sense to me since it shouldn't care about the contract logic if stubbed. When running the unit test, we get the error Error: Transaction reverted: function returned an unexpected amount of data. The line corresponding to the error is purchaseTokenInstance.decimals() where purchaseTokenInstance is a IERC20MetadataUpgradable. If I use Hardhat console logging, the function doesn't actually execute and spit out values. Reproduction steps

contract.function.returns(BigNumber.from("1000"));

Expected behavior calls contract.function should just return ("1000") in unit tests, instead of reverting as in the description.

wei3erHase commented 2 years ago

ey @aazhou1 , could you provide an isolated example that replicates the bug?