Waffle icon indicating copy to clipboard operation
Waffle copied to clipboard

Mocking ether `receive()`

Open sebastiantf opened this issue 2 years ago • 0 comments

Is there an easy way to mock the ether transfer to a contract via the receive() method?

I tried the following but didn't work:

const mockRevertOnReceiveEtherContract = await deployMockContract(
  this.signers.alice,
  [{ stateMutability: "payable", type: "receive" }]
);
await mockRevertOnReceiveEtherContract.mock.receive.reverts();
const mockRevertOnReceiveEtherContract = await deployMockContract(
  this.signers.alice,
  ["receive() external payable"]
);

await mockRevertOnReceiveEtherContract.mock.receive.reverts();

sebastiantf avatar May 25 '22 11:05 sebastiantf