crytic / crytic/slither

Foundry expectEmit detector

Open
#2,036 0 comments 0 reactions 0 assignees View on GitHub
enhancement new detector
Dominant language
Python
Stars
6.4k
Forks
1.1k
PR merge metrics
No merged PRs in 30d

Description

### Describe the desired feature

In foundry tests, the [expectEmit feature](https://book.getfoundry.sh/cheatcodes/expect-emit?highlight=expectEmit#expectemit) accepts multiple arguments including 4 booleans. It is easy to make a mistake. This detector will ensure that the arguments correctly match the event signature.

Example:

```
// event MyEvent(uint data, address indexed addr1, address indexed addr2, address indexed addr3);
vm.expectEmit(true, true, false, true);
emit MyEvent(1, addr1, addr2, addr3);
myContract.callFunctionThatEmitsMyEvent();
```

In the above example, the event signature shows 3 indexed params so there are three topics. There is also a non-indexed `data` param which goes into the event data.

However, the expectEmit will only check `addr1` and `addr2` since the 3rd parameter of expectEmit is set to false.

A slither detector could give a warning:
`expectEmit arguments do not match event signature`

cc: @montyly

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.