Events not emitted during tests

I’m implementing OpenZeppelin’s PullPayment (4.0.0) contract.
Unfortunately, during testing I’m always getting AssertionError: Expected event "Deposited" to be emitted, but it wasn't Also the Withdrawn event doesn’t get emitted. But _asyncTransfer seems to run properly as Transfergets emitted.

I checked my ABI and it seems the contract is compiled correctly.

:computer: Environment
I’m using Hardhart with Waffle, Chai, Mocha, Ethers.js.

:1234: Code to reproduce
This is my contract
This is my test

2 Likes

Hi @philipp,

Welcome to the community :wave:

I am sorry that you are having this issue. Can you share a simple contract and test?

Perhaps similar to the following:

Hi @philipp -- I'm having the same problem. Did you ever figure out what it was? I tried looking at This is my test, but I got a 404 from github.

Ok, I figured it out. Events from other contracts are not in receipts. You have to use expectEvent.inTransaction instead of just expectEvent. Something like:

await expectEvent.inTransaction(receipt.tx, Escrow, 'Deposited', {payee: beneficiary, weiAmount: refund});

Where Escrow is the Escrow contract.