Skip to content

Commit

Permalink
chore: add edge case covering #4920 (comment)
Browse files Browse the repository at this point in the history
  • Loading branch information
Evalir committed Jun 12, 2023
1 parent ec4106d commit b98c8ee
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions testdata/cheats/ExpectEmit.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,11 @@ contract Emitter {
this.emitWindow();
}

function emitWindowAndOnTest(ExpectEmitTest t) public {
this.emitWindow();
t.emitLocal();
}

/// Ref: issue #1214
function doesNothing() public pure {}

Expand Down Expand Up @@ -124,6 +129,10 @@ contract ExpectEmitTest is DSTest {
emitter = new Emitter();
}

function emitLocal() public {
emit A(1);
}

function testFailExpectEmitDanglingNoReference() public {
cheats.expectEmit(false, false, false, false);
}
Expand Down Expand Up @@ -549,6 +558,17 @@ contract ExpectEmitTest is DSTest {
emitter.emitWindow();
}

/// emitWindowAndOnTest emits [[A, B, C, D, E], [A]]. The interesting bit is that the
/// second call that emits [A] is on this same contract. We should still be able to match
/// [A, A] as the call made to this contract is still external.
function testEmitWindowAndOnTest() public {
cheats.expectEmit(true, false, false, true);
emit A(1);
cheats.expectEmit(true, false, false, true);
emit A(1);
emitter.emitWindowAndOnTest(this);
}

/// This test will fail if we check that all expected logs were emitted
/// after every call from the same depth as the call that invoked the cheatcode.
///
Expand Down

0 comments on commit b98c8ee

Please sign in to comment.