-
Notifications
You must be signed in to change notification settings - Fork 11.6k
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
Remove async
from describe
blocks and add missing await
in tests
#4942
Conversation
|
I forgot to mention:
|
Hey @fvictorio, thank you for raising this. After we migrated tests to Ethers I think this was one of our major worries (getting ghost tests). For the record, this comes from this PR. I guess the oversight came from the previous order of the arguments but I can't explain how I fixed the tests, and I think we'll need to discuss adding the |
async
from describe
blocks and add missing await
in tests
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, we need to discuss the options to avoid it happening again, but the PR is good to go rn.
Thanks for the review! |
Maybe you can consider adding this somewhere in the tests setup: process.on("unhandledRejection", (reason, promise) => {
throw promise;
}); |
Changes to the test files look good. Is the hardhat update necessary, it comes with a big |
@fvictorio we see a lot of changes to the package-lock.json, is there any reason for upgrading Hardhat? We may do this in a future PR but I wonder if we need it now |
No, no need to update it now. You might get a 10-15% performance improvement, but there isn't a strong reason for you to upgrade. I can rebase that commit out if you want. |
Yeah I think we'd prefer to keep this PR short. We still want to upgrade for next hardfork though |
6f14527
to
51fd58c
Compare
Done! |
I tried this suggestion and a couple more of issues came up. Thanks! I'm updating |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for all your work @fvictorio 🙏🏻
I created an issue for the ESLint rule so we can discuss it later: #4943
Rn it's looking good again, let's wait on @Amxx approval.
Moved process.on('unhandledRejection', reason => {
throw new Error(reason);
}); to a dedicated file + added a missing await (are there any more?) |
Right, the one you spotted is a tricky one given is expecting no changes. The test should make sure the function is called before asserting, though. I don't expect other tests to be in similar cases. |
When testing the latest version of Hardhat in the OZ repo, we noticed that some of the tests were suddenly failing. The problem was caused by a combination of some missing or extra
async
/await
keywords. Mainly: the functions of somedescribe
blocks had theasync
keyword (and they shouldn't), and some async assertions were missing theawait
keyword. This, combined with the different performance characteristics of the latest HH version, surfaced some issues that weren't showing up before just by coincidence. I fixed that in fe64f5c.After that, some other tests started failing. Most of them are related to event assertions that either had the wrong order of arguments, or had a missing argument. These were actually failing before, but since they weren't being awaited, they were floating rejected promises that didn't make the tests fail. I fixed that in 258a203.
Now there is only one test failing, the
grants role to the user
test inAccessManager.test.js
. This is asserting that aRoleAccessRequested
was emitted but, as far as I can tell, that event doesn't exist anymore. I couldn't find an equivalent one so I just left it as it was; I'm sure you can fix it faster than me.PR Checklist
This PR only affects tests, so no docs change or changeset entry is needed.
npx changeset add
)