mockContract doesn't seem to work
const [sender, receiver] = await provider.getWallets();
const mockContract = await deployMockContract(sender, abi);
Problem 1:
Before, I even mock return values for the mockContract, I want to call function as normal. FYI, abi is ERC20 contract. So I do this:
await mockContract.approve(address, 20);
This fails.
cannot estimate gas; transaction may fail or may require manual gas limit
If I first call this await mockContract.mock.approve.returns(false); and then call await mockContract.approve(address, 20);, it doesn't fail, but then the problem is that approve method wouldn't work. So the idea is that approve should work at first, then I should mock the method with returned value false.
Any idea ?
You should only mock interfaces for contracts, not actual contracts. This way, it is more clear that before you can use a function, you must set a mocked behavior for that function.
I believe that's the intended behavior.