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

How to use MockContract when the contract is passed as an argument to a interface? #566

Open
PaulRBerg opened this issue Sep 2, 2021 · 1 comment
Labels
waffle-mock-contract Anything related to the mocking package

Comments

@PaulRBerg
Copy link
Contributor

I love MockContract, but it can't be used when the mocked contract is used as an argument to a contract interface.

Foo myFoo = Foo(fooAddress);

When fooAddress is an instance of MockContract, my test fails with the following error:

Error: Transaction reverted: function call to a non-contract account

How can we use MockContract in this scenario?

@rzadp rzadp added the waffle-mock-contract Anything related to the mocking package label Jul 29, 2022
@Najada
Copy link

Najada commented Aug 11, 2022

Hi, I was able to bypass this issue by configuring my environment like this:

const { ethers, waffle } = require('hardhat');
const provider = waffle.provider;

Use it as the following for getting the wallets: const [owner, notOwner] = provider.getWallets();

On my project I have the same exact use case as you, ie: C3ProjectToken token = C3ProjectToken(tokenAddress);

and it works fine :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
waffle-mock-contract Anything related to the mocking package
Projects
None yet
Development

No branches or pull requests

3 participants