Mocking method with bytes type
Hi, I'm trying to mock swap method on Uniswap V2 pair contract. The method has the following signature:
function swap(uint amount0Out, uint amount1Out, address to, bytes calldata data);
I have no idea how to mock it properly, because whatever I input as the data parameter I always get a revert with error that method on mock has not been set up. I don't see anything in the docs about that.
I tried using this method as simply as
swap(0, 0, address(this), '')
in Solidity but mocking it with either of
await mockPair.mock.swap.withArgs(0, 0, myContract.address, '')
await mockPair.mock.swap.withArgs(0, 0, myContract.address, '0x')
still failed.
Is there a way to do this?
still failed.
Could you provide the error msg or more context?
For example see it in action: https://github.com/EthWorks/Waffle/compare/master...wachulski:issue/477/mocking-calldata-example
Maybe you just need utils.toUtf8Bytes('') or your contract definitions do sth suspicious with addresses. I simplified my example and moved out addresses.