-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
vm.expectEmit is breaking in tests #5117
Comments
Hey @lyoungblood thanks for this! I believe this change has to do with #4920 — from what I can see here, it's not super clear but it looks like you might have an ordering issue from what I see in the traces? It's worth mentioning that the behavior now is that events are expected to be emitted in the next call. So if you're matching multiple events across multiple calls, you need to "declare" the events to be matched before the call were they're going to be emitted. If you think this is actually a bug, could you maybe provide a more minimal repro? I'm 100% happy to look into this, just can' determine it from looking at these traces. |
Closing—stale and could not reproduce, plus further QA seems this is correct. |
This might be a genuine bug - I'm in the same boat as @lyoungblood. I'm as confident a person can be that there's no additional non-static call (
As you can see, all event arguments match. You can see the full logs here. I think I know what's going on. The bug started to occur only after adding two more @lyoungblood seems also to have had multiple |
Hmmm interesting—I've tried to reproduce this but can't—do you think you can give a smol repro @PaulRBerg ? I think I might know what's going on here but need something I can test against. |
Aight ser @PaulRBerg — I took a quick look at this, and it seems like events do differ. The emitted event for the test is the following one: event InstallPlugin(address owner, IPRBProxy proxy, IPRBProxyPlugin indexed plugin); While the emitted test on the registry is this one: event InstallPlugin(address indexed owner, IPRBProxy indexed proxy, IPRBProxyPlugin indexed plugin); The event emitted in the test only has one indexed param, but the event emitted from the contract has 3. |
I agree that if indexed params differ they should be considered different, so a solution here is probably just to make this easier to catch and have a better failure message. Ref #592 (comment) |
Oh my! I'm sorry for the false alarm, @Evalir. Thanks for tracking the cause down. I agree with both of you that Foundry should consider these as different events (since the event topics would be different, I think). And I also agree that the solution is to throw a more specific error message. |
No problem @PaulRBerg — glad this was just a false alarm haha. I definitely agree—we should give #592 a go and try to be more specific on what failed. I'll close this, and let's keep the convo going on 592! |
Component
Forge
Have you ensured that all of these are up to date?
What version of Foundry are you on?
forge 0.2.0 (08a629a 2023-06-03T00:14:26.563741000Z)
What command(s) is the bug in?
forge test -vvv
Operating System
Linux
Describe the bug
On the latest nightly build
forge 0.2.0 (08a629a 2023-06-03T00:14:26.563741000Z)
a test withvm.expectEmit(true, true, true, true, address(faucetToken));
throws an unexpected test failure:But on a previous build,
forge 0.2.0 (200b3f4 2023-05-05T00:04:35.225055000Z)
the same test succeeds:The full trace of the failing test is:
I don't want to include the complete test, but the section with breakage looks like this:
Thanks for your help with this issue!
The text was updated successfully, but these errors were encountered: