test for multiple error types on a function
Co-Authored-By: Eric Mastro <eric.mastro@gmail.com>
This commit is contained in:
parent
2da59a86c3
commit
17c6e9a8c5
|
@ -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].}
|
||||
|
|
|
@ -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 {
|
||||
|
|
Loading…
Reference in New Issue