-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✨ Simplify possible errors, transaction error handler contains transa…
…ction error
- Loading branch information
Showing
9 changed files
with
76 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,38 @@ | ||
# Error Handler | ||
|
||
Trident allows you to specify custom error handler for each Instruction. | ||
Trident allows you to specify a custom error handler for each instruction. | ||
|
||
This can be particularly helpful: | ||
This can be particularly helpful in the following scenarios: | ||
|
||
- If Transaction returns Error, you can specify to omit this error and continue with the fuzzing instruction. | ||
- Using the `tx_error_handler` you can check if the error returned is desired based on the Accounts and Input data that were used. | ||
- If a transaction returns an error, you can choose to omit this error and continue the fuzzing process. | ||
- Using the `tx_error_handler`, you can check if the returned error is desired based on the accounts and input data that were used. | ||
|
||
!!! tip | ||
|
||
The default behavior of the function is that the error is returned. | ||
By default, transaction errors are propagated, meaning that if the transaction fails, the fuzzing iteration is stopped, and a new fuzzing iteration is started. | ||
|
||
```rust | ||
/// default implementation | ||
/// Default implementation | ||
fn tx_error_handler( | ||
&self, | ||
e: FuzzClientErrorWithOrigin, | ||
e: TransactionError, | ||
ix_data: Vec<u8>, | ||
pre_ix_acc_infos: &[SnapshotAccount], | ||
) -> Result<(), FuzzClientErrorWithOrigin> { | ||
) -> Result<(), TransactionError> { | ||
Err(e) | ||
} | ||
``` | ||
|
||
To omit the Error and continue with the next Instruction in the iteration, you can do | ||
To omit the error and continue with the next instruction in the iteration, you can use the following implementation: | ||
|
||
```rust | ||
/// custom implementation | ||
/// Custom implementation | ||
fn tx_error_handler( | ||
&self, | ||
e: FuzzClientErrorWithOrigin, | ||
e: TransactionError, | ||
ix_data: Vec<u8>, | ||
pre_ix_acc_infos: &[SnapshotAccount], | ||
) -> Result<(), FuzzClientErrorWithOrigin> { | ||
) -> Result<(), TransactionError> { | ||
Ok(()) | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters