Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mock function is executing contract logic despite mocked instructions #159

Open
aazhou1 opened this issue Sep 25, 2022 · 1 comment
Open

Comments

@aazhou1
Copy link

aazhou1 commented Sep 25, 2022

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
Copy link
Member

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants