test custom arguments when sending transaction

This commit is contained in:
Mark Spanbroek 2024-03-21 08:21:12 +01:00 committed by markspanbroek
parent 9cb033e865
commit a6f136afdd
2 changed files with 34 additions and 0 deletions

View File

@ -84,3 +84,30 @@ suite "Contract custom errors":
except ErrorWithDynamicAndStaticStruct as error:
check error.arguments.one == ("1", 2.u256)
check error.arguments.two == (3.u256, 4.u256)
test "handles gas estimation errors":
proc revertsTransaction(contract: TestCustomErrors)
{.contract, errors:[ErrorWithArguments].}
let contract = contract.connect(provider.getSigner())
try:
await contract.revertsTransaction()
fail()
except ErrorWithArguments as error:
check error.arguments.one == 1.u256
check error.arguments.two == true
test "handles transaction submission errors":
proc revertsTransaction(contract: TestCustomErrors)
{.contract, errors:[ErrorWithArguments].}
# skip gas estimation
let overrides = TransactionOverrides(gasLimit: some 1000000.u256)
let contract = contract.connect(provider.getSigner())
try:
await contract.revertsTransaction(overrides = overrides)
fail()
except ErrorWithArguments as error:
check error.arguments.one == 1.u256
check error.arguments.two == true

View File

@ -41,4 +41,11 @@ contract TestCustomErrors {
StaticStruct(3, 4)
);
}
string private state;
function revertsTransaction() public {
state = "updated state";
revert ErrorWithArguments(1, true);
}
}