test for multiple error types on a function

Co-Authored-By: Eric Mastro <eric.mastro@gmail.com>
This commit is contained in:
Mark Spanbroek 2024-05-15 13:43:42 +02:00 committed by markspanbroek
parent 2da59a86c3
commit 17c6e9a8c5
2 changed files with 17 additions and 0 deletions

View File

@ -85,6 +85,16 @@ suite "Contract custom errors":
check error.arguments.one == ("1", 2.u256)
check error.arguments.two == (3.u256, 4.u256)
test "handles multiple error types":
proc revertsMultipleErrors(contract: TestCustomErrors, simple: bool)
{.contract, errors:[SimpleError, ErrorWithArguments].}
let contract = contract.connect(provider.getSigner())
expect SimpleError:
await contract.revertsMultipleErrors(simple = true)
expect ErrorWithArguments:
await contract.revertsMultipleErrors(simple = false)
test "handles gas estimation errors":
proc revertsTransaction(contract: TestCustomErrors)
{.contract, errors:[ErrorWithArguments].}

View File

@ -42,6 +42,13 @@ contract TestCustomErrors {
);
}
function revertsMultipleErrors(bool simple) public pure {
if (simple) {
revert SimpleError();
}
revert ErrorWithArguments(1, false);
}
string private state;
function revertsTransaction() public {