Skip to content

How does the testEnteringRaffleEmitsEvent function work? #3519

Answered by chainflash
nabil-ziani asked this question in Q&A
Discussion options

You must be logged in to vote

Bro

vm.expectEmit(true, false, false, false, address(raffle));

We write this part above because the expectEmit function is defined in this way:

function expectEmit(
  bool checkTopic1,
  bool checkTopic2,
  bool checkTopic3,
  bool checkData,
  address emitter
) external;

In fact, we are saying that we expect an event with these parameters to be emitted, but something is still missing.
We haven't specified the name and value of the event, so we need to add the following line as well :

emit RaffleEntered(PLAYER);

Here, we manually (mock) emit the event that we expect and event name and value are specified.
Think of it this way: it’s like saying, “Wait, an event is going to be emitted. O…

Replies: 1 comment 4 replies

Comment options

You must be logged in to vote
4 replies
@EngrPips
Comment options

@chainflash
Comment options

@nabil-ziani
Comment options

@chainflash
Comment options

Answer selected by nabil-ziani
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants