-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Contract event listener is not firing when running hardhat tests on ethers v6 #4044
Comments
Thank you @lescaudr, I can confirm this. It's an important problem, I'll try to get it fixed asap. |
The same problem, .on is not working with hardhat node v2.12.3. Is there a version where it works? |
@tevdoradze it should still work if you use ethers v5 (and the associated plugins: |
Released in hardhat-ethers v3.0.3 🎉 |
It still doesn't work in tests |
@shaggyrec if you have reproduction steps, please open an issue about it. |
I confirm it works perfectly @shaggyrec, see the branch "fixed" on Thanks @fvictorio |
Yeah. Seems like working for your case and the standard hardhat But for Patric Collins' tutorial updated to the latest versions it doesn't work. I have no idea why. |
You are right @shaggyrec, indexed events are not triggered, I created a new issue #4098. Also found that when triggering multiple events, only the first is triggered. |
if it doesn't work in your tests you are most likely not waiting long enough:
If you work with an upgradable contract you may need to add |
@tevdoradze polling interval is not the resolution here in ether v6. The bug has been confirmed, and is in progress |
update? |
It has been fixed 3 weeks ago #4098 (comment) |
+fix tests ( NomicFoundation/hardhat#4044 ) by upgrading @nomicfoundation/hardhat-ethers to 3.0.4
+ fix ( NomicFoundation/hardhat#4044 ) by upgrading @nomicfoundation/hardhat-ethers to 3.0.4 + add some docs
+ fix ( NomicFoundation/hardhat#4044 ) by upgrading @nomicfoundation/hardhat-ethers to 3.0.4 + add some docs
Version of Hardhat
2.15.0
What happened?
I'm running into the same issue as this one #1692 from 2 years ago with the correct modification in ethers v6 but the contract.on is not triggered.
Contract:
I'm adding the Promise to ensure to wait until the event is emitted.
From the receipt, the event is properly emitted, then it wait indefinitely because the event is never emitted.
If I emit the event manually using
contractA.emit("TokensMinted", 123);
, then I get the console.log and the promise is resolved.Minimal reproduction steps
Repo to reproduce the issue easily: https://github.com/lescaudr/ethers-event-issue
pnpm install
pnpm compile
pnpm test
Search terms
No response
The text was updated successfully, but these errors were encountered: