feat(cheatcodes
): V1 expectRevert
behavior
#7238
Labels
A-cheatcodes
Area: cheatcodes
T-likely-breaking
Type: requires changes that can be breaking
T-to-discuss
Type: requires discussion
Motivation
expect*
cheatcodes are ALL intended to function only for the next call. That means, if the next call does not fulfill theexpect*
set up before making it, tests should fail. However, this is not the case forexpectRevert
works right now.See: #3723, #3437, #4832 .
expectRevert
, since inception, works differently from intended: it matches reverts at the test level, not at the next call level. This means that reverting cheatcodes were being incorrectly catched byexpectRevert
(we're supposed to bypass checks for cheatcode calls) and also led users to use cheatcode incorrectly as illustrated in #3723, sometimes becoming actual accepted foundry patterns. It also meant that, if used to catch any revert without matching revert data, any revert at any point in the test after theexpectRevert
cheatcode was used could make the test pass. This is especially dangerous as it can hide actual code failures from intended reverts.New behavior
expectRevert
now only works on the nextCALL
. Cheatcode calls are now ignored properly, even if those cheatcode calls revert. To illustrate, after introducing this new behavior, these are examples of now both passing and failing tests:The text was updated successfully, but these errors were encountered: