Skip to content

expectRevert with count = 0 swallows non-matching reverts #10858

@frangio

Description

@frangio

Is it expected that this test should pass?

function testShouldFailIfExpectRevertWrongString() public {
Reverter reverter = new Reverter();
vm.expectRevert("my not so cool error", 0);
reverter.revertWithMessage("my cool error");
}

Perhaps it was an error in #9574? It doesn't seem like the intention of the original test:

function testFailExpectRevertWrongString() public {
Reverter reverter = new Reverter();
vm.expectRevert("my not so cool error");
reverter.revertWithMessage("my cool error");
}

What seems to be happening is expectRevert with count = 0 allows non-matching reverts because it just checks the count of matching reverts. This was not intuitive to me.

Allowing count = 0 seems error prone, I'm not sure it would be legitimate in any context.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

Status

Completed

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions