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
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 ispurchaseTokenInstance.decimals()
where purchaseTokenInstance is a IERC20MetadataUpgradable. If I use Hardhat console logging, the function doesn't actually execute and spit out values. Reproduction stepscontract.function.returns(BigNumber.from("1000"));
Expected behavior calls contract.function should just return ("1000") in unit tests, instead of reverting as in the description.