File tree Expand file tree Collapse file tree 3 files changed +48
-2
lines changed Expand file tree Collapse file tree 3 files changed +48
-2
lines changed Original file line number Diff line number Diff line change @@ -1656,8 +1656,9 @@ impl Inspector<&mut dyn DatabaseExt> for Cheatcodes {
1656
1656
} )
1657
1657
. collect :: < Vec < _ > > ( ) ;
1658
1658
1659
- // Not all emits were matched.
1660
- if self . expected_emits . iter ( ) . any ( |( expected, _) | !expected. found ) {
1659
+ // Revert if not all emits expected were matched.
1660
+ if self . expected_emits . iter ( ) . any ( |( expected, _) | !expected. found && expected. count > 0 )
1661
+ {
1661
1662
outcome. result . result = InstructionResult :: Revert ;
1662
1663
outcome. result . output = "log != expected log" . abi_encode ( ) . into ( ) ;
1663
1664
return outcome;
Original file line number Diff line number Diff line change @@ -404,3 +404,6 @@ test_repro!(10302);
404
404
405
405
// https://github.com/foundry-rs/foundry/issues/10477
406
406
test_repro ! ( 10477 ) ;
407
+
408
+ // https://github.com/foundry-rs/foundry/issues/10527
409
+ test_repro ! ( 10527 ) ;
Original file line number Diff line number Diff line change
1
+ // SPDX-License-Identifier: MIT OR Apache-2.0
2
+ pragma solidity ^ 0.8.18 ;
3
+
4
+ import "ds-test/test.sol " ;
5
+ import "cheats/Vm.sol " ;
6
+
7
+ contract A {
8
+ event Event1 ();
9
+ event Event2 ();
10
+
11
+ function foo () public {
12
+ emit Event1 ();
13
+ }
14
+
15
+ function bar () public {
16
+ emit Event2 ();
17
+ }
18
+ }
19
+
20
+ contract Issue10527Test is DSTest {
21
+ Vm constant vm = Vm (HEVM_ADDRESS);
22
+
23
+ A a;
24
+
25
+ function setUp () public {
26
+ a = new A ();
27
+ }
28
+
29
+ function test_foo_Event1 () public {
30
+ vm.expectEmit (address (a));
31
+ emit A.Event1 ();
32
+
33
+ a.foo ();
34
+ }
35
+
36
+ function test_foo_Event2 () public {
37
+ vm.expectEmit ({emitter: address (a), count: 0 });
38
+ emit A.Event2 ();
39
+
40
+ a.foo ();
41
+ }
42
+ }
You can’t perform that action at this time.
0 commit comments