# Table of Contents - [Trident Documentation - Trident](#trident-documentation-trident) - [Changelog - Trident](#changelog-trident) - [Commands - Trident](#commands-trident) - [FAQ - Trident](#faq-trident) - [Get Help - Trident](#get-help-trident) - [Installation - Trident](#installation-trident) - [Start Fuzzing - Trident](#start-fuzzing-trident) - [Executing the Fuzz Test - Trident](#executing-the-fuzz-test-trident) - [Writing fuzz test - Trident](#writing-fuzz-test-trident) - [Fuzzing Flows - Trident](#fuzzing-flows-trident) - [Instruction Accounts - Trident](#instruction-accounts-trident) - [Instruction Data - Trident](#instruction-data-trident) - [Remaining Accounts - Trident](#remaining-accounts-trident) - [Regression testing - Trident](#regression-testing-trident) - [Transaction Methods - Trident](#transaction-methods-trident) - [Transaction Error Hook - Trident](#transaction-error-hook-trident) - [Transaction Invariant Hook - Trident](#transaction-invariant-hook-trident) - [Multi-Instruction Transactions - Trident](#multi-instruction-transactions-trident) - [Pre and Post Transaction Hooks - Trident](#pre-and-post-transaction-hooks-trident) - [Trident API & Macro Reference - Trident](#trident-api-macro-reference-trident) - [Trident Advanced - Trident](#trident-advanced-trident) - [TridentAccount attributes - Trident](#tridentaccount-attributes-trident) - [Instruction Hooks - Trident](#instruction-hooks-trident) - [Typed Accounts - Trident](#typed-accounts-trident) - [Transaction Hooks - Trident](#transaction-hooks-trident) - [Trident - Trident](#trident-trident) - [Trident's Fuzz Client - Trident](#trident-s-fuzz-client-trident) - [TridentAccounts - Trident](#tridentaccounts-trident) - [TridentInstruction - Trident](#tridentinstruction-trident) - [TridentRemainingAccounts - Trident](#tridentremainingaccounts-trident) - [TridentTransaction - Trident](#tridenttransaction-trident) - [Custom types - Trident](#custom-types-trident) - [FuzzAccounts - Trident](#fuzzaccounts-trident) - [TridentAccount - Trident](#tridentaccount-trident) - [Trident examples - Trident](#trident-examples-trident) - [TridentPubkey - Trident](#tridentpubkey-trident) - [TridentSVM - Trident](#tridentsvm-trident) - [Flow Executor - Trident](#flow-executor-trident) - [Trident Manifest - Trident](#trident-manifest-trident) - [Code Coverage - Trident](#code-coverage-trident) - [Dashboard - Trident](#dashboard-trident) - [Trident](#trident) - [Trident Documentation - Trident](#trident-documentation-trident) - [Trident - Trident](#trident-trident) - [Trident Documentation - Trident](#trident-documentation-trident) - [Trident Documentation - Trident](#trident-documentation-trident) - [Trident](#trident) - [Trident - Trident](#trident-trident) - [Redirecting](#redirecting) - [Trident API & Macro Reference - Trident](#trident-api-macro-reference-trident) - [TridentSVM - Trident](#tridentsvm-trident) - [Trident examples - Trident](#trident-examples-trident) - [Start Fuzzing - Trident](#start-fuzzing-trident) - [Trident Advanced - Trident](#trident-advanced-trident) - [Trident Manifest - Trident](#trident-manifest-trident) - [Installation - Trident](#installation-trident) - [Installation - Trident](#installation-trident) - [Introduction - Trident](#introduction-trident) - [Commands - Trident](#commands-trident) - [Changelog - Trident](#changelog-trident) - [Changelog - Trident](#changelog-trident) - [Changelog - Trident](#changelog-trident) - [FAQ - Trident](#faq-trident) - [Installation - Trident](#installation-trident) - [Docker Image - Trident](#docker-image-trident) - [Run - Trident](#run-trident) - [Introduction - Trident](#introduction-trident) - [Start Fuzzing - Trident](#start-fuzzing-trident) - [Start Fuzzing - Trident](#start-fuzzing-trident) - [Examples - Trident](#examples-trident) - [Get Help - Trident](#get-help-trident) - [Trident Advanced - Trident](#trident-advanced-trident) - [Trident Advanced - Trident](#trident-advanced-trident) - [Run and Debug - Trident](#run-and-debug-trident) - [Fuzz Test Lifecycle - Trident](#fuzz-test-lifecycle-trident) - [Writing fuzz test - Trident](#writing-fuzz-test-trident) - [Current limitations - Trident](#current-limitations-trident) - [Fuzzing Examples - Trident](#fuzzing-examples-trident) - [Trident API & Macro Reference - Trident](#trident-api-macro-reference-trident) - [Trident API & Macro Reference - Trident](#trident-api-macro-reference-trident) - [Executing the Fuzz Test - Trident](#executing-the-fuzz-test-trident) - [Run - Trident](#run-trident) - [Introduction - Trident](#introduction-trident) - [Code Coverage - Trident](#code-coverage-trident) - [Examples - Trident](#examples-trident) - [Trident Manifest - Trident](#trident-manifest-trident) - [Trident Manifest - Trident](#trident-manifest-trident) - [TridentSVM - Trident](#tridentsvm-trident) - [Trident SVM - Trident](#trident-svm-trident) - [Installation - Trident](#installation-trident) - [Dashboard - Trident](#dashboard-trident) - [Trident examples - Trident](#trident-examples-trident) - [Trident Examples - Trident](#trident-examples-trident) - [Writing fuzz test - Trident](#writing-fuzz-test-trident) - [Regression testing - Trident](#regression-testing-trident) - [Installation - Trident](#installation-trident) - [Installation - Trident](#installation-trident) - [Commands - Trident](#commands-trident) - [Commands - Trident](#commands-trident) - [FAQ - Trident](#faq-trident) - [Get Help - Trident](#get-help-trident) - [Changelog - Trident](#changelog-trident) - [Commands - Trident](#commands-trident) - [FAQ - Trident](#faq-trident) - [Trident Features - Trident](#trident-features-trident) - [Get Help - Trident](#get-help-trident) - [Changelog - Trident](#changelog-trident) - [Trident by Examples - Trident](#trident-by-examples-trident) - [Writing fuzz test - Trident](#writing-fuzz-test-trident) - [Executing the Fuzz Test - Trident](#executing-the-fuzz-test-trident) - [Writing fuzz test - Trident](#writing-fuzz-test-trident) - [FAQ - Trident](#faq-trident) - [Executing the Fuzz Test - Trident](#executing-the-fuzz-test-trident) - [Code Coverage - Trident](#code-coverage-trident) - [Get Help - Trident](#get-help-trident) - [Trident's Fuzz Client - Trident](#trident-s-fuzz-client-trident) - [Dashboard - Trident](#dashboard-trident) - [Regression testing - Trident](#regression-testing-trident) - [Changelog - Trident](#changelog-trident) - [General Configuration - Trident](#general-configuration-trident) - [AFL Configuration - Trident](#afl-configuration-trident) - [Honggfuzz Configuration - Trident](#honggfuzz-configuration-trident) - [Fuzzing Statistics - Trident](#fuzzing-statistics-trident) - [Invariant Checks - Trident](#invariant-checks-trident) - [Instructions Sequences - Trident](#instructions-sequences-trident) - [Genesis - Trident](#genesis-trident) - [Error Handler - Trident](#error-handler-trident) - [Fuzz Instructions - Trident](#fuzz-instructions-trident) - [Current limitations - Trident](#current-limitations-trident) - [Get Help - Trident](#get-help-trident) - [Arbitrary Data - Trident](#arbitrary-data-trident) - [Trident by Examples - Trident](#trident-by-examples-trident) - [Commands - Trident](#commands-trident) - [Trident Manifest - Trident](#trident-manifest-trident) - [FAQ - Trident](#faq-trident) - [Writing fuzz test - Trident](#writing-fuzz-test-trident) - [Trident Features - Trident](#trident-features-trident) - [Account Storages - Trident](#account-storages-trident) - [Changelog - Trident](#changelog-trident) - [Instructions Sequences - Trident](#instructions-sequences-trident) - [Fuzzing Statistics - Trident](#fuzzing-statistics-trident) - [Invariant Checks - Trident](#invariant-checks-trident) - [Programs and Accounts - Trident](#programs-and-accounts-trident) - [Error Handler - Trident](#error-handler-trident) - [Account Storages - Trident](#account-storages-trident) - [Installation - Trident](#installation-trident) - [Current Limitations - Trident](#current-limitations-trident) - [Fuzz Instructions - Trident](#fuzz-instructions-trident) - [Customize Instruction Data - Trident](#customize-instruction-data-trident) - [Trident Manifest - Trident](#trident-manifest-trident) - [Fuzz Test Lifecycle - Trident](#fuzz-test-lifecycle-trident) - [Fuzz Test Lifecycle - Trident](#fuzz-test-lifecycle-trident) --- # Trident Documentation - Trident [Skip to content](https://ackee.xyz/trident/docs/latest/#trident-documentation) Trident Documentation[#](https://ackee.xyz/trident/docs/latest/#trident-documentation "Permanent link") ======================================================================================================== Fuzzing is a technique to test the robustness of a program by providing it with random inputs. Trident is a Manually Guided Fuzzing framework for Solana. It lets you to execute instructions of your Solana programs with random data and observe the changes in the state of the program. Getting started[#](https://ackee.xyz/trident/docs/latest/#getting-started "Permanent link") -------------------------------------------------------------------------------------------- * [Installation](https://ackee.xyz/trident/docs/latest/basics/installation/) - Install the Trident Fuzz Testing Framework * [Start Fuzzing](https://ackee.xyz/trident/docs/latest/start-fuzzing/) - Focus on security and start fuzzing immediately Advanced fuzzing customization[#](https://ackee.xyz/trident/docs/latest/#advanced-fuzzing-customization "Permanent link") -------------------------------------------------------------------------------------------------------------------------- Explore the various features Trident provides. * [Transaction Hooks](https://ackee.xyz/trident/docs/latest/trident-advanced/trident-transactions/transaction-hooks/) - Create and manipulate transactions with different methods * [Multi-Instruction Transactions](https://ackee.xyz/trident/docs/latest/trident-advanced/trident-transactions/multi-instruction-transactions/) - Compose fuzzed transactions with multiple instructions * [Trident Manifest](https://ackee.xyz/trident/docs/latest/trident-manifest/) - Customize your fuzz tests with different configurations * [Code Coverage](https://ackee.xyz/trident/docs/latest/trident-advanced/code-coverage/) - Track and display fuzz test code coverage * [Dashboard](https://ackee.xyz/trident/docs/latest/trident-advanced/dashboard/) - A web-based interface for visualizing fuzzing session results * [Regression Testing](https://ackee.xyz/trident/docs/latest/trident-advanced/regression/) - Track and compare fuzzing session results API & Macros Reference[#](https://ackee.xyz/trident/docs/latest/#api-macros-reference "Permanent link") -------------------------------------------------------------------------------------------------------- Check out the API and macro reference for Trident. * [Trident API & Macros](https://ackee.xyz/trident/docs/latest/trident-api-macro/) Trident Examples[#](https://ackee.xyz/trident/docs/latest/#trident-examples "Permanent link") ---------------------------------------------------------------------------------------------- Check out examples to learn how to use Trident. * [Trident Examples](https://ackee.xyz/trident/docs/latest/trident-examples/trident-examples/) TridentSVM[#](https://ackee.xyz/trident/docs/latest/#tridentsvm "Permanent link") ---------------------------------------------------------------------------------- Check out the TridentSVM, lightweight fuzzing execution and account storage environment. * [TridentSVM](https://ackee.xyz/trident/docs/latest/trident-svm/) What is Fuzzing ?[#](https://ackee.xyz/trident/docs/latest/#what-is-fuzzing "Permanent link") ---------------------------------------------------------------------------------------------- _"Fuzz testing is an automated technique that provides generated random, invalid, or unexpected input data to your program. This helps discover unknown bugs and vulnerabilities, potentially preventing zero-day exploits."_ \--:--\--:-- Back to top --- # Changelog - Trident [Skip to content](https://ackee.xyz/trident/docs/latest/basics/CHANGELOG/#changelog) Changelog[#](https://ackee.xyz/trident/docs/latest/basics/CHANGELOG/#changelog "Permanent link") ================================================================================================= All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) , and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html) (SemVer). **Note**: Version 0 of Semantic Versioning is handled differently from version 1 and above. The minor version will be incremented upon a breaking change and the patch version will be incremented for features. \[dev\] - Unreleased[#](https://ackee.xyz/trident/docs/latest/basics/CHANGELOG/#dev-unreleased "Permanent link") ----------------------------------------------------------------------------------------------------------------- **Added** **Removed** **Changed** \[0.11.1\] - 2025-10-21[#](https://ackee.xyz/trident/docs/latest/basics/CHANGELOG/#0111-2025-10-21 "Permanent link") --------------------------------------------------------------------------------------------------------------------- **Added** **Removed** * Removed lld linker ([394](https://github.com/Ackee-Blockchain/trident/pull/394) ) **Changed** \[0.11.0\] - 2025-08-14[#](https://ackee.xyz/trident/docs/latest/basics/CHANGELOG/#0110-2025-08-14 "Permanent link") --------------------------------------------------------------------------------------------------------------------- **Added** * Add server for displaying content of fuzzing artifacts ([347](https://github.com/Ackee-Blockchain/trident/pull/347) ) * Add fuzz artifacts directory to the fuzz test folder ([343](https://github.com/Ackee-Blockchain/trident/pull/343) ) * Added state monitoring support for fuzzing metrics ([341](https://github.com/Ackee-Blockchain/trident/pull/341) ) * Added dashboard support for fuzzing metrics ([340](https://github.com/Ackee-Blockchain/trident/pull/340) ) * Code coverage tracking support enabled and configured via Trident.toml. Coverage data can be visualized using the VS Code extension [330](https://github.com/Ackee-Blockchain/trident/pull/330) * Added features to enable syscalls in fuzzing ([329](https://github.com/Ackee-Blockchain/trident/pull/329) ) * Add `--skip-build` flag to only initialize fuzz test without building the project ([325](https://github.com/Ackee-Blockchain/trident/pull/325) ) * Add support for space, lamports and owner to TridentAccounts macro ([320](https://github.com/Ackee-Blockchain/trident/pull/320) ) **Removed** **Changed** * FuzzTest fields are now aggregated into Trident struct ([339](https://github.com/Ackee-Blockchain/trident/pull/339) ) * Add support for reproducible fuzzing with thread-specific seeds ([332](https://github.com/Ackee-Blockchain/trident/pull/332) ) * Move Trident.toml into trident-tests folder ([328](https://github.com/Ackee-Blockchain/trident/pull/328) ) * Conversion from AFL and Honggfuzz into Manually Guided Fuzzing ([324](https://github.com/Ackee-Blockchain/trident/pull/324) ) * Update template generation to use tera ([326](https://github.com/Ackee-Blockchain/trident/pull/326) ) \[0.10.0\] - 2025-03-13[#](https://ackee.xyz/trident/docs/latest/basics/CHANGELOG/#0100-2025-03-13 "Permanent link") --------------------------------------------------------------------------------------------------------------------- **Added** * TransactionSelector allows to select and execute random transaction with hooks and without hooks ([297](https://github.com/Ackee-Blockchain/trident/pull/297) ) * Added "random\_tail" attribute to TridentFlowExecutor macro to allow random tail generation ([296](https://github.com/Ackee-Blockchain/trident/pull/296) ) * Added support for seeds constraint for accounts structs ([284](https://github.com/Ackee-Blockchain/trident/pull/284) ) * Additional methods accessing the AccountsStorage and creating corresponding accounts are now optional ("token","vote", "stake") ([279](https://github.com/Ackee-Blockchain/trident/pull/279) ) * Derive macros now use own syn parser for better extensibility and UX ([275](https://github.com/Ackee-Blockchain/trident/pull/275) ) * Program ID inside test\_fuzz.rs file is now automatically filled in is present in the program IDL ([272](https://github.com/Ackee-Blockchain/trident/pull/272) ) * Added additional attributes to TridentAccounts, mut and signer ([268](https://github.com/Ackee-Blockchain/trident/pull/268) ) * Users can now specify a program for which they want to add or initialize a fuzz test using `--program-name` flag ([273](https://github.com/Ackee-Blockchain/trident/pull/273) ) * Allow custom test name specification in fuzz test creation with `--test-name` flag ([274](https://github.com/Ackee-Blockchain/trident/pull/274) ) **Removed** * The DisplayIx macro is now removed, Debug trait was implemented for instruction inputs ([281](https://github.com/Ackee-Blockchain/trident/pull/281) ) **Changed** * FuzzTestExecutor and FlowExecutor are grouped together and FuzzTest has client as generic instead of TridentSVM ([294](https://github.com/Ackee-Blockchain/trident/pull/294) ) * Changed Transaction sequence logic ([289](https://github.com/Ackee-Blockchain/trident/pull/289) ) * AccountsStorages are simplified, no types are required to define ([276](https://github.com/Ackee-Blockchain/trident/pull/276) ) * Trident Architecture changes containing multiple features and improvements (details in the PR)([267](https://github.com/Ackee-Blockchain/trident/pull/267) ) * get or create token account methods fixed for native token accounts ([262](https://github.com/Ackee-Blockchain/trident/pull/262) ) \[0.9.1\] - 2025-02-03[#](https://ackee.xyz/trident/docs/latest/basics/CHANGELOG/#091-2025-02-03 "Permanent link") ------------------------------------------------------------------------------------------------------------------- **Added** * added warp to time manipulation ([259](https://github.com/Ackee-Blockchain/trident/pull/259) ) * added methods to check if account storage is empty ([258](https://github.com/Ackee-Blockchain/trident/pull/258) ) * added support for post-instruction behavior ([257](https://github.com/Ackee-Blockchain/trident/pull/257) ) **Removed** **Changed** \[0.9.0\] - 2025-01-15[#](https://ackee.xyz/trident/docs/latest/basics/CHANGELOG/#090-2025-01-15 "Permanent link") ------------------------------------------------------------------------------------------------------------------- **Added** * added support for composite accounts ([245](https://github.com/Ackee-Blockchain/trident/pull/245) ) * Trident SVM + AFL (see the PR for more details) ([234](https://github.com/Ackee-Blockchain/trident/pull/234) ) **Removed** * removed fuzz\_iteration from test\_fuzz.rs ([243](https://github.com/Ackee-Blockchain/trident/pull/243) ) **Changed** * renamed Config to TridentConfig ([246](https://github.com/Ackee-Blockchain/trident/pull/246) ) * errors are simplified and transaction error contains only transaction error ([244](https://github.com/Ackee-Blockchain/trident/pull/244) ) \[0.8.1\] - 2024-11-14[#](https://ackee.xyz/trident/docs/latest/basics/CHANGELOG/#081-2024-11-14 "Permanent link") ------------------------------------------------------------------------------------------------------------------- **Removed** * removed unnecessary deserialization with AccountsSnapshots, to deserialize data implementation AccountDeserialize can be used ([221](https://github.com/Ackee-Blockchain/trident/pull/221) ) **Changed** * improve AccountsStorage module structure and remove unnecessary methods in FuzzClient ([223](https://github.com/Ackee-Blockchain/trident/pull/223) ) * improve manipulations with AccountsStorages in get\_accounts() function ([219](https://github.com/Ackee-Blockchain/trident/pull/219) ) **Added** * add pre\_sequence!, middle\_sequence! and post\_sequence! for easier sequence definition ([220](https://github.com/Ackee-Blockchain/trident/pull/220) ) * add/ add support for Clock sysvar manipulations with the client(i.e. warp to slot/epoch and forward in time) ([217](https://github.com/Ackee-Blockchain/trident/pull/217) ) \[0.8.0\] - 2024-10-21[#](https://ackee.xyz/trident/docs/latest/basics/CHANGELOG/#080-2024-10-21 "Permanent link") ------------------------------------------------------------------------------------------------------------------- **Added** * impr/ allow to specify programs and accounts in the Trident Manifest ([207](https://github.com/Ackee-Blockchain/trident/pull/207) ) * impr/ added get\_program\_id function to the IxOps and FuzzTestExecutor ([199](https://github.com/Ackee-Blockchain/trident/pull/199) ) **Changed** * impr/ improve init command, modify program manifest automatically, add init force, add howto subcommand ([208](https://github.com/Ackee-Blockchain/trident/pull/208) ) * impr/ allow to derive AccountsSnapshots for empty Account Context ([209](https://github.com/Ackee-Blockchain/trident/pull/209) ) * impr/ fuzz flags are read at start of fuzzing session from Config instead of env variable and transaction dispatch was added to increase FuzzTestExecutor readability ([204](https://github.com/Ackee-Blockchain/trident/pull/204) ) * impr/ allow various instructions to be generated in case of multiple programs in the Anchor workspace ([200](https://github.com/Ackee-Blockchain/trident/pull/200) ) * feat/ option to add account into Fuzz Test environment with base64 data ([197](https://github.com/Ackee-Blockchain/trident/pull/197) ) * impr/ instead of parsing source code and creating our IDL, read anchor IDL ([198](https://github.com/Ackee-Blockchain/trident/pull/196) ) **Removed** * del/remove integration tests supported by Trident, this feature adds more unnecessary overhead compared to its value ([196](https://github.com/Ackee-Blockchain/trident/pull/198) ) \[0.7.0\] - 2024-08-14[#](https://ackee.xyz/trident/docs/latest/basics/CHANGELOG/#070-2024-08-14 "Permanent link") ------------------------------------------------------------------------------------------------------------------- **Added** * impr/ add feature flag to the AccountsSnapshots macro ([183](https://github.com/Ackee-Blockchain/trident/pull/183) ) * feat/ add Support for CPI ([182](https://github.com/Ackee-Blockchain/trident/pull/182) ) * feat/ add option to initialize Trident with Macro/File (for Snapshots) option based on preference ([179](https://github.com/Ackee-Blockchain/trident/pull/179) ) * feat/create AccountsSnapshots derive macro for Snapshots creation ([#177](https://github.com/Ackee-Blockchain/trident/pull/177) ) * feat/fuzzing moved to separate crate trident-fuzz ([#175](https://github.com/Ackee-Blockchain/trident/pull/175) ) * feat/unify dependencies provided by the Trident ([#172](https://github.com/Ackee-Blockchain/trident/pull/172) ) * feat/fuzzer-stats-logging, an optional statistics output for fuzzing session ([#144](https://github.com/Ackee-Blockchain/trident/pull/144) ) **Fixed** * fix/in case of fuzzing failure throw error instead of only printing message ([#167](https://github.com/Ackee-Blockchain/trident/pull/167) ) * fix/snapshot's zeroed account as optional ([#170](https://github.com/Ackee-Blockchain/trident/pull/170) ) **Removed** * del/remove localnet subcommand ([178](https://github.com/Ackee-Blockchain/trident/pull/178) ) * del/remove unnecessary fuzzing feature as trident is mainly fuzzer ([#176](https://github.com/Ackee-Blockchain/trident/pull/176) ) * del/remove Trident explorer ([#171](https://github.com/Ackee-Blockchain/trident/pull/171) ) \[0.6.0\] - 2024-05-20[#](https://ackee.xyz/trident/docs/latest/basics/CHANGELOG/#060-2024-05-20 "Permanent link") ------------------------------------------------------------------------------------------------------------------- **Added** * feat/anchor 0.30.0 support ([#148](https://github.com/Ackee-Blockchain/trident/pull/148) ) * fix/allow to process duplicate transactions ([#147](https://github.com/Ackee-Blockchain/trident/pull/147) ) * feat/possibility to implement custom transaction error handling ([#145](https://github.com/Ackee-Blockchain/trident/pull/145) ) * feat/support of automatically obtaining fully qualified paths of Data Accounts Custom types for `accounts_snapshots.rs` ([#141](https://github.com/Ackee-Blockchain/trident/pull/141) ) * feat/allow direct accounts manipulation and storage ([#142](https://github.com/Ackee-Blockchain/trident/pull/142) ) * feat/support of non-corresponding instruction and context names ([#130](https://github.com/Ackee-Blockchain/trident/pull/130) ) * feat/refactored and improved program flow during init and build, added activity indicator ([#129](https://github.com/Ackee-Blockchain/trident/pull/129) ) * feat/allow solana versions up to v1.17.\* and pin Rust 1.77 nightly compiler ([#128](https://github.com/Ackee-Blockchain/trident/pull/128) ) * feat/new init command option to initialize fuzz or poc tests only ([#124](https://github.com/Ackee-Blockchain/trident/pull/124) ) * feat/debug-mode detailed output ([#125](https://github.com/Ackee-Blockchain/trident/pull/125) ) * feat/anchor 0.29.0 support ([#121](https://github.com/Ackee-Blockchain/trident/pull/121) ) * doc/add help comment + update documentation ([#120](https://github.com/Ackee-Blockchain/trident/pull/120) ) * feat/fuzzer error handling ([#118](https://github.com/Ackee-Blockchain/trident/pull/118) ) * feat/convert fuzz Pubkey to AccountId ([#116](https://github.com/Ackee-Blockchain/trident/pull/116) ) * feat/additional anchor types ([#115](https://github.com/Ackee-Blockchain/trident/pull/115) ) * feat/import ToAccountInfo trait in fuzzing prelude ([#113](https://github.com/Ackee-Blockchain/trident/pull/113) ) * test/added code generation and macros tests ([#112](https://github.com/Ackee-Blockchain/trident/pull/112) ) * feat/fuzzer framework core, macros, helpers, templates, and examples. ([#111](https://github.com/Ackee-Blockchain/trident/pull/111) ) * feat/improved trident-tests folder structure for PoC and Fuzz Tests ([#109](https://github.com/Ackee-Blockchain/trident/pull/109) ) * feat/support for additional fuzzer parameters in Trident.toml config file ([#107](https://github.com/Ackee-Blockchain/trident/pull/107) ) * feat/possibility to pass params to the fuzzer via Trident.toml config file ([#106](https://github.com/Ackee-Blockchain/trident/pull/106) ) * feat/client now reads by default keypair from default location ([#105](https://github.com/Ackee-Blockchain/trident/pull/105) ) * feat/added new --exit-code option to return corresponding exit code based on fuzz test result ([#104](https://github.com/Ackee-Blockchain/trident/pull/104) ) * feat/removed/updated deprecated functions, removed allow deprecated macros ([#103](https://github.com/Ackee-Blockchain/trident/pull/103) ) * feat/added new function to read keypair file generated by Anchor ([#102](https://github.com/Ackee-Blockchain/trident/pull/102) ) * feat/clean command ([#101](https://github.com/Ackee-Blockchain/trident/pull/101) ) * feat/improved program\_client generated code ([#100](https://github.com/Ackee-Blockchain/trident/pull/100) ) * feat/automatically add hfuzz\_target to .gitignore file ([#99](https://github.com/Ackee-Blockchain/trident/pull/99) ) * feat/support for dynamic templates. ([#98](https://github.com/Ackee-Blockchain/trident/pull/98) ) **Fixed** * fix/refactored fuzz test executor error handling ([#127](https://github.com/Ackee-Blockchain/trident/pull/127) ) * fix/warn user on composite accounts and continue fuzz test generation ([#133](https://github.com/Ackee-Blockchain/trident/pull/133) ) * fix/progress bar loop lock release ([#132](https://github.com/Ackee-Blockchain/trident/pull/132) ) * fix/fixed fuzz test generation with init-if-needed Anchor feature ([#131](https://github.com/Ackee-Blockchain/trident/pull/131) ) * fix/program client custom types ([#117](https://github.com/Ackee-Blockchain/trident/pull/117) ) * fix/check fuzz test name collision by checking the name against HashSet ([#114](https://github.com/Ackee-Blockchain/trident/pull/114) ) \[0.5.0\] - 2023-08-28[#](https://ackee.xyz/trident/docs/latest/basics/CHANGELOG/#050-2023-08-28 "Permanent link") ------------------------------------------------------------------------------------------------------------------- **Added** * cli: Added trident subcommand `fuzz` to run and debug fuzz tests using honggfuzz-rs. * cli: Added trident `--skip-fuzzer` option for `init` subcommand to skip generation of fuzz test templates. * client: Added new Cargo feature `fuzzing` that enables optional dependencies related to fuzz testing. \[0.4.1\] - 2023-08-21[#](https://ackee.xyz/trident/docs/latest/basics/CHANGELOG/#041-2023-08-21 "Permanent link") ------------------------------------------------------------------------------------------------------------------- **Changed** * Upgrade Solana (`=1.16.6`) and Anchor framework (`=0.28.0`) versions. **Fixed** * Implemented Anchor Client logic was not able to work with newer version of Anchor. Fixed with `async_rpc` and `async` feature. * Trident init IDL Parse Error on newer version of Rust, fixed with updated `accounts` token. \[0.3.0\] - 2022-09-23[#](https://ackee.xyz/trident/docs/latest/basics/CHANGELOG/#030-2022-09-23 "Permanent link") ------------------------------------------------------------------------------------------------------------------- **Changed** * Upgrade Solana (`~1.10`) and Anchor framework (`~0.25`) versions **Added** * Custom Solana RPC error reporter. If the Solana RPC error is thrown, the error code, message and data (logs) are reported to the output. * Custom imports in the `.program_client`. User is able to import custom types and structures into program client. The import part of the code would not be re-generated. \[0.2.0\] - 2022-07-27[#](https://ackee.xyz/trident/docs/latest/basics/CHANGELOG/#020-2022-07-27 "Permanent link") ------------------------------------------------------------------------------------------------------------------- **Added** * Trident is now configurable. This requires `Trident.toml` file to exist in the project's root directory - without this file the execution will fail. To solve this re-run `trident init` or just create an empty `Trident.toml` file in the project's root directory. Back to top --- # Commands - Trident [Skip to content](https://ackee.xyz/trident/docs/latest/basics/commands/#commands) Commands[#](https://ackee.xyz/trident/docs/latest/basics/commands/#commands "Permanent link") ============================================================================================== Trident CLI supports the following commands: `trident init`[#](https://ackee.xyz/trident/docs/latest/basics/commands/#trident-init "Permanent link") -------------------------------------------------------------------------------------------------------- Initializes Trident Workspace and generates new Fuzz Test Template. Creates the following structure: `[](https://ackee.xyz/trident/docs/latest/basics/commands/#__codelineno-0-1) project-root [](https://ackee.xyz/trident/docs/latest/basics/commands/#__codelineno-0-2) ├── trident-tests [](https://ackee.xyz/trident/docs/latest/basics/commands/#__codelineno-0-3) │ ├── fuzz_0 # particular fuzz test [](https://ackee.xyz/trident/docs/latest/basics/commands/#__codelineno-0-4) │ │ ├── instructions # instructions folder [](https://ackee.xyz/trident/docs/latest/basics/commands/#__codelineno-0-5) │ │ ├── transactions # transactions folder [](https://ackee.xyz/trident/docs/latest/basics/commands/#__codelineno-0-6) │ │ ├── test_fuzz.rs # the binary target of your fuzz test [](https://ackee.xyz/trident/docs/latest/basics/commands/#__codelineno-0-7) │ │ ├── types.rs # the types of your fuzz test [](https://ackee.xyz/trident/docs/latest/basics/commands/#__codelineno-0-8) │ │ └── fuzz_instructions.rs # the definition of your fuzz test [](https://ackee.xyz/trident/docs/latest/basics/commands/#__codelineno-0-9) │ ├── fuzz_1 [](https://ackee.xyz/trident/docs/latest/basics/commands/#__codelineno-0-10) │ ├── fuzz_X # possible multiple fuzz tests [](https://ackee.xyz/trident/docs/latest/basics/commands/#__codelineno-0-11) │ ├── fuzzing # compilations and crashes folder [](https://ackee.xyz/trident/docs/latest/basics/commands/#__codelineno-0-12) │ ├── Cargo.toml [](https://ackee.xyz/trident/docs/latest/basics/commands/#__codelineno-0-13) │ └── Trident.toml # Configuration file located in trident-tests directory [](https://ackee.xyz/trident/docs/latest/basics/commands/#__codelineno-0-14) └── ...` #### Options[#](https://ackee.xyz/trident/docs/latest/basics/commands/#options "Permanent link") * `-f, --force` - Force Trident initialization. Trident dependencies will be updated based on the version of Trident CLI. * `-s, --skip-build` - Skip building the program before initializing Trident. * `-p, --program-name ` - Specify the name of the program for which fuzz test will be generated. * `-t, --test-name ` - Name of the fuzz test to initialize. * * * `trident how`[#](https://ackee.xyz/trident/docs/latest/basics/commands/#trident-how "Permanent link") ------------------------------------------------------------------------------------------------------ Show the HowTo message about writing fuzz tests. * * * `trident fuzz`[#](https://ackee.xyz/trident/docs/latest/basics/commands/#trident-fuzz "Permanent link") -------------------------------------------------------------------------------------------------------- Run fuzz subcommands. With fuzz subcommands you can add new fuzz test template or you can run fuzz test on already initialized one. **Examples:** `[](https://ackee.xyz/trident/docs/latest/basics/commands/#__codelineno-1-1) trident fuzz add [](https://ackee.xyz/trident/docs/latest/basics/commands/#__codelineno-1-2) trident fuzz run fuzz_0 [](https://ackee.xyz/trident/docs/latest/basics/commands/#__codelineno-1-3) trident fuzz debug ` ### `trident fuzz add`[#](https://ackee.xyz/trident/docs/latest/basics/commands/#trident-fuzz-add "Permanent link") Generate new Fuzz Test template. #### Options[#](https://ackee.xyz/trident/docs/latest/basics/commands/#options_1 "Permanent link") * `-p, --program-name ` - Specify the name of the program for which the fuzz test will be generated. * `-t, --test-name ` - Name of the fuzz test to add. * `-s, --skip-build` - Skip building the program before adding new fuzz test. * * * ### `trident fuzz run `[#](https://ackee.xyz/trident/docs/latest/basics/commands/#trident-fuzz-run-fuzz_target "Permanent link") Directory Note Execute fuzz tests from the `trident-tests` directory. Solana Logs In case you want to see the logs of the fuzzed transactions, prefix the command with `TRIDENT_LOG=1`. `[](https://ackee.xyz/trident/docs/latest/basics/commands/#__codelineno-2-1) TRIDENT_LOG=1 trident fuzz run ` Runs the specified Fuzz Target using Trident's Manually Guided Fuzzing (e.g., fuzz\_0). #### Arguments[#](https://ackee.xyz/trident/docs/latest/basics/commands/#arguments "Permanent link") * `` - Name of the desired fuzz template to execute (for example fuzz\_0). * `[seed]` - Master seed used for fuzzing, if not provided it will be generated randomly. #### Options[#](https://ackee.xyz/trident/docs/latest/basics/commands/#options_2 "Permanent link") * `-w, --with-exit-code` - Run the fuzzing with exit code, i.e. if it discovers crash the Trident will exit with exit code 1. * * * ### `trident fuzz debug `[#](https://ackee.xyz/trident/docs/latest/basics/commands/#trident-fuzz-debug-fuzz_target-seed "Permanent link") Debug crashes by analyzing specific crash files using the provided seed. #### Arguments[#](https://ackee.xyz/trident/docs/latest/basics/commands/#arguments_1 "Permanent link") * `` - Name of the desired fuzz template to execute (for example fuzz\_0). * `` - Master seed of the desired fuzz template to execute. Debug Output The debug output includes: 1. Transaction logs 2. Instruction data structures 3. Panic/Crash information * * * `trident clean`[#](https://ackee.xyz/trident/docs/latest/basics/commands/#trident-clean "Permanent link") ---------------------------------------------------------------------------------------------------------- Clean build target, additionally perform `anchor clean`. * * * `trident server`[#](https://ackee.xyz/trident/docs/latest/basics/commands/#trident-server "Permanent link") ------------------------------------------------------------------------------------------------------------ Starts the Trident Server, in order to make it easier to visualize the fuzzing dashboard, more info in the [dashboard](https://ackee.xyz/trident/docs/latest/trident-advanced/dashboard/) section. * * * `trident compare`[#](https://ackee.xyz/trident/docs/latest/basics/commands/#trident-compare "Permanent link") -------------------------------------------------------------------------------------------------------------- Allows you to compare two fuzzing regression results. More info in the [regression](https://ackee.xyz/trident/docs/latest/trident-advanced/regression/) section. * * * Back to top --- # FAQ - Trident [Skip to content](https://ackee.xyz/trident/docs/latest/basics/faq/#faq) FAQ[#](https://ackee.xyz/trident/docs/latest/basics/faq/#faq "Permanent link") =============================================================================== _Is Trident supported only with Anchor?_ * Currently yes, Trident under the hood obtains data from the IDL generated by Anchor. _I created the Fuzz Test, what should I do next?_ * Start here [Start Fuzzing](https://ackee.xyz/trident/docs/latest/start-fuzzing/) . _Is Trident open-source?_ * Yes, here [Trident](https://github.com/Ackee-Blockchain/trident) . _I would like to report an Issue with Trident, what should I do?_ * Create [issue](https://github.com/Ackee-Blockchain/trident/issues) . _Is Trident deployed on Mainnet / Devnet / Testnet?_ * No, Trident is Fuzz Testing Framework, not Solana Program. _What type of Fuzzer is Trident?_ * Currently, we refer to it as _"coverage guided gray box fuzzer"_. Back to top --- # Get Help - Trident [Skip to content](https://ackee.xyz/trident/docs/latest/basics/get-help/#get-help) Get Help[#](https://ackee.xyz/trident/docs/latest/basics/get-help/#get-help "Permanent link") ============================================================================================== Need help writing Fuzz Tests? Do not hesitate to join our [Discord server](https://discord.gg/3czRpmGmeC) ! Back to top --- # Installation - Trident [Skip to content](https://ackee.xyz/trident/docs/latest/basics/installation/#installation) Installation[#](https://ackee.xyz/trident/docs/latest/basics/installation/#installation "Permanent link") ========================================================================================================== Trident requires the following prerequisites: Prerequisites Before proceeding, ensure you have installed: * [Rust](https://www.rust-lang.org/tools/install) (stable version) * [Solana CLI](https://solana.com/docs/intro/installation) * [Anchor](https://www.anchor-lang.com/docs/installation) Check out [supported versions](https://ackee.xyz/trident/docs/latest/basics/installation/#supported-versions) for version compatibility. Install Trident[#](https://ackee.xyz/trident/docs/latest/basics/installation/#install-trident "Permanent link") ---------------------------------------------------------------------------------------------------------------- `[](https://ackee.xyz/trident/docs/latest/basics/installation/#__codelineno-0-1) cargo install trident-cli` You can also use the `version` flag to install a specific version: `[](https://ackee.xyz/trident/docs/latest/basics/installation/#__codelineno-1-1) cargo install trident-cli --version x.y.z` Install cargo-llvm-cov[#](https://ackee.xyz/trident/docs/latest/basics/installation/#install-cargo-llvm-cov "Permanent link") ------------------------------------------------------------------------------------------------------------------------------ To enable code coverage tracking during fuzzing, install [cargo-llvm-cov](https://github.com/taiki-e/cargo-llvm-cov) : `[](https://ackee.xyz/trident/docs/latest/basics/installation/#__codelineno-2-1) cargo +stable install cargo-llvm-cov --locked` Supported versions[#](https://ackee.xyz/trident/docs/latest/basics/installation/#supported-versions "Permanent link") ---------------------------------------------------------------------------------------------------------------------- Version Table Legend * \= Develop branch * \= Released version * `-` = Not required/supported | **Version Type** | **Anchor** | **Solana** | **Rust** | **Honggfuzz** | **AFL** | | --- | --- | --- | --- | --- | --- | | Development | `>=0.29.0` | `>=1.17.3` | `1.86` | `-` | `-` | | **Current (0.11.x)** | `>=0.29.0` | `>=1.17.3` | `1.86` | `-` | `-` | | **0.10.x** | `>=0.29.0 < 0.31.0` | `>=1.17.3 < 2.1` | `nightly` | `0.5.56` | `0.15.11` | | **0.9.x** | `>=0.29.0 < 0.31.0` | `>=1.17.3 < 2.1` | `nightly` | `0.5.56` | `0.15.11` | | **0.8.x** | `0.30.1` | `^1.17.4` | `nightly` | `0.5.56` | `-` | | **0.7.x** | `>=0.29.*` | `^1.17.4` | `nightly` | `0.5.56` | `-` | | **0.6.x** | `>=0.29.*` | `^1.17` | `nightly` | `0.5.55` | `-` | | **0.5.x** | `~0.28.*` | `=1.16.6` | `-` | `-` | `-` | | **0.4.x** | `~0.27.*` | `>=1.15` | `-` | `-` | `-` | | **0.3.x** | `~0.25.*` | `>=1.10` | `-` | `-` | `-` | | **0.2.x** | `~0.24.*` | `>=1.9` | `-` | `-` | `-` | Back to top --- # Start Fuzzing - Trident [Skip to content](https://ackee.xyz/trident/docs/latest/start-fuzzing/#start-fuzzing) Start Fuzzing[#](https://ackee.xyz/trident/docs/latest/start-fuzzing/#start-fuzzing "Permanent link") ====================================================================================================== To start writing fuzz tests, you need to initialize Trident in your Anchor-based workspace. `[](https://ackee.xyz/trident/docs/latest/start-fuzzing/#__codelineno-0-1) trident init` If you have already initialized Trident, you can add a new fuzz test using: `[](https://ackee.xyz/trident/docs/latest/start-fuzzing/#__codelineno-1-1) trident fuzz add` Trident creates a new fuzz test template in the `trident-tests` directory, with the following structure: `[](https://ackee.xyz/trident/docs/latest/start-fuzzing/#__codelineno-2-1) project-root [](https://ackee.xyz/trident/docs/latest/start-fuzzing/#__codelineno-2-2) ├── trident-tests [](https://ackee.xyz/trident/docs/latest/start-fuzzing/#__codelineno-2-3) │ ├── fuzz_0 # particular fuzz test [](https://ackee.xyz/trident/docs/latest/start-fuzzing/#__codelineno-2-4) │ │ ├── instructions # instructions folder [](https://ackee.xyz/trident/docs/latest/start-fuzzing/#__codelineno-2-5) │ │ ├── transactions # transactions folder [](https://ackee.xyz/trident/docs/latest/start-fuzzing/#__codelineno-2-6) │ │ ├── test_fuzz.rs # the binary target of your fuzz test [](https://ackee.xyz/trident/docs/latest/start-fuzzing/#__codelineno-2-7) │ │ ├── types.rs # the types of your fuzz test [](https://ackee.xyz/trident/docs/latest/start-fuzzing/#__codelineno-2-8) │ │ └── fuzz_instructions.rs # the definition of your fuzz test [](https://ackee.xyz/trident/docs/latest/start-fuzzing/#__codelineno-2-9) │ ├── fuzz_1 [](https://ackee.xyz/trident/docs/latest/start-fuzzing/#__codelineno-2-10) │ ├── fuzz_X # possible multiple fuzz tests [](https://ackee.xyz/trident/docs/latest/start-fuzzing/#__codelineno-2-11) │ ├── fuzzing # compilations and crashes folder [](https://ackee.xyz/trident/docs/latest/start-fuzzing/#__codelineno-2-12) │ ├── Cargo.toml [](https://ackee.xyz/trident/docs/latest/start-fuzzing/#__codelineno-2-13) │ └── Trident.toml [](https://ackee.xyz/trident/docs/latest/start-fuzzing/#__codelineno-2-14) └── ...` `Instructions` folder contains the `instructions` that can be used in the fuzz test. `Transactions` folder contains the `transactions` that will be used during the fuzzing, each transaction can contain `one` or `multiple instructions`, based on the developer's choice. By default there is only one instruction in each transaction. Back to top --- # Executing the Fuzz Test - Trident [Skip to content](https://ackee.xyz/trident/docs/latest/start-fuzzing/executing-fuzz-test/#executing-the-fuzz-test) Executing the Fuzz Test[#](https://ackee.xyz/trident/docs/latest/start-fuzzing/executing-fuzz-test/#executing-the-fuzz-test "Permanent link") ============================================================================================================================================== To execute the fuzz test, navigate to the `trident-tests` directory and run the following command to execute the fuzz test: `[](https://ackee.xyz/trident/docs/latest/start-fuzzing/executing-fuzz-test/#__codelineno-0-1) trident fuzz run [](https://ackee.xyz/trident/docs/latest/start-fuzzing/executing-fuzz-test/#__codelineno-0-2) # for example: [](https://ackee.xyz/trident/docs/latest/start-fuzzing/executing-fuzz-test/#__codelineno-0-3) # trident fuzz run fuzz_0 [](https://ackee.xyz/trident/docs/latest/start-fuzzing/executing-fuzz-test/#__codelineno-0-4) # seed is optional, if not provided, a random seed will be used` Directory Note Execute fuzz tests from the `trident-tests` directory. Solana Logs In case you want to see the logs of the fuzzed transactions, prefix the command with `TRIDENT_LOG=1`. `[](https://ackee.xyz/trident/docs/latest/start-fuzzing/executing-fuzz-test/#__codelineno-1-1) TRIDENT_LOG=1 trident fuzz run ` For the output reference and additional options such as debugging the found issues, check out [Commands](https://ackee.xyz/trident/docs/latest/basics/commands/) . For the additional customization through the `trident.toml` file, check out the [Trident Manifest](https://ackee.xyz/trident/docs/latest/trident-manifest/) page. Back to top --- # Writing fuzz test - Trident [Skip to content](https://ackee.xyz/trident/docs/latest/start-fuzzing/writting-fuzz-test/#writing-fuzz-test) Writing fuzz test[#](https://ackee.xyz/trident/docs/latest/start-fuzzing/writting-fuzz-test/#writing-fuzz-test "Permanent link") ================================================================================================================================= Trident is Manually Guided fuzzing framework for Solana programs. In order to start fuzzing, you need to guide the fuzzer by specifying what are the expected inputs to instruction or the expected sequences of instructions to execute. **Why is this important?** Letting the fuzzer to generate completely random instruction inputs and completely random sequences of instruction would lead in most case * to transaction failures, which would mean the fuzzer is not properly fuzzing the logic within the program; and * executing irrelevant random instruction sequences, which would again lead to transaction failures. Guide the fuzzer[#](https://ackee.xyz/trident/docs/latest/start-fuzzing/writting-fuzz-test/#guide-the-fuzzer "Permanent link") ------------------------------------------------------------------------------------------------------------------------------- Start with properly configuring different types of instruction inputs: * [Instruction Data](https://ackee.xyz/trident/docs/latest/start-fuzzing/writting-fuzz-test/instruction-data/) * [Instruction Accounts](https://ackee.xyz/trident/docs/latest/start-fuzzing/writting-fuzz-test/instruction-accounts/) * [Fuzzing Flows](https://ackee.xyz/trident/docs/latest/start-fuzzing/writting-fuzz-test/fuzzing-flows/) * (Optional) [Remaining Accounts](https://ackee.xyz/trident/docs/latest/start-fuzzing/writting-fuzz-test/remaining-accounts/) Back to top --- # Fuzzing Flows - Trident [Skip to content](https://ackee.xyz/trident/docs/latest/start-fuzzing/writting-fuzz-test/fuzzing-flows/#fuzzing-flows) Fuzzing Flows[#](https://ackee.xyz/trident/docs/latest/start-fuzzing/writting-fuzz-test/fuzzing-flows/#fuzzing-flows "Permanent link") ======================================================================================================================================= Before you start fuzzing, you need to guide the fuzzer on which transactions it should execute. This is important because if your program contains a lot of instructions and we let the fuzzer randomly pick from them, most of the time the fuzzer would pick incorrect sequences. This is due to the fact that Solana programs expect some kind of order. For example, DeFi protocols most likely expect something like: 1. Initialize Config 2. Initialize User 3. User deposit 4. User swap (there might be multiple swaps, with random order, this is achieved with flows) 5. User withdraw 6. User account remove 7. Collect trading fees 8. ... For that reason, it is required to slightly guide the fuzzer. The following code shows the default state of the `test_fuzz.rs` file. `[](https://ackee.xyz/trident/docs/latest/start-fuzzing/writting-fuzz-test/fuzzing-flows/#__codelineno-0-1) #[derive(FuzzTestMethods)] [](https://ackee.xyz/trident/docs/latest/start-fuzzing/writting-fuzz-test/fuzzing-flows/#__codelineno-0-2) struct FuzzTest { [](https://ackee.xyz/trident/docs/latest/start-fuzzing/writting-fuzz-test/fuzzing-flows/#__codelineno-0-3) /// for fuzzing [](https://ackee.xyz/trident/docs/latest/start-fuzzing/writting-fuzz-test/fuzzing-flows/#__codelineno-0-4) trident: Trident, [](https://ackee.xyz/trident/docs/latest/start-fuzzing/writting-fuzz-test/fuzzing-flows/#__codelineno-0-5) /// for storing fuzzing accounts [](https://ackee.xyz/trident/docs/latest/start-fuzzing/writting-fuzz-test/fuzzing-flows/#__codelineno-0-6) fuzz_accounts: FuzzAccounts, [](https://ackee.xyz/trident/docs/latest/start-fuzzing/writting-fuzz-test/fuzzing-flows/#__codelineno-0-7) } [](https://ackee.xyz/trident/docs/latest/start-fuzzing/writting-fuzz-test/fuzzing-flows/#__codelineno-0-8)[](https://ackee.xyz/trident/docs/latest/start-fuzzing/writting-fuzz-test/fuzzing-flows/#__codelineno-0-9) #[flow_executor] [](https://ackee.xyz/trident/docs/latest/start-fuzzing/writting-fuzz-test/fuzzing-flows/#__codelineno-0-10) impl FuzzTest { [](https://ackee.xyz/trident/docs/latest/start-fuzzing/writting-fuzz-test/fuzzing-flows/#__codelineno-0-11) fn new() -> Self { [](https://ackee.xyz/trident/docs/latest/start-fuzzing/writting-fuzz-test/fuzzing-flows/#__codelineno-0-12) Self { [](https://ackee.xyz/trident/docs/latest/start-fuzzing/writting-fuzz-test/fuzzing-flows/#__codelineno-0-13) trident: Trident::default(), [](https://ackee.xyz/trident/docs/latest/start-fuzzing/writting-fuzz-test/fuzzing-flows/#__codelineno-0-14) fuzz_accounts: FuzzAccounts::default(), [](https://ackee.xyz/trident/docs/latest/start-fuzzing/writting-fuzz-test/fuzzing-flows/#__codelineno-0-15) } [](https://ackee.xyz/trident/docs/latest/start-fuzzing/writting-fuzz-test/fuzzing-flows/#__codelineno-0-16) } [](https://ackee.xyz/trident/docs/latest/start-fuzzing/writting-fuzz-test/fuzzing-flows/#__codelineno-0-17) [](https://ackee.xyz/trident/docs/latest/start-fuzzing/writting-fuzz-test/fuzzing-flows/#__codelineno-0-18) #[init] [](https://ackee.xyz/trident/docs/latest/start-fuzzing/writting-fuzz-test/fuzzing-flows/#__codelineno-0-19) fn start(&mut self) { [](https://ackee.xyz/trident/docs/latest/start-fuzzing/writting-fuzz-test/fuzzing-flows/#__codelineno-0-20) // perform any initialization here, this method will be executed [](https://ackee.xyz/trident/docs/latest/start-fuzzing/writting-fuzz-test/fuzzing-flows/#__codelineno-0-21) // at start of each iteration [](https://ackee.xyz/trident/docs/latest/start-fuzzing/writting-fuzz-test/fuzzing-flows/#__codelineno-0-22) } [](https://ackee.xyz/trident/docs/latest/start-fuzzing/writting-fuzz-test/fuzzing-flows/#__codelineno-0-23) [](https://ackee.xyz/trident/docs/latest/start-fuzzing/writting-fuzz-test/fuzzing-flows/#__codelineno-0-24) #[flow] [](https://ackee.xyz/trident/docs/latest/start-fuzzing/writting-fuzz-test/fuzzing-flows/#__codelineno-0-25) fn flow1(&mut self) { [](https://ackee.xyz/trident/docs/latest/start-fuzzing/writting-fuzz-test/fuzzing-flows/#__codelineno-0-26) // perform logic which is meant to be fuzzed [](https://ackee.xyz/trident/docs/latest/start-fuzzing/writting-fuzz-test/fuzzing-flows/#__codelineno-0-27) // this flow is selected randomly from other flows [](https://ackee.xyz/trident/docs/latest/start-fuzzing/writting-fuzz-test/fuzzing-flows/#__codelineno-0-28) } [](https://ackee.xyz/trident/docs/latest/start-fuzzing/writting-fuzz-test/fuzzing-flows/#__codelineno-0-29) [](https://ackee.xyz/trident/docs/latest/start-fuzzing/writting-fuzz-test/fuzzing-flows/#__codelineno-0-30) #[flow] [](https://ackee.xyz/trident/docs/latest/start-fuzzing/writting-fuzz-test/fuzzing-flows/#__codelineno-0-31) fn flow2(&mut self) { [](https://ackee.xyz/trident/docs/latest/start-fuzzing/writting-fuzz-test/fuzzing-flows/#__codelineno-0-32) // perform logic which is meant to be fuzzed [](https://ackee.xyz/trident/docs/latest/start-fuzzing/writting-fuzz-test/fuzzing-flows/#__codelineno-0-33) // this flow is selected randomly from other flows [](https://ackee.xyz/trident/docs/latest/start-fuzzing/writting-fuzz-test/fuzzing-flows/#__codelineno-0-34) } [](https://ackee.xyz/trident/docs/latest/start-fuzzing/writting-fuzz-test/fuzzing-flows/#__codelineno-0-35) [](https://ackee.xyz/trident/docs/latest/start-fuzzing/writting-fuzz-test/fuzzing-flows/#__codelineno-0-36) #[end] [](https://ackee.xyz/trident/docs/latest/start-fuzzing/writting-fuzz-test/fuzzing-flows/#__codelineno-0-37) fn end(&mut self) { [](https://ackee.xyz/trident/docs/latest/start-fuzzing/writting-fuzz-test/fuzzing-flows/#__codelineno-0-38) // perform any cleaning here, this method will be executed [](https://ackee.xyz/trident/docs/latest/start-fuzzing/writting-fuzz-test/fuzzing-flows/#__codelineno-0-39) // at the end of each iteration [](https://ackee.xyz/trident/docs/latest/start-fuzzing/writting-fuzz-test/fuzzing-flows/#__codelineno-0-40) } [](https://ackee.xyz/trident/docs/latest/start-fuzzing/writting-fuzz-test/fuzzing-flows/#__codelineno-0-41) } [](https://ackee.xyz/trident/docs/latest/start-fuzzing/writting-fuzz-test/fuzzing-flows/#__codelineno-0-42)[](https://ackee.xyz/trident/docs/latest/start-fuzzing/writting-fuzz-test/fuzzing-flows/#__codelineno-0-43) fn main() { [](https://ackee.xyz/trident/docs/latest/start-fuzzing/writting-fuzz-test/fuzzing-flows/#__codelineno-0-44) FuzzTest::fuzz(1000, 100); [](https://ackee.xyz/trident/docs/latest/start-fuzzing/writting-fuzz-test/fuzzing-flows/#__codelineno-0-45) }` Let's describe the `test_fuzz.rs` file. The main[#](https://ackee.xyz/trident/docs/latest/start-fuzzing/writting-fuzz-test/fuzzing-flows/#the-main "Permanent link") ----------------------------------------------------------------------------------------------------------------------------- `[](https://ackee.xyz/trident/docs/latest/start-fuzzing/writting-fuzz-test/fuzzing-flows/#__codelineno-1-1) fn main() { [](https://ackee.xyz/trident/docs/latest/start-fuzzing/writting-fuzz-test/fuzzing-flows/#__codelineno-1-2) FuzzTest::fuzz(1000, 100); [](https://ackee.xyz/trident/docs/latest/start-fuzzing/writting-fuzz-test/fuzzing-flows/#__codelineno-1-3) }` This is the starting point of the fuzzing. Here you can specify how many iterations you want to run and how many flows you want to execute in each iteration. Flows are described below. The `FuzzTest` struct[#](https://ackee.xyz/trident/docs/latest/start-fuzzing/writting-fuzz-test/fuzzing-flows/#the-fuzztest-struct "Permanent link") ----------------------------------------------------------------------------------------------------------------------------------------------------- This is a struct containing Trident, which contains multiple methods for fuzzing, collecting fuzzing metrics, etc., and FuzzAccounts, which is used to store account IDs and their corresponding Pubkeys (addresses). `[](https://ackee.xyz/trident/docs/latest/start-fuzzing/writting-fuzz-test/fuzzing-flows/#__codelineno-2-1) #[derive(FuzzTestMethods)] [](https://ackee.xyz/trident/docs/latest/start-fuzzing/writting-fuzz-test/fuzzing-flows/#__codelineno-2-2) struct FuzzTest { [](https://ackee.xyz/trident/docs/latest/start-fuzzing/writting-fuzz-test/fuzzing-flows/#__codelineno-2-3) /// for fuzzing [](https://ackee.xyz/trident/docs/latest/start-fuzzing/writting-fuzz-test/fuzzing-flows/#__codelineno-2-4) trident: Trident, [](https://ackee.xyz/trident/docs/latest/start-fuzzing/writting-fuzz-test/fuzzing-flows/#__codelineno-2-5) /// for storing fuzzing accounts [](https://ackee.xyz/trident/docs/latest/start-fuzzing/writting-fuzz-test/fuzzing-flows/#__codelineno-2-6) fuzz_accounts: FuzzAccounts, [](https://ackee.xyz/trident/docs/latest/start-fuzzing/writting-fuzz-test/fuzzing-flows/#__codelineno-2-7) }` The `impl FuzzTest` block[#](https://ackee.xyz/trident/docs/latest/start-fuzzing/writting-fuzz-test/fuzzing-flows/#the-impl-fuzztest-block "Permanent link") ------------------------------------------------------------------------------------------------------------------------------------------------------------- This is the main block where you guide the fuzzer to perform the fuzzing. ### The `new` method[#](https://ackee.xyz/trident/docs/latest/start-fuzzing/writting-fuzz-test/fuzzing-flows/#the-new-method "Permanent link") The `new` method is called once at the start of the fuzzing. It is used to initialize the fuzzer and the fuzzing accounts to their default state (so empty). ### The `#[init]` method[#](https://ackee.xyz/trident/docs/latest/start-fuzzing/writting-fuzz-test/fuzzing-flows/#the-init-method "Permanent link") The `#[init]` method is executed at the start of each iteration. As described above, it is possible to specify the number of iterations and flows, meaning that this `#[init]` method will be executed at the start of each iteration. Within it, you can perform execution of transactions which should initialize something in your program, for example Global Config, User account, Token Accounts, etc. ### The `#[flow]` method[#](https://ackee.xyz/trident/docs/latest/start-fuzzing/writting-fuzz-test/fuzzing-flows/#the-flow-method "Permanent link") Methods marked with `#[flow]` are where the fuzzing happens (apart from the fact that the instructions contain random data on their inputs). Methods marked with `#[flow]` are selected randomly from other flows and executed in random order. As shown in the source code below, the `flow1` and `flow2` methods are marked with `#[flow]`. This means, in each iteration, 100 flow methods will be selected in random order and the logic specified in the methods will be executed. So if we have two flow methods, the random order can be `flow1`, `flow1`, `flow2`, `flow2`, `flow1`, `flow1`, etc., until 100 flows are executed. `[](https://ackee.xyz/trident/docs/latest/start-fuzzing/writting-fuzz-test/fuzzing-flows/#__codelineno-3-1) #[flow_executor] [](https://ackee.xyz/trident/docs/latest/start-fuzzing/writting-fuzz-test/fuzzing-flows/#__codelineno-3-2) impl FuzzTest { [](https://ackee.xyz/trident/docs/latest/start-fuzzing/writting-fuzz-test/fuzzing-flows/#__codelineno-3-3) fn new() -> Self { [](https://ackee.xyz/trident/docs/latest/start-fuzzing/writting-fuzz-test/fuzzing-flows/#__codelineno-3-4) Self { [](https://ackee.xyz/trident/docs/latest/start-fuzzing/writting-fuzz-test/fuzzing-flows/#__codelineno-3-5) trident: Trident::default(), [](https://ackee.xyz/trident/docs/latest/start-fuzzing/writting-fuzz-test/fuzzing-flows/#__codelineno-3-6) fuzz_accounts: FuzzAccounts::default(), [](https://ackee.xyz/trident/docs/latest/start-fuzzing/writting-fuzz-test/fuzzing-flows/#__codelineno-3-7) } [](https://ackee.xyz/trident/docs/latest/start-fuzzing/writting-fuzz-test/fuzzing-flows/#__codelineno-3-8) } [](https://ackee.xyz/trident/docs/latest/start-fuzzing/writting-fuzz-test/fuzzing-flows/#__codelineno-3-9) [](https://ackee.xyz/trident/docs/latest/start-fuzzing/writting-fuzz-test/fuzzing-flows/#__codelineno-3-10) #[init] [](https://ackee.xyz/trident/docs/latest/start-fuzzing/writting-fuzz-test/fuzzing-flows/#__codelineno-3-11) fn start(&mut self) { [](https://ackee.xyz/trident/docs/latest/start-fuzzing/writting-fuzz-test/fuzzing-flows/#__codelineno-3-12) // perform any initialization here, this method will be executed [](https://ackee.xyz/trident/docs/latest/start-fuzzing/writting-fuzz-test/fuzzing-flows/#__codelineno-3-13) // at start of each iteration [](https://ackee.xyz/trident/docs/latest/start-fuzzing/writting-fuzz-test/fuzzing-flows/#__codelineno-3-14) } [](https://ackee.xyz/trident/docs/latest/start-fuzzing/writting-fuzz-test/fuzzing-flows/#__codelineno-3-15) [](https://ackee.xyz/trident/docs/latest/start-fuzzing/writting-fuzz-test/fuzzing-flows/#__codelineno-3-16) #[flow] [](https://ackee.xyz/trident/docs/latest/start-fuzzing/writting-fuzz-test/fuzzing-flows/#__codelineno-3-17) fn flow1(&mut self) { [](https://ackee.xyz/trident/docs/latest/start-fuzzing/writting-fuzz-test/fuzzing-flows/#__codelineno-3-18) // perform logic which is meant to be fuzzed [](https://ackee.xyz/trident/docs/latest/start-fuzzing/writting-fuzz-test/fuzzing-flows/#__codelineno-3-19) // this flow is selected randomly from other flows [](https://ackee.xyz/trident/docs/latest/start-fuzzing/writting-fuzz-test/fuzzing-flows/#__codelineno-3-20) } [](https://ackee.xyz/trident/docs/latest/start-fuzzing/writting-fuzz-test/fuzzing-flows/#__codelineno-3-21) [](https://ackee.xyz/trident/docs/latest/start-fuzzing/writting-fuzz-test/fuzzing-flows/#__codelineno-3-22) #[flow] [](https://ackee.xyz/trident/docs/latest/start-fuzzing/writting-fuzz-test/fuzzing-flows/#__codelineno-3-23) fn flow2(&mut self) { [](https://ackee.xyz/trident/docs/latest/start-fuzzing/writting-fuzz-test/fuzzing-flows/#__codelineno-3-24) // perform logic which is meant to be fuzzed [](https://ackee.xyz/trident/docs/latest/start-fuzzing/writting-fuzz-test/fuzzing-flows/#__codelineno-3-25) // this flow is selected randomly from other flows [](https://ackee.xyz/trident/docs/latest/start-fuzzing/writting-fuzz-test/fuzzing-flows/#__codelineno-3-26) } [](https://ackee.xyz/trident/docs/latest/start-fuzzing/writting-fuzz-test/fuzzing-flows/#__codelineno-3-27) [](https://ackee.xyz/trident/docs/latest/start-fuzzing/writting-fuzz-test/fuzzing-flows/#__codelineno-3-28) #[end] [](https://ackee.xyz/trident/docs/latest/start-fuzzing/writting-fuzz-test/fuzzing-flows/#__codelineno-3-29) fn end(&mut self) { [](https://ackee.xyz/trident/docs/latest/start-fuzzing/writting-fuzz-test/fuzzing-flows/#__codelineno-3-30) // perform any cleaning here, this method will be executed [](https://ackee.xyz/trident/docs/latest/start-fuzzing/writting-fuzz-test/fuzzing-flows/#__codelineno-3-31) // at the end of each iteration [](https://ackee.xyz/trident/docs/latest/start-fuzzing/writting-fuzz-test/fuzzing-flows/#__codelineno-3-32) } [](https://ackee.xyz/trident/docs/latest/start-fuzzing/writting-fuzz-test/fuzzing-flows/#__codelineno-3-33) }` An example[#](https://ackee.xyz/trident/docs/latest/start-fuzzing/writting-fuzz-test/fuzzing-flows/#an-example "Permanent link") --------------------------------------------------------------------------------------------------------------------------------- As an example: * Within the block below, we have 4 flows. The `start` method is executed at the start of each iteration. The `flow1`, `flow2`, `flow3`, and `flow4` methods are executed in random order in each iteration. * There will be 1000 iterations and 100 flows executed in each iteration. * A random order of `MoveEastTransaction`, `MoveSouthTransaction`, `MoveNorthTransaction`, and `MoveWestTransaction` will be executed in each iteration, due to the fact that they are marked with `#[flow]`. `[](https://ackee.xyz/trident/docs/latest/start-fuzzing/writting-fuzz-test/fuzzing-flows/#__codelineno-4-1) #[flow_executor] [](https://ackee.xyz/trident/docs/latest/start-fuzzing/writting-fuzz-test/fuzzing-flows/#__codelineno-4-2) impl FuzzTest { [](https://ackee.xyz/trident/docs/latest/start-fuzzing/writting-fuzz-test/fuzzing-flows/#__codelineno-4-3) fn new() -> Self { [](https://ackee.xyz/trident/docs/latest/start-fuzzing/writting-fuzz-test/fuzzing-flows/#__codelineno-4-4) Self { [](https://ackee.xyz/trident/docs/latest/start-fuzzing/writting-fuzz-test/fuzzing-flows/#__codelineno-4-5) trident: Trident::default(), [](https://ackee.xyz/trident/docs/latest/start-fuzzing/writting-fuzz-test/fuzzing-flows/#__codelineno-4-6) fuzz_accounts: FuzzAccounts::default(), [](https://ackee.xyz/trident/docs/latest/start-fuzzing/writting-fuzz-test/fuzzing-flows/#__codelineno-4-7) } [](https://ackee.xyz/trident/docs/latest/start-fuzzing/writting-fuzz-test/fuzzing-flows/#__codelineno-4-8) } [](https://ackee.xyz/trident/docs/latest/start-fuzzing/writting-fuzz-test/fuzzing-flows/#__codelineno-4-9) #[init] [](https://ackee.xyz/trident/docs/latest/start-fuzzing/writting-fuzz-test/fuzzing-flows/#__codelineno-4-10) fn start(&mut self) { [](https://ackee.xyz/trident/docs/latest/start-fuzzing/writting-fuzz-test/fuzzing-flows/#__codelineno-4-11) let mut tx = InitializeTransaction::build(&mut self.trident, &mut self.fuzz_accounts); [](https://ackee.xyz/trident/docs/latest/start-fuzzing/writting-fuzz-test/fuzzing-flows/#__codelineno-4-12) [](https://ackee.xyz/trident/docs/latest/start-fuzzing/writting-fuzz-test/fuzzing-flows/#__codelineno-4-13) self.trident [](https://ackee.xyz/trident/docs/latest/start-fuzzing/writting-fuzz-test/fuzzing-flows/#__codelineno-4-14) .execute_transaction(&mut tx, Some("Initialize")); [](https://ackee.xyz/trident/docs/latest/start-fuzzing/writting-fuzz-test/fuzzing-flows/#__codelineno-4-15) } [](https://ackee.xyz/trident/docs/latest/start-fuzzing/writting-fuzz-test/fuzzing-flows/#__codelineno-4-16) [](https://ackee.xyz/trident/docs/latest/start-fuzzing/writting-fuzz-test/fuzzing-flows/#__codelineno-4-17) #[flow] [](https://ackee.xyz/trident/docs/latest/start-fuzzing/writting-fuzz-test/fuzzing-flows/#__codelineno-4-18) fn flow1(&mut self) { [](https://ackee.xyz/trident/docs/latest/start-fuzzing/writting-fuzz-test/fuzzing-flows/#__codelineno-4-19) let mut tx = MoveEastTransaction::build(&mut self.trident, &mut self.fuzz_accounts); [](https://ackee.xyz/trident/docs/latest/start-fuzzing/writting-fuzz-test/fuzzing-flows/#__codelineno-4-20) self.trident.execute_transaction(&mut tx, Some("MoveEast")); [](https://ackee.xyz/trident/docs/latest/start-fuzzing/writting-fuzz-test/fuzzing-flows/#__codelineno-4-21) } [](https://ackee.xyz/trident/docs/latest/start-fuzzing/writting-fuzz-test/fuzzing-flows/#__codelineno-4-22) #[flow] [](https://ackee.xyz/trident/docs/latest/start-fuzzing/writting-fuzz-test/fuzzing-flows/#__codelineno-4-23) fn flow2(&mut self) { [](https://ackee.xyz/trident/docs/latest/start-fuzzing/writting-fuzz-test/fuzzing-flows/#__codelineno-4-24) let mut tx = MoveSouthTransaction::build(&mut self.trident, &mut self.fuzz_accounts); [](https://ackee.xyz/trident/docs/latest/start-fuzzing/writting-fuzz-test/fuzzing-flows/#__codelineno-4-25) self.trident.execute_transaction(&mut tx, Some("MoveSouth")); [](https://ackee.xyz/trident/docs/latest/start-fuzzing/writting-fuzz-test/fuzzing-flows/#__codelineno-4-26) } [](https://ackee.xyz/trident/docs/latest/start-fuzzing/writting-fuzz-test/fuzzing-flows/#__codelineno-4-27) #[flow] [](https://ackee.xyz/trident/docs/latest/start-fuzzing/writting-fuzz-test/fuzzing-flows/#__codelineno-4-28) fn flow3(&mut self) { [](https://ackee.xyz/trident/docs/latest/start-fuzzing/writting-fuzz-test/fuzzing-flows/#__codelineno-4-29) let mut tx = MoveNorthTransaction::build(&mut self.trident, &mut self.fuzz_accounts); [](https://ackee.xyz/trident/docs/latest/start-fuzzing/writting-fuzz-test/fuzzing-flows/#__codelineno-4-30) self.trident.execute_transaction(&mut tx, Some("MoveNorth")); [](https://ackee.xyz/trident/docs/latest/start-fuzzing/writting-fuzz-test/fuzzing-flows/#__codelineno-4-31) } [](https://ackee.xyz/trident/docs/latest/start-fuzzing/writting-fuzz-test/fuzzing-flows/#__codelineno-4-32) #[flow] [](https://ackee.xyz/trident/docs/latest/start-fuzzing/writting-fuzz-test/fuzzing-flows/#__codelineno-4-33) fn flow4(&mut self) { [](https://ackee.xyz/trident/docs/latest/start-fuzzing/writting-fuzz-test/fuzzing-flows/#__codelineno-4-34) let mut tx = MoveWestTransaction::build(&mut self.trident, &mut self.fuzz_accounts); [](https://ackee.xyz/trident/docs/latest/start-fuzzing/writting-fuzz-test/fuzzing-flows/#__codelineno-4-35) self.trident.execute_transaction(&mut tx, Some("MoveWest")); [](https://ackee.xyz/trident/docs/latest/start-fuzzing/writting-fuzz-test/fuzzing-flows/#__codelineno-4-36) } [](https://ackee.xyz/trident/docs/latest/start-fuzzing/writting-fuzz-test/fuzzing-flows/#__codelineno-4-37) } [](https://ackee.xyz/trident/docs/latest/start-fuzzing/writting-fuzz-test/fuzzing-flows/#__codelineno-4-38)[](https://ackee.xyz/trident/docs/latest/start-fuzzing/writting-fuzz-test/fuzzing-flows/#__codelineno-4-39) fn main() { [](https://ackee.xyz/trident/docs/latest/start-fuzzing/writting-fuzz-test/fuzzing-flows/#__codelineno-4-40) FuzzTest::fuzz(1000, 100); [](https://ackee.xyz/trident/docs/latest/start-fuzzing/writting-fuzz-test/fuzzing-flows/#__codelineno-4-41) }` Back to top --- # Instruction Accounts - Trident [Skip to content](https://ackee.xyz/trident/docs/latest/start-fuzzing/writting-fuzz-test/instruction-accounts/#instruction-accounts) Instruction Accounts[#](https://ackee.xyz/trident/docs/latest/start-fuzzing/writting-fuzz-test/instruction-accounts/#instruction-accounts "Permanent link") ============================================================================================================================================================ Accounts are storage entities on the Solana Blockchain. They may be simple wallets (consisting of regular keypairs) or accounts with more complex address structures, such as Program Derived Addresses (PDAs). During fuzzing, Trident sends random Accounts to the program's instructions. However, the account addresses are not completely random but are taken from the Fuzz Test's account storage. Trident generates random indexes to the account storage. This approach is crucial, as allowing the fuzzer to generate completely random account addresses would lead to many failed transactions (i.e., nothing would be fuzzed). Your responsibility is to guide Trident on which storage locations it should retrieve accounts from. Additionally, if particular account types are expected, such as Token Account, Mint Account, etc., your responsibility is to initialize them within the `set_accounts` method. Setup Instruction Accounts[#](https://ackee.xyz/trident/docs/latest/start-fuzzing/writting-fuzz-test/instruction-accounts/#setup-instruction-accounts "Permanent link") ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ There are two ways to guide the fuzzer about which storage locations to retrieve accounts from: 1. Using the `TridentAccounts` macro 2. Manually setting the accounts using the `set_accounts` method ### Using the TridentAccounts Macro[#](https://ackee.xyz/trident/docs/latest/start-fuzzing/writting-fuzz-test/instruction-accounts/#using-the-tridentaccounts-macro "Permanent link") The `TridentAccounts` macro is used to derive account handling functionality for instruction accounts (similar to the Context structure in Anchor-based programs). You can check the [TridentAccounts attributes](https://ackee.xyz/trident/docs/latest/trident-api-macro/attributes-for-accounts/account-attributes/) page to see the attributes that can be used. Consider the following example: `[](https://ackee.xyz/trident/docs/latest/start-fuzzing/writting-fuzz-test/instruction-accounts/#__codelineno-0-1) /// Instruction Accounts [](https://ackee.xyz/trident/docs/latest/start-fuzzing/writting-fuzz-test/instruction-accounts/#__codelineno-0-2) #[derive(Arbitrary, Debug, Clone, TridentAccounts)] [](https://ackee.xyz/trident/docs/latest/start-fuzzing/writting-fuzz-test/instruction-accounts/#__codelineno-0-3) #[instruction_data(InitializeFnInstructionData)] [](https://ackee.xyz/trident/docs/latest/start-fuzzing/writting-fuzz-test/instruction-accounts/#__codelineno-0-4) #[storage(FuzzAccounts)] [](https://ackee.xyz/trident/docs/latest/start-fuzzing/writting-fuzz-test/instruction-accounts/#__codelineno-0-5) pub struct InitializeFnInstructionAccounts { [](https://ackee.xyz/trident/docs/latest/start-fuzzing/writting-fuzz-test/instruction-accounts/#__codelineno-0-6) #[account( [](https://ackee.xyz/trident/docs/latest/start-fuzzing/writting-fuzz-test/instruction-accounts/#__codelineno-0-7) mut, [](https://ackee.xyz/trident/docs/latest/start-fuzzing/writting-fuzz-test/instruction-accounts/#__codelineno-0-8) signer, [](https://ackee.xyz/trident/docs/latest/start-fuzzing/writting-fuzz-test/instruction-accounts/#__codelineno-0-9) storage = author, [](https://ackee.xyz/trident/docs/latest/start-fuzzing/writting-fuzz-test/instruction-accounts/#__codelineno-0-10) storage::account_id = (0..1) [](https://ackee.xyz/trident/docs/latest/start-fuzzing/writting-fuzz-test/instruction-accounts/#__codelineno-0-11) )] [](https://ackee.xyz/trident/docs/latest/start-fuzzing/writting-fuzz-test/instruction-accounts/#__codelineno-0-12) pub author: TridentAccount, [](https://ackee.xyz/trident/docs/latest/start-fuzzing/writting-fuzz-test/instruction-accounts/#__codelineno-0-13) #[account( [](https://ackee.xyz/trident/docs/latest/start-fuzzing/writting-fuzz-test/instruction-accounts/#__codelineno-0-14) mut, [](https://ackee.xyz/trident/docs/latest/start-fuzzing/writting-fuzz-test/instruction-accounts/#__codelineno-0-15) storage::name = hello_world_account, [](https://ackee.xyz/trident/docs/latest/start-fuzzing/writting-fuzz-test/instruction-accounts/#__codelineno-0-16) storage::account_id = (0..3) [](https://ackee.xyz/trident/docs/latest/start-fuzzing/writting-fuzz-test/instruction-accounts/#__codelineno-0-17) seeds = [b"hello_world_seed"], [](https://ackee.xyz/trident/docs/latest/start-fuzzing/writting-fuzz-test/instruction-accounts/#__codelineno-0-18) )] [](https://ackee.xyz/trident/docs/latest/start-fuzzing/writting-fuzz-test/instruction-accounts/#__codelineno-0-19) pub hello_world_account: TridentAccount, [](https://ackee.xyz/trident/docs/latest/start-fuzzing/writting-fuzz-test/instruction-accounts/#__codelineno-0-20) #[account(address = "11111111111111111111111111111111", skip_snapshot)] [](https://ackee.xyz/trident/docs/latest/start-fuzzing/writting-fuzz-test/instruction-accounts/#__codelineno-0-21) pub system_program: TridentAccount, [](https://ackee.xyz/trident/docs/latest/start-fuzzing/writting-fuzz-test/instruction-accounts/#__codelineno-0-22) }` The example specifies these attributes: * `#[instruction_data(InitializeFnInstructionData)]` - Specifies the instruction data type (helpful if instruction data input is part of PDA seeds) * `#[storage(FuzzAccounts)]` - Specifies the account storage type * `mut` - Marks the account as mutable * `signer` - Marks the account as a transaction signer * `storage::name = ` - Links the account to a storage location for address retrieval * `storage::account_id = (0..3)` - Randomly generates an account id from the range of values, this is particularly helpful if you want to try to send different accounts to the instruction * `address = "..."` - Sets a constant address for the account * `seeds = [b"hello_world_seed"]` - Specifies the seeds for Program Derived Addresses (PDAs) * `skip_snapshot` - Excludes the account from snapshot creation ### Manual Accounts Setup[#](https://ackee.xyz/trident/docs/latest/start-fuzzing/writting-fuzz-test/instruction-accounts/#manual-accounts-setup "Permanent link") If you need more control than the `TridentAccounts` macro provides, you can manually set up accounts using the `set_accounts` function: Precedence of `set_accounts` The `set_accounts` method takes precedence over the `TridentAccounts` macro attributes. Any behavior defined in the `set_accounts` method will override the behavior defined in the `TridentAccounts` macro. `[](https://ackee.xyz/trident/docs/latest/start-fuzzing/writting-fuzz-test/instruction-accounts/#__codelineno-1-1) impl InstructionSetters for ExampleInstruction { [](https://ackee.xyz/trident/docs/latest/start-fuzzing/writting-fuzz-test/instruction-accounts/#__codelineno-1-2) type IxAccounts = FuzzAccounts; [](https://ackee.xyz/trident/docs/latest/start-fuzzing/writting-fuzz-test/instruction-accounts/#__codelineno-1-3) [](https://ackee.xyz/trident/docs/latest/start-fuzzing/writting-fuzz-test/instruction-accounts/#__codelineno-1-4) fn set_accounts(&mut self, trident: &mut Trident, fuzz_accounts: &mut Self::IxAccounts) { [](https://ackee.xyz/trident/docs/latest/start-fuzzing/writting-fuzz-test/instruction-accounts/#__codelineno-1-5) // Generate random account id [](https://ackee.xyz/trident/docs/latest/start-fuzzing/writting-fuzz-test/instruction-accounts/#__codelineno-1-6) let account_id = trident.gen_range(0..3); [](https://ackee.xyz/trident/docs/latest/start-fuzzing/writting-fuzz-test/instruction-accounts/#__codelineno-1-7) [](https://ackee.xyz/trident/docs/latest/start-fuzzing/writting-fuzz-test/instruction-accounts/#__codelineno-1-8) // Create and store a PDA [](https://ackee.xyz/trident/docs/latest/start-fuzzing/writting-fuzz-test/instruction-accounts/#__codelineno-1-9) let hello_world_account = fuzz_accounts.hello_world_account.get_or_create( [](https://ackee.xyz/trident/docs/latest/start-fuzzing/writting-fuzz-test/instruction-accounts/#__codelineno-1-10) account_id, [](https://ackee.xyz/trident/docs/latest/start-fuzzing/writting-fuzz-test/instruction-accounts/#__codelineno-1-11) trident, [](https://ackee.xyz/trident/docs/latest/start-fuzzing/writting-fuzz-test/instruction-accounts/#__codelineno-1-12) Some(PdaSeeds::new(&[b"hello_world_seed"], self.get_program_id())), [](https://ackee.xyz/trident/docs/latest/start-fuzzing/writting-fuzz-test/instruction-accounts/#__codelineno-1-13) None, [](https://ackee.xyz/trident/docs/latest/start-fuzzing/writting-fuzz-test/instruction-accounts/#__codelineno-1-14) ); [](https://ackee.xyz/trident/docs/latest/start-fuzzing/writting-fuzz-test/instruction-accounts/#__codelineno-1-15) [](https://ackee.xyz/trident/docs/latest/start-fuzzing/writting-fuzz-test/instruction-accounts/#__codelineno-1-16) // Set the account address [](https://ackee.xyz/trident/docs/latest/start-fuzzing/writting-fuzz-test/instruction-accounts/#__codelineno-1-17) self.accounts [](https://ackee.xyz/trident/docs/latest/start-fuzzing/writting-fuzz-test/instruction-accounts/#__codelineno-1-18) .hello_world_account [](https://ackee.xyz/trident/docs/latest/start-fuzzing/writting-fuzz-test/instruction-accounts/#__codelineno-1-19) .set_address(hello_world_account); [](https://ackee.xyz/trident/docs/latest/start-fuzzing/writting-fuzz-test/instruction-accounts/#__codelineno-1-20) } [](https://ackee.xyz/trident/docs/latest/start-fuzzing/writting-fuzz-test/instruction-accounts/#__codelineno-1-21) }` In the previous examples: * We configured the fuzzer to always keep the `author` account as a `signer` and as `mutable`. It will be stored in the `FuzzAccounts::author` storage, and the account id will be randomly generated from the range of 0 to 1. * We configured the fuzzer to always keep the `hello_world_account` as a `mutable` account, which will be stored in the `FuzzAccounts::hello_world_account` storage, and it will be a PDA with an address derived from the `seeds` attribute, and the account id will be randomly generated from the range of 0 to 3. * We configured the fuzzer to always keep the `system_program` account as a `constant`. Snapshots of this account before and after the instruction execution will not be taken. Back to top --- # Instruction Data - Trident [Skip to content](https://ackee.xyz/trident/docs/latest/start-fuzzing/writting-fuzz-test/instruction-data/#instruction-data) Instruction Data[#](https://ackee.xyz/trident/docs/latest/start-fuzzing/writting-fuzz-test/instruction-data/#instruction-data "Permanent link") ================================================================================================================================================ Instructions on Solana can have parameters. Trident lets you to send random data as the instruction parameters. Manual Data Setup[#](https://ackee.xyz/trident/docs/latest/start-fuzzing/writting-fuzz-test/instruction-data/#manual-data-setup "Permanent link") -------------------------------------------------------------------------------------------------------------------------------------------------- The following example shows how to specify what data should be sent to the instruction. In this case we are guiding the Trident to always generate random number from 0 to `u8::MAX` and use it as the `input` parameter of the instruction. `[](https://ackee.xyz/trident/docs/latest/start-fuzzing/writting-fuzz-test/instruction-data/#__codelineno-0-1) impl InstructionSetters for DepositObligationCollateralV2Instruction { [](https://ackee.xyz/trident/docs/latest/start-fuzzing/writting-fuzz-test/instruction-data/#__codelineno-0-2) type IxAccounts = FuzzAccounts; [](https://ackee.xyz/trident/docs/latest/start-fuzzing/writting-fuzz-test/instruction-data/#__codelineno-0-3) [](https://ackee.xyz/trident/docs/latest/start-fuzzing/writting-fuzz-test/instruction-data/#__codelineno-0-4) fn set_data( [](https://ackee.xyz/trident/docs/latest/start-fuzzing/writting-fuzz-test/instruction-data/#__codelineno-0-5) &mut self, trident: &mut Trident, _fuzz_accounts: &mut Self::IxAccounts [](https://ackee.xyz/trident/docs/latest/start-fuzzing/writting-fuzz-test/instruction-data/#__codelineno-0-6) ) { [](https://ackee.xyz/trident/docs/latest/start-fuzzing/writting-fuzz-test/instruction-data/#__codelineno-0-7) self.data.input = trident.gen_range(0..u8::MAX); [](https://ackee.xyz/trident/docs/latest/start-fuzzing/writting-fuzz-test/instruction-data/#__codelineno-0-8) } [](https://ackee.xyz/trident/docs/latest/start-fuzzing/writting-fuzz-test/instruction-data/#__codelineno-0-9) }` Back to top --- # Remaining Accounts - Trident [Skip to content](https://ackee.xyz/trident/docs/latest/start-fuzzing/writting-fuzz-test/remaining-accounts/#remaining-accounts) Remaining Accounts[#](https://ackee.xyz/trident/docs/latest/start-fuzzing/writting-fuzz-test/remaining-accounts/#remaining-accounts "Permanent link") ====================================================================================================================================================== Some Solana instructions require additional accounts beyond their primary accounts. These are called "remaining accounts" and can be configured using the `set_remaining_accounts` function. Manual Remaining Accounts Setup[#](https://ackee.xyz/trident/docs/latest/start-fuzzing/writting-fuzz-test/remaining-accounts/#manual-remaining-accounts-setup "Permanent link") -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Remaining accounts are defined as a struct with the `TridentRemainingAccounts` derive macro. The macro expects remaining accounts as an array of `TridentAccount`, allowing you to specify any number of additional accounts. Remaining Accounts Configuration Do not forget to add remaining accounts to the `Instruction` struct. Additionally the field has to be named `remaining_accounts`. Here's an example of how to set up remaining accounts: `[](https://ackee.xyz/trident/docs/latest/start-fuzzing/writting-fuzz-test/remaining-accounts/#__codelineno-0-1) pub struct SomeInstruction { [](https://ackee.xyz/trident/docs/latest/start-fuzzing/writting-fuzz-test/remaining-accounts/#__codelineno-0-2) pub accounts: SomeInstructionAccounts, [](https://ackee.xyz/trident/docs/latest/start-fuzzing/writting-fuzz-test/remaining-accounts/#__codelineno-0-3) pub data: SomeInstructionData, [](https://ackee.xyz/trident/docs/latest/start-fuzzing/writting-fuzz-test/remaining-accounts/#__codelineno-0-4) pub remaining_accounts: SomeInstructionRemainingAccounts, [](https://ackee.xyz/trident/docs/latest/start-fuzzing/writting-fuzz-test/remaining-accounts/#__codelineno-0-5) } [](https://ackee.xyz/trident/docs/latest/start-fuzzing/writting-fuzz-test/remaining-accounts/#__codelineno-0-6)[](https://ackee.xyz/trident/docs/latest/start-fuzzing/writting-fuzz-test/remaining-accounts/#__codelineno-0-7) #[derive(Arbitrary, Debug, Clone, TridentRemainingAccounts)] [](https://ackee.xyz/trident/docs/latest/start-fuzzing/writting-fuzz-test/remaining-accounts/#__codelineno-0-8) pub struct SomeInstructionRemainingAccounts { [](https://ackee.xyz/trident/docs/latest/start-fuzzing/writting-fuzz-test/remaining-accounts/#__codelineno-0-9) pub remaining_accounts: [TridentAccount; 5], [](https://ackee.xyz/trident/docs/latest/start-fuzzing/writting-fuzz-test/remaining-accounts/#__codelineno-0-10) } [](https://ackee.xyz/trident/docs/latest/start-fuzzing/writting-fuzz-test/remaining-accounts/#__codelineno-0-11)[](https://ackee.xyz/trident/docs/latest/start-fuzzing/writting-fuzz-test/remaining-accounts/#__codelineno-0-12) impl InstructionSetters for SomeInstruction { [](https://ackee.xyz/trident/docs/latest/start-fuzzing/writting-fuzz-test/remaining-accounts/#__codelineno-0-13) type IxAccounts = FuzzAccounts; [](https://ackee.xyz/trident/docs/latest/start-fuzzing/writting-fuzz-test/remaining-accounts/#__codelineno-0-14) [](https://ackee.xyz/trident/docs/latest/start-fuzzing/writting-fuzz-test/remaining-accounts/#__codelineno-0-15) fn set_remaining_accounts( [](https://ackee.xyz/trident/docs/latest/start-fuzzing/writting-fuzz-test/remaining-accounts/#__codelineno-0-16) &mut self, [](https://ackee.xyz/trident/docs/latest/start-fuzzing/writting-fuzz-test/remaining-accounts/#__codelineno-0-17) trident: &mut Trident, [](https://ackee.xyz/trident/docs/latest/start-fuzzing/writting-fuzz-test/remaining-accounts/#__codelineno-0-18) fuzz_accounts: &mut Self::IxAccounts, [](https://ackee.xyz/trident/docs/latest/start-fuzzing/writting-fuzz-test/remaining-accounts/#__codelineno-0-19) ) { [](https://ackee.xyz/trident/docs/latest/start-fuzzing/writting-fuzz-test/remaining-accounts/#__codelineno-0-20) [](https://ackee.xyz/trident/docs/latest/start-fuzzing/writting-fuzz-test/remaining-accounts/#__codelineno-0-21) // Generate random account id [](https://ackee.xyz/trident/docs/latest/start-fuzzing/writting-fuzz-test/remaining-accounts/#__codelineno-0-22) let account_id = trident.gen_range(0..3); [](https://ackee.xyz/trident/docs/latest/start-fuzzing/writting-fuzz-test/remaining-accounts/#__codelineno-0-23) [](https://ackee.xyz/trident/docs/latest/start-fuzzing/writting-fuzz-test/remaining-accounts/#__codelineno-0-24) // Get the account from storage using the generated index [](https://ackee.xyz/trident/docs/latest/start-fuzzing/writting-fuzz-test/remaining-accounts/#__codelineno-0-25) let remaining_account1 = fuzz_accounts [](https://ackee.xyz/trident/docs/latest/start-fuzzing/writting-fuzz-test/remaining-accounts/#__codelineno-0-26) .owner [](https://ackee.xyz/trident/docs/latest/start-fuzzing/writting-fuzz-test/remaining-accounts/#__codelineno-0-27) .get_or_create(account_id, trident, None, None); [](https://ackee.xyz/trident/docs/latest/start-fuzzing/writting-fuzz-test/remaining-accounts/#__codelineno-0-28) [](https://ackee.xyz/trident/docs/latest/start-fuzzing/writting-fuzz-test/remaining-accounts/#__codelineno-0-29) // Configure the account meta with: [](https://ackee.xyz/trident/docs/latest/start-fuzzing/writting-fuzz-test/remaining-accounts/#__codelineno-0-30) // - Account public key [](https://ackee.xyz/trident/docs/latest/start-fuzzing/writting-fuzz-test/remaining-accounts/#__codelineno-0-31) // - is_signer flag (false in this example) [](https://ackee.xyz/trident/docs/latest/start-fuzzing/writting-fuzz-test/remaining-accounts/#__codelineno-0-32) // - is_writable flag (true in this example) [](https://ackee.xyz/trident/docs/latest/start-fuzzing/writting-fuzz-test/remaining-accounts/#__codelineno-0-33) self.remaining_accounts.remaining_accounts[0].set_account_meta( [](https://ackee.xyz/trident/docs/latest/start-fuzzing/writting-fuzz-test/remaining-accounts/#__codelineno-0-34) remaining_account1, [](https://ackee.xyz/trident/docs/latest/start-fuzzing/writting-fuzz-test/remaining-accounts/#__codelineno-0-35) false, // is_signer [](https://ackee.xyz/trident/docs/latest/start-fuzzing/writting-fuzz-test/remaining-accounts/#__codelineno-0-36) true // is_writable [](https://ackee.xyz/trident/docs/latest/start-fuzzing/writting-fuzz-test/remaining-accounts/#__codelineno-0-37) ); [](https://ackee.xyz/trident/docs/latest/start-fuzzing/writting-fuzz-test/remaining-accounts/#__codelineno-0-38) } [](https://ackee.xyz/trident/docs/latest/start-fuzzing/writting-fuzz-test/remaining-accounts/#__codelineno-0-39) }` * The `set_remaining_accounts` function works similarly to `set_accounts` * Each remaining account can be configured with its own signer and writable permissions * You can access remaining accounts using array indexing (e.g., `remaining_accounts[0]`) * The number of remaining accounts is fixed at compile time by the array size Back to top --- # Regression testing - Trident [Skip to content](https://ackee.xyz/trident/docs/latest/trident-advanced/regression/#regression-testing) Regression testing[#](https://ackee.xyz/trident/docs/latest/trident-advanced/regression/#regression-testing "Permanent link") ============================================================================================================================== Regression testing is the process of re-running tests to ensure that previously working functionality still works after code changes. Trident allows for regression testing by specifying which accounts should be included in the regression test, generating a JSON file format with all monitored state and providing a subcommand to compare two regression test results. Regression test setup[#](https://ackee.xyz/trident/docs/latest/trident-advanced/regression/#regression-test-setup "Permanent link") ------------------------------------------------------------------------------------------------------------------------------------ 1. First, decide which account(s) should be included in the regression test. 2. Add the accounts for tracking, this can be done as shown in the following code snippet. Check the `add_to_regression` method. `[](https://ackee.xyz/trident/docs/latest/trident-advanced/regression/#__codelineno-0-1) #[flow_executor] [](https://ackee.xyz/trident/docs/latest/trident-advanced/regression/#__codelineno-0-2) impl FuzzTest { [](https://ackee.xyz/trident/docs/latest/trident-advanced/regression/#__codelineno-0-3) fn new() -> Self { [](https://ackee.xyz/trident/docs/latest/trident-advanced/regression/#__codelineno-0-4) Self { [](https://ackee.xyz/trident/docs/latest/trident-advanced/regression/#__codelineno-0-5) trident: Trident::default(), [](https://ackee.xyz/trident/docs/latest/trident-advanced/regression/#__codelineno-0-6) fuzz_accounts: FuzzAccounts::default(), [](https://ackee.xyz/trident/docs/latest/trident-advanced/regression/#__codelineno-0-7) } [](https://ackee.xyz/trident/docs/latest/trident-advanced/regression/#__codelineno-0-8) } [](https://ackee.xyz/trident/docs/latest/trident-advanced/regression/#__codelineno-0-9) [](https://ackee.xyz/trident/docs/latest/trident-advanced/regression/#__codelineno-0-10) #[init] [](https://ackee.xyz/trident/docs/latest/trident-advanced/regression/#__codelineno-0-11) fn start(&mut self) { [](https://ackee.xyz/trident/docs/latest/trident-advanced/regression/#__codelineno-0-12) let mut ix = InitializeFnTransaction::build(&mut self.trident, &mut self.fuzz_accounts); [](https://ackee.xyz/trident/docs/latest/trident-advanced/regression/#__codelineno-0-13) [](https://ackee.xyz/trident/docs/latest/trident-advanced/regression/#__codelineno-0-14) self.trident.execute_transaction(&mut ix, Some("Init")); [](https://ackee.xyz/trident/docs/latest/trident-advanced/regression/#__codelineno-0-15) [](https://ackee.xyz/trident/docs/latest/trident-advanced/regression/#__codelineno-0-16) // Add the account to the regression test [](https://ackee.xyz/trident/docs/latest/trident-advanced/regression/#__codelineno-0-17) self.trident.add_to_regression( [](https://ackee.xyz/trident/docs/latest/trident-advanced/regression/#__codelineno-0-18) &ix.instruction.accounts.hello_world_account.pubkey(), [](https://ackee.xyz/trident/docs/latest/trident-advanced/regression/#__codelineno-0-19) "hello_world_account", [](https://ackee.xyz/trident/docs/latest/trident-advanced/regression/#__codelineno-0-20) ); [](https://ackee.xyz/trident/docs/latest/trident-advanced/regression/#__codelineno-0-21) } [](https://ackee.xyz/trident/docs/latest/trident-advanced/regression/#__codelineno-0-22) [](https://ackee.xyz/trident/docs/latest/trident-advanced/regression/#__codelineno-0-23) #[flow(weight = 5)] [](https://ackee.xyz/trident/docs/latest/trident-advanced/regression/#__codelineno-0-24) fn flow1(&mut self) { [](https://ackee.xyz/trident/docs/latest/trident-advanced/regression/#__codelineno-0-25) // This flow will be executed 60% of the time [](https://ackee.xyz/trident/docs/latest/trident-advanced/regression/#__codelineno-0-26) let mut ix = InitializeFnTransaction::build(&mut self.trident, &mut self.fuzz_accounts); [](https://ackee.xyz/trident/docs/latest/trident-advanced/regression/#__codelineno-0-27) self.trident.execute_transaction(&mut ix, Some("Flow1")); [](https://ackee.xyz/trident/docs/latest/trident-advanced/regression/#__codelineno-0-28) } [](https://ackee.xyz/trident/docs/latest/trident-advanced/regression/#__codelineno-0-29) [](https://ackee.xyz/trident/docs/latest/trident-advanced/regression/#__codelineno-0-30) #[flow(weight = 5)] [](https://ackee.xyz/trident/docs/latest/trident-advanced/regression/#__codelineno-0-31) fn flow2(&mut self) { [](https://ackee.xyz/trident/docs/latest/trident-advanced/regression/#__codelineno-0-32) // This flow will be executed 40% of the time [](https://ackee.xyz/trident/docs/latest/trident-advanced/regression/#__codelineno-0-33) let mut ix = InitializeFnTransaction::build(&mut self.trident, &mut self.fuzz_accounts); [](https://ackee.xyz/trident/docs/latest/trident-advanced/regression/#__codelineno-0-34) self.trident.execute_transaction(&mut ix, Some("Flow2")); [](https://ackee.xyz/trident/docs/latest/trident-advanced/regression/#__codelineno-0-35) } [](https://ackee.xyz/trident/docs/latest/trident-advanced/regression/#__codelineno-0-36) #[flow(weight = 90)] [](https://ackee.xyz/trident/docs/latest/trident-advanced/regression/#__codelineno-0-37) fn flow3(&mut self) { [](https://ackee.xyz/trident/docs/latest/trident-advanced/regression/#__codelineno-0-38) // This flow will be executed 40% of the time [](https://ackee.xyz/trident/docs/latest/trident-advanced/regression/#__codelineno-0-39) let mut ix = InitializeFnTransaction::build(&mut self.trident, &mut self.fuzz_accounts); [](https://ackee.xyz/trident/docs/latest/trident-advanced/regression/#__codelineno-0-40) self.trident.execute_transaction(&mut ix, Some("Flow3")); [](https://ackee.xyz/trident/docs/latest/trident-advanced/regression/#__codelineno-0-41) } [](https://ackee.xyz/trident/docs/latest/trident-advanced/regression/#__codelineno-0-42) [](https://ackee.xyz/trident/docs/latest/trident-advanced/regression/#__codelineno-0-43) #[end] [](https://ackee.xyz/trident/docs/latest/trident-advanced/regression/#__codelineno-0-44) fn cleanup(&mut self) -> Result<(), FuzzingError> { [](https://ackee.xyz/trident/docs/latest/trident-advanced/regression/#__codelineno-0-45) // This method will be called after all flows have been executed [](https://ackee.xyz/trident/docs/latest/trident-advanced/regression/#__codelineno-0-46) Ok(()) [](https://ackee.xyz/trident/docs/latest/trident-advanced/regression/#__codelineno-0-47) } [](https://ackee.xyz/trident/docs/latest/trident-advanced/regression/#__codelineno-0-48) } [](https://ackee.xyz/trident/docs/latest/trident-advanced/regression/#__codelineno-0-49)[](https://ackee.xyz/trident/docs/latest/trident-advanced/regression/#__codelineno-0-50) fn main() { [](https://ackee.xyz/trident/docs/latest/trident-advanced/regression/#__codelineno-0-51) FuzzTest::fuzz(1000, 100); [](https://ackee.xyz/trident/docs/latest/trident-advanced/regression/#__codelineno-0-52) }` 3. Enable the regression test in the [Trident manifest](https://ackee.xyz/trident/docs/latest/trident-manifest/#fuzzing-metrics) by setting: `[](https://ackee.xyz/trident/docs/latest/trident-advanced/regression/#__codelineno-1-1) [fuzz.regression] [](https://ackee.xyz/trident/docs/latest/trident-advanced/regression/#__codelineno-1-2) enabled = true` 4. Run the fuzz test to generate the regression test data. 5. Run the same fuzz test with the same MASTER SEED on a different version of the program. 6. Run the following command to compare the generated JSON files. `[](https://ackee.xyz/trident/docs/latest/trident-advanced/regression/#__codelineno-2-1) trident compare ` Back to top --- # Transaction Methods - Trident [Skip to content](https://ackee.xyz/trident/docs/latest/trident-advanced/trident-transactions/transaction-hooks/#transaction-methods) Transaction Methods[#](https://ackee.xyz/trident/docs/latest/trident-advanced/trident-transactions/transaction-hooks/#transaction-methods "Permanent link") ============================================================================================================================================================ Trident supports customizing transaction behavior with `Transaction Hooks`. * [Pre-Transaction Execution](https://ackee.xyz/trident/docs/latest/trident-advanced/trident-transactions/transaction-hooks/pre-post-execution/) : Perform custom logic before transaction execution * [Post-Transaction Execution](https://ackee.xyz/trident/docs/latest/trident-advanced/trident-transactions/transaction-hooks/pre-post-execution/) : Perform custom logic after transaction execution * [Transaction Invariants](https://ackee.xyz/trident/docs/latest/trident-advanced/trident-transactions/transaction-hooks/invariant-check/) : Validate transaction-specific invariants * [Transaction Error Handling](https://ackee.xyz/trident/docs/latest/trident-advanced/trident-transactions/transaction-hooks/error-handler/) : Handle transaction errors * [Typed Accounts](https://ackee.xyz/trident/docs/latest/trident-advanced/trident-transactions/transaction-hooks/typed-accounts/) : Deserialize accounts into typed data to perform differential analysis Back to top --- # Transaction Error Hook - Trident [Skip to content](https://ackee.xyz/trident/docs/latest/trident-advanced/trident-transactions/transaction-hooks/error-handler/#transaction-error-hook) Transaction Error Hook[#](https://ackee.xyz/trident/docs/latest/trident-advanced/trident-transactions/transaction-hooks/error-handler/#transaction-error-hook "Permanent link") ================================================================================================================================================================================ Trident lets you handle errors that occur during transaction execution. This feature is helpful when you want to investigate errors and verify if the behavior is as expected. Error Hook Execution Order The `transaction_error_handler` method is called only when the transaction has `FAILED`. `[](https://ackee.xyz/trident/docs/latest/trident-advanced/trident-transactions/transaction-hooks/error-handler/#__codelineno-0-1) impl TransactionHooks for ExampleTransaction { [](https://ackee.xyz/trident/docs/latest/trident-advanced/trident-transactions/transaction-hooks/error-handler/#__codelineno-0-2) type IxAccounts = FuzzAccounts; [](https://ackee.xyz/trident/docs/latest/trident-advanced/trident-transactions/transaction-hooks/error-handler/#__codelineno-0-3) [](https://ackee.xyz/trident/docs/latest/trident-advanced/trident-transactions/transaction-hooks/error-handler/#__codelineno-0-4) fn transaction_error_handler(&self, e: TransactionError) -> Result<(), TransactionError> { [](https://ackee.xyz/trident/docs/latest/trident-advanced/trident-transactions/transaction-hooks/error-handler/#__codelineno-0-5) // Your custom error handling logic goes here [](https://ackee.xyz/trident/docs/latest/trident-advanced/trident-transactions/transaction-hooks/error-handler/#__codelineno-0-6) } [](https://ackee.xyz/trident/docs/latest/trident-advanced/trident-transactions/transaction-hooks/error-handler/#__codelineno-0-7) }` Example[#](https://ackee.xyz/trident/docs/latest/trident-advanced/trident-transactions/transaction-hooks/error-handler/#example "Permanent link") -------------------------------------------------------------------------------------------------------------------------------------------------- The following example demonstrates: * Logging the error * Returning Ok to suppress the error `[](https://ackee.xyz/trident/docs/latest/trident-advanced/trident-transactions/transaction-hooks/error-handler/#__codelineno-1-1) impl TransactionHooks for ExampleTransaction { [](https://ackee.xyz/trident/docs/latest/trident-advanced/trident-transactions/transaction-hooks/error-handler/#__codelineno-1-2) type IxAccounts = FuzzAccounts; [](https://ackee.xyz/trident/docs/latest/trident-advanced/trident-transactions/transaction-hooks/error-handler/#__codelineno-1-3) [](https://ackee.xyz/trident/docs/latest/trident-advanced/trident-transactions/transaction-hooks/error-handler/#__codelineno-1-4) fn transaction_error_handler(&self, e: TransactionError) -> Result<(), TransactionError> { [](https://ackee.xyz/trident/docs/latest/trident-advanced/trident-transactions/transaction-hooks/error-handler/#__codelineno-1-5) // Example: Log the error and decide whether to propagate it [](https://ackee.xyz/trident/docs/latest/trident-advanced/trident-transactions/transaction-hooks/error-handler/#__codelineno-1-6) eprintln!("Transaction failed with error: {:?}", e); [](https://ackee.xyz/trident/docs/latest/trident-advanced/trident-transactions/transaction-hooks/error-handler/#__codelineno-1-7) [](https://ackee.xyz/trident/docs/latest/trident-advanced/trident-transactions/transaction-hooks/error-handler/#__codelineno-1-8) // Return Ok to suppress the error, or Err to propagate it [](https://ackee.xyz/trident/docs/latest/trident-advanced/trident-transactions/transaction-hooks/error-handler/#__codelineno-1-9) Ok(()) [](https://ackee.xyz/trident/docs/latest/trident-advanced/trident-transactions/transaction-hooks/error-handler/#__codelineno-1-10) } [](https://ackee.xyz/trident/docs/latest/trident-advanced/trident-transactions/transaction-hooks/error-handler/#__codelineno-1-11) }` Back to top --- # Transaction Invariant Hook - Trident [Skip to content](https://ackee.xyz/trident/docs/latest/trident-advanced/trident-transactions/transaction-hooks/invariant-check/#transaction-invariant-hook) Transaction Invariant Hook[#](https://ackee.xyz/trident/docs/latest/trident-advanced/trident-transactions/transaction-hooks/invariant-check/#transaction-invariant-hook "Permanent link") ========================================================================================================================================================================================== Transaction invariant checks let you compare account states before and after transaction execution (differential analysis), or verify that accounts are in a specific state after the transaction. This is useful to validate transaction behavior and ensure accounts are not modified in unexpected ways. Invariant Check Execution Order The `transaction_invariant_check` method is called only after the transaction is `SUCCESSFULLY` executed. `[](https://ackee.xyz/trident/docs/latest/trident-advanced/trident-transactions/transaction-hooks/invariant-check/#__codelineno-0-1) impl TransactionHooks for ExampleTransaction { [](https://ackee.xyz/trident/docs/latest/trident-advanced/trident-transactions/transaction-hooks/invariant-check/#__codelineno-0-2) fn transaction_invariant_check(&self) -> Result<(), FuzzingError> { [](https://ackee.xyz/trident/docs/latest/trident-advanced/trident-transactions/transaction-hooks/invariant-check/#__codelineno-0-3) // Your custom differential analysis goes here [](https://ackee.xyz/trident/docs/latest/trident-advanced/trident-transactions/transaction-hooks/invariant-check/#__codelineno-0-4) } [](https://ackee.xyz/trident/docs/latest/trident-advanced/trident-transactions/transaction-hooks/invariant-check/#__codelineno-0-5) }` Example[#](https://ackee.xyz/trident/docs/latest/trident-advanced/trident-transactions/transaction-hooks/invariant-check/#example "Permanent link") ---------------------------------------------------------------------------------------------------------------------------------------------------- The following example demonstrates: * Obtaining the owner's balance after the transaction, with `.get_snapshot_after()` (post transaction snapshot) * Comparing the balance to the expected balance (500 lamports) `[](https://ackee.xyz/trident/docs/latest/trident-advanced/trident-transactions/transaction-hooks/invariant-check/#__codelineno-1-1) impl TransactionHooks for ExampleTransaction { [](https://ackee.xyz/trident/docs/latest/trident-advanced/trident-transactions/transaction-hooks/invariant-check/#__codelineno-1-2) fn transaction_invariant_check(&self) -> Result<(), FuzzingError> { [](https://ackee.xyz/trident/docs/latest/trident-advanced/trident-transactions/transaction-hooks/invariant-check/#__codelineno-1-3) // Obtain the owner's balance after the transaction [](https://ackee.xyz/trident/docs/latest/trident-advanced/trident-transactions/transaction-hooks/invariant-check/#__codelineno-1-4) let owner_lamports = self [](https://ackee.xyz/trident/docs/latest/trident-advanced/trident-transactions/transaction-hooks/invariant-check/#__codelineno-1-5) .instruction [](https://ackee.xyz/trident/docs/latest/trident-advanced/trident-transactions/transaction-hooks/invariant-check/#__codelineno-1-6) .accounts [](https://ackee.xyz/trident/docs/latest/trident-advanced/trident-transactions/transaction-hooks/invariant-check/#__codelineno-1-7) .owner [](https://ackee.xyz/trident/docs/latest/trident-advanced/trident-transactions/transaction-hooks/invariant-check/#__codelineno-1-8) .get_snapshot_after() [](https://ackee.xyz/trident/docs/latest/trident-advanced/trident-transactions/transaction-hooks/invariant-check/#__codelineno-1-9) .lamports(); [](https://ackee.xyz/trident/docs/latest/trident-advanced/trident-transactions/transaction-hooks/invariant-check/#__codelineno-1-10) [](https://ackee.xyz/trident/docs/latest/trident-advanced/trident-transactions/transaction-hooks/invariant-check/#__codelineno-1-11) // Compare the balance and return error if not valid [](https://ackee.xyz/trident/docs/latest/trident-advanced/trident-transactions/transaction-hooks/invariant-check/#__codelineno-1-12) if owner_lamports > 500 { [](https://ackee.xyz/trident/docs/latest/trident-advanced/trident-transactions/transaction-hooks/invariant-check/#__codelineno-1-13) return Err(FuzzingError::with_message( [](https://ackee.xyz/trident/docs/latest/trident-advanced/trident-transactions/transaction-hooks/invariant-check/#__codelineno-1-14) "Owner lamports should be less than 500", [](https://ackee.xyz/trident/docs/latest/trident-advanced/trident-transactions/transaction-hooks/invariant-check/#__codelineno-1-15) )); [](https://ackee.xyz/trident/docs/latest/trident-advanced/trident-transactions/transaction-hooks/invariant-check/#__codelineno-1-16) } [](https://ackee.xyz/trident/docs/latest/trident-advanced/trident-transactions/transaction-hooks/invariant-check/#__codelineno-1-17) Ok(()) [](https://ackee.xyz/trident/docs/latest/trident-advanced/trident-transactions/transaction-hooks/invariant-check/#__codelineno-1-18) } [](https://ackee.xyz/trident/docs/latest/trident-advanced/trident-transactions/transaction-hooks/invariant-check/#__codelineno-1-19) }` Back to top --- # Multi-Instruction Transactions - Trident [Skip to content](https://ackee.xyz/trident/docs/latest/trident-advanced/trident-transactions/multi-instruction-transactions/#multi-instruction-transactions) Multi-Instruction Transactions[#](https://ackee.xyz/trident/docs/latest/trident-advanced/trident-transactions/multi-instruction-transactions/#multi-instruction-transactions "Permanent link") =============================================================================================================================================================================================== Trident supports fuzzing of multiple instructions within one transaction. By default, separate folders for `instructions` and `transactions` are created. To create multi-instruction transactions, either modify an existing `transaction` in its corresponding `.rs` file or create a new one. Instruction Resolution Order In multi-instruction transactions, instruction hooks are executed in the same order as the instructions are defined in the transaction structure. Example[#](https://ackee.xyz/trident/docs/latest/trident-advanced/trident-transactions/multi-instruction-transactions/#example "Permanent link") ------------------------------------------------------------------------------------------------------------------------------------------------- The following example demonstrates: * Creating a multi-instruction transaction * Adding the transaction to the `FuzzTransactions` enum `[](https://ackee.xyz/trident/docs/latest/trident-advanced/trident-transactions/multi-instruction-transactions/#__codelineno-0-1) // example_transaction.rs [](https://ackee.xyz/trident/docs/latest/trident-advanced/trident-transactions/multi-instruction-transactions/#__codelineno-0-2) use crate::fuzz_accounts::FuzzAccounts; [](https://ackee.xyz/trident/docs/latest/trident-advanced/trident-transactions/multi-instruction-transactions/#__codelineno-0-3) use crate::instructions::*; [](https://ackee.xyz/trident/docs/latest/trident-advanced/trident-transactions/multi-instruction-transactions/#__codelineno-0-4) use trident_fuzz::fuzzing::*; [](https://ackee.xyz/trident/docs/latest/trident-advanced/trident-transactions/multi-instruction-transactions/#__codelineno-0-5)[](https://ackee.xyz/trident/docs/latest/trident-advanced/trident-transactions/multi-instruction-transactions/#__codelineno-0-6) /// Customize transaction behavior by adding more instructions. [](https://ackee.xyz/trident/docs/latest/trident-advanced/trident-transactions/multi-instruction-transactions/#__codelineno-0-7) /// [](https://ackee.xyz/trident/docs/latest/trident-advanced/trident-transactions/multi-instruction-transactions/#__codelineno-0-8) /// Docs: https://ackee.xyz/trident/docs/latest/trident-advanced/trident-transactions/multi-instruction-transactions/ [](https://ackee.xyz/trident/docs/latest/trident-advanced/trident-transactions/multi-instruction-transactions/#__codelineno-0-9) #[derive(Debug, TridentTransaction, Default)] [](https://ackee.xyz/trident/docs/latest/trident-advanced/trident-transactions/multi-instruction-transactions/#__codelineno-0-10) pub struct ExampleTransaction { [](https://ackee.xyz/trident/docs/latest/trident-advanced/trident-transactions/multi-instruction-transactions/#__codelineno-0-11) pub instruction1: ExampleInstruction1, // instruction one [](https://ackee.xyz/trident/docs/latest/trident-advanced/trident-transactions/multi-instruction-transactions/#__codelineno-0-12) pub instruction2: ExampleInstruction2, // instruction two [](https://ackee.xyz/trident/docs/latest/trident-advanced/trident-transactions/multi-instruction-transactions/#__codelineno-0-13) } [](https://ackee.xyz/trident/docs/latest/trident-advanced/trident-transactions/multi-instruction-transactions/#__codelineno-0-14) [](https://ackee.xyz/trident/docs/latest/trident-advanced/trident-transactions/multi-instruction-transactions/#__codelineno-0-15)[](https://ackee.xyz/trident/docs/latest/trident-advanced/trident-transactions/multi-instruction-transactions/#__codelineno-0-16) impl TransactionHooks for ExampleTransaction {}` Back to top --- # Pre and Post Transaction Hooks - Trident [Skip to content](https://ackee.xyz/trident/docs/latest/trident-advanced/trident-transactions/transaction-hooks/pre-post-execution/#pre-and-post-transaction-hooks) Pre and Post Transaction Hooks[#](https://ackee.xyz/trident/docs/latest/trident-advanced/trident-transactions/transaction-hooks/pre-post-execution/#pre-and-post-transaction-hooks "Permanent link") ===================================================================================================================================================================================================== Trident lets you perform specific logic before and after transaction execution with pre\_transaction and post\_transaction methods. These methods accept a `FuzzClient` parameter, which provides methods to interact with the fuzzing environment. See the [FuzzClient](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-fuzz-client/fuzz-client-trait/) documentation for details. Post-Transaction Execution Order The `post_transaction` method is called only after the transaction is `SUCCESSFULLY` executed. `[](https://ackee.xyz/trident/docs/latest/trident-advanced/trident-transactions/transaction-hooks/pre-post-execution/#__codelineno-0-1) impl TransactionHooks for ExampleTransaction { [](https://ackee.xyz/trident/docs/latest/trident-advanced/trident-transactions/transaction-hooks/pre-post-execution/#__codelineno-0-2) fn pre_transaction(&self, client: &mut impl FuzzClient) { [](https://ackee.xyz/trident/docs/latest/trident-advanced/trident-transactions/transaction-hooks/pre-post-execution/#__codelineno-0-3) // Your custom logic goes here [](https://ackee.xyz/trident/docs/latest/trident-advanced/trident-transactions/transaction-hooks/pre-post-execution/#__codelineno-0-4) } [](https://ackee.xyz/trident/docs/latest/trident-advanced/trident-transactions/transaction-hooks/pre-post-execution/#__codelineno-0-5) }` `[](https://ackee.xyz/trident/docs/latest/trident-advanced/trident-transactions/transaction-hooks/pre-post-execution/#__codelineno-1-1) impl TransactionHooks for ExampleTransaction { [](https://ackee.xyz/trident/docs/latest/trident-advanced/trident-transactions/transaction-hooks/pre-post-execution/#__codelineno-1-2) fn post_transaction(&self, client: &mut impl FuzzClient) { [](https://ackee.xyz/trident/docs/latest/trident-advanced/trident-transactions/transaction-hooks/pre-post-execution/#__codelineno-1-3) // Your custom logic goes here [](https://ackee.xyz/trident/docs/latest/trident-advanced/trident-transactions/transaction-hooks/pre-post-execution/#__codelineno-1-4) } [](https://ackee.xyz/trident/docs/latest/trident-advanced/trident-transactions/transaction-hooks/pre-post-execution/#__codelineno-1-5) }` Example[#](https://ackee.xyz/trident/docs/latest/trident-advanced/trident-transactions/transaction-hooks/pre-post-execution/#example "Permanent link") ------------------------------------------------------------------------------------------------------------------------------------------------------- The following examples demonstrate: * Always forward in time before the transaction * Always forward in time after the transaction `[](https://ackee.xyz/trident/docs/latest/trident-advanced/trident-transactions/transaction-hooks/pre-post-execution/#__codelineno-2-1) impl TransactionHooks for ExampleTransaction { [](https://ackee.xyz/trident/docs/latest/trident-advanced/trident-transactions/transaction-hooks/pre-post-execution/#__codelineno-2-2) fn pre_transaction(&self, client: &mut impl FuzzClient) { [](https://ackee.xyz/trident/docs/latest/trident-advanced/trident-transactions/transaction-hooks/pre-post-execution/#__codelineno-2-3) client.forward_in_time(500); [](https://ackee.xyz/trident/docs/latest/trident-advanced/trident-transactions/transaction-hooks/pre-post-execution/#__codelineno-2-4) } [](https://ackee.xyz/trident/docs/latest/trident-advanced/trident-transactions/transaction-hooks/pre-post-execution/#__codelineno-2-5) }` `[](https://ackee.xyz/trident/docs/latest/trident-advanced/trident-transactions/transaction-hooks/pre-post-execution/#__codelineno-3-1) impl TransactionHooks for ExampleTransaction { [](https://ackee.xyz/trident/docs/latest/trident-advanced/trident-transactions/transaction-hooks/pre-post-execution/#__codelineno-3-2) fn post_transaction(&self, client: &mut impl FuzzClient) { [](https://ackee.xyz/trident/docs/latest/trident-advanced/trident-transactions/transaction-hooks/pre-post-execution/#__codelineno-3-3) client.forward_in_time(500); [](https://ackee.xyz/trident/docs/latest/trident-advanced/trident-transactions/transaction-hooks/pre-post-execution/#__codelineno-3-4) } [](https://ackee.xyz/trident/docs/latest/trident-advanced/trident-transactions/transaction-hooks/pre-post-execution/#__codelineno-3-5) }` Back to top --- # Trident API & Macro Reference - Trident [Skip to content](https://ackee.xyz/trident/docs/latest/trident-api-macro/#trident-api-macro-reference) Trident API & Macro Reference[#](https://ackee.xyz/trident/docs/latest/trident-api-macro/#trident-api-macro-reference "Permanent link") ======================================================================================================================================== This section contains the API and macro reference for Trident. Trident[#](https://ackee.xyz/trident/docs/latest/trident-api-macro/#trident "Permanent link") ---------------------------------------------------------------------------------------------- The Trident struct is the main entry point for fuzzing. It provides methods to interact with the fuzzing environment. * [Trident](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident/trident/) Trident's Fuzz Client[#](https://ackee.xyz/trident/docs/latest/trident-api-macro/#tridents-fuzz-client "Permanent link") ------------------------------------------------------------------------------------------------------------------------- FuzzClient represents the API to interact with the client. * [FuzzClient](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-fuzz-client/fuzz-client-trait/) Trident Accounts attributes[#](https://ackee.xyz/trident/docs/latest/trident-api-macro/#trident-accounts-attributes "Permanent link") -------------------------------------------------------------------------------------------------------------------------------------- Trident Accounts attributes help to define accounts used in the fuzzing environment. * [TridentAccounts](https://ackee.xyz/trident/docs/latest/trident-api-macro/attributes-for-accounts/account-attributes/) Hooks[#](https://ackee.xyz/trident/docs/latest/trident-api-macro/#hooks "Permanent link") ------------------------------------------------------------------------------------------ Transaction Hooks are used to customize what should be done before the transaction is executed, after it is executed and to check if the changes are valid with invariant checks. * [TransactionHooks](https://ackee.xyz/trident/docs/latest/trident-api-macro/hooks/transaction-hooks/) Instruction Hooks are used to customize instruction data and accounts if the Trident Accounts attributes are not enough. * [InstructionHooks](https://ackee.xyz/trident/docs/latest/trident-api-macro/hooks/instruction-hooks/) Trident Macros[#](https://ackee.xyz/trident/docs/latest/trident-api-macro/#trident-macros "Permanent link") ------------------------------------------------------------------------------------------------------------ Trident macros are used to define required methods for fuzzing. * [TridentTransaction](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-macros/trident-transaction/) * [TridentInstruction](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-macros/trident-instruction/) * [TridentAccounts](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-macros/trident-accounts/) * [TridentRemainingAccounts](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-macros/trident-remaining-accounts/) * [TridentFlowExecutor](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-macros/trident-flow-executor/) Trident Types[#](https://ackee.xyz/trident/docs/latest/trident-api-macro/#trident-types "Permanent link") ---------------------------------------------------------------------------------------------------------- Trident types represent the types utilized during fuzzing. * [FuzzAccounts](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-types/fuzz-accounts/) * [TridentAccount](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-types/trident-account/) * [TridentPubkey](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-types/trident-pubkey/) * [CustomTypes](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-types/custom-types/) Back to top --- # Trident Advanced - Trident [Skip to content](https://ackee.xyz/trident/docs/latest/trident-advanced/#trident-advanced) Trident Advanced[#](https://ackee.xyz/trident/docs/latest/trident-advanced/#trident-advanced "Permanent link") =============================================================================================================== This section contains advanced customization options for Trident. Transaction-related[#](https://ackee.xyz/trident/docs/latest/trident-advanced/#transaction-related "Permanent link") --------------------------------------------------------------------------------------------------------------------- * [Transaction Hooks](https://ackee.xyz/trident/docs/latest/trident-advanced/trident-transactions/transaction-hooks/) - Add custom logic to the transaction execution process * [Multi-Instruction Transactions](https://ackee.xyz/trident/docs/latest/trident-advanced/trident-transactions/multi-instruction-transactions/) - Execute multiple instructions in a single transaction Analysis & Visualization[#](https://ackee.xyz/trident/docs/latest/trident-advanced/#analysis-visualization "Permanent link") ----------------------------------------------------------------------------------------------------------------------------- * [Code Coverage](https://ackee.xyz/trident/docs/latest/trident-advanced/code-coverage/) - Measure code coverage of the fuzzed program * [Dashboard](https://ackee.xyz/trident/docs/latest/trident-advanced/dashboard/) - Visualize fuzzing metrics in a dashboard * [Regression Testing](https://ackee.xyz/trident/docs/latest/trident-advanced/regression/) - Compare two regression test results Back to top --- # TridentAccount attributes - Trident [Skip to content](https://ackee.xyz/trident/docs/latest/trident-api-macro/attributes-for-accounts/account-attributes/#tridentaccount-attributes) TridentAccount attributes[#](https://ackee.xyz/trident/docs/latest/trident-api-macro/attributes-for-accounts/account-attributes/#tridentaccount-attributes "Permanent link") ============================================================================================================================================================================= These attributes are applied to individual account fields using the `#[account(...)]` syntax. ### `account(mut)`[#](https://ackee.xyz/trident/docs/latest/trident-api-macro/attributes-for-accounts/account-attributes/#accountmut "Permanent link") Marks the account as mutable. This will set the `is_writable` flag to `true` in the generated `AccountMeta`. `This attribute is optional` `[](https://ackee.xyz/trident/docs/latest/trident-api-macro/attributes-for-accounts/account-attributes/#__codelineno-0-1) #[derive(TridentAccounts)] [](https://ackee.xyz/trident/docs/latest/trident-api-macro/attributes-for-accounts/account-attributes/#__codelineno-0-2) pub struct ExampleAccounts { [](https://ackee.xyz/trident/docs/latest/trident-api-macro/attributes-for-accounts/account-attributes/#__codelineno-0-3) #[account(mut)] [](https://ackee.xyz/trident/docs/latest/trident-api-macro/attributes-for-accounts/account-attributes/#__codelineno-0-4) pub mutable_account: TridentAccount, [](https://ackee.xyz/trident/docs/latest/trident-api-macro/attributes-for-accounts/account-attributes/#__codelineno-0-5) }` * * * ### `account(signer)`[#](https://ackee.xyz/trident/docs/latest/trident-api-macro/attributes-for-accounts/account-attributes/#accountsigner "Permanent link") Marks the account as a signer. This will set the `is_signer` flag to `true` in the generated `AccountMeta`. `This attribute is optional` `[](https://ackee.xyz/trident/docs/latest/trident-api-macro/attributes-for-accounts/account-attributes/#__codelineno-1-1) #[derive(TridentAccounts)] [](https://ackee.xyz/trident/docs/latest/trident-api-macro/attributes-for-accounts/account-attributes/#__codelineno-1-2) pub struct ExampleAccounts { [](https://ackee.xyz/trident/docs/latest/trident-api-macro/attributes-for-accounts/account-attributes/#__codelineno-1-3) #[account(signer)] [](https://ackee.xyz/trident/docs/latest/trident-api-macro/attributes-for-accounts/account-attributes/#__codelineno-1-4) pub authority: TridentAccount, [](https://ackee.xyz/trident/docs/latest/trident-api-macro/attributes-for-accounts/account-attributes/#__codelineno-1-5) }` * * * ### `account(address)`[#](https://ackee.xyz/trident/docs/latest/trident-api-macro/attributes-for-accounts/account-attributes/#accountaddress "Permanent link") Sets a fixed address for the account. Useful for program IDs that have known addresses. `This attribute is optional` `[](https://ackee.xyz/trident/docs/latest/trident-api-macro/attributes-for-accounts/account-attributes/#__codelineno-2-1) #[derive(TridentAccounts)] [](https://ackee.xyz/trident/docs/latest/trident-api-macro/attributes-for-accounts/account-attributes/#__codelineno-2-2) pub struct ExampleAccounts { [](https://ackee.xyz/trident/docs/latest/trident-api-macro/attributes-for-accounts/account-attributes/#__codelineno-2-3) #[account(address = "11111111111111111111111111111111")] [](https://ackee.xyz/trident/docs/latest/trident-api-macro/attributes-for-accounts/account-attributes/#__codelineno-2-4) pub system_program: TridentAccount, [](https://ackee.xyz/trident/docs/latest/trident-api-macro/attributes-for-accounts/account-attributes/#__codelineno-2-5) }` * * * ### `account(storage::name)`[#](https://ackee.xyz/trident/docs/latest/trident-api-macro/attributes-for-accounts/account-attributes/#accountstoragename "Permanent link") Specifies which storage to use for the account. This determines where the account address is stored and managed. `This attribute is optional` `[](https://ackee.xyz/trident/docs/latest/trident-api-macro/attributes-for-accounts/account-attributes/#__codelineno-3-1) #[derive(TridentAccounts)] [](https://ackee.xyz/trident/docs/latest/trident-api-macro/attributes-for-accounts/account-attributes/#__codelineno-3-2) pub struct ExampleAccounts { [](https://ackee.xyz/trident/docs/latest/trident-api-macro/attributes-for-accounts/account-attributes/#__codelineno-3-3) #[account(storage::name = owner)] [](https://ackee.xyz/trident/docs/latest/trident-api-macro/attributes-for-accounts/account-attributes/#__codelineno-3-4) pub owner: TridentAccount, [](https://ackee.xyz/trident/docs/latest/trident-api-macro/attributes-for-accounts/account-attributes/#__codelineno-3-5) }` * * * ### `account(storage::account_id)`[#](https://ackee.xyz/trident/docs/latest/trident-api-macro/attributes-for-accounts/account-attributes/#accountstorageaccount_id "Permanent link") Specifies a range of random numbers generated and mapped to address (Pubkey). A bigger range results in more random account addresses being fuzzed. `This attribute is optional` `[](https://ackee.xyz/trident/docs/latest/trident-api-macro/attributes-for-accounts/account-attributes/#__codelineno-4-1) #[derive(TridentAccounts)] [](https://ackee.xyz/trident/docs/latest/trident-api-macro/attributes-for-accounts/account-attributes/#__codelineno-4-2) pub struct ExampleAccounts { [](https://ackee.xyz/trident/docs/latest/trident-api-macro/attributes-for-accounts/account-attributes/#__codelineno-4-3) #[account(storage::name = owner)] [](https://ackee.xyz/trident/docs/latest/trident-api-macro/attributes-for-accounts/account-attributes/#__codelineno-4-4) pub owner: TridentAccount, [](https://ackee.xyz/trident/docs/latest/trident-api-macro/attributes-for-accounts/account-attributes/#__codelineno-4-5) }` * * * ### `account(skip_snapshot)`[#](https://ackee.xyz/trident/docs/latest/trident-api-macro/attributes-for-accounts/account-attributes/#accountskip_snapshot "Permanent link") Excludes the account from state snapshots. Useful for accounts that don't need to be tracked for state changes. `This attribute is optional` `[](https://ackee.xyz/trident/docs/latest/trident-api-macro/attributes-for-accounts/account-attributes/#__codelineno-5-1) #[derive(TridentAccounts)] [](https://ackee.xyz/trident/docs/latest/trident-api-macro/attributes-for-accounts/account-attributes/#__codelineno-5-2) pub struct ExampleAccounts { [](https://ackee.xyz/trident/docs/latest/trident-api-macro/attributes-for-accounts/account-attributes/#__codelineno-5-3) #[account(skip_snapshot)] [](https://ackee.xyz/trident/docs/latest/trident-api-macro/attributes-for-accounts/account-attributes/#__codelineno-5-4) pub ignored_for_snapshots: TridentAccount, [](https://ackee.xyz/trident/docs/latest/trident-api-macro/attributes-for-accounts/account-attributes/#__codelineno-5-5) }` * * * ### `account(seeds)`[#](https://ackee.xyz/trident/docs/latest/trident-api-macro/attributes-for-accounts/account-attributes/#accountseeds "Permanent link") Defines Program Derived Address (PDA) seeds for the account. The seeds can include references to other accounts in the struct, allowing for dependency-based PDA derivation. `This attribute is optional but requires the storage attribute` `[](https://ackee.xyz/trident/docs/latest/trident-api-macro/attributes-for-accounts/account-attributes/#__codelineno-6-1) #[derive(TridentAccounts)] [](https://ackee.xyz/trident/docs/latest/trident-api-macro/attributes-for-accounts/account-attributes/#__codelineno-6-2) pub struct ExampleAccounts { [](https://ackee.xyz/trident/docs/latest/trident-api-macro/attributes-for-accounts/account-attributes/#__codelineno-6-3) #[account(storage = pdas, seeds = [b"seed", authority.key().as_ref()])] [](https://ackee.xyz/trident/docs/latest/trident-api-macro/attributes-for-accounts/account-attributes/#__codelineno-6-4) pub pda_account: TridentAccount, [](https://ackee.xyz/trident/docs/latest/trident-api-macro/attributes-for-accounts/account-attributes/#__codelineno-6-5) }` * * * ### `account(program_id)`[#](https://ackee.xyz/trident/docs/latest/trident-api-macro/attributes-for-accounts/account-attributes/#accountprogram_id "Permanent link") Specifies the program ID for PDA derivation. If not provided, the program ID of the instruction will be used. `This attribute is applied at the field level and is used with seeds` `[](https://ackee.xyz/trident/docs/latest/trident-api-macro/attributes-for-accounts/account-attributes/#__codelineno-7-1) #[derive(TridentAccounts)] [](https://ackee.xyz/trident/docs/latest/trident-api-macro/attributes-for-accounts/account-attributes/#__codelineno-7-2) pub struct ExampleAccounts { [](https://ackee.xyz/trident/docs/latest/trident-api-macro/attributes-for-accounts/account-attributes/#__codelineno-7-3) #[account( [](https://ackee.xyz/trident/docs/latest/trident-api-macro/attributes-for-accounts/account-attributes/#__codelineno-7-4) storage = custom_pda, [](https://ackee.xyz/trident/docs/latest/trident-api-macro/attributes-for-accounts/account-attributes/#__codelineno-7-5) seeds = [b"seed"], [](https://ackee.xyz/trident/docs/latest/trident-api-macro/attributes-for-accounts/account-attributes/#__codelineno-7-6) program_id = pubkey!("11111111111111111111111111111111") [](https://ackee.xyz/trident/docs/latest/trident-api-macro/attributes-for-accounts/account-attributes/#__codelineno-7-7) )] [](https://ackee.xyz/trident/docs/latest/trident-api-macro/attributes-for-accounts/account-attributes/#__codelineno-7-8) pub custom_pda: TridentAccount, [](https://ackee.xyz/trident/docs/latest/trident-api-macro/attributes-for-accounts/account-attributes/#__codelineno-7-9) }` * * * ### `account(lamports)`[#](https://ackee.xyz/trident/docs/latest/trident-api-macro/attributes-for-accounts/account-attributes/#accountlamports "Permanent link") Specifies the lamports for the account. If not provided, the default is 500 \* LAMPORTS\_PER\_SOL. `This attribute is optional but requires the storage attribute` `[](https://ackee.xyz/trident/docs/latest/trident-api-macro/attributes-for-accounts/account-attributes/#__codelineno-8-1) #[derive(TridentAccounts)] [](https://ackee.xyz/trident/docs/latest/trident-api-macro/attributes-for-accounts/account-attributes/#__codelineno-8-2) pub struct ExampleAccounts { [](https://ackee.xyz/trident/docs/latest/trident-api-macro/attributes-for-accounts/account-attributes/#__codelineno-8-3) #[account( [](https://ackee.xyz/trident/docs/latest/trident-api-macro/attributes-for-accounts/account-attributes/#__codelineno-8-4) storage = custom_pda, [](https://ackee.xyz/trident/docs/latest/trident-api-macro/attributes-for-accounts/account-attributes/#__codelineno-8-5) lamports = 5 * LAMPORTS_PER_SOL [](https://ackee.xyz/trident/docs/latest/trident-api-macro/attributes-for-accounts/account-attributes/#__codelineno-8-6) )] [](https://ackee.xyz/trident/docs/latest/trident-api-macro/attributes-for-accounts/account-attributes/#__codelineno-8-7) pub wallet: TridentAccount, [](https://ackee.xyz/trident/docs/latest/trident-api-macro/attributes-for-accounts/account-attributes/#__codelineno-8-8) }` * * * ### `account(space)`[#](https://ackee.xyz/trident/docs/latest/trident-api-macro/attributes-for-accounts/account-attributes/#accountspace "Permanent link") Specifies the space for the account. If not provided, the default is 0. `This attribute is optional but requires the storage attribute and owner attribute` `[](https://ackee.xyz/trident/docs/latest/trident-api-macro/attributes-for-accounts/account-attributes/#__codelineno-9-1) #[derive(TridentAccounts)] [](https://ackee.xyz/trident/docs/latest/trident-api-macro/attributes-for-accounts/account-attributes/#__codelineno-9-2) pub struct ExampleAccounts { [](https://ackee.xyz/trident/docs/latest/trident-api-macro/attributes-for-accounts/account-attributes/#__codelineno-9-3) #[account( [](https://ackee.xyz/trident/docs/latest/trident-api-macro/attributes-for-accounts/account-attributes/#__codelineno-9-4) storage = custom_pda, [](https://ackee.xyz/trident/docs/latest/trident-api-macro/attributes-for-accounts/account-attributes/#__codelineno-9-5) space = 8 + 100, [](https://ackee.xyz/trident/docs/latest/trident-api-macro/attributes-for-accounts/account-attributes/#__codelineno-9-6) owner = pubkey!("program id goes here") [](https://ackee.xyz/trident/docs/latest/trident-api-macro/attributes-for-accounts/account-attributes/#__codelineno-9-7) )] [](https://ackee.xyz/trident/docs/latest/trident-api-macro/attributes-for-accounts/account-attributes/#__codelineno-9-8) pub custom_pda: TridentAccount, [](https://ackee.xyz/trident/docs/latest/trident-api-macro/attributes-for-accounts/account-attributes/#__codelineno-9-9) }` * * * ### `account(owner)`[#](https://ackee.xyz/trident/docs/latest/trident-api-macro/attributes-for-accounts/account-attributes/#accountowner "Permanent link") Specifies the owner for the account. If not provided, the system program is the default. `This attribute is optional but requires the storage attribute` `[](https://ackee.xyz/trident/docs/latest/trident-api-macro/attributes-for-accounts/account-attributes/#__codelineno-10-1) #[derive(TridentAccounts)] [](https://ackee.xyz/trident/docs/latest/trident-api-macro/attributes-for-accounts/account-attributes/#__codelineno-10-2) pub struct ExampleAccounts { [](https://ackee.xyz/trident/docs/latest/trident-api-macro/attributes-for-accounts/account-attributes/#__codelineno-10-3) #[account( [](https://ackee.xyz/trident/docs/latest/trident-api-macro/attributes-for-accounts/account-attributes/#__codelineno-10-4) storage = custom_pda, [](https://ackee.xyz/trident/docs/latest/trident-api-macro/attributes-for-accounts/account-attributes/#__codelineno-10-5) owner = pubkey!("program id goes here") [](https://ackee.xyz/trident/docs/latest/trident-api-macro/attributes-for-accounts/account-attributes/#__codelineno-10-6) )] [](https://ackee.xyz/trident/docs/latest/trident-api-macro/attributes-for-accounts/account-attributes/#__codelineno-10-7) pub custom_pda: TridentAccount, [](https://ackee.xyz/trident/docs/latest/trident-api-macro/attributes-for-accounts/account-attributes/#__codelineno-10-8) }` Back to top --- # Instruction Hooks - Trident [Skip to content](https://ackee.xyz/trident/docs/latest/trident-api-macro/hooks/instruction-hooks/#instruction-hooks) Instruction Hooks[#](https://ackee.xyz/trident/docs/latest/trident-api-macro/hooks/instruction-hooks/#instruction-hooks "Permanent link") ========================================================================================================================================== These methods can be overridden to customize instruction behavior during fuzzing. ### `set_data`[#](https://ackee.xyz/trident/docs/latest/trident-api-macro/hooks/instruction-hooks/#set_data "Permanent link") Override this method to customize how instruction data is set during fuzzing. `[](https://ackee.xyz/trident/docs/latest/trident-api-macro/hooks/instruction-hooks/#__codelineno-0-1) fn set_data(&mut self, trident: &mut Trident, fuzz_accounts: &mut Self::IxAccounts) { [](https://ackee.xyz/trident/docs/latest/trident-api-macro/hooks/instruction-hooks/#__codelineno-0-2) // Custom data setting logic [](https://ackee.xyz/trident/docs/latest/trident-api-macro/hooks/instruction-hooks/#__codelineno-0-3) }` * * * ### `set_accounts`[#](https://ackee.xyz/trident/docs/latest/trident-api-macro/hooks/instruction-hooks/#set_accounts "Permanent link") Override this method to customize how instruction accounts are set during fuzzing. `[](https://ackee.xyz/trident/docs/latest/trident-api-macro/hooks/instruction-hooks/#__codelineno-1-1) fn set_accounts(&mut self, trident: &mut Trident, fuzz_accounts: &mut Self::IxAccounts) { [](https://ackee.xyz/trident/docs/latest/trident-api-macro/hooks/instruction-hooks/#__codelineno-1-2) // Custom account setting logic [](https://ackee.xyz/trident/docs/latest/trident-api-macro/hooks/instruction-hooks/#__codelineno-1-3) }` * * * ### `set_remaining_accounts`[#](https://ackee.xyz/trident/docs/latest/trident-api-macro/hooks/instruction-hooks/#set_remaining_accounts "Permanent link") Override this method to customize how remaining accounts are set during fuzzing. `[](https://ackee.xyz/trident/docs/latest/trident-api-macro/hooks/instruction-hooks/#__codelineno-2-1) fn set_remaining_accounts( [](https://ackee.xyz/trident/docs/latest/trident-api-macro/hooks/instruction-hooks/#__codelineno-2-2) &mut self, [](https://ackee.xyz/trident/docs/latest/trident-api-macro/hooks/instruction-hooks/#__codelineno-2-3) trident: &mut Trident, [](https://ackee.xyz/trident/docs/latest/trident-api-macro/hooks/instruction-hooks/#__codelineno-2-4) fuzz_accounts: &mut Self::IxAccounts, [](https://ackee.xyz/trident/docs/latest/trident-api-macro/hooks/instruction-hooks/#__codelineno-2-5) ) { [](https://ackee.xyz/trident/docs/latest/trident-api-macro/hooks/instruction-hooks/#__codelineno-2-6) // Custom remaining accounts setting logic [](https://ackee.xyz/trident/docs/latest/trident-api-macro/hooks/instruction-hooks/#__codelineno-2-7) }` * * * Back to top --- # Typed Accounts - Trident [Skip to content](https://ackee.xyz/trident/docs/latest/trident-advanced/trident-transactions/transaction-hooks/typed-accounts/#typed-accounts) Typed Accounts[#](https://ackee.xyz/trident/docs/latest/trident-advanced/trident-transactions/transaction-hooks/typed-accounts/#typed-accounts "Permanent link") ================================================================================================================================================================= If you need to work with `data accounts` in the `Transaction hooks`, you will first need to deserialize the accounts. For deserialization into known structs, Trident generates `types.rs`, where each struct derives `BorshDeserialize` and `BorshSerialize`. Serialization/Deserialization * If you use custom Serialization/Deserialization, you will need to add it also to the `types.rs` file. Example[#](https://ackee.xyz/trident/docs/latest/trident-advanced/trident-transactions/transaction-hooks/typed-accounts/#example "Permanent link") --------------------------------------------------------------------------------------------------------------------------------------------------- The following example demonstrates: * Obtaining example data account after the transaction, with `.get_snapshot_after()` (post transaction snapshot) * `.data_no_discriminator()` ensures that the first 8 bytes (account discriminator) are not included in the deserialization * Deserializing the data account into the `ExampleDataAccount` struct `[](https://ackee.xyz/trident/docs/latest/trident-advanced/trident-transactions/transaction-hooks/typed-accounts/#__codelineno-0-1) // types.rs [](https://ackee.xyz/trident/docs/latest/trident-advanced/trident-transactions/transaction-hooks/typed-accounts/#__codelineno-0-2) #[derive(Arbitrary, Debug, BorshDeserialize, BorshSerialize, Clone)] [](https://ackee.xyz/trident/docs/latest/trident-advanced/trident-transactions/transaction-hooks/typed-accounts/#__codelineno-0-3) pub struct ExampleDataAccount { [](https://ackee.xyz/trident/docs/latest/trident-advanced/trident-transactions/transaction-hooks/typed-accounts/#__codelineno-0-4) pub data: u64, [](https://ackee.xyz/trident/docs/latest/trident-advanced/trident-transactions/transaction-hooks/typed-accounts/#__codelineno-0-5) }` `[](https://ackee.xyz/trident/docs/latest/trident-advanced/trident-transactions/transaction-hooks/typed-accounts/#__codelineno-1-1) // example_transaction.rs [](https://ackee.xyz/trident/docs/latest/trident-advanced/trident-transactions/transaction-hooks/typed-accounts/#__codelineno-1-2)[](https://ackee.xyz/trident/docs/latest/trident-advanced/trident-transactions/transaction-hooks/typed-accounts/#__codelineno-1-3) #[derive(Arbitrary, Debug, TridentTransaction)] [](https://ackee.xyz/trident/docs/latest/trident-advanced/trident-transactions/transaction-hooks/typed-accounts/#__codelineno-1-4) pub struct ExampleTransaction { [](https://ackee.xyz/trident/docs/latest/trident-advanced/trident-transactions/transaction-hooks/typed-accounts/#__codelineno-1-5) pub instruction: ExampleInstruction, [](https://ackee.xyz/trident/docs/latest/trident-advanced/trident-transactions/transaction-hooks/typed-accounts/#__codelineno-1-6) } [](https://ackee.xyz/trident/docs/latest/trident-advanced/trident-transactions/transaction-hooks/typed-accounts/#__codelineno-1-7)[](https://ackee.xyz/trident/docs/latest/trident-advanced/trident-transactions/transaction-hooks/typed-accounts/#__codelineno-1-8) impl TransactionHooks for ExampleTransaction { [](https://ackee.xyz/trident/docs/latest/trident-advanced/trident-transactions/transaction-hooks/typed-accounts/#__codelineno-1-9) fn post_transaction(&self, client: &mut impl FuzzClient) { [](https://ackee.xyz/trident/docs/latest/trident-advanced/trident-transactions/transaction-hooks/typed-accounts/#__codelineno-1-10) // Take account [](https://ackee.xyz/trident/docs/latest/trident-advanced/trident-transactions/transaction-hooks/typed-accounts/#__codelineno-1-11) let example_account = [](https://ackee.xyz/trident/docs/latest/trident-advanced/trident-transactions/transaction-hooks/typed-accounts/#__codelineno-1-12) self.instruction.accounts.example_data_account.get_snapshot_after(); [](https://ackee.xyz/trident/docs/latest/trident-advanced/trident-transactions/transaction-hooks/typed-accounts/#__codelineno-1-13) [](https://ackee.xyz/trident/docs/latest/trident-advanced/trident-transactions/transaction-hooks/typed-accounts/#__codelineno-1-14) // obtain data without the first 8 bytes (account discriminator) and [](https://ackee.xyz/trident/docs/latest/trident-advanced/trident-transactions/transaction-hooks/typed-accounts/#__codelineno-1-15) // deserialize the data [](https://ackee.xyz/trident/docs/latest/trident-advanced/trident-transactions/transaction-hooks/typed-accounts/#__codelineno-1-16) let example_account = [](https://ackee.xyz/trident/docs/latest/trident-advanced/trident-transactions/transaction-hooks/typed-accounts/#__codelineno-1-17) ExampleDataAccount::deserialize( [](https://ackee.xyz/trident/docs/latest/trident-advanced/trident-transactions/transaction-hooks/typed-accounts/#__codelineno-1-18) &mut example_account.data_no_discriminator() [](https://ackee.xyz/trident/docs/latest/trident-advanced/trident-transactions/transaction-hooks/typed-accounts/#__codelineno-1-19) ).unwrap(); [](https://ackee.xyz/trident/docs/latest/trident-advanced/trident-transactions/transaction-hooks/typed-accounts/#__codelineno-1-20) [](https://ackee.xyz/trident/docs/latest/trident-advanced/trident-transactions/transaction-hooks/typed-accounts/#__codelineno-1-21) // your additional custom code here ... [](https://ackee.xyz/trident/docs/latest/trident-advanced/trident-transactions/transaction-hooks/typed-accounts/#__codelineno-1-22) } [](https://ackee.xyz/trident/docs/latest/trident-advanced/trident-transactions/transaction-hooks/typed-accounts/#__codelineno-1-23) }` Back to top --- # Transaction Hooks - Trident [Skip to content](https://ackee.xyz/trident/docs/latest/trident-api-macro/hooks/transaction-hooks/#transaction-hooks) Transaction Hooks[#](https://ackee.xyz/trident/docs/latest/trident-api-macro/hooks/transaction-hooks/#transaction-hooks "Permanent link") ========================================================================================================================================== These methods can be overridden to customize transaction behavior during fuzzing. ### `pre_transaction`[#](https://ackee.xyz/trident/docs/latest/trident-api-macro/hooks/transaction-hooks/#pre_transaction "Permanent link") Override this method to perform custom actions before the transaction is executed. `[](https://ackee.xyz/trident/docs/latest/trident-api-macro/hooks/transaction-hooks/#__codelineno-0-1) fn pre_transaction(&self, client: &mut impl FuzzClient) { [](https://ackee.xyz/trident/docs/latest/trident-api-macro/hooks/transaction-hooks/#__codelineno-0-2) // Custom pre-transaction logic [](https://ackee.xyz/trident/docs/latest/trident-api-macro/hooks/transaction-hooks/#__codelineno-0-3) // e.g., set up accounts, perform checks, etc. [](https://ackee.xyz/trident/docs/latest/trident-api-macro/hooks/transaction-hooks/#__codelineno-0-4) }` * * * ### `post_transaction`[#](https://ackee.xyz/trident/docs/latest/trident-api-macro/hooks/transaction-hooks/#post_transaction "Permanent link") Override this method to perform custom actions after the transaction is executed. `[](https://ackee.xyz/trident/docs/latest/trident-api-macro/hooks/transaction-hooks/#__codelineno-1-1) fn post_transaction(&self, client: &mut impl FuzzClient) { [](https://ackee.xyz/trident/docs/latest/trident-api-macro/hooks/transaction-hooks/#__codelineno-1-2) // Custom post-transaction logic [](https://ackee.xyz/trident/docs/latest/trident-api-macro/hooks/transaction-hooks/#__codelineno-1-3) // e.g., cleanup, additional checks, etc. [](https://ackee.xyz/trident/docs/latest/trident-api-macro/hooks/transaction-hooks/#__codelineno-1-4) }` * * * ### `transaction_invariant_check`[#](https://ackee.xyz/trident/docs/latest/trident-api-macro/hooks/transaction-hooks/#transaction_invariant_check "Permanent link") Override this method to perform custom invariant checks on the transaction results. `[](https://ackee.xyz/trident/docs/latest/trident-api-macro/hooks/transaction-hooks/#__codelineno-2-1) fn transaction_invariant_check(&self) -> Result<(), FuzzingError> { [](https://ackee.xyz/trident/docs/latest/trident-api-macro/hooks/transaction-hooks/#__codelineno-2-2) // Custom invariant checks [](https://ackee.xyz/trident/docs/latest/trident-api-macro/hooks/transaction-hooks/#__codelineno-2-3) // Return Err(FuzzingError) if invariants are violated [](https://ackee.xyz/trident/docs/latest/trident-api-macro/hooks/transaction-hooks/#__codelineno-2-4) Ok(()) [](https://ackee.xyz/trident/docs/latest/trident-api-macro/hooks/transaction-hooks/#__codelineno-2-5) }` **Returns:** * `Ok(())` if all invariants pass * `Err(FuzzingError)` if any invariant is violated * * * ### `transaction_error_handler`[#](https://ackee.xyz/trident/docs/latest/trident-api-macro/hooks/transaction-hooks/#transaction_error_handler "Permanent link") Override this method to handle transaction errors with custom logic. `[](https://ackee.xyz/trident/docs/latest/trident-api-macro/hooks/transaction-hooks/#__codelineno-3-1) fn transaction_error_handler(&self, error: TransactionError) { [](https://ackee.xyz/trident/docs/latest/trident-api-macro/hooks/transaction-hooks/#__codelineno-3-2) // Custom error handling logic [](https://ackee.xyz/trident/docs/latest/trident-api-macro/hooks/transaction-hooks/#__codelineno-3-3) // e.g., logging, state cleanup, etc. [](https://ackee.xyz/trident/docs/latest/trident-api-macro/hooks/transaction-hooks/#__codelineno-3-4) }` * * * Back to top --- # Trident - Trident [Skip to content](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident/trident/#trident) Trident[#](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident/trident/#trident "Permanent link") ============================================================================================================== The `Trident` struct is the main orchestrator for fuzzing operations. It manages the fuzzing client, random number generation, and provides methods for executing transactions and collecting metrics. `[](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident/trident/#__codelineno-0-1) pub struct Trident { [](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident/trident/#__codelineno-0-2) client: TridentSVM, [](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident/trident/#__codelineno-0-3) fuzzing_data: TridentFuzzingData, [](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident/trident/#__codelineno-0-4) rng: TridentRng, [](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident/trident/#__codelineno-0-5) }` Core Methods[#](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident/trident/#core-methods "Permanent link") ------------------------------------------------------------------------------------------------------------------------ ### `execute_transaction`[#](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident/trident/#execute_transaction "Permanent link") Executes a transaction with all transaction hooks enabled, including pre/post transaction hooks and error handling. `[](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident/trident/#__codelineno-1-1) pub fn execute_transaction( [](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident/trident/#__codelineno-1-2) &mut self, [](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident/trident/#__codelineno-1-3) transaction: &mut T, [](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident/trident/#__codelineno-1-4) transaction_name_override: Option<&str>, [](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident/trident/#__codelineno-1-5) ) where [](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident/trident/#__codelineno-1-6) T: TransactionHooks + TransactionGetters + TransactionSetters + TransactionPrivateMethods + std::fmt::Debug` **Parameters:** - `transaction` - The transaction to execute - `transaction_name_override` - Optional custom name for the transaction (used in metrics) * * * ### `get_client`[#](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident/trident/#get_client "Permanent link") Returns a mutable reference to the underlying fuzzing client. `[](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident/trident/#__codelineno-2-1) pub fn get_client(&mut self) -> &mut impl FuzzClient` * * * ### `airdrop`[#](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident/trident/#airdrop "Permanent link") Adds lamports to the specified account address. `[](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident/trident/#__codelineno-3-1) pub fn airdrop(&mut self, address: &Pubkey, amount: u64)` **Parameters:** - `address` - The account to receive the lamports - `amount` - The number of lamports to add * * * Random Number Generation Methods[#](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident/trident/#random-number-generation-methods "Permanent link") ---------------------------------------------------------------------------------------------------------------------------------------------------------------- ### `gen_range`[#](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident/trident/#gen_range "Permanent link") Generates a random number within the specified range. `[](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident/trident/#__codelineno-4-1) pub fn gen_range(&mut self, range: R) -> T [](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident/trident/#__codelineno-4-2) where [](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident/trident/#__codelineno-4-3) T: SampleUniform, [](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident/trident/#__codelineno-4-4) R: SampleRange` * * * ### `gen_pubkey`[#](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident/trident/#gen_pubkey "Permanent link") Generates a random public key. `[](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident/trident/#__codelineno-5-1) pub fn gen_pubkey(&mut self) -> Pubkey` * * * ### `gen_string`[#](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident/trident/#gen_string "Permanent link") Generates a random string of the specified length. `[](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident/trident/#__codelineno-6-1) pub fn gen_string(&mut self, length: usize) -> String` * * * ### `fill_bytes`[#](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident/trident/#fill_bytes "Permanent link") Fills the provided byte array with random data. `[](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident/trident/#__codelineno-7-1) pub fn fill_bytes(&mut self, bytes: &mut [u8])` * * * Metrics Methods[#](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident/trident/#metrics-methods "Permanent link") ------------------------------------------------------------------------------------------------------------------------------ ### `add_histogram_metric`[#](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident/trident/#add_histogram_metric "Permanent link") Adds a value to a histogram metric. Only records if the fuzzing metrics are enabled. `[](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident/trident/#__codelineno-8-1) pub fn add_histogram_metric(&mut self, metric_name: &str, value: f64)` * * * ### `add_accumulator_metric`[#](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident/trident/#add_accumulator_metric "Permanent link") Adds a value to an accumulator metric. Only records if the fuzzing metrics are enabled. `[](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident/trident/#__codelineno-9-1) pub fn add_accumulator_metric(&mut self, metric_name: &str, value: f64)` * * * Regression Testing Methods[#](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident/trident/#regression-testing-methods "Permanent link") ---------------------------------------------------------------------------------------------------------------------------------------------------- ### `add_to_regression`[#](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident/trident/#add_to_regression "Permanent link") Adds an account to the regression test. Only records if the fuzzing regression is enabled. `[](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident/trident/#__codelineno-10-1) pub fn add_to_regression(&mut self, account: &Pubkey, account_name: &str)` * * * Back to top --- # Trident's Fuzz Client - Trident [Skip to content](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-fuzz-client/fuzz-client-trait/#tridents-fuzz-client) Trident's Fuzz Client[#](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-fuzz-client/fuzz-client-trait/#tridents-fuzz-client "Permanent link") =============================================================================================================================================================== Trident's Client (`FuzzClient`) is a wrapper around the [TridentSVM](https://ackee.xyz/trident/docs/latest/trident-svm/) that provides methods to manipulate the execution environment during fuzzing. This section describes the methods that are available in the `FuzzClient`. Trident Client Methods[#](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-fuzz-client/fuzz-client-trait/#trident-client-methods "Permanent link") ------------------------------------------------------------------------------------------------------------------------------------------------------------------ ### `deploy_entrypoint`[#](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-fuzz-client/fuzz-client-trait/#deploy_entrypoint "Permanent link") Syscalls Feature Requirement This method is only available if the `syscall-v1` or `syscall-v2` features are enabled. Deploys a program through its entrypoint. `[](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-fuzz-client/fuzz-client-trait/#__codelineno-0-1) fn deploy_entrypoint(&mut self, program: TridentEntrypoint)` * * * ### `deploy_program`[#](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-fuzz-client/fuzz-client-trait/#deploy_program "Permanent link") Deploys a program as binary. `[](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-fuzz-client/fuzz-client-trait/#__codelineno-1-1) fn deploy_program(&mut self, program: TridentProgram)` * * * ### `get_sysvar`[#](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-fuzz-client/fuzz-client-trait/#get_sysvar "Permanent link") Retrieves `Sysvars` like `Rent`, `Clock`, etc. `[](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-fuzz-client/fuzz-client-trait/#__codelineno-2-1) fn get_sysvar(&self) -> T` * * * ### `warp_to_epoch`[#](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-fuzz-client/fuzz-client-trait/#warp_to_epoch "Permanent link") Advances the fuzz test to a specific epoch. `[](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-fuzz-client/fuzz-client-trait/#__codelineno-3-1) fn warp_to_epoch(&mut self, warp_epoch: u64)` * * * ### `warp_to_slot`[#](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-fuzz-client/fuzz-client-trait/#warp_to_slot "Permanent link") Advances the fuzz test to a specific slot. `[](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-fuzz-client/fuzz-client-trait/#__codelineno-4-1) fn warp_to_slot(&mut self, warp_slot: u64)` * * * ### `warp_to_timestamp`[#](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-fuzz-client/fuzz-client-trait/#warp_to_timestamp "Permanent link") Sets the fuzz test to a specific timestamp. `[](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-fuzz-client/fuzz-client-trait/#__codelineno-5-1) fn warp_to_timestamp(&mut self, warp_timestamp: i64)` * * * ### `forward_in_time`[#](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-fuzz-client/fuzz-client-trait/#forward_in_time "Permanent link") Advances the fuzz test by the specified number of seconds. `[](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-fuzz-client/fuzz-client-trait/#__codelineno-6-1) fn forward_in_time(&mut self, seconds: i64)` * * * ### `set_account_custom`[#](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-fuzz-client/fuzz-client-trait/#set_account_custom "Permanent link") Creates or overwrites an account at the specified address, bypassing normal runtime checks. `[](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-fuzz-client/fuzz-client-trait/#__codelineno-7-1) fn set_account_custom(&mut self, address: &Pubkey, account: &AccountSharedData)` * * * ### `get_account`[#](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-fuzz-client/fuzz-client-trait/#get_account "Permanent link") Retrieves the account data at the specified address. `[](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-fuzz-client/fuzz-client-trait/#__codelineno-8-1) fn get_account(&mut self, key: &Pubkey) -> AccountSharedData` * * * ### `payer`[#](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-fuzz-client/fuzz-client-trait/#payer "Permanent link") Returns the keypair of the client's payer account. `[](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-fuzz-client/fuzz-client-trait/#__codelineno-9-1) fn payer(&self) -> Keypair` * * * ### `get_last_blockhash`[#](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-fuzz-client/fuzz-client-trait/#get_last_blockhash "Permanent link") Retrieves the most recent blockhash. Warning Currently, this method is not implemented and a call to this method will result in a panic. `[](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-fuzz-client/fuzz-client-trait/#__codelineno-10-1) fn get_last_blockhash(&self) -> Hash` Back to top --- # TridentAccounts - Trident [Skip to content](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-macros/trident-accounts/#tridentaccounts) TridentAccounts[#](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-macros/trident-accounts/#tridentaccounts "Permanent link") ============================================================================================================================================== The `TridentAccounts` macro is used to derive required methods for account structures. Derived Traits[#](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-macros/trident-accounts/#derived-traits "Permanent link") -------------------------------------------------------------------------------------------------------------------------------------------- The macro implements the following trait: * `AccountsMethods` - Methods to resolve accounts Manual Implementation Note There is no need to manually implement any methods of this trait. The macro handles all implementations automatically based on the account structure and attributes. Accounts Methods[#](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-macros/trident-accounts/#accounts-methods "Permanent link") ------------------------------------------------------------------------------------------------------------------------------------------------ Internal Method These methods are used internally by Trident and it is not expected to use them manually. ### `resolve_accounts`[#](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-macros/trident-accounts/#resolve_accounts "Permanent link") Resolves all accounts based on their constraints and dependencies. The macro automatically analyzes seed dependencies and sorts fields in the correct resolution order. `[](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-macros/trident-accounts/#__codelineno-0-1) fn resolve_accounts( [](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-macros/trident-accounts/#__codelineno-0-2) &mut self, [](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-macros/trident-accounts/#__codelineno-0-3) trident: &mut Trident, [](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-macros/trident-accounts/#__codelineno-0-4) ix_accounts: &mut Self::IxAccounts, [](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-macros/trident-accounts/#__codelineno-0-5) program_id: Pubkey, [](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-macros/trident-accounts/#__codelineno-0-6) instruction_data: &Self::IxData, [](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-macros/trident-accounts/#__codelineno-0-7) )` * * * ### `to_account_meta`[#](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-macros/trident-accounts/#to_account_meta "Permanent link") Converts all accounts to AccountMeta format for Solana instructions. `[](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-macros/trident-accounts/#__codelineno-1-1) fn to_account_meta(&mut self) -> Vec` * * * ### `capture_before`[#](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-macros/trident-accounts/#capture_before "Permanent link") Captures the state of accounts before transaction execution. `[](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-macros/trident-accounts/#__codelineno-2-1) fn capture_before(&mut self, client: &mut impl FuzzClient)` * * * ### `capture_after`[#](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-macros/trident-accounts/#capture_after "Permanent link") Captures the state of accounts after transaction execution. `[](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-macros/trident-accounts/#__codelineno-3-1) fn capture_after(&mut self, client: &mut impl FuzzClient)` * * * Struct-Level Attributes[#](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-macros/trident-accounts/#struct-level-attributes "Permanent link") -------------------------------------------------------------------------------------------------------------------------------------------------------------- These attributes are applied to the struct definition itself. ### `instruction_data`[#](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-macros/trident-accounts/#instruction_data "Permanent link") Specifies the instruction data type that will be used with these accounts. `This attribute is mandatory and applied at the struct level` `[](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-macros/trident-accounts/#__codelineno-4-1) #[derive(TridentAccounts)] [](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-macros/trident-accounts/#__codelineno-4-2) #[instruction_data(ExampleInstructionData)] [](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-macros/trident-accounts/#__codelineno-4-3) pub struct ExampleAccounts { [](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-macros/trident-accounts/#__codelineno-4-4) // fields... [](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-macros/trident-accounts/#__codelineno-4-5) }` * * * ### `storage`[#](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-macros/trident-accounts/#storage "Permanent link") Specifies the storage type for accounts, which is used to manage account state during fuzzing. `This attribute is mandatory and applied at the struct level` `[](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-macros/trident-accounts/#__codelineno-5-1) #[derive(TridentAccounts)] [](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-macros/trident-accounts/#__codelineno-5-2) #[storage(ExampleStorage)] [](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-macros/trident-accounts/#__codelineno-5-3) pub struct ExampleAccounts { [](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-macros/trident-accounts/#__codelineno-5-4) // fields... [](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-macros/trident-accounts/#__codelineno-5-5) }` * * * Back to top --- # TridentInstruction - Trident [Skip to content](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-macros/trident-instruction/#tridentinstruction) TridentInstruction[#](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-macros/trident-instruction/#tridentinstruction "Permanent link") ======================================================================================================================================================= The `TridentInstruction` macro is used to derive required methods for `Instructions`. This procedural macro automatically implements instruction-related functionality for structs that represent instructions. Required Field Names The macro parser strictly requires the struct to have an `accounts` field named exactly `accounts`. If a remaining accounts field is used, it must be named exactly `remaining_accounts`. Derived Traits[#](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-macros/trident-instruction/#derived-traits "Permanent link") ----------------------------------------------------------------------------------------------------------------------------------------------- The macro implements the following traits: * `InstructionGetters` - Methods to retrieve instruction data * `InstructionSetters` - Methods to set up instruction state Manual Implementation Note There is no need to manually implement the getter, setter, or hook methods. The macro handles these implementations automatically based on the structure of your instruction. Instruction Getters[#](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-macros/trident-instruction/#instruction-getters "Permanent link") --------------------------------------------------------------------------------------------------------------------------------------------------------- Internal Method These methods are used internally by Trident and it is not expected to use them manually. ### `get_discriminator`[#](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-macros/trident-instruction/#get_discriminator "Permanent link") Returns the instruction discriminator (identifier bytes) that uniquely identifies this instruction of the program. `[](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-macros/trident-instruction/#__codelineno-0-1) fn get_discriminator(&self) -> Vec` * * * ### `get_program_id`[#](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-macros/trident-instruction/#get_program_id "Permanent link") Returns the program ID that will process this instruction. `[](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-macros/trident-instruction/#__codelineno-1-1) fn get_program_id(&self) -> solana_sdk::pubkey::Pubkey` * * * ### `to_account_metas`[#](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-macros/trident-instruction/#to_account_metas "Permanent link") Converts all accounts to AccountMeta format for Solana instructions. `[](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-macros/trident-instruction/#__codelineno-2-1) fn to_account_metas(&mut self) -> Vec` * * * Instruction Setters[#](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-macros/trident-instruction/#instruction-setters "Permanent link") --------------------------------------------------------------------------------------------------------------------------------------------------------- Internal Method These methods are used internally by Trident and it is not expected to use them manually. ### `set_snapshot_before`[#](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-macros/trident-instruction/#set_snapshot_before "Permanent link") Captures the state of all accounts before instruction execution. `[](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-macros/trident-instruction/#__codelineno-3-1) fn set_snapshot_before(&mut self, client: &mut impl FuzzClient)` * * * ### `set_snapshot_after`[#](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-macros/trident-instruction/#set_snapshot_after "Permanent link") Captures the state of all accounts after instruction execution. `[](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-macros/trident-instruction/#__codelineno-4-1) fn set_snapshot_after(&mut self, client: &mut impl FuzzClient)` * * * ### `resolve_accounts`[#](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-macros/trident-instruction/#resolve_accounts "Permanent link") Resolves all accounts needed for this instruction. `[](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-macros/trident-instruction/#__codelineno-5-1) fn resolve_accounts( [](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-macros/trident-instruction/#__codelineno-5-2) &mut self, [](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-macros/trident-instruction/#__codelineno-5-3) client: &mut impl FuzzClient, [](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-macros/trident-instruction/#__codelineno-5-4) fuzz_accounts: &mut Self::IxAccounts, [](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-macros/trident-instruction/#__codelineno-5-5) )` * * * Struct-Level Attributes[#](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-macros/trident-instruction/#struct-level-attributes "Permanent link") ----------------------------------------------------------------------------------------------------------------------------------------------------------------- These attributes are applied to the struct definition itself. ### `program_id`[#](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-macros/trident-instruction/#program_id "Permanent link") Specifies the program ID that will process this instruction. This can be provided as a string literal containing a base58-encoded public key. `This attribute is mandatory` `[](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-macros/trident-instruction/#__codelineno-6-1) #[derive(Arbitrary, Debug, TridentInstruction)] [](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-macros/trident-instruction/#__codelineno-6-2) #[program_id("KLend2g3cP87fffoy8q1mQqGKjrxjC8boSyAYavgmjD")] [](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-macros/trident-instruction/#__codelineno-6-3) pub struct ExampleInstruction { [](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-macros/trident-instruction/#__codelineno-6-4) pub accounts: ExampleInstructionAccounts, [](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-macros/trident-instruction/#__codelineno-6-5) pub data: ExampleInstructionData, [](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-macros/trident-instruction/#__codelineno-6-6) }` * * * ### `discriminator`[#](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-macros/trident-instruction/#discriminator "Permanent link") Specifies the instruction discriminator bytes that uniquely identify this instruction to the program. This is typically an 8-byte array. `This attribute is mandatory` `[](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-macros/trident-instruction/#__codelineno-7-1) #[derive(Arbitrary, Debug, TridentInstruction)] [](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-macros/trident-instruction/#__codelineno-7-2) #[discriminator([33u8, 132u8, 147u8, 228u8, 151u8, 192u8, 72u8, 89u8])] [](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-macros/trident-instruction/#__codelineno-7-3) pub struct ExampleInstruction { [](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-macros/trident-instruction/#__codelineno-7-4) pub accounts: ExampleInstructionAccounts, [](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-macros/trident-instruction/#__codelineno-7-5) pub data: ExampleInstructionData, [](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-macros/trident-instruction/#__codelineno-7-6) }` Back to top --- # TridentRemainingAccounts - Trident [Skip to content](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-macros/trident-remaining-accounts/#tridentremainingaccounts) TridentRemainingAccounts[#](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-macros/trident-remaining-accounts/#tridentremainingaccounts "Permanent link") ========================================================================================================================================================================== The `TridentRemainingAccounts` macro is used to derive required methods for `remaining account structures`. The struct must have exactly one field that holds the remaining accounts and is of type `[TridentAccount; X]`, with `X` being the number of remaining accounts, required. `[](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-macros/trident-remaining-accounts/#__codelineno-0-1) #[derive(Arbitrary, Debug, TridentRemainingAccounts)] [](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-macros/trident-remaining-accounts/#__codelineno-0-2) pub struct ExampleRemainingAccounts { [](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-macros/trident-remaining-accounts/#__codelineno-0-3) pub remaining_accounts: [TridentAccount; 2], [](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-macros/trident-remaining-accounts/#__codelineno-0-4) }` Derived Traits[#](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-macros/trident-remaining-accounts/#derived-traits "Permanent link") ------------------------------------------------------------------------------------------------------------------------------------------------------ The macro implements the following trait: * `RemainingAccountsMethods` - Methods to resolve remaining accounts Manual Implementation Note There is no need to manually implement any methods of this trait. The macro handles all implementations automatically based on the account structure and attributes. Dynamic Sizing Behavior The macro will only process accounts until it encounters the first unset remaining account. This allows for dynamic sizing of remaining accounts. Remaining Accounts Methods[#](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-macros/trident-remaining-accounts/#remaining-accounts-methods "Permanent link") ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ Internal Method These methods are used internally by Trident and it is not expected to use them manually. The macro implements the `RemainingAccountsMethods` trait with the corresponding methods: ### `to_account_meta`[#](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-macros/trident-remaining-accounts/#to_account_meta "Permanent link") Convert accounts to account metas `[](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-macros/trident-remaining-accounts/#__codelineno-1-1) fn to_account_meta(&mut self) -> Vec;` * * * ### `capture_before`[#](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-macros/trident-remaining-accounts/#capture_before "Permanent link") Capture account state before transaction execution `[](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-macros/trident-remaining-accounts/#__codelineno-2-1) fn capture_before(&mut self, client: &mut impl FuzzClient);` * * * ### `capture_after`[#](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-macros/trident-remaining-accounts/#capture_after "Permanent link") Capture account state after transaction execution `[](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-macros/trident-remaining-accounts/#__codelineno-3-1) fn capture_after(&mut self, client: &mut impl FuzzClient);` Back to top --- # TridentTransaction - Trident [Skip to content](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-macros/trident-transaction/#tridenttransaction) TridentTransaction[#](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-macros/trident-transaction/#tridenttransaction "Permanent link") ======================================================================================================================================================= The `TridentTransaction` macro is used to derive required methods for `Transactions`. This procedural macro automatically implements transaction-related functionality for structs that represent transactions. Derived Traits[#](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-macros/trident-transaction/#derived-traits "Permanent link") ----------------------------------------------------------------------------------------------------------------------------------------------- The macro implements the following traits: * `TransactionGetters` - Methods to retrieve transaction data * `TransactionSetters` - Methods to set up transaction state Manual Implementation Note There is no need to manually implement the TransactionGetters and TransactionSetters. The macro handles these implementations automatically based on the structure of your transaction. Transaction Getters[#](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-macros/trident-transaction/#transaction-getters "Permanent link") --------------------------------------------------------------------------------------------------------------------------------------------------------- Internal Method These methods are used internally by Trident and it is not expected to use them manually. ### `get_transaction_name`[#](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-macros/trident-transaction/#get_transaction_name "Permanent link") Returns the name of the transaction. If a custom name is provided via the `#[name("...")]` attribute, that name will be used; otherwise, the struct name is used. `[](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-macros/trident-transaction/#__codelineno-0-1) fn get_transaction_name(&self) -> String` * * * ### `get_instruction_discriminators`[#](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-macros/trident-transaction/#get_instruction_discriminators "Permanent link") Returns the instruction discriminators (identifiers) for all instructions in the transaction. `[](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-macros/trident-transaction/#__codelineno-1-1) fn get_instruction_discriminators(&self) -> Vec>` * * * ### `get_instruction_program_ids`[#](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-macros/trident-transaction/#get_instruction_program_ids "Permanent link") Returns the program IDs that will process the instructions. `[](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-macros/trident-transaction/#__codelineno-2-1) fn get_instruction_program_ids(&self) -> Vec` * * * ### `get_instruction_data`[#](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-macros/trident-transaction/#get_instruction_data "Permanent link") Returns the instruction-specific data/parameters for all instructions in the transaction. `[](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-macros/trident-transaction/#__codelineno-3-1) fn get_instruction_data(&mut self, client: &mut impl FuzzClient) -> Vec>` * * * ### `get_instruction_accounts`[#](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-macros/trident-transaction/#get_instruction_accounts "Permanent link") Returns the account metadata needed for the instructions. `[](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-macros/trident-transaction/#__codelineno-4-1) fn get_instruction_accounts(&mut self, client: &mut impl FuzzClient) -> Vec>` * * * Transaction Setters[#](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-macros/trident-transaction/#transaction-setters "Permanent link") --------------------------------------------------------------------------------------------------------------------------------------------------------- Internal Method `set_snapshot_before`, `set_snapshot_after` and `set_instructions` methods are used internally by Trident and is not expected to use them manually. ### `build`[#](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-macros/trident-transaction/#build "Permanent link") Creates a new transaction instance from fuzzer data. `[](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-macros/trident-transaction/#__codelineno-5-1) fn build(trident: &mut Trident, fuzz_accounts: &mut Self::IxAccounts) -> Self [](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-macros/trident-transaction/#__codelineno-5-2) where [](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-macros/trident-transaction/#__codelineno-5-3) Self: Default` * * * ### `set_snapshot_before`[#](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-macros/trident-transaction/#set_snapshot_before "Permanent link") Captures the state of all accounts before transaction execution. `[](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-macros/trident-transaction/#__codelineno-6-1) fn set_snapshot_before(&mut self, client: &mut impl FuzzClient)` * * * ### `set_snapshot_after`[#](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-macros/trident-transaction/#set_snapshot_after "Permanent link") Captures the state of all accounts after transaction execution. `[](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-macros/trident-transaction/#__codelineno-7-1) fn set_snapshot_after(&mut self, client: &mut impl FuzzClient)` * * * ### `set_instructions`[#](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-macros/trident-transaction/#set_instructions "Permanent link") Sets up all instructions for the transaction. Instruction Setup Order The order in which the instruction inputs are set is: 1. `set_data` - Sets up instruction-specific data 2. `resolve_accounts` - Resolves account addresses 3. `set_accounts` - Sets up account metadata 4. `set_remaining_accounts` - Sets up any additional accounts `[](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-macros/trident-transaction/#__codelineno-8-1) fn set_instructions( [](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-macros/trident-transaction/#__codelineno-8-2) &mut self, [](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-macros/trident-transaction/#__codelineno-8-3) trident: &mut Trident, [](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-macros/trident-transaction/#__codelineno-8-4) fuzz_accounts: &mut Self::IxAccounts, [](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-macros/trident-transaction/#__codelineno-8-5) )` Back to top --- # Custom types - Trident [Skip to content](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-types/custom-types/#custom-types) Custom types[#](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-types/custom-types/#custom-types "Permanent link") =================================================================================================================================== Trident generates custom types within `types.rs` file. These types are taken from the program's IDL. You can add your own custom types to the `types.rs` file, or you can modify existing types. Back to top --- # FuzzAccounts - Trident [Skip to content](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-types/fuzz-accounts/#fuzzaccounts) FuzzAccounts[#](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-types/fuzz-accounts/#fuzzaccounts "Permanent link") ==================================================================================================================================== `FuzzAccounts` is a struct that contains `all the accounts that can be used in the fuzz test` i.e. `storage` for accounts. By default, Trident generates the struct based on the program's IDL, i.e. for each account Trident generates a field in the struct. On demand, you can add your own accounts to the struct, these accounts are meant to be used within the `set_accounts`, `set_remaining_accounts` and potentially within the `set_data` methods, with the corresponding account indexes. `[](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-types/fuzz-accounts/#__codelineno-0-1) pub struct FuzzAccounts { [](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-types/fuzz-accounts/#__codelineno-0-2) pub account1: AccountsStorage, [](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-types/fuzz-accounts/#__codelineno-0-3) pub account2: AccountsStorage, [](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-types/fuzz-accounts/#__codelineno-0-4) pub account3: AccountsStorage, [](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-types/fuzz-accounts/#__codelineno-0-5) pub account4: AccountsStorage, [](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-types/fuzz-accounts/#__codelineno-0-6) pub account5: AccountsStorage, [](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-types/fuzz-accounts/#__codelineno-0-7) pub account6: AccountsStorage, [](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-types/fuzz-accounts/#__codelineno-0-8) /// .... [](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-types/fuzz-accounts/#__codelineno-0-9) }` Implemented Methods[#](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-types/fuzz-accounts/#implemented-methods "Permanent link") -------------------------------------------------------------------------------------------------------------------------------------------------- The following section contains the methods that are available for the `AccountsStorage` struct. ### `is_empty`[#](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-types/fuzz-accounts/#is_empty "Permanent link") Returns true if no accounts are stored. `[](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-types/fuzz-accounts/#__codelineno-1-1) fn is_empty(&self) -> bool` * * * ### `get_or_create`[#](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-types/fuzz-accounts/#get_or_create "Permanent link") Gets an existing account or creates a new one with specified metadata. `[](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-types/fuzz-accounts/#__codelineno-2-1) fn get_or_create( [](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-types/fuzz-accounts/#__codelineno-2-2) &mut self, [](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-types/fuzz-accounts/#__codelineno-2-3) account_id: AccountId, [](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-types/fuzz-accounts/#__codelineno-2-4) trident: &mut Trident, [](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-types/fuzz-accounts/#__codelineno-2-5) seeds: Option, [](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-types/fuzz-accounts/#__codelineno-2-6) account_metadata: Option [](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-types/fuzz-accounts/#__codelineno-2-7) ) -> Pubkey` * * * ### `get_or_create_token_account`[#](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-types/fuzz-accounts/#get_or_create_token_account "Permanent link") Token Feature Requirement This method is only available if the `token` feature is enabled. Creates or retrieves a token account with specified parameters. `[](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-types/fuzz-accounts/#__codelineno-3-1) fn get_or_create_token_account( [](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-types/fuzz-accounts/#__codelineno-3-2) &mut self, [](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-types/fuzz-accounts/#__codelineno-3-3) account_id: AccountId, [](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-types/fuzz-accounts/#__codelineno-3-4) trident: &mut Trident, [](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-types/fuzz-accounts/#__codelineno-3-5) seeds: Option, [](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-types/fuzz-accounts/#__codelineno-3-6) mint: Pubkey, [](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-types/fuzz-accounts/#__codelineno-3-7) owner: Pubkey, [](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-types/fuzz-accounts/#__codelineno-3-8) amount: u64, [](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-types/fuzz-accounts/#__codelineno-3-9) delegate: Option, [](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-types/fuzz-accounts/#__codelineno-3-10) delegated_amount: u64, [](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-types/fuzz-accounts/#__codelineno-3-11) close_authority: Option [](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-types/fuzz-accounts/#__codelineno-3-12) ) -> Pubkey` * * * ### `get_or_create_mint_account`[#](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-types/fuzz-accounts/#get_or_create_mint_account "Permanent link") Token Feature Requirement This method is only available if the `token` feature is enabled. Creates or retrieves a mint account for tokens. `[](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-types/fuzz-accounts/#__codelineno-4-1) fn get_or_create_mint_account( [](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-types/fuzz-accounts/#__codelineno-4-2) &mut self, [](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-types/fuzz-accounts/#__codelineno-4-3) account_id: AccountId, [](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-types/fuzz-accounts/#__codelineno-4-4) trident: &mut Trident, [](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-types/fuzz-accounts/#__codelineno-4-5) seeds: Option, [](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-types/fuzz-accounts/#__codelineno-4-6) decimals: u8, [](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-types/fuzz-accounts/#__codelineno-4-7) owner: &Pubkey, [](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-types/fuzz-accounts/#__codelineno-4-8) freeze_authority: Option [](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-types/fuzz-accounts/#__codelineno-4-9) ) -> Pubkey` * * * ### `get_or_create_delegated_account`[#](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-types/fuzz-accounts/#get_or_create_delegated_account "Permanent link") Stake Feature Requirement This method is only available if the `stake` feature is enabled. Creates or retrieves a delegated stake account. `[](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-types/fuzz-accounts/#__codelineno-5-1) fn get_or_create_delegated_account( [](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-types/fuzz-accounts/#__codelineno-5-2) &mut self, [](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-types/fuzz-accounts/#__codelineno-5-3) account_id: AccountId, [](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-types/fuzz-accounts/#__codelineno-5-4) trident: &mut Trident, [](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-types/fuzz-accounts/#__codelineno-5-5) seeds: Option, [](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-types/fuzz-accounts/#__codelineno-5-6) voter_pubkey: Pubkey, [](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-types/fuzz-accounts/#__codelineno-5-7) staker: Pubkey, [](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-types/fuzz-accounts/#__codelineno-5-8) withdrawer: Pubkey, [](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-types/fuzz-accounts/#__codelineno-5-9) stake: u64, [](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-types/fuzz-accounts/#__codelineno-5-10) activation_epoch: Epoch, [](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-types/fuzz-accounts/#__codelineno-5-11) deactivation_epoch: Option, [](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-types/fuzz-accounts/#__codelineno-5-12) lockup: Option [](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-types/fuzz-accounts/#__codelineno-5-13) ) -> Pubkey` * * * ### `get_or_create_initialized_account`[#](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-types/fuzz-accounts/#get_or_create_initialized_account "Permanent link") Stake Feature Requirement This method is only available if the `stake` feature is enabled. Creates or retrieves an initialized stake account. `[](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-types/fuzz-accounts/#__codelineno-6-1) fn get_or_create_initialized_account( [](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-types/fuzz-accounts/#__codelineno-6-2) &mut self, [](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-types/fuzz-accounts/#__codelineno-6-3) account_id: AccountId, [](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-types/fuzz-accounts/#__codelineno-6-4) trident: &mut Trident, [](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-types/fuzz-accounts/#__codelineno-6-5) seeds: Option, [](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-types/fuzz-accounts/#__codelineno-6-6) staker: Pubkey, [](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-types/fuzz-accounts/#__codelineno-6-7) withdrawer: Pubkey, [](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-types/fuzz-accounts/#__codelineno-6-8) lockup: Option [](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-types/fuzz-accounts/#__codelineno-6-9) ) -> Pubkey` * * * ### `get_or_create_vote_account`[#](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-types/fuzz-accounts/#get_or_create_vote_account "Permanent link") Vote Feature Requirement This method is only available if the `vote` feature is enabled. Creates or retrieves a vote account. `[](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-types/fuzz-accounts/#__codelineno-7-1) fn get_or_create_vote_account( [](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-types/fuzz-accounts/#__codelineno-7-2) &mut self, [](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-types/fuzz-accounts/#__codelineno-7-3) account_id: AccountId, [](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-types/fuzz-accounts/#__codelineno-7-4) trident: &mut Trident, [](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-types/fuzz-accounts/#__codelineno-7-5) seeds: Option, [](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-types/fuzz-accounts/#__codelineno-7-6) node_pubkey: &Pubkey, [](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-types/fuzz-accounts/#__codelineno-7-7) authorized_voter: &Pubkey, [](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-types/fuzz-accounts/#__codelineno-7-8) authorized_withdrawer: &Pubkey, [](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-types/fuzz-accounts/#__codelineno-7-9) commission: u8, [](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-types/fuzz-accounts/#__codelineno-7-10) clock: &Clock [](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-types/fuzz-accounts/#__codelineno-7-11) ) -> Pubkey` PdaSeeds and AccountMetadata[#](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-types/fuzz-accounts/#pdaseeds-and-accountmetadata "Permanent link") -------------------------------------------------------------------------------------------------------------------------------------------------------------------- The `PdaSeeds` and `AccountMetadata` types are optional parameters that can be used to create a Program Derived Address (`Pda`) and pass additional metadata to the account creation process, respectively. ### `PdaSeeds`[#](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-types/fuzz-accounts/#pdaseeds "Permanent link") `[](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-types/fuzz-accounts/#__codelineno-8-1) pub struct PdaSeeds<'a> { [](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-types/fuzz-accounts/#__codelineno-8-2) pub seeds: &'a [&'a [u8]], [](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-types/fuzz-accounts/#__codelineno-8-3) pub program_id: Pubkey, [](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-types/fuzz-accounts/#__codelineno-8-4) } [](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-types/fuzz-accounts/#__codelineno-8-5) impl<'a> PdaSeeds<'a> { [](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-types/fuzz-accounts/#__codelineno-8-6) pub fn new(seeds: &'a [&'a [u8]], program_id: Pubkey) -> Self { [](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-types/fuzz-accounts/#__codelineno-8-7) Self { seeds, program_id } [](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-types/fuzz-accounts/#__codelineno-8-8) } [](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-types/fuzz-accounts/#__codelineno-8-9) }` * * * ### `AccountMetadata`[#](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-types/fuzz-accounts/#accountmetadata "Permanent link") `[](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-types/fuzz-accounts/#__codelineno-9-1) pub struct AccountMetadata { [](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-types/fuzz-accounts/#__codelineno-9-2) pub lamports: u64, [](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-types/fuzz-accounts/#__codelineno-9-3) pub space: usize, [](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-types/fuzz-accounts/#__codelineno-9-4) pub owner: Pubkey, [](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-types/fuzz-accounts/#__codelineno-9-5) } [](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-types/fuzz-accounts/#__codelineno-9-6) impl AccountMetadata { [](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-types/fuzz-accounts/#__codelineno-9-7) pub fn new(lamports: u64, space: usize, owner: Pubkey) -> Self { [](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-types/fuzz-accounts/#__codelineno-9-8) Self { [](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-types/fuzz-accounts/#__codelineno-9-9) lamports, [](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-types/fuzz-accounts/#__codelineno-9-10) space, [](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-types/fuzz-accounts/#__codelineno-9-11) owner, [](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-types/fuzz-accounts/#__codelineno-9-12) } [](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-types/fuzz-accounts/#__codelineno-9-13) } [](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-types/fuzz-accounts/#__codelineno-9-14) }` Back to top --- # TridentAccount - Trident [Skip to content](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-types/trident-account/#tridentaccount) TridentAccount[#](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-types/trident-account/#tridentaccount "Permanent link") ========================================================================================================================================== Trident Account is a wrapper around `AccountMeta`, `SnapshotAccount` and `AccountId`. `AccountMeta` is a type which is used within `Transaction`, it specifies account address, `isSigner` and `isWritable` flags. `SnapshotAccount` is Trident's custom type which is used to capture account state before and after the transaction. `AccountId` is a randomly generated number which is used to identify account within its corresponding `AccountStorage`. `[](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-types/trident-account/#__codelineno-0-1) #[derive(Debug, Clone)] [](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-types/trident-account/#__codelineno-0-2) pub struct TridentAccount { [](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-types/trident-account/#__codelineno-0-3) pub account_id: AccountId, [](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-types/trident-account/#__codelineno-0-4) account_meta: Option, [](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-types/trident-account/#__codelineno-0-5) snapshot_before: Option, [](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-types/trident-account/#__codelineno-0-6) snapshot_after: Option, [](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-types/trident-account/#__codelineno-0-7) }` Implemented Methods[#](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-types/trident-account/#implemented-methods "Permanent link") ---------------------------------------------------------------------------------------------------------------------------------------------------- The following section contains the methods that are available for the `TridentAccount` struct. ### `set_account_meta`[#](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-types/trident-account/#set_account_meta "Permanent link") Sets the account metadata with specified address and flags. `[](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-types/trident-account/#__codelineno-1-1) fn set_account_meta(&mut self, address: Pubkey, is_signer: bool, is_writable: bool)` * * * ### `get_snapshot_before`[#](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-types/trident-account/#get_snapshot_before "Permanent link") Returns the account snapshot taken before transaction execution. `[](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-types/trident-account/#__codelineno-2-1) fn get_snapshot_before(&self) -> &SnapshotAccount` * * * ### `get_snapshot_after`[#](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-types/trident-account/#get_snapshot_after "Permanent link") Returns the account snapshot taken after transaction execution. `[](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-types/trident-account/#__codelineno-3-1) fn get_snapshot_after(&self) -> &SnapshotAccount` * * * ### `set_is_signer`[#](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-types/trident-account/#set_is_signer "Permanent link") Sets the account as a signer. `[](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-types/trident-account/#__codelineno-4-1) fn set_is_signer(&mut self)` * * * ### `set_is_writable`[#](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-types/trident-account/#set_is_writable "Permanent link") Sets the account as writable. `[](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-types/trident-account/#__codelineno-5-1) fn set_is_writable(&mut self)` * * * ### `set_address`[#](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-types/trident-account/#set_address "Permanent link") Sets the account's address. `[](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-types/trident-account/#__codelineno-6-1) fn set_address(&mut self, address: Pubkey)` * * * ### `pubkey`[#](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-types/trident-account/#pubkey "Permanent link") Returns the account's public key. `[](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-types/trident-account/#__codelineno-7-1) fn pubkey(&self) -> Pubkey` * * * ### `capture_before`[#](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-types/trident-account/#capture_before "Permanent link") Internal Method This method is internal and should not be used directly. Captures the account state before transaction execution. `[](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-types/trident-account/#__codelineno-8-1) fn capture_before(&mut self, client: &mut impl FuzzClient)` * * * ### `capture_after`[#](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-types/trident-account/#capture_after "Permanent link") Internal Method This method is internal and should not be used directly. Captures the account state after transaction execution. `[](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-types/trident-account/#__codelineno-9-1) fn capture_after(&mut self, client: &mut impl FuzzClient)` * * * ### `to_account_meta`[#](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-types/trident-account/#to_account_meta "Permanent link") Internal Method This method is internal and should not be used directly. Returns the `AccountMeta` if set, panics if not set. `[](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-types/trident-account/#__codelineno-10-1) fn to_account_meta(&self) -> AccountMeta` * * * ### `is_account_meta_set`[#](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-types/trident-account/#is_account_meta_set "Permanent link") Internal Method This method is internal and should not be used directly. Returns whether the account meta has been set. `[](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-types/trident-account/#__codelineno-11-1) fn is_account_meta_set(&self) -> bool` Back to top --- # Trident examples - Trident Trident examples ================ * **Hello World!** * * * Hello World example with Trident. [Hello World!](https://github.com/Ackee-Blockchain/trident/tree/develop/examples/hello_world) * **Cross-Program Invocation** * * * Trident supports Cross-Program Invocation, you can fuzz your programs and create NFTs at the same time. [Simple CPI](https://github.com/Ackee-Blockchain/trident/tree/develop/examples/cpi) [CPI with Metaplex Metadata Program](https://github.com/Ackee-Blockchain/trident/tree/develop/examples/metaplex) * **Benchmarking** * * * Trident contains benchmarks of [Daedaluzz: A Benchmark Generator for Smart-Contract Fuzzers](https://github.com/Consensys/daedaluzz) rewritten in Rust. [Trident Benchmark](https://github.com/Ackee-Blockchain/trident/tree/develop/examples/trident-benchmark) * **Fuzzing Pipeline** * * * Trident provides a fuzzing pipeline that can be used to fuzz your programs. [Fuzzing pipeline](https://github.com/Ackee-Blockchain/trident/blob/master/.github/workflows/fuzz.yml) Back to top --- # TridentPubkey - Trident [Skip to content](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-types/trident-pubkey/#tridentpubkey) TridentPubkey[#](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-types/trident-pubkey/#tridentpubkey "Permanent link") ======================================================================================================================================= `TridentPubkey` is a wrapper around `Pubkey` and `AccountId`. `Pubkey` is a type from the `solana-sdk` crate that corresponds to a Solana account address. `AccountId` is a randomly generated number which is used to identify account within its corresponding `AccountStorage`. `[](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-types/trident-pubkey/#__codelineno-0-1) #[derive(Debug, Clone)] [](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-types/trident-pubkey/#__codelineno-0-2) pub struct TridentPubkey { [](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-types/trident-pubkey/#__codelineno-0-3) pub account_id: AccountId, [](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-types/trident-pubkey/#__codelineno-0-4) pub pubkey: Pubkey, [](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-types/trident-pubkey/#__codelineno-0-5) }` Implemented Methods[#](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-types/trident-pubkey/#implemented-methods "Permanent link") --------------------------------------------------------------------------------------------------------------------------------------------------- The following section contains the methods that are available for the `TridentPubkey` struct. ### `set_pubkey`[#](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-types/trident-pubkey/#set_pubkey "Permanent link") Sets the public key for this instance. `[](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-types/trident-pubkey/#__codelineno-1-1) fn set_pubkey(&mut self, pubkey: Pubkey)` * * * ### `get_pubkey`[#](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-types/trident-pubkey/#get_pubkey "Permanent link") Returns the stored public key. `[](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-types/trident-pubkey/#__codelineno-2-1) fn get_pubkey(&self) -> Pubkey` * * * Implemented Traits[#](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-types/trident-pubkey/#implemented-traits "Permanent link") ------------------------------------------------------------------------------------------------------------------------------------------------- * `From` - Creates a new instance with the given account\_id and default pubkey * `BorshSerialize` - Serializes only the pubkey field * `BorshDeserialize` - Deserializes only the pubkey field, sets default account\_id * `Serialize` (serde) - Serializes only the pubkey field * `Deserialize` (serde) - Deserializes only the pubkey field, sets default account\_id * `Arbitrary` - Generates random account\_id and default pubkey Back to top --- # TridentSVM - Trident [Skip to content](https://ackee.xyz/trident/docs/latest/trident-svm/#tridentsvm) TridentSVM[#](https://ackee.xyz/trident/docs/latest/trident-svm/#tridentsvm "Permanent link") ============================================================================================== TridentSVM is a fast execution and accounts storage environment which is utilized within the Trident. Github repository: [Trident SVM](https://github.com/Ackee-Blockchain/trident-svm) TridentSVM uses [Anza's SVM API](https://www.anza.xyz/blog/anzas-new-svm-api) Back to top --- # Flow Executor - Trident [Skip to content](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-macros/trident-flow-executor/#flow-executor) Flow Executor[#](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-macros/trident-flow-executor/#flow-executor "Permanent link") =============================================================================================================================================== The Flow Executor macros are a set of attribute macros used to define and control execution flows. These macros help organize and manage the execution of complex test scenarios. Available Macros[#](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-macros/trident-flow-executor/#available-macros "Permanent link") ----------------------------------------------------------------------------------------------------------------------------------------------------- The Flow Executor functionality consists of four main attribute macros: 1. `#[flow_executor]` - Implements the flow executor for a struct 2. `#[flow]` - Marks a method as part of the execution flow 3. `#[init]` - Marks a method to run once at the beginning of each iteration before all flow methods 4. `#[end]` - Marks a method to run once at the end of each iteration after all flow methods Usage[#](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-macros/trident-flow-executor/#usage "Permanent link") ------------------------------------------------------------------------------------------------------------------------------- `[](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-macros/trident-flow-executor/#__codelineno-0-1) #[derive(FuzzTestMethods)] [](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-macros/trident-flow-executor/#__codelineno-0-2) struct FuzzTest { [](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-macros/trident-flow-executor/#__codelineno-0-3) /// for fuzzing [](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-macros/trident-flow-executor/#__codelineno-0-4) trident: Trident, [](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-macros/trident-flow-executor/#__codelineno-0-5) /// for storing fuzzing accounts [](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-macros/trident-flow-executor/#__codelineno-0-6) fuzz_accounts: FuzzAccounts, [](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-macros/trident-flow-executor/#__codelineno-0-7) } [](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-macros/trident-flow-executor/#__codelineno-0-8)[](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-macros/trident-flow-executor/#__codelineno-0-9) #[flow_executor] [](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-macros/trident-flow-executor/#__codelineno-0-10) impl FuzzTest { [](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-macros/trident-flow-executor/#__codelineno-0-11) fn new() -> Self { [](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-macros/trident-flow-executor/#__codelineno-0-12) Self { [](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-macros/trident-flow-executor/#__codelineno-0-13) trident: Trident::default(), [](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-macros/trident-flow-executor/#__codelineno-0-14) fuzz_accounts: FuzzAccounts::default(), [](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-macros/trident-flow-executor/#__codelineno-0-15) } [](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-macros/trident-flow-executor/#__codelineno-0-16) } [](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-macros/trident-flow-executor/#__codelineno-0-17) [](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-macros/trident-flow-executor/#__codelineno-0-18) #[init] [](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-macros/trident-flow-executor/#__codelineno-0-19) fn start(&mut self) { [](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-macros/trident-flow-executor/#__codelineno-0-20) // perform any initialization here, this method will be executed [](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-macros/trident-flow-executor/#__codelineno-0-21) // at start of each iteration [](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-macros/trident-flow-executor/#__codelineno-0-22) } [](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-macros/trident-flow-executor/#__codelineno-0-23) [](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-macros/trident-flow-executor/#__codelineno-0-24) #[flow] [](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-macros/trident-flow-executor/#__codelineno-0-25) fn flow1(&mut self) { [](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-macros/trident-flow-executor/#__codelineno-0-26) // perform logic which is meant to be fuzzed [](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-macros/trident-flow-executor/#__codelineno-0-27) // this flow is selected randomly from other flows [](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-macros/trident-flow-executor/#__codelineno-0-28) } [](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-macros/trident-flow-executor/#__codelineno-0-29) [](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-macros/trident-flow-executor/#__codelineno-0-30) #[flow] [](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-macros/trident-flow-executor/#__codelineno-0-31) fn flow2(&mut self) { [](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-macros/trident-flow-executor/#__codelineno-0-32) // perform logic which is meant to be fuzzed [](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-macros/trident-flow-executor/#__codelineno-0-33) // this flow is selected randomly from other flows [](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-macros/trident-flow-executor/#__codelineno-0-34) } [](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-macros/trident-flow-executor/#__codelineno-0-35) [](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-macros/trident-flow-executor/#__codelineno-0-36) #[end] [](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-macros/trident-flow-executor/#__codelineno-0-37) fn end(&mut self) { [](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-macros/trident-flow-executor/#__codelineno-0-38) // perform any cleanup here, this method will be executed [](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-macros/trident-flow-executor/#__codelineno-0-39) // at the end of each iteration [](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-macros/trident-flow-executor/#__codelineno-0-40) } [](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-macros/trident-flow-executor/#__codelineno-0-41) }` Implementation-Level attributes[#](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-macros/trident-flow-executor/#implementation-level-attributes "Permanent link") ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- ### `#[flow_executor]`[#](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-macros/trident-flow-executor/#flow_executor "Permanent link") The `flow_executor` attribute macro is applied to an `impl` block and implements the flow executor functionality for the struct. `[](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-macros/trident-flow-executor/#__codelineno-1-1) #[flow_executor] [](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-macros/trident-flow-executor/#__codelineno-1-2) impl FuzzTest { [](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-macros/trident-flow-executor/#__codelineno-1-3) // Flow methods... [](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-macros/trident-flow-executor/#__codelineno-1-4) }` * * * Method-Level attributes[#](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-macros/trident-flow-executor/#method-level-attributes "Permanent link") ------------------------------------------------------------------------------------------------------------------------------------------------------------------- ### `#[init]`[#](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-macros/trident-flow-executor/#init "Permanent link") The `init` attribute macro marks a method as the initialization method for the flows. This method is executed at the beginning of each iteration before all flow methods. Initialization Method It is possible to define only one initialization method. `[](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-macros/trident-flow-executor/#__codelineno-2-1) #[init] [](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-macros/trident-flow-executor/#__codelineno-2-2) fn initialize(&mut self) { [](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-macros/trident-flow-executor/#__codelineno-2-3) // Initialization logic [](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-macros/trident-flow-executor/#__codelineno-2-4) // Perform initialization Transaction here [](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-macros/trident-flow-executor/#__codelineno-2-5) }` * * * ### `#[flow]`[#](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-macros/trident-flow-executor/#flow "Permanent link") The `flow` attribute macro marks a method as part of the execution flow. Flow Methods It is possible to define multiple flow methods. If multiple flows are defined, the fuzzer will pick randomly and generate a sequence of random flows to execute. `[](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-macros/trident-flow-executor/#__codelineno-3-1) #[flow] [](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-macros/trident-flow-executor/#__codelineno-3-2) fn step_one(&mut self) { [](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-macros/trident-flow-executor/#__codelineno-3-3) // Flow step implementation [](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-macros/trident-flow-executor/#__codelineno-3-4) }` * * * ### `#[end]`[#](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-macros/trident-flow-executor/#end "Permanent link") The `end` attribute macro marks a method to run once at the end of each iteration after all flow methods. Cleanup Method It is possible to define only one end method. `[](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-macros/trident-flow-executor/#__codelineno-4-1) #[end] [](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-macros/trident-flow-executor/#__codelineno-4-2) fn cleanup(&mut self) { [](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-macros/trident-flow-executor/#__codelineno-4-3) // Cleanup logic [](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-macros/trident-flow-executor/#__codelineno-4-4) }` Generated Methods[#](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-macros/trident-flow-executor/#generated-methods "Permanent link") ------------------------------------------------------------------------------------------------------------------------------------------------------- ### `fuzz`[#](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-macros/trident-flow-executor/#fuzz "Permanent link") Runs the fuzzing process with multiple concurrent fuzzing threads. `[](https://ackee.xyz/trident/docs/latest/trident-api-macro/trident-macros/trident-flow-executor/#__codelineno-5-1) fn fuzz(iterations: u64, flow_calls_per_iteration: u64)` * `iterations` - Number of iterations to run * `flow_calls_per_iteration` - Number of flow methods called in each iteration (e.g. if the `flow_calls_per_iteration` is 100, the fuzzer will pick a random sequence of 100 flow methods to execute in each iteration) Back to top --- # Trident Manifest - Trident [Skip to content](https://ackee.xyz/trident/docs/latest/trident-manifest/#trident-manifest) Trident Manifest[#](https://ackee.xyz/trident/docs/latest/trident-manifest/#trident-manifest "Permanent link") =============================================================================================================== Trident supports its own Trident Manifest, called `Trident.toml`. This section describes all possible configuration fields. Fuzzing Metrics[#](https://ackee.xyz/trident/docs/latest/trident-manifest/#fuzzing-metrics "Permanent link") ------------------------------------------------------------------------------------------------------------- `[](https://ackee.xyz/trident/docs/latest/trident-manifest/#__codelineno-0-1) [fuzz.metrics] [](https://ackee.xyz/trident/docs/latest/trident-manifest/#__codelineno-0-2) enabled = true [](https://ackee.xyz/trident/docs/latest/trident-manifest/#__codelineno-0-3) dashboard = false [](https://ackee.xyz/trident/docs/latest/trident-manifest/#__codelineno-0-4) json = false` * `enabled` - Trident will show and save statistics after the fuzzing session. * `dashboard` - Trident will save a HTML dashboard after the fuzzing session. * `json` - Trident will save a JSON file after the fuzzing session. * * * Regression testing[#](https://ackee.xyz/trident/docs/latest/trident-manifest/#regression-testing "Permanent link") ------------------------------------------------------------------------------------------------------------------- `[](https://ackee.xyz/trident/docs/latest/trident-manifest/#__codelineno-1-1) [fuzz.regression] [](https://ackee.xyz/trident/docs/latest/trident-manifest/#__codelineno-1-2) enabled = true` * `enabled` - Trident will save a JSON file with all monitored states after the fuzzing session. Regression testing * Keep in mind that the feature hashes contents of accounts, if the contents are dependant for example on time, the final hash might not be the same as the one from the first fuzzing session. * * * Fuzzing Coverage[#](https://ackee.xyz/trident/docs/latest/trident-manifest/#fuzzing-coverage "Permanent link") --------------------------------------------------------------------------------------------------------------- `[](https://ackee.xyz/trident/docs/latest/trident-manifest/#__codelineno-2-1) [fuzz.coverage] [](https://ackee.xyz/trident/docs/latest/trident-manifest/#__codelineno-2-2) enable = true # default: false [](https://ackee.xyz/trident/docs/latest/trident-manifest/#__codelineno-2-3) server_port = 58432 # default: 58432 [](https://ackee.xyz/trident/docs/latest/trident-manifest/#__codelineno-2-4) loopcount = 5 # default: 0 [](https://ackee.xyz/trident/docs/latest/trident-manifest/#__codelineno-2-5) format = "json" # default: "json" [](https://ackee.xyz/trident/docs/latest/trident-manifest/#__codelineno-2-6) attach_extension = true # default: false` The coverage configuration enables code coverage analysis during fuzzing sessions, providing insights into which parts of your program are being tested. * `enable` - When set to `true`, Trident collects code coverage data throughout the fuzzing session and generates a comprehensive report upon completion. * `server_port` - Specifies the HTTP server port used for communication between Trident and the [Solana VS Code extension](https://marketplace.visualstudio.com/items?itemName=AckeeBlockchain.solana) . * `loopcount` - Defines the number of execution flows processed before generating an intermediate coverage data file. Lower values provide more frequent coverage updates at the cost of performance. When set to `0`, coverage files are only generated at the end of the fuzzing session. * `format` - Determines the output format for coverage reports. Trident supports both `json` and `html` formats. * `attach_extension` - Enables real-time coverage visualization in VS Code when the extension is active. This feature requires `loopcount` to be greater than `0` and `format` to be set to `json`. Warning Coverage is only gathered for the programs deployed through an entrypoint! Entrypoint deployment guide 1. Comment out the program in `Trident.toml` `[](https://ackee.xyz/trident/docs/latest/trident-manifest/#__codelineno-3-1) # [[fuzz.programs]] [](https://ackee.xyz/trident/docs/latest/trident-manifest/#__codelineno-3-2) # address = "example_address" [](https://ackee.xyz/trident/docs/latest/trident-manifest/#__codelineno-3-3) # program = "../target/deploy/example_program.so"` 2. Add the program dependency to `Cargo.toml` `[](https://ackee.xyz/trident/docs/latest/trident-manifest/#__codelineno-4-1) [dependencies.example_program] [](https://ackee.xyz/trident/docs/latest/trident-manifest/#__codelineno-4-2) path = "../programs/example_program"` 3. Add `syscall-v1` or `syscall-v2` feature depending on the version of `solana-program`. Programs written for `solana-program` v1.x should use `syscall-v1`, programs written for `solana-program` v2.x should use `syscall-v2` feature. `[](https://ackee.xyz/trident/docs/latest/trident-manifest/#__codelineno-5-1) [dependencies.trident-fuzz] [](https://ackee.xyz/trident/docs/latest/trident-manifest/#__codelineno-5-2) features = ["syscall-v2"]` 4. Import the programs entrypoint in `test_fuzz.rs` `[](https://ackee.xyz/trident/docs/latest/trident-manifest/#__codelineno-6-1) use example_program::entry as example_entrypoint;` 5. Deploy the entrypoint in `test_fuzz.rs` `[](https://ackee.xyz/trident/docs/latest/trident-manifest/#__codelineno-7-1) impl FuzzTest { [](https://ackee.xyz/trident/docs/latest/trident-manifest/#__codelineno-7-2) fn new() -> Self { [](https://ackee.xyz/trident/docs/latest/trident-manifest/#__codelineno-7-3) let mut trident = Trident::default(); [](https://ackee.xyz/trident/docs/latest/trident-manifest/#__codelineno-7-4) [](https://ackee.xyz/trident/docs/latest/trident-manifest/#__codelineno-7-5) // Deploy through the entrypoint [](https://ackee.xyz/trident/docs/latest/trident-manifest/#__codelineno-7-6) let program = TridentEntrypoint::new(example_program::ID, None, processor!(example_entrypoint)); [](https://ackee.xyz/trident/docs/latest/trident-manifest/#__codelineno-7-7) trident.get_client().deploy_entrypoint(program); [](https://ackee.xyz/trident/docs/latest/trident-manifest/#__codelineno-7-8) [](https://ackee.xyz/trident/docs/latest/trident-manifest/#__codelineno-7-9) Self { [](https://ackee.xyz/trident/docs/latest/trident-manifest/#__codelineno-7-10) trident, [](https://ackee.xyz/trident/docs/latest/trident-manifest/#__codelineno-7-11) fuzz_accounts: FuzzAccounts::default(), [](https://ackee.xyz/trident/docs/latest/trident-manifest/#__codelineno-7-12) } [](https://ackee.xyz/trident/docs/latest/trident-manifest/#__codelineno-7-13) } [](https://ackee.xyz/trident/docs/latest/trident-manifest/#__codelineno-7-14) ...` * * * Programs[#](https://ackee.xyz/trident/docs/latest/trident-manifest/#programs "Permanent link") ----------------------------------------------------------------------------------------------- * Use dumped program from desired cluster, during fuzzing. `[](https://ackee.xyz/trident/docs/latest/trident-manifest/#__codelineno-8-1) [[fuzz.programs]] [](https://ackee.xyz/trident/docs/latest/trident-manifest/#__codelineno-8-2) address = "metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s" [](https://ackee.xyz/trident/docs/latest/trident-manifest/#__codelineno-8-3) upgrade_authority = "account address goes here" [](https://ackee.xyz/trident/docs/latest/trident-manifest/#__codelineno-8-4) program = "metaplex-program/metaplex-token-metadata.so"` * * * Accounts[#](https://ackee.xyz/trident/docs/latest/trident-manifest/#accounts "Permanent link") ----------------------------------------------------------------------------------------------- * Use dumped accounts from desired cluster, during fuzzing. `[](https://ackee.xyz/trident/docs/latest/trident-manifest/#__codelineno-9-1) [[fuzz.accounts]] [](https://ackee.xyz/trident/docs/latest/trident-manifest/#__codelineno-9-2) address = "6YG3J7PaxyMnnbU67ifyrgF3BzNzc7cD8hPkqK6ATweE" [](https://ackee.xyz/trident/docs/latest/trident-manifest/#__codelineno-9-3) filename = "tests/accounts/core_bridge_mainnet/guardian_set_5_mock.json"` * * * Back to top --- # Code Coverage - Trident [Skip to content](https://ackee.xyz/trident/docs/latest/trident-advanced/code-coverage/#code-coverage) Code Coverage[#](https://ackee.xyz/trident/docs/latest/trident-advanced/code-coverage/#code-coverage "Permanent link") ======================================================================================================================= Trident's code coverage feature analyzes which parts of your Solana program are tested during fuzzing sessions, helping you identify untested code paths and improve test effectiveness. Your browser does not support the video tag. Key features: * **Real-time Analysis**: Monitor coverage as fuzzing progresses * **Multiple Formats**: Generate reports in JSON and HTML formats * **VS Code Integration**: Visualize coverage directly in your IDE using [Solana VS Code extension](https://marketplace.visualstudio.com/items?itemName=AckeeBlockchain.solana) * **Detailed Reporting**: Get insights into line coverage, branch coverage, and execution paths Gathering Coverage Data[#](https://ackee.xyz/trident/docs/latest/trident-advanced/code-coverage/#gathering-coverage-data "Permanent link") ------------------------------------------------------------------------------------------------------------------------------------------- 1. Enable coverage in the [Trident manifest](https://ackee.xyz/trident/docs/latest/trident-manifest/#fuzzing-coverage) 2. Deploy your program through the [entrypoint](https://ackee.xyz/trident/docs/latest/trident-manifest/#entrypoint-deployment) 3. Run the fuzz test Viewing Coverage Reports[#](https://ackee.xyz/trident/docs/latest/trident-advanced/code-coverage/#viewing-coverage-reports "Permanent link") --------------------------------------------------------------------------------------------------------------------------------------------- You have two options for displaying coverage data: generate an HTML report for browser viewing, or generate a JSON report for VS Code integration. ### Live Coverage Updates[#](https://ackee.xyz/trident/docs/latest/trident-advanced/code-coverage/#live-coverage-updates "Permanent link") For real-time coverage monitoring during fuzzing: 1. Set `format = "json"` in the [Trident manifest](https://ackee.xyz/trident/docs/latest/trident-manifest/#fuzzing-coverage) 2. Set `loopcount` to a value other than `0` e.g., `5` for frequent updates, for more info check out [Trident manifest](https://ackee.xyz/trident/docs/latest/trident-manifest/#entrypoint-deployment) 3. Install the [Solana VS Code extension](https://marketplace.visualstudio.com/items?itemName=AckeeBlockchain.solana) 4. Choose one of these options: * **Automatic**: Set `attach_extension = true` in the [Trident manifest](https://ackee.xyz/trident/docs/latest/trident-manifest/#fuzzing-coverage) to automatically show live updates while the fuzz test is running * **Manual**: Use the command `Solana: Show Code Coverage` and select the "Attach to active fuzzing session" option ### Post-Session Coverage Analysis[#](https://ackee.xyz/trident/docs/latest/trident-advanced/code-coverage/#post-session-coverage-analysis "Permanent link") 1. Set `format = "json"` in the [Trident manifest](https://ackee.xyz/trident/docs/latest/trident-manifest/#fuzzing-coverage) before running the fuzz test 2. Run the fuzz test 3. Install the [Solana VS Code extension](https://marketplace.visualstudio.com/items?itemName=AckeeBlockchain.solana) 4. Run the VS Code command `Solana: Show Code Coverage` and select the "Load generated JSON report" option ### HTML Report[#](https://ackee.xyz/trident/docs/latest/trident-advanced/code-coverage/#html-report "Permanent link") 1. Set `format = "html"` in the [Trident manifest](https://ackee.xyz/trident/docs/latest/trident-manifest/#fuzzing-coverage) before running the fuzz test 2. Run the fuzz test 3. After the fuzz test finishes, the HTML report will be stored in the `-coverage-report` folder 4. Open the HTML report in your browser Back to top --- # Dashboard - Trident [Skip to content](https://ackee.xyz/trident/docs/latest/trident-advanced/dashboard/#dashboard) Dashboard[#](https://ackee.xyz/trident/docs/latest/trident-advanced/dashboard/#dashboard "Permanent link") =========================================================================================================== The Trident Dashboard provides a web-based interface for visualizing fuzzing session results through interactive charts and comprehensive statistics. Your browser does not support the video tag. Features: * **Session Statistics**: View execution counts, success rates, and performance metrics * **Interactive Charts**: Explore results through dynamic visualizations * **Browser Access**: Open in any web browser without additional software * **Comprehensive Analysis**: Insights into instruction coverage and account interactions Viewing the Dashboard[#](https://ackee.xyz/trident/docs/latest/trident-advanced/dashboard/#viewing-the-dashboard "Permanent link") ----------------------------------------------------------------------------------------------------------------------------------- 1. Open another terminal window and execute `trident server` from the fuzz-tests directory. 2. Open your browser and navigate to the provided URL (typically `http://localhost:8080`). 3. Enable the dashboard in the [Trident manifest](https://ackee.xyz/trident/docs/latest/trident-manifest/#fuzzing-metrics) by setting `dashboard = true`. `[](https://ackee.xyz/trident/docs/latest/trident-advanced/dashboard/#__codelineno-0-1) [fuzz.metrics] [](https://ackee.xyz/trident/docs/latest/trident-advanced/dashboard/#__codelineno-0-2) enabled = true [](https://ackee.xyz/trident/docs/latest/trident-advanced/dashboard/#__codelineno-0-3) dashboard = true` 4. Run the fuzz test to generate dashboard data. Monitoring custom fuzzing metrics[#](https://ackee.xyz/trident/docs/latest/trident-advanced/dashboard/#monitoring-custom-fuzzing-metrics "Permanent link") ----------------------------------------------------------------------------------------------------------------------------------------------------------- Trident allows you to monitor custom fuzzing metrics. If your program expects integer instruction inputs, it is possible to collect data on the randomly generated values and display them in the dashboard. To do this, you need to add `trident.add_histogram_metric` to the `#[init]`, `#[flow]` or `#[end]` functions. The following code snippet shows how the `InitializeFnTransaction` instruction input is monitored; the statistics will be displayed in the dashboard. `[](https://ackee.xyz/trident/docs/latest/trident-advanced/dashboard/#__codelineno-1-1) #[flow_executor] [](https://ackee.xyz/trident/docs/latest/trident-advanced/dashboard/#__codelineno-1-2) impl FuzzTest { [](https://ackee.xyz/trident/docs/latest/trident-advanced/dashboard/#__codelineno-1-3) fn new() -> Self { [](https://ackee.xyz/trident/docs/latest/trident-advanced/dashboard/#__codelineno-1-4) Self { [](https://ackee.xyz/trident/docs/latest/trident-advanced/dashboard/#__codelineno-1-5) trident: Trident::default(), [](https://ackee.xyz/trident/docs/latest/trident-advanced/dashboard/#__codelineno-1-6) fuzz_accounts: FuzzAccounts::default(), [](https://ackee.xyz/trident/docs/latest/trident-advanced/dashboard/#__codelineno-1-7) } [](https://ackee.xyz/trident/docs/latest/trident-advanced/dashboard/#__codelineno-1-8) } [](https://ackee.xyz/trident/docs/latest/trident-advanced/dashboard/#__codelineno-1-9) [](https://ackee.xyz/trident/docs/latest/trident-advanced/dashboard/#__codelineno-1-10) #[init] [](https://ackee.xyz/trident/docs/latest/trident-advanced/dashboard/#__codelineno-1-11) fn start(&mut self) { [](https://ackee.xyz/trident/docs/latest/trident-advanced/dashboard/#__codelineno-1-12) let mut ix = InitializeFnTransaction::build(&mut self.trident, &mut self.fuzz_accounts); [](https://ackee.xyz/trident/docs/latest/trident-advanced/dashboard/#__codelineno-1-13) [](https://ackee.xyz/trident/docs/latest/trident-advanced/dashboard/#__codelineno-1-14) self.trident.execute_transaction(&mut ix, Some("Init")); [](https://ackee.xyz/trident/docs/latest/trident-advanced/dashboard/#__codelineno-1-15) } [](https://ackee.xyz/trident/docs/latest/trident-advanced/dashboard/#__codelineno-1-16) [](https://ackee.xyz/trident/docs/latest/trident-advanced/dashboard/#__codelineno-1-17) #[flow(weight = 5)] [](https://ackee.xyz/trident/docs/latest/trident-advanced/dashboard/#__codelineno-1-18) fn flow1(&mut self) { [](https://ackee.xyz/trident/docs/latest/trident-advanced/dashboard/#__codelineno-1-19) let mut ix = InitializeFnTransaction::build(&mut self.trident, &mut self.fuzz_accounts); [](https://ackee.xyz/trident/docs/latest/trident-advanced/dashboard/#__codelineno-1-20) self.trident.execute_transaction(&mut ix, Some("Flow1")); [](https://ackee.xyz/trident/docs/latest/trident-advanced/dashboard/#__codelineno-1-21) [](https://ackee.xyz/trident/docs/latest/trident-advanced/dashboard/#__codelineno-1-22) // Add the histogram metric to the dashboard [](https://ackee.xyz/trident/docs/latest/trident-advanced/dashboard/#__codelineno-1-23) self.trident [](https://ackee.xyz/trident/docs/latest/trident-advanced/dashboard/#__codelineno-1-24) .add_histogram_metric("flow1_metric", ix.instruction.data.input as f64); [](https://ackee.xyz/trident/docs/latest/trident-advanced/dashboard/#__codelineno-1-25) } [](https://ackee.xyz/trident/docs/latest/trident-advanced/dashboard/#__codelineno-1-26) [](https://ackee.xyz/trident/docs/latest/trident-advanced/dashboard/#__codelineno-1-27) #[flow(weight = 5)] [](https://ackee.xyz/trident/docs/latest/trident-advanced/dashboard/#__codelineno-1-28) fn flow2(&mut self) { [](https://ackee.xyz/trident/docs/latest/trident-advanced/dashboard/#__codelineno-1-29) //.... [](https://ackee.xyz/trident/docs/latest/trident-advanced/dashboard/#__codelineno-1-30) } [](https://ackee.xyz/trident/docs/latest/trident-advanced/dashboard/#__codelineno-1-31) #[flow(weight = 90)] [](https://ackee.xyz/trident/docs/latest/trident-advanced/dashboard/#__codelineno-1-32) fn flow3(&mut self) { [](https://ackee.xyz/trident/docs/latest/trident-advanced/dashboard/#__codelineno-1-33) //.... [](https://ackee.xyz/trident/docs/latest/trident-advanced/dashboard/#__codelineno-1-34) } [](https://ackee.xyz/trident/docs/latest/trident-advanced/dashboard/#__codelineno-1-35) #[end] [](https://ackee.xyz/trident/docs/latest/trident-advanced/dashboard/#__codelineno-1-36) fn cleanup(&mut self) -> Result<(), FuzzingError> { [](https://ackee.xyz/trident/docs/latest/trident-advanced/dashboard/#__codelineno-1-37) //.... [](https://ackee.xyz/trident/docs/latest/trident-advanced/dashboard/#__codelineno-1-38) } [](https://ackee.xyz/trident/docs/latest/trident-advanced/dashboard/#__codelineno-1-39) }` Back to top --- # Trident [Skip to content](https://ackee.xyz/trident/docs/0.7.0/#trident) Trident[#](https://ackee.xyz/trident/docs/0.7.0/#trident "Permanent link") =========================================================================== ![Trident](https://ackee.xyz/trident/docs/0.7.0/images/trident-logo-smaller.png) Rust-based Fuzzing framework for Solana programs to help you ship secure code. * **Getting Started** * * * Install the Trident Fuzz Testing Framework [Getting started](https://ackee.xyz/trident/docs/0.7.0/getting-started/getting-started/) * **Start Fuzzing** * * * Focus on security and start fuzzing immediatelly [Start Fuzzing](https://ackee.xyz/trident/docs/0.7.0/fuzzing/first-steps/fuzz-test-initialization/) * **Check the GitHub for unreleased features** * * * Check our GitHub repository to see the unreleased features [Trident Repository](https://github.com/Ackee-Blockchain/trident/tree/develop) * **Trident by Examples** * * * Try the Fuzzing Examples [Trident Examples](https://ackee.xyz/trident/docs/0.7.0/fuzzing/extra/examples/) What is Fuzzing ?[#](https://ackee.xyz/trident/docs/0.7.0/#what-is-fuzzing "Permanent link") --------------------------------------------------------------------------------------------- _"Fuzz testing is an automated technique that provides generated random, invalid, or unexpected input data to your program. This helps discover unknown bugs and vulnerabilities, potentially preventing zero-day exploits."_ Trident equips developers with tools to efficiently develop fuzz tests for Anchor-based programs. It streamlines the fuzz testing process through automation and comprehensive support * **Trident Workflow** * * * * **Automatically parses Anchor-based programs** to generate necessary implementations for deserializing instruction accounts. * **Generates templates** for developers to customize according to the specific needs of their fuzz test scenarios. * **Offers derive macros** to effortlessly implement required traits, reducing manual coding efforts. * **Includes a bank client** and helper functions for simplified account management during testing. * **Provides a Command-Line Interface** (CLI) for executing and debugging fuzz tests with ease. * **Trident Capabilities** * * * * **Execution Order of Instructions**: Test different sequences and their effects on the program to uncover sequence-related vulnerabilities. * **Instruction Parameters**: Identify how variations in inputs influence program behavior, testing for robustness against a wide range of data. * **Instruction Accounts**: Explore the impact of different account states on the software's functionality, ensuring comprehensive account testing. * **Comprehensive Testing**: Conduct thorough and effective fuzz testing by combining any of the above aspects. Back to top --- # Trident Documentation - Trident [Skip to content](https://ackee.xyz/trident/docs/0.11.1/#trident-documentation) Trident Documentation[#](https://ackee.xyz/trident/docs/0.11.1/#trident-documentation "Permanent link") ======================================================================================================== Fuzzing is a technique to test the robustness of a program by providing it with random inputs. Trident is a Manually Guided Fuzzing framework for Solana. It lets you to execute instructions of your Solana programs with random data and observe the changes in the state of the program. Getting started[#](https://ackee.xyz/trident/docs/0.11.1/#getting-started "Permanent link") -------------------------------------------------------------------------------------------- * [Installation](https://ackee.xyz/trident/docs/0.11.1/basics/installation/) - Install the Trident Fuzz Testing Framework * [Start Fuzzing](https://ackee.xyz/trident/docs/0.11.1/start-fuzzing/) - Focus on security and start fuzzing immediately Advanced fuzzing customization[#](https://ackee.xyz/trident/docs/0.11.1/#advanced-fuzzing-customization "Permanent link") -------------------------------------------------------------------------------------------------------------------------- Explore the various features Trident provides. * [Transaction Hooks](https://ackee.xyz/trident/docs/0.11.1/trident-advanced/trident-transactions/transaction-hooks/) - Create and manipulate transactions with different methods * [Multi-Instruction Transactions](https://ackee.xyz/trident/docs/0.11.1/trident-advanced/trident-transactions/multi-instruction-transactions/) - Compose fuzzed transactions with multiple instructions * [Trident Manifest](https://ackee.xyz/trident/docs/0.11.1/trident-manifest/) - Customize your fuzz tests with different configurations * [Code Coverage](https://ackee.xyz/trident/docs/0.11.1/trident-advanced/code-coverage/) - Track and display fuzz test code coverage * [Dashboard](https://ackee.xyz/trident/docs/0.11.1/trident-advanced/dashboard/) - A web-based interface for visualizing fuzzing session results * [Regression Testing](https://ackee.xyz/trident/docs/0.11.1/trident-advanced/regression/) - Track and compare fuzzing session results API & Macros Reference[#](https://ackee.xyz/trident/docs/0.11.1/#api-macros-reference "Permanent link") -------------------------------------------------------------------------------------------------------- Check out the API and macro reference for Trident. * [Trident API & Macros](https://ackee.xyz/trident/docs/0.11.1/trident-api-macro/) Trident Examples[#](https://ackee.xyz/trident/docs/0.11.1/#trident-examples "Permanent link") ---------------------------------------------------------------------------------------------- Check out examples to learn how to use Trident. * [Trident Examples](https://ackee.xyz/trident/docs/0.11.1/trident-examples/trident-examples/) TridentSVM[#](https://ackee.xyz/trident/docs/0.11.1/#tridentsvm "Permanent link") ---------------------------------------------------------------------------------- Check out the TridentSVM, lightweight fuzzing execution and account storage environment. * [TridentSVM](https://ackee.xyz/trident/docs/0.11.1/trident-svm/) What is Fuzzing ?[#](https://ackee.xyz/trident/docs/0.11.1/#what-is-fuzzing "Permanent link") ---------------------------------------------------------------------------------------------- _"Fuzz testing is an automated technique that provides generated random, invalid, or unexpected input data to your program. This helps discover unknown bugs and vulnerabilities, potentially preventing zero-day exploits."_ Back to top --- # Trident - Trident [Skip to content](https://ackee.xyz/trident/docs/0.6.0/#trident) Trident[#](https://ackee.xyz/trident/docs/0.6.0/#trident "Permanent link") =========================================================================== Trident is a Rust-based framework to fuzz and integration test Solana programs to help you ship secure code. Features[#](https://ackee.xyz/trident/docs/0.6.0/#features "Permanent link") ============================================================================= * **Automated Test Generation**: Simplifies the testing process by automatically creating templates for fuzz and integration tests for programs written using the Anchor Framework. * **Dynamic Data Generation**: Increases test coverage with random instruction data and pseudo-random accounts for unpredictable fuzz test scenarios. * **Custom Instruction Sequences**: Provides the flexibility to design specific sequences of instructions to meet particular testing needs or to focus on particular aspects of program behavior during fuzz testing. Invariant Checks: Allows for custom invariants checks to spot vulnerabilities and unwanted behaviors. Back to top --- # Trident Documentation - Trident [Skip to content](https://ackee.xyz/trident/docs/dev/#trident-documentation) Trident Documentation[#](https://ackee.xyz/trident/docs/dev/#trident-documentation "Permanent link") ===================================================================================================== Fuzzing is a technique to test the robustness of a program by providing it with random inputs. Trident is a Manually Guided Fuzzing framework for Solana. It lets you to execute instructions of your Solana programs with random data and observe the changes in the state of the program. Getting started[#](https://ackee.xyz/trident/docs/dev/#getting-started "Permanent link") ----------------------------------------------------------------------------------------- * [Installation](https://ackee.xyz/trident/docs/dev/basics/installation/) - Install the Trident Fuzz Testing Framework * [Start Fuzzing](https://ackee.xyz/trident/docs/dev/start-fuzzing/) - Focus on security and start fuzzing immediately Advanced fuzzing customization[#](https://ackee.xyz/trident/docs/dev/#advanced-fuzzing-customization "Permanent link") ----------------------------------------------------------------------------------------------------------------------- Explore the various features Trident provides. * [Transaction Hooks](https://ackee.xyz/trident/docs/dev/trident-advanced/trident-transactions/transaction-hooks/) - Create and manipulate transactions with different methods * [Multi-Instruction Transactions](https://ackee.xyz/trident/docs/dev/trident-advanced/trident-transactions/multi-instruction-transactions/) - Compose fuzzed transactions with multiple instructions * [Trident Manifest](https://ackee.xyz/trident/docs/dev/trident-manifest/) - Customize your fuzz tests with different configurations * [Code Coverage](https://ackee.xyz/trident/docs/dev/trident-advanced/code-coverage/) - Track and display fuzz test code coverage * [Dashboard](https://ackee.xyz/trident/docs/dev/trident-advanced/dashboard/) - A web-based interface for visualizing fuzzing session results * [Regression Testing](https://ackee.xyz/trident/docs/dev/trident-advanced/regression/) - Track and compare fuzzing session results API & Macros Reference[#](https://ackee.xyz/trident/docs/dev/#api-macros-reference "Permanent link") ----------------------------------------------------------------------------------------------------- Check out the API and macro reference for Trident. * [Trident API & Macros](https://ackee.xyz/trident/docs/dev/trident-api-macro/) Trident Examples[#](https://ackee.xyz/trident/docs/dev/#trident-examples "Permanent link") ------------------------------------------------------------------------------------------- Check out examples to learn how to use Trident. * [Trident Examples](https://ackee.xyz/trident/docs/dev/trident-examples/trident-examples/) TridentSVM[#](https://ackee.xyz/trident/docs/dev/#tridentsvm "Permanent link") ------------------------------------------------------------------------------- Check out the TridentSVM, lightweight fuzzing execution and account storage environment. * [TridentSVM](https://ackee.xyz/trident/docs/dev/trident-svm/) What is Fuzzing ?[#](https://ackee.xyz/trident/docs/dev/#what-is-fuzzing "Permanent link") ------------------------------------------------------------------------------------------- _"Fuzz testing is an automated technique that provides generated random, invalid, or unexpected input data to your program. This helps discover unknown bugs and vulnerabilities, potentially preventing zero-day exploits."_ Back to top --- # Trident Documentation - Trident [Skip to content](https://ackee.xyz/trident/docs/0.10.0/#trident-documentation) Trident Documentation[#](https://ackee.xyz/trident/docs/0.10.0/#trident-documentation "Permanent link") ======================================================================================================== Getting started[#](https://ackee.xyz/trident/docs/0.10.0/#getting-started "Permanent link") -------------------------------------------------------------------------------------------- * [Installation](https://ackee.xyz/trident/docs/0.10.0/basics/installation/) - Install the Trident Fuzz Testing Framework * [Start Fuzzing](https://ackee.xyz/trident/docs/0.10.0/start-fuzzing/) - Focus on security and start fuzzing immediately Advanced fuzzing customization[#](https://ackee.xyz/trident/docs/0.10.0/#advanced-fuzzing-customization "Permanent link") -------------------------------------------------------------------------------------------------------------------------- Explore the various features Trident provides. * [Transaction Hooks](https://ackee.xyz/trident/docs/0.10.0/trident-advanced/trident-transactions/transaction-hooks/) - Create and manipulate transactions with different methods * [Fuzzing Flows](https://ackee.xyz/trident/docs/0.10.0/trident-advanced/trident-transactions/trident-fuzzing-flows/) - Explore different approaches to fuzz your program * [Multi-Instruction Transactions](https://ackee.xyz/trident/docs/0.10.0/trident-advanced/trident-transactions/multi-instruction-transactions/) - Compose fuzzed transactions with multiple instructions * [Trident Manifest](https://ackee.xyz/trident/docs/0.10.0/trident-manifest/) - Customize your fuzz tests with different configurations API & Macros Reference[#](https://ackee.xyz/trident/docs/0.10.0/#api-macros-reference "Permanent link") -------------------------------------------------------------------------------------------------------- Check out the API and macro reference for Trident. * [Trident API & Macros](https://ackee.xyz/trident/docs/0.10.0/trident-api-macro/) Trident Examples[#](https://ackee.xyz/trident/docs/0.10.0/#trident-examples "Permanent link") ---------------------------------------------------------------------------------------------- Check out examples to learn how to use Trident. * [Trident Examples](https://ackee.xyz/trident/docs/0.10.0/trident-examples/trident-examples/) TridentSVM[#](https://ackee.xyz/trident/docs/0.10.0/#tridentsvm "Permanent link") ---------------------------------------------------------------------------------- Check out the TridentSVM, lightweight fuzzing execution and account storage environment. * [TridentSVM](https://ackee.xyz/trident/docs/0.10.0/trident-svm/) What is Fuzzing ?[#](https://ackee.xyz/trident/docs/0.10.0/#what-is-fuzzing "Permanent link") ---------------------------------------------------------------------------------------------- _"Fuzz testing is an automated technique that provides generated random, invalid, or unexpected input data to your program. This helps discover unknown bugs and vulnerabilities, potentially preventing zero-day exploits."_ Back to top --- # Trident [Skip to content](https://ackee.xyz/trident/docs/0.8.1/#what-is-fuzzing) Trident ======= ![Trident](https://ackee.xyz/trident/docs/0.8.1/images/trident-logo-smaller.png) Rust-based Fuzzing framework for Solana programs to help you ship secure code. * **Getting Started** * * * Install the Trident Fuzz Testing Framework [Installation](https://ackee.xyz/trident/docs/0.8.1/installation/installation/) * **Start Fuzzing** * * * Focus on security and start fuzzing immediately [Start Fuzzing](https://ackee.xyz/trident/docs/0.8.1/writing-fuzz-test/writing-fuzz-test/) * **Check the GitHub for unreleased features** * * * Check our GitHub repository to see the unreleased features [Trident Repository](https://github.com/Ackee-Blockchain/trident/tree/develop) * **Trident by Examples** * * * Try the Fuzzing Examples [Trident Examples](https://ackee.xyz/trident/docs/0.8.1/examples/examples/) What is Fuzzing ?[#](https://ackee.xyz/trident/docs/0.8.1/#what-is-fuzzing "Permanent link") --------------------------------------------------------------------------------------------- _"Fuzz testing is an automated technique that provides generated random, invalid, or unexpected input data to your program. This helps discover unknown bugs and vulnerabilities, potentially preventing zero-day exploits."_ Back to top --- # Trident - Trident [Skip to content](https://ackee.xyz/trident/docs/0.9.1/#what-is-fuzzing) Trident ======= ![Trident](https://ackee.xyz/trident/docs/0.9.1/images/trident-logo-smaller.png) Rust-based Fuzzing framework for Solana programs to help you ship secure code. * **Getting Started** * * * Install the Trident Fuzz Testing Framework [Installation](https://ackee.xyz/trident/docs/0.9.1/installation/installation/) * **Start Fuzzing** * * * Focus on security and start fuzzing immediately [Start Fuzzing](https://ackee.xyz/trident/docs/0.9.1/writing-fuzz-test/writing-fuzz-test/) * **Check the GitHub for unreleased features** * * * Check our GitHub repository to see the unreleased features [Trident Repository](https://github.com/Ackee-Blockchain/trident/tree/develop) * **Trident by Examples** * * * Try the Fuzzing Examples [Trident Examples](https://ackee.xyz/trident/docs/0.9.1/examples/examples/) What is Fuzzing ?[#](https://ackee.xyz/trident/docs/0.9.1/#what-is-fuzzing "Permanent link") --------------------------------------------------------------------------------------------- _"Fuzz testing is an automated technique that provides generated random, invalid, or unexpected input data to your program. This helps discover unknown bugs and vulnerabilities, potentially preventing zero-day exploits."_ Back to top --- # Redirecting Redirecting to [latest/](https://ackee.xyz/trident/docs/latest/) ... --- # Trident API & Macro Reference - Trident [Skip to content](https://ackee.xyz/trident/docs/0.11.1/trident-api-macro/#trident-api-macro-reference) Trident API & Macro Reference[#](https://ackee.xyz/trident/docs/0.11.1/trident-api-macro/#trident-api-macro-reference "Permanent link") ======================================================================================================================================== This section contains the API and macro reference for Trident. Trident[#](https://ackee.xyz/trident/docs/0.11.1/trident-api-macro/#trident "Permanent link") ---------------------------------------------------------------------------------------------- The Trident struct is the main entry point for fuzzing. It provides methods to interact with the fuzzing environment. * [Trident](https://ackee.xyz/trident/docs/0.11.1/trident-api-macro/trident/trident/) Trident's Fuzz Client[#](https://ackee.xyz/trident/docs/0.11.1/trident-api-macro/#tridents-fuzz-client "Permanent link") ------------------------------------------------------------------------------------------------------------------------- FuzzClient represents the API to interact with the client. * [FuzzClient](https://ackee.xyz/trident/docs/0.11.1/trident-api-macro/trident-fuzz-client/fuzz-client-trait/) Trident Accounts attributes[#](https://ackee.xyz/trident/docs/0.11.1/trident-api-macro/#trident-accounts-attributes "Permanent link") -------------------------------------------------------------------------------------------------------------------------------------- Trident Accounts attributes help to define accounts used in the fuzzing environment. * [TridentAccounts](https://ackee.xyz/trident/docs/0.11.1/trident-api-macro/attributes-for-accounts/account-attributes/) Hooks[#](https://ackee.xyz/trident/docs/0.11.1/trident-api-macro/#hooks "Permanent link") ------------------------------------------------------------------------------------------ Transaction Hooks are used to customize what should be done before the transaction is executed, after it is executed and to check if the changes are valid with invariant checks. * [TransactionHooks](https://ackee.xyz/trident/docs/0.11.1/trident-api-macro/hooks/transaction-hooks/) Instruction Hooks are used to customize instruction data and accounts if the Trident Accounts attributes are not enough. * [InstructionHooks](https://ackee.xyz/trident/docs/0.11.1/trident-api-macro/hooks/instruction-hooks/) Trident Macros[#](https://ackee.xyz/trident/docs/0.11.1/trident-api-macro/#trident-macros "Permanent link") ------------------------------------------------------------------------------------------------------------ Trident macros are used to define required methods for fuzzing. * [TridentTransaction](https://ackee.xyz/trident/docs/0.11.1/trident-api-macro/trident-macros/trident-transaction/) * [TridentInstruction](https://ackee.xyz/trident/docs/0.11.1/trident-api-macro/trident-macros/trident-instruction/) * [TridentAccounts](https://ackee.xyz/trident/docs/0.11.1/trident-api-macro/trident-macros/trident-accounts/) * [TridentRemainingAccounts](https://ackee.xyz/trident/docs/0.11.1/trident-api-macro/trident-macros/trident-remaining-accounts/) * [TridentFlowExecutor](https://ackee.xyz/trident/docs/0.11.1/trident-api-macro/trident-macros/trident-flow-executor/) Trident Types[#](https://ackee.xyz/trident/docs/0.11.1/trident-api-macro/#trident-types "Permanent link") ---------------------------------------------------------------------------------------------------------- Trident types represent the types utilized during fuzzing. * [FuzzAccounts](https://ackee.xyz/trident/docs/0.11.1/trident-api-macro/trident-types/fuzz-accounts/) * [TridentAccount](https://ackee.xyz/trident/docs/0.11.1/trident-api-macro/trident-types/trident-account/) * [TridentPubkey](https://ackee.xyz/trident/docs/0.11.1/trident-api-macro/trident-types/trident-pubkey/) * [CustomTypes](https://ackee.xyz/trident/docs/0.11.1/trident-api-macro/trident-types/custom-types/) Back to top --- # TridentSVM - Trident [Skip to content](https://ackee.xyz/trident/docs/0.11.1/trident-svm/#tridentsvm) TridentSVM[#](https://ackee.xyz/trident/docs/0.11.1/trident-svm/#tridentsvm "Permanent link") ============================================================================================== TridentSVM is a fast execution and accounts storage environment which is utilized within the Trident. Github repository: [Trident SVM](https://github.com/Ackee-Blockchain/trident-svm) TridentSVM uses [Anza's SVM API](https://www.anza.xyz/blog/anzas-new-svm-api) Back to top --- # Trident examples - Trident Trident examples ================ * **Hello World!** * * * Hello World example with Trident. [Hello World!](https://github.com/Ackee-Blockchain/trident/tree/develop/examples/hello_world) * **Cross-Program Invocation** * * * Trident supports Cross-Program Invocation, you can fuzz your programs and create NFTs at the same time. [Simple CPI](https://github.com/Ackee-Blockchain/trident/tree/develop/examples/cpi) [CPI with Metaplex Metadata Program](https://github.com/Ackee-Blockchain/trident/tree/develop/examples/metaplex) * **Benchmarking** * * * Trident contains benchmarks of [Daedaluzz: A Benchmark Generator for Smart-Contract Fuzzers](https://github.com/Consensys/daedaluzz) rewritten in Rust. [Trident Benchmark](https://github.com/Ackee-Blockchain/trident/tree/develop/examples/trident-benchmark) * **Fuzzing Pipeline** * * * Trident provides a fuzzing pipeline that can be used to fuzz your programs. [Fuzzing pipeline](https://github.com/Ackee-Blockchain/trident/blob/master/.github/workflows/fuzz.yml) Back to top --- # Start Fuzzing - Trident [Skip to content](https://ackee.xyz/trident/docs/0.11.1/start-fuzzing/#start-fuzzing) Start Fuzzing[#](https://ackee.xyz/trident/docs/0.11.1/start-fuzzing/#start-fuzzing "Permanent link") ====================================================================================================== To start writing fuzz tests, you need to initialize Trident in your Anchor-based workspace. `[](https://ackee.xyz/trident/docs/0.11.1/start-fuzzing/#__codelineno-0-1) trident init` If you have already initialized Trident, you can add a new fuzz test using: `[](https://ackee.xyz/trident/docs/0.11.1/start-fuzzing/#__codelineno-1-1) trident fuzz add` Trident creates a new fuzz test template in the `trident-tests` directory, with the following structure: `[](https://ackee.xyz/trident/docs/0.11.1/start-fuzzing/#__codelineno-2-1) project-root [](https://ackee.xyz/trident/docs/0.11.1/start-fuzzing/#__codelineno-2-2) ├── trident-tests [](https://ackee.xyz/trident/docs/0.11.1/start-fuzzing/#__codelineno-2-3) │ ├── fuzz_0 # particular fuzz test [](https://ackee.xyz/trident/docs/0.11.1/start-fuzzing/#__codelineno-2-4) │ │ ├── instructions # instructions folder [](https://ackee.xyz/trident/docs/0.11.1/start-fuzzing/#__codelineno-2-5) │ │ ├── transactions # transactions folder [](https://ackee.xyz/trident/docs/0.11.1/start-fuzzing/#__codelineno-2-6) │ │ ├── test_fuzz.rs # the binary target of your fuzz test [](https://ackee.xyz/trident/docs/0.11.1/start-fuzzing/#__codelineno-2-7) │ │ ├── types.rs # the types of your fuzz test [](https://ackee.xyz/trident/docs/0.11.1/start-fuzzing/#__codelineno-2-8) │ │ └── fuzz_instructions.rs # the definition of your fuzz test [](https://ackee.xyz/trident/docs/0.11.1/start-fuzzing/#__codelineno-2-9) │ ├── fuzz_1 [](https://ackee.xyz/trident/docs/0.11.1/start-fuzzing/#__codelineno-2-10) │ ├── fuzz_X # possible multiple fuzz tests [](https://ackee.xyz/trident/docs/0.11.1/start-fuzzing/#__codelineno-2-11) │ ├── fuzzing # compilations and crashes folder [](https://ackee.xyz/trident/docs/0.11.1/start-fuzzing/#__codelineno-2-12) │ ├── Cargo.toml [](https://ackee.xyz/trident/docs/0.11.1/start-fuzzing/#__codelineno-2-13) │ └── Trident.toml [](https://ackee.xyz/trident/docs/0.11.1/start-fuzzing/#__codelineno-2-14) └── ...` `Instructions` folder contains the `instructions` that can be used in the fuzz test. `Transactions` folder contains the `transactions` that will be used during the fuzzing, each transaction can contain `one` or `multiple instructions`, based on the developer's choice. By default there is only one instruction in each transaction. Back to top --- # Trident Advanced - Trident [Skip to content](https://ackee.xyz/trident/docs/0.11.1/trident-advanced/#trident-advanced) Trident Advanced[#](https://ackee.xyz/trident/docs/0.11.1/trident-advanced/#trident-advanced "Permanent link") =============================================================================================================== This section contains advanced customization options for Trident. Transaction-related[#](https://ackee.xyz/trident/docs/0.11.1/trident-advanced/#transaction-related "Permanent link") --------------------------------------------------------------------------------------------------------------------- * [Transaction Hooks](https://ackee.xyz/trident/docs/0.11.1/trident-advanced/trident-transactions/transaction-hooks/) - Add custom logic to the transaction execution process * [Multi-Instruction Transactions](https://ackee.xyz/trident/docs/0.11.1/trident-advanced/trident-transactions/multi-instruction-transactions/) - Execute multiple instructions in a single transaction Analysis & Visualization[#](https://ackee.xyz/trident/docs/0.11.1/trident-advanced/#analysis-visualization "Permanent link") ----------------------------------------------------------------------------------------------------------------------------- * [Code Coverage](https://ackee.xyz/trident/docs/0.11.1/trident-advanced/code-coverage/) - Measure code coverage of the fuzzed program * [Dashboard](https://ackee.xyz/trident/docs/0.11.1/trident-advanced/dashboard/) - Visualize fuzzing metrics in a dashboard * [Regression Testing](https://ackee.xyz/trident/docs/0.11.1/trident-advanced/regression/) - Compare two regression test results Back to top --- # Trident Manifest - Trident [Skip to content](https://ackee.xyz/trident/docs/0.11.1/trident-manifest/#trident-manifest) Trident Manifest[#](https://ackee.xyz/trident/docs/0.11.1/trident-manifest/#trident-manifest "Permanent link") =============================================================================================================== Trident supports its own Trident Manifest, called `Trident.toml`. This section describes all possible configuration fields. Fuzzing Metrics[#](https://ackee.xyz/trident/docs/0.11.1/trident-manifest/#fuzzing-metrics "Permanent link") ------------------------------------------------------------------------------------------------------------- `[](https://ackee.xyz/trident/docs/0.11.1/trident-manifest/#__codelineno-0-1) [fuzz.metrics] [](https://ackee.xyz/trident/docs/0.11.1/trident-manifest/#__codelineno-0-2) enabled = true [](https://ackee.xyz/trident/docs/0.11.1/trident-manifest/#__codelineno-0-3) dashboard = false [](https://ackee.xyz/trident/docs/0.11.1/trident-manifest/#__codelineno-0-4) json = false` * `enabled` - Trident will show and save statistics after the fuzzing session. * `dashboard` - Trident will save a HTML dashboard after the fuzzing session. * `json` - Trident will save a JSON file after the fuzzing session. * * * Regression testing[#](https://ackee.xyz/trident/docs/0.11.1/trident-manifest/#regression-testing "Permanent link") ------------------------------------------------------------------------------------------------------------------- `[](https://ackee.xyz/trident/docs/0.11.1/trident-manifest/#__codelineno-1-1) [fuzz.regression] [](https://ackee.xyz/trident/docs/0.11.1/trident-manifest/#__codelineno-1-2) enabled = true` * `enabled` - Trident will save a JSON file with all monitored states after the fuzzing session. Regression testing * Keep in mind that the feature hashes contents of accounts, if the contents are dependant for example on time, the final hash might not be the same as the one from the first fuzzing session. * * * Fuzzing Coverage[#](https://ackee.xyz/trident/docs/0.11.1/trident-manifest/#fuzzing-coverage "Permanent link") --------------------------------------------------------------------------------------------------------------- `[](https://ackee.xyz/trident/docs/0.11.1/trident-manifest/#__codelineno-2-1) [fuzz.coverage] [](https://ackee.xyz/trident/docs/0.11.1/trident-manifest/#__codelineno-2-2) enable = true # default: false [](https://ackee.xyz/trident/docs/0.11.1/trident-manifest/#__codelineno-2-3) server_port = 58432 # default: 58432 [](https://ackee.xyz/trident/docs/0.11.1/trident-manifest/#__codelineno-2-4) loopcount = 5 # default: 0 [](https://ackee.xyz/trident/docs/0.11.1/trident-manifest/#__codelineno-2-5) format = "json" # default: "json" [](https://ackee.xyz/trident/docs/0.11.1/trident-manifest/#__codelineno-2-6) attach_extension = true # default: false` The coverage configuration enables code coverage analysis during fuzzing sessions, providing insights into which parts of your program are being tested. * `enable` - When set to `true`, Trident collects code coverage data throughout the fuzzing session and generates a comprehensive report upon completion. * `server_port` - Specifies the HTTP server port used for communication between Trident and the [Solana VS Code extension](https://marketplace.visualstudio.com/items?itemName=AckeeBlockchain.solana) . * `loopcount` - Defines the number of execution flows processed before generating an intermediate coverage data file. Lower values provide more frequent coverage updates at the cost of performance. When set to `0`, coverage files are only generated at the end of the fuzzing session. * `format` - Determines the output format for coverage reports. Trident supports both `json` and `html` formats. * `attach_extension` - Enables real-time coverage visualization in VS Code when the extension is active. This feature requires `loopcount` to be greater than `0` and `format` to be set to `json`. Warning Coverage is only gathered for the programs deployed through an entrypoint! Entrypoint deployment guide 1. Comment out the program in `Trident.toml` `[](https://ackee.xyz/trident/docs/0.11.1/trident-manifest/#__codelineno-3-1) # [[fuzz.programs]] [](https://ackee.xyz/trident/docs/0.11.1/trident-manifest/#__codelineno-3-2) # address = "example_address" [](https://ackee.xyz/trident/docs/0.11.1/trident-manifest/#__codelineno-3-3) # program = "../target/deploy/example_program.so"` 2. Add the program dependency to `Cargo.toml` `[](https://ackee.xyz/trident/docs/0.11.1/trident-manifest/#__codelineno-4-1) [dependencies.example_program] [](https://ackee.xyz/trident/docs/0.11.1/trident-manifest/#__codelineno-4-2) path = "../programs/example_program"` 3. Add `syscall-v1` or `syscall-v2` feature depending on the version of `solana-program`. Programs written for `solana-program` v1.x should use `syscall-v1`, programs written for `solana-program` v2.x should use `syscall-v2` feature. `[](https://ackee.xyz/trident/docs/0.11.1/trident-manifest/#__codelineno-5-1) [dependencies.trident-fuzz] [](https://ackee.xyz/trident/docs/0.11.1/trident-manifest/#__codelineno-5-2) features = ["syscall-v2"]` 4. Import the programs entrypoint in `test_fuzz.rs` `[](https://ackee.xyz/trident/docs/0.11.1/trident-manifest/#__codelineno-6-1) use example_program::entry as example_entrypoint;` 5. Deploy the entrypoint in `test_fuzz.rs` `[](https://ackee.xyz/trident/docs/0.11.1/trident-manifest/#__codelineno-7-1) impl FuzzTest { [](https://ackee.xyz/trident/docs/0.11.1/trident-manifest/#__codelineno-7-2) fn new() -> Self { [](https://ackee.xyz/trident/docs/0.11.1/trident-manifest/#__codelineno-7-3) let mut trident = Trident::default(); [](https://ackee.xyz/trident/docs/0.11.1/trident-manifest/#__codelineno-7-4) [](https://ackee.xyz/trident/docs/0.11.1/trident-manifest/#__codelineno-7-5) // Deploy through the entrypoint [](https://ackee.xyz/trident/docs/0.11.1/trident-manifest/#__codelineno-7-6) let program = TridentEntrypoint::new(example_program::ID, None, processor!(example_entrypoint)); [](https://ackee.xyz/trident/docs/0.11.1/trident-manifest/#__codelineno-7-7) trident.get_client().deploy_entrypoint(program); [](https://ackee.xyz/trident/docs/0.11.1/trident-manifest/#__codelineno-7-8) [](https://ackee.xyz/trident/docs/0.11.1/trident-manifest/#__codelineno-7-9) Self { [](https://ackee.xyz/trident/docs/0.11.1/trident-manifest/#__codelineno-7-10) trident, [](https://ackee.xyz/trident/docs/0.11.1/trident-manifest/#__codelineno-7-11) fuzz_accounts: FuzzAccounts::default(), [](https://ackee.xyz/trident/docs/0.11.1/trident-manifest/#__codelineno-7-12) } [](https://ackee.xyz/trident/docs/0.11.1/trident-manifest/#__codelineno-7-13) } [](https://ackee.xyz/trident/docs/0.11.1/trident-manifest/#__codelineno-7-14) ...` * * * Programs[#](https://ackee.xyz/trident/docs/0.11.1/trident-manifest/#programs "Permanent link") ----------------------------------------------------------------------------------------------- * Use dumped program from desired cluster, during fuzzing. `[](https://ackee.xyz/trident/docs/0.11.1/trident-manifest/#__codelineno-8-1) [[fuzz.programs]] [](https://ackee.xyz/trident/docs/0.11.1/trident-manifest/#__codelineno-8-2) address = "metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s" [](https://ackee.xyz/trident/docs/0.11.1/trident-manifest/#__codelineno-8-3) upgrade_authority = "account address goes here" [](https://ackee.xyz/trident/docs/0.11.1/trident-manifest/#__codelineno-8-4) program = "metaplex-program/metaplex-token-metadata.so"` * * * Accounts[#](https://ackee.xyz/trident/docs/0.11.1/trident-manifest/#accounts "Permanent link") ----------------------------------------------------------------------------------------------- * Use dumped accounts from desired cluster, during fuzzing. `[](https://ackee.xyz/trident/docs/0.11.1/trident-manifest/#__codelineno-9-1) [[fuzz.accounts]] [](https://ackee.xyz/trident/docs/0.11.1/trident-manifest/#__codelineno-9-2) address = "6YG3J7PaxyMnnbU67ifyrgF3BzNzc7cD8hPkqK6ATweE" [](https://ackee.xyz/trident/docs/0.11.1/trident-manifest/#__codelineno-9-3) filename = "tests/accounts/core_bridge_mainnet/guardian_set_5_mock.json"` * * * Back to top --- # Installation - Trident [Skip to content](https://ackee.xyz/trident/docs/0.11.1/basics/installation/#installation) Installation[#](https://ackee.xyz/trident/docs/0.11.1/basics/installation/#installation "Permanent link") ========================================================================================================== Trident requires the following prerequisites: Prerequisites Before proceeding, ensure you have installed: * [Rust](https://www.rust-lang.org/tools/install) (stable version) * [Solana CLI](https://solana.com/docs/intro/installation) * [Anchor](https://www.anchor-lang.com/docs/installation) Check out [supported versions](https://ackee.xyz/trident/docs/0.11.1/basics/installation/#supported-versions) for version compatibility. Install Trident[#](https://ackee.xyz/trident/docs/0.11.1/basics/installation/#install-trident "Permanent link") ---------------------------------------------------------------------------------------------------------------- `[](https://ackee.xyz/trident/docs/0.11.1/basics/installation/#__codelineno-0-1) cargo install trident-cli` You can also use the `version` flag to install a specific version: `[](https://ackee.xyz/trident/docs/0.11.1/basics/installation/#__codelineno-1-1) cargo install trident-cli --version x.y.z` Install cargo-llvm-cov[#](https://ackee.xyz/trident/docs/0.11.1/basics/installation/#install-cargo-llvm-cov "Permanent link") ------------------------------------------------------------------------------------------------------------------------------ To enable code coverage tracking during fuzzing, install [cargo-llvm-cov](https://github.com/taiki-e/cargo-llvm-cov) : `[](https://ackee.xyz/trident/docs/0.11.1/basics/installation/#__codelineno-2-1) cargo +stable install cargo-llvm-cov --locked` Supported versions[#](https://ackee.xyz/trident/docs/0.11.1/basics/installation/#supported-versions "Permanent link") ---------------------------------------------------------------------------------------------------------------------- Version Table Legend * \= Develop branch * \= Released version * `-` = Not required/supported | **Version Type** | **Anchor** | **Solana** | **Rust** | **Honggfuzz** | **AFL** | | --- | --- | --- | --- | --- | --- | | Development | `>=0.29.0` | `>=1.17.3` | `1.86` | `-` | `-` | | **Current (0.11.x)** | `>=0.29.0` | `>=1.17.3` | `1.86` | `-` | `-` | | **0.10.x** | `>=0.29.0 < 0.31.0` | `>=1.17.3 < 2.1` | `nightly` | `0.5.56` | `0.15.11` | | **0.9.x** | `>=0.29.0 < 0.31.0` | `>=1.17.3 < 2.1` | `nightly` | `0.5.56` | `0.15.11` | | **0.8.x** | `0.30.1` | `^1.17.4` | `nightly` | `0.5.56` | `-` | | **0.7.x** | `>=0.29.*` | `^1.17.4` | `nightly` | `0.5.56` | `-` | | **0.6.x** | `>=0.29.*` | `^1.17` | `nightly` | `0.5.55` | `-` | | **0.5.x** | `~0.28.*` | `=1.16.6` | `-` | `-` | `-` | | **0.4.x** | `~0.27.*` | `>=1.15` | `-` | `-` | `-` | | **0.3.x** | `~0.25.*` | `>=1.10` | `-` | `-` | `-` | | **0.2.x** | `~0.24.*` | `>=1.9` | `-` | `-` | `-` | Back to top --- # Installation - Trident [Skip to content](https://ackee.xyz/trident/docs/0.7.0/getting-started/getting-started/#installation) Installation[#](https://ackee.xyz/trident/docs/0.7.0/getting-started/getting-started/#installation "Permanent link") ===================================================================================================================== This guide will walk you through the Installation process of Trident. Important **Prerequisite** It is expected that you have installed: * Rust ([Install Rust](https://www.rust-lang.org/tools/install) ) * Solana CLI ([Install Solana CLI](https://docs.solanalabs.com/cli/install) ) * Anchor Framework ([Install Anchor](https://www.anchor-lang.com/docs/installation) ) For supported versions check the [Supported Versions](https://ackee.xyz/trident/docs/0.7.0/getting-started/getting-started/#supported-versions) Install System Dependencies[#](https://ackee.xyz/trident/docs/0.7.0/getting-started/getting-started/#install-system-dependencies "Permanent link") --------------------------------------------------------------------------------------------------------------------------------------------------- Update your package list and install the required packages: `[](https://ackee.xyz/trident/docs/0.7.0/getting-started/getting-started/#__codelineno-0-1) sudo apt-get update [](https://ackee.xyz/trident/docs/0.7.0/getting-started/getting-started/#__codelineno-0-2) sudo apt-get install -y \ [](https://ackee.xyz/trident/docs/0.7.0/getting-started/getting-started/#__codelineno-0-3) curl \ [](https://ackee.xyz/trident/docs/0.7.0/getting-started/getting-started/#__codelineno-0-4) git \ [](https://ackee.xyz/trident/docs/0.7.0/getting-started/getting-started/#__codelineno-0-5) build-essential \ [](https://ackee.xyz/trident/docs/0.7.0/getting-started/getting-started/#__codelineno-0-6) pkg-config \ [](https://ackee.xyz/trident/docs/0.7.0/getting-started/getting-started/#__codelineno-0-7) libssl-dev \ [](https://ackee.xyz/trident/docs/0.7.0/getting-started/getting-started/#__codelineno-0-8) npm \ [](https://ackee.xyz/trident/docs/0.7.0/getting-started/getting-started/#__codelineno-0-9) vim \ [](https://ackee.xyz/trident/docs/0.7.0/getting-started/getting-started/#__codelineno-0-10) nano \ [](https://ackee.xyz/trident/docs/0.7.0/getting-started/getting-started/#__codelineno-0-11) wget \ [](https://ackee.xyz/trident/docs/0.7.0/getting-started/getting-started/#__codelineno-0-12) binutils-dev \ [](https://ackee.xyz/trident/docs/0.7.0/getting-started/getting-started/#__codelineno-0-13) libunwind-dev \ [](https://ackee.xyz/trident/docs/0.7.0/getting-started/getting-started/#__codelineno-0-14) lldb` Install Trident and Honggfuzz[#](https://ackee.xyz/trident/docs/0.7.0/getting-started/getting-started/#install-trident-and-honggfuzz "Permanent link") ------------------------------------------------------------------------------------------------------------------------------------------------------- Install them using the following commands: `[](https://ackee.xyz/trident/docs/0.7.0/getting-started/getting-started/#__codelineno-1-1) cargo install trident-cli [](https://ackee.xyz/trident/docs/0.7.0/getting-started/getting-started/#__codelineno-1-2) cargo install honggfuzz` Supported versions[#](https://ackee.xyz/trident/docs/0.7.0/getting-started/getting-started/#supported-versions "Permanent link") --------------------------------------------------------------------------------------------------------------------------------- | Trident CLI | Anchor | Solana | Rust | Honggfuzz | | --- | --- | --- | --- | --- | | `v0.7.0` | `>=0.29.*`1 | `^1.17.4` | `nightly` | `0.5.56` | | `v0.6.0` | `>=0.29.*`1 | `^1.17` | `nightly` | `0.5.55` | | `v0.5.0` | `~0.28.*` | `=1.16.6` | \- | \- | | `v0.4.0` | `~0.27.*` | `>=1.15` | \- | \- | | `v0.3.0` | `~0.25.*` | `>=1.10` | \- | \- | | `v0.2.0` | `~0.24.*` | `>=1.9` | \- | \- | 1. To use Trident with Anchor 0.29.0, run the following commands from your project's root directory after Trident initialization: `[](https://ackee.xyz/trident/docs/0.7.0/getting-started/getting-started/#__codelineno-2-1) cargo update [[email protected]](https://ackee.xyz/cdn-cgi/l/email-protection) --precise 0.29.0 [](https://ackee.xyz/trident/docs/0.7.0/getting-started/getting-started/#__codelineno-2-2) cargo update [[email protected]](https://ackee.xyz/cdn-cgi/l/email-protection) --precise 0.29.0` Back to top --- # Introduction - Trident [Skip to content](https://ackee.xyz/trident/docs/0.7.0/integration-tests/poc-introduction/#introduction) Introduction[#](https://ackee.xyz/trident/docs/0.7.0/integration-tests/poc-introduction/#introduction "Permanent link") ======================================================================================================================== Trident supports writing Integration Tests in Rust. marcinv@XPS15:~/Work/tooling/trident/examples/turnstile$ marcinv@XPS15:~/Work/tooling/trident/examples/turnstile$ t marcinv@XPS15:~/Work/tooling/trident/examples/turnstile$ tr marcinv@XPS15:~/Work/tooling/trident/examples/turnstile$ tri marcinv@XPS15:~/Work/tooling/trident/examples/turnstile$ trid marcinv@XPS15:~/Work/tooling/trident/examples/turnstile$ tride marcinv@XPS15:~/Work/tooling/trident/examples/turnstile$ triden marcinv@XPS15:~/Work/tooling/trident/examples/turnstile$ trident marcinv@XPS15:~/Work/tooling/trident/examples/turnstile$ trident marcinv@XPS15:~/Work/tooling/trident/examples/turnstile$ trident marcinv@XPS15:~/Work/tooling/trident/examples/turnstile$ trident t marcinv@XPS15:~/Work/tooling/trident/examples/turnstile$ trident te marcinv@XPS15:~/Work/tooling/trident/examples/turnstile$ trident tes marcinv@XPS15:~/Work/tooling/trident/examples/turnstile$ trident test marcinv@XPS15:~/Work/tooling/trident/examples/turnstile$ trident test Finished test \[unoptimized + debuginfo\] target(s) in 0.17s Running unittests src/lib.rs (target/debug/deps/program\_client-35df7129a7acbd48)running 0 teststest result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s Running tests/test.rs (target/debug/deps/test-e1d41610f5897c1f)running 2 tests\-------------- TEST START --------------program\_keypair(1).pubkey = Po1RaS8BEDbNcn5oXsFryAeQ6Wn8fvmE111DJaKCgPCWaiting for fees to stabilize 1...test test\_unhappy\_path ... okWaiting for fees to stabilize 2...test test\_happy\_path ... oktest result: ok. 2 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 14.89s Running unittests src/lib.rs (target/debug/deps/turnstile-451803623b25a701)running 1 testtest test\_id ... oktest result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s Doc-tests program\_clientmarcinv@XPS15:~/Work/tooling/trident/examples/turnstile$ exit Back to top --- # Commands - Trident [Skip to content](https://ackee.xyz/trident/docs/0.11.1/basics/commands/#commands) Commands[#](https://ackee.xyz/trident/docs/0.11.1/basics/commands/#commands "Permanent link") ============================================================================================== Trident CLI supports the following commands: `trident init`[#](https://ackee.xyz/trident/docs/0.11.1/basics/commands/#trident-init "Permanent link") -------------------------------------------------------------------------------------------------------- Initializes Trident Workspace and generates new Fuzz Test Template. Creates the following structure: `[](https://ackee.xyz/trident/docs/0.11.1/basics/commands/#__codelineno-0-1) project-root [](https://ackee.xyz/trident/docs/0.11.1/basics/commands/#__codelineno-0-2) ├── trident-tests [](https://ackee.xyz/trident/docs/0.11.1/basics/commands/#__codelineno-0-3) │ ├── fuzz_0 # particular fuzz test [](https://ackee.xyz/trident/docs/0.11.1/basics/commands/#__codelineno-0-4) │ │ ├── instructions # instructions folder [](https://ackee.xyz/trident/docs/0.11.1/basics/commands/#__codelineno-0-5) │ │ ├── transactions # transactions folder [](https://ackee.xyz/trident/docs/0.11.1/basics/commands/#__codelineno-0-6) │ │ ├── test_fuzz.rs # the binary target of your fuzz test [](https://ackee.xyz/trident/docs/0.11.1/basics/commands/#__codelineno-0-7) │ │ ├── types.rs # the types of your fuzz test [](https://ackee.xyz/trident/docs/0.11.1/basics/commands/#__codelineno-0-8) │ │ └── fuzz_instructions.rs # the definition of your fuzz test [](https://ackee.xyz/trident/docs/0.11.1/basics/commands/#__codelineno-0-9) │ ├── fuzz_1 [](https://ackee.xyz/trident/docs/0.11.1/basics/commands/#__codelineno-0-10) │ ├── fuzz_X # possible multiple fuzz tests [](https://ackee.xyz/trident/docs/0.11.1/basics/commands/#__codelineno-0-11) │ ├── fuzzing # compilations and crashes folder [](https://ackee.xyz/trident/docs/0.11.1/basics/commands/#__codelineno-0-12) │ ├── Cargo.toml [](https://ackee.xyz/trident/docs/0.11.1/basics/commands/#__codelineno-0-13) │ └── Trident.toml # Configuration file located in trident-tests directory [](https://ackee.xyz/trident/docs/0.11.1/basics/commands/#__codelineno-0-14) └── ...` #### Options[#](https://ackee.xyz/trident/docs/0.11.1/basics/commands/#options "Permanent link") * `-f, --force` - Force Trident initialization. Trident dependencies will be updated based on the version of Trident CLI. * `-s, --skip-build` - Skip building the program before initializing Trident. * `-p, --program-name ` - Specify the name of the program for which fuzz test will be generated. * `-t, --test-name ` - Name of the fuzz test to initialize. * * * `trident how`[#](https://ackee.xyz/trident/docs/0.11.1/basics/commands/#trident-how "Permanent link") ------------------------------------------------------------------------------------------------------ Show the HowTo message about writing fuzz tests. * * * `trident fuzz`[#](https://ackee.xyz/trident/docs/0.11.1/basics/commands/#trident-fuzz "Permanent link") -------------------------------------------------------------------------------------------------------- Run fuzz subcommands. With fuzz subcommands you can add new fuzz test template or you can run fuzz test on already initialized one. **Examples:** `[](https://ackee.xyz/trident/docs/0.11.1/basics/commands/#__codelineno-1-1) trident fuzz add [](https://ackee.xyz/trident/docs/0.11.1/basics/commands/#__codelineno-1-2) trident fuzz run fuzz_0 [](https://ackee.xyz/trident/docs/0.11.1/basics/commands/#__codelineno-1-3) trident fuzz debug ` ### `trident fuzz add`[#](https://ackee.xyz/trident/docs/0.11.1/basics/commands/#trident-fuzz-add "Permanent link") Generate new Fuzz Test template. #### Options[#](https://ackee.xyz/trident/docs/0.11.1/basics/commands/#options_1 "Permanent link") * `-p, --program-name ` - Specify the name of the program for which the fuzz test will be generated. * `-t, --test-name ` - Name of the fuzz test to add. * `-s, --skip-build` - Skip building the program before adding new fuzz test. * * * ### `trident fuzz run `[#](https://ackee.xyz/trident/docs/0.11.1/basics/commands/#trident-fuzz-run-fuzz_target "Permanent link") Directory Note Execute fuzz tests from the `trident-tests` directory. Solana Logs In case you want to see the logs of the fuzzed transactions, prefix the command with `TRIDENT_LOG=1`. `[](https://ackee.xyz/trident/docs/0.11.1/basics/commands/#__codelineno-2-1) TRIDENT_LOG=1 trident fuzz run ` Runs the specified Fuzz Target using Trident's Manually Guided Fuzzing (e.g., fuzz\_0). #### Arguments[#](https://ackee.xyz/trident/docs/0.11.1/basics/commands/#arguments "Permanent link") * `` - Name of the desired fuzz template to execute (for example fuzz\_0). * `[seed]` - Master seed used for fuzzing, if not provided it will be generated randomly. #### Options[#](https://ackee.xyz/trident/docs/0.11.1/basics/commands/#options_2 "Permanent link") * `-w, --with-exit-code` - Run the fuzzing with exit code, i.e. if it discovers crash the Trident will exit with exit code 1. * * * ### `trident fuzz debug `[#](https://ackee.xyz/trident/docs/0.11.1/basics/commands/#trident-fuzz-debug-fuzz_target-seed "Permanent link") Debug crashes by analyzing specific crash files using the provided seed. #### Arguments[#](https://ackee.xyz/trident/docs/0.11.1/basics/commands/#arguments_1 "Permanent link") * `` - Name of the desired fuzz template to execute (for example fuzz\_0). * `` - Master seed of the desired fuzz template to execute. Debug Output The debug output includes: 1. Transaction logs 2. Instruction data structures 3. Panic/Crash information * * * `trident clean`[#](https://ackee.xyz/trident/docs/0.11.1/basics/commands/#trident-clean "Permanent link") ---------------------------------------------------------------------------------------------------------- Clean build target, additionally perform `anchor clean`. * * * `trident server`[#](https://ackee.xyz/trident/docs/0.11.1/basics/commands/#trident-server "Permanent link") ------------------------------------------------------------------------------------------------------------ Starts the Trident Server, in order to make it easier to visualize the fuzzing dashboard, more info in the [dashboard](https://ackee.xyz/trident/docs/0.11.1/trident-advanced/dashboard/) section. * * * `trident compare`[#](https://ackee.xyz/trident/docs/0.11.1/basics/commands/#trident-compare "Permanent link") -------------------------------------------------------------------------------------------------------------- Allows you to compare two fuzzing regression results. More info in the [regression](https://ackee.xyz/trident/docs/0.11.1/trident-advanced/regression/) section. * * * Back to top --- # Changelog - Trident [Skip to content](https://ackee.xyz/trident/docs/0.6.0/CHANGELOG/#changelog) Changelog[#](https://ackee.xyz/trident/docs/0.6.0/CHANGELOG/#changelog "Permanent link") ========================================================================================= All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) , and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html) (SemVer). **Note**: Version 0 of Semantic Versioning is handled differently from version 1 and above. The minor version will be incremented upon a breaking change and the patch version will be incremented for features. \[dev\] - Unreleased[#](https://ackee.xyz/trident/docs/0.6.0/CHANGELOG/#dev-unreleased "Permanent link") --------------------------------------------------------------------------------------------------------- \[0.6.0\] - 2024-05-20[#](https://ackee.xyz/trident/docs/0.6.0/CHANGELOG/#060-2024-05-20 "Permanent link") ----------------------------------------------------------------------------------------------------------- ### Added[#](https://ackee.xyz/trident/docs/0.6.0/CHANGELOG/#added "Permanent link") * feat/anchor 0.30.0 support ([#148](https://github.com/Ackee-Blockchain/trident/pull/148) ) * fix/allow to process duplicate transactions ([#147](https://github.com/Ackee-Blockchain/trident/pull/147) ) * feat/possibility to implement custom transaction error handling ([#145](https://github.com/Ackee-Blockchain/trident/pull/145) ) * feat/support of automatically obtaining fully qualified paths of Data Accounts Custom types for `accounts_snapshots.rs` ([#141](https://github.com/Ackee-Blockchain/trident/pull/141) ) * feat/allow direct accounts manipulation and storage ([#142](https://github.com/Ackee-Blockchain/trident/pull/142) ) * feat/support of non-corresponding instruction and context names ([#130](https://github.com/Ackee-Blockchain/trident/pull/130) ) * feat/refactored and improved program flow during init and build, added activity indicator ([#129](https://github.com/Ackee-Blockchain/trident/pull/129) ) * feat/allow solana versions up to v1.17.\* and pin Rust 1.77 nightly compiler ([#128](https://github.com/Ackee-Blockchain/trident/pull/128) ) * feat/new init command option to initialize fuzz or poc tests only ([#124](https://github.com/Ackee-Blockchain/trident/pull/124) ) * feat/debug-mode detailed output ([#125](https://github.com/Ackee-Blockchain/trident/pull/125) ) * feat/anchor 0.29.0 support ([#121](https://github.com/Ackee-Blockchain/trident/pull/121) ) * doc/add help comment + update documentation ([#120](https://github.com/Ackee-Blockchain/trident/pull/120) ) * feat/fuzzer error handling ([#118](https://github.com/Ackee-Blockchain/trident/pull/118) ) * feat/convert fuzz Pubkey to AccountId ([#116](https://github.com/Ackee-Blockchain/trident/pull/116) ) * feat/additional anchor types ([#115](https://github.com/Ackee-Blockchain/trident/pull/115) ) * feat/import ToAccountInfo trait in fuzzing prelude ([#113](https://github.com/Ackee-Blockchain/trident/pull/113) ) * test/added code generation and macros tests ([#112](https://github.com/Ackee-Blockchain/trident/pull/112) ) * feat/fuzzer framework core, macros, helpers, templates, and examples. ([#111](https://github.com/Ackee-Blockchain/trident/pull/111) ) * feat/improved trident-tests folder structure for PoC and Fuzz Tests ([#109](https://github.com/Ackee-Blockchain/trident/pull/109) ) * feat/support for additional fuzzer parameters in Trident.toml config file ([#107](https://github.com/Ackee-Blockchain/trident/pull/107) ) * feat/posibility to pass params to the fuzzer via Trident.toml config file ([#106](https://github.com/Ackee-Blockchain/trident/pull/106) ) * feat/client now reads by default keypair from default location ([#105](https://github.com/Ackee-Blockchain/trident/pull/105) ) * feat/added new --exit-code option to return corresponding exit code based on fuzz test result ([#104](https://github.com/Ackee-Blockchain/trident/pull/104) ) * feat/removed/updated deprecated functions, removed allow deprecated macros ([#103](https://github.com/Ackee-Blockchain/trident/pull/103) ) * feat/added new function to read keypair file generated by Anchor ([#102](https://github.com/Ackee-Blockchain/trident/pull/102) ) * feat/clean command ([#101](https://github.com/Ackee-Blockchain/trident/pull/101) ) * feat/improved program\_client generated code ([#100](https://github.com/Ackee-Blockchain/trident/pull/100) ) * feat/automatically add hfuzz\_target to .gitignore file ([#99](https://github.com/Ackee-Blockchain/trident/pull/99) ) * feat/support for dynamic templates. ([#98](https://github.com/Ackee-Blockchain/trident/pull/98) ) ### Fixed[#](https://ackee.xyz/trident/docs/0.6.0/CHANGELOG/#fixed "Permanent link") * fix/refactored fuzz test executor error handling ([#127](https://github.com/Ackee-Blockchain/trident/pull/127) ) * fix/warn user on composite accounts and continue fuzz test generation ([#133](https://github.com/Ackee-Blockchain/trident/pull/133) ) * fix/progress bar loop lock release ([#132](https://github.com/Ackee-Blockchain/trident/pull/132) ) * fix/fixed fuzz test generation with init-if-needed Anchor feature ([#131](https://github.com/Ackee-Blockchain/trident/pull/131) ) * fix/program client custom types ([#117](https://github.com/Ackee-Blockchain/trident/pull/117) ) * fix/check fuzz test name collision by checking the name against HashSet ([#114](https://github.com/Ackee-Blockchain/trident/pull/114) ) \[0.5.0\] - 2023-08-28[#](https://ackee.xyz/trident/docs/0.6.0/CHANGELOG/#050-2023-08-28 "Permanent link") ----------------------------------------------------------------------------------------------------------- ### Added[#](https://ackee.xyz/trident/docs/0.6.0/CHANGELOG/#added_1 "Permanent link") * cli: Added trident subcommand `fuzz` to run and debug fuzz tests using honggfuzz-rs. * cli: Added trident `--skip-fuzzer` option for `init` subcommand to skip generation of fuzz test templates. * client: Added new Cargo feature `fuzzing` that enables optional dependencies related to fuzz testing. \[0.4.1\] - 2023-08-21[#](https://ackee.xyz/trident/docs/0.6.0/CHANGELOG/#041-2023-08-21 "Permanent link") ----------------------------------------------------------------------------------------------------------- ### Changed[#](https://ackee.xyz/trident/docs/0.6.0/CHANGELOG/#changed "Permanent link") * Upgrade Solana (`=1.16.6`) and Anchor framework (`=0.28.0`) versions. ### Fixed[#](https://ackee.xyz/trident/docs/0.6.0/CHANGELOG/#fixed_1 "Permanent link") * Implemented Anchor Client logic was not able to work with newer version of Anchor. Fixed with `async_rpc` and `async` feature. * Trident init IDL Parse Error on newer version of Rust, fixed with updated `accounts` token. \[0.3.0\] - 2022-09-23[#](https://ackee.xyz/trident/docs/0.6.0/CHANGELOG/#030-2022-09-23 "Permanent link") ----------------------------------------------------------------------------------------------------------- ### Changed[#](https://ackee.xyz/trident/docs/0.6.0/CHANGELOG/#changed_1 "Permanent link") * Upgrade Solana (`~1.10`) and Anchor framework (`~0.25`) versions ### Added[#](https://ackee.xyz/trident/docs/0.6.0/CHANGELOG/#added_2 "Permanent link") * Custom Solana RPC error reporter. If the Solana RPC error is thrown, the error code, message and data (logs) are reported to the output. * Custom imports in the `.program_client`. User is able to import custom types and structures into program client. The import part of the code would not be re-generated. \[0.2.0\] - 2022-07-27[#](https://ackee.xyz/trident/docs/0.6.0/CHANGELOG/#020-2022-07-27 "Permanent link") ----------------------------------------------------------------------------------------------------------- ### Added[#](https://ackee.xyz/trident/docs/0.6.0/CHANGELOG/#added_3 "Permanent link") * Trident is now configurable. This requires `Trident.toml` file to exist in the project's root directory - without this file the execution will fail. To solve this re-run `trident init` or just create an empty `Trident.toml` file in the project's root directory. Back to top --- # Changelog - Trident [Skip to content](https://ackee.xyz/trident/docs/0.7.0/CHANGELOG/#changelog) Changelog[#](https://ackee.xyz/trident/docs/0.7.0/CHANGELOG/#changelog "Permanent link") ========================================================================================= All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) , and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html) (SemVer). **Note**: Version 0 of Semantic Versioning is handled differently from version 1 and above. The minor version will be incremented upon a breaking change and the patch version will be incremented for features. \[dev\] - Unreleased[#](https://ackee.xyz/trident/docs/0.7.0/CHANGELOG/#dev-unreleased "Permanent link") --------------------------------------------------------------------------------------------------------- \[0.7.0\] - 2024-08-14[#](https://ackee.xyz/trident/docs/0.7.0/CHANGELOG/#070-2024-08-14 "Permanent link") ----------------------------------------------------------------------------------------------------------- **Added** * impr/ add feature flag to the AccountsSnapshots macro ([183](https://github.com/Ackee-Blockchain/trident/pull/183) ) * feat/ add Support for CPI ([182](https://github.com/Ackee-Blockchain/trident/pull/182) ) * feat/ add option to initialize Trident with Macro/File (for Snapshots) option based on preference ([179](https://github.com/Ackee-Blockchain/trident/pull/179) ) * feat/create AccountsSnapshots derive macro for Snapshots creation ([#177](https://github.com/Ackee-Blockchain/trident/pull/177) ) * feat/fuzzing moved to separate crate trident-fuzz ([#175](https://github.com/Ackee-Blockchain/trident/pull/175) ) * feat/unify dependencies provided by the Trident ([#172](https://github.com/Ackee-Blockchain/trident/pull/172) ) * feat/fuzzer-stats-logging, an optional statistics output for fuzzing session ([#144](https://github.com/Ackee-Blockchain/trident/pull/144) ) **Fixed** * fix/in case of fuzzing failure throw error instead of only printing message ([#167](https://github.com/Ackee-Blockchain/trident/pull/167) ) * fix/snapshot's zeroed account as optional ([#170](https://github.com/Ackee-Blockchain/trident/pull/170) ) **Removed** * del/remove localnet subcommand ([178](https://github.com/Ackee-Blockchain/trident/pull/178) ) * del/remove unnecessary fuzzing feature as trident is mainly fuzzer ([#176](https://github.com/Ackee-Blockchain/trident/pull/176) ) * del/remove Trident explorer ([#171](https://github.com/Ackee-Blockchain/trident/pull/171) ) \[0.6.0\] - 2024-05-20[#](https://ackee.xyz/trident/docs/0.7.0/CHANGELOG/#060-2024-05-20 "Permanent link") ----------------------------------------------------------------------------------------------------------- **Added** * feat/anchor 0.30.0 support ([#148](https://github.com/Ackee-Blockchain/trident/pull/148) ) * fix/allow to process duplicate transactions ([#147](https://github.com/Ackee-Blockchain/trident/pull/147) ) * feat/possibility to implement custom transaction error handling ([#145](https://github.com/Ackee-Blockchain/trident/pull/145) ) * feat/support of automatically obtaining fully qualified paths of Data Accounts Custom types for `accounts_snapshots.rs` ([#141](https://github.com/Ackee-Blockchain/trident/pull/141) ) * feat/allow direct accounts manipulation and storage ([#142](https://github.com/Ackee-Blockchain/trident/pull/142) ) * feat/support of non-corresponding instruction and context names ([#130](https://github.com/Ackee-Blockchain/trident/pull/130) ) * feat/refactored and improved program flow during init and build, added activity indicator ([#129](https://github.com/Ackee-Blockchain/trident/pull/129) ) * feat/allow solana versions up to v1.17.\* and pin Rust 1.77 nightly compiler ([#128](https://github.com/Ackee-Blockchain/trident/pull/128) ) * feat/new init command option to initialize fuzz or poc tests only ([#124](https://github.com/Ackee-Blockchain/trident/pull/124) ) * feat/debug-mode detailed output ([#125](https://github.com/Ackee-Blockchain/trident/pull/125) ) * feat/anchor 0.29.0 support ([#121](https://github.com/Ackee-Blockchain/trident/pull/121) ) * doc/add help comment + update documentation ([#120](https://github.com/Ackee-Blockchain/trident/pull/120) ) * feat/fuzzer error handling ([#118](https://github.com/Ackee-Blockchain/trident/pull/118) ) * feat/convert fuzz Pubkey to AccountId ([#116](https://github.com/Ackee-Blockchain/trident/pull/116) ) * feat/additional anchor types ([#115](https://github.com/Ackee-Blockchain/trident/pull/115) ) * feat/import ToAccountInfo trait in fuzzing prelude ([#113](https://github.com/Ackee-Blockchain/trident/pull/113) ) * test/added code generation and macros tests ([#112](https://github.com/Ackee-Blockchain/trident/pull/112) ) * feat/fuzzer framework core, macros, helpers, templates, and examples. ([#111](https://github.com/Ackee-Blockchain/trident/pull/111) ) * feat/improved trident-tests folder structure for PoC and Fuzz Tests ([#109](https://github.com/Ackee-Blockchain/trident/pull/109) ) * feat/support for additional fuzzer parameters in Trident.toml config file ([#107](https://github.com/Ackee-Blockchain/trident/pull/107) ) * feat/posibility to pass params to the fuzzer via Trident.toml config file ([#106](https://github.com/Ackee-Blockchain/trident/pull/106) ) * feat/client now reads by default keypair from default location ([#105](https://github.com/Ackee-Blockchain/trident/pull/105) ) * feat/added new --exit-code option to return corresponding exit code based on fuzz test result ([#104](https://github.com/Ackee-Blockchain/trident/pull/104) ) * feat/removed/updated deprecated functions, removed allow deprecated macros ([#103](https://github.com/Ackee-Blockchain/trident/pull/103) ) * feat/added new function to read keypair file generated by Anchor ([#102](https://github.com/Ackee-Blockchain/trident/pull/102) ) * feat/clean command ([#101](https://github.com/Ackee-Blockchain/trident/pull/101) ) * feat/improved program\_client generated code ([#100](https://github.com/Ackee-Blockchain/trident/pull/100) ) * feat/automatically add hfuzz\_target to .gitignore file ([#99](https://github.com/Ackee-Blockchain/trident/pull/99) ) * feat/support for dynamic templates. ([#98](https://github.com/Ackee-Blockchain/trident/pull/98) ) **Fixed** * fix/refactored fuzz test executor error handling ([#127](https://github.com/Ackee-Blockchain/trident/pull/127) ) * fix/warn user on composite accounts and continue fuzz test generation ([#133](https://github.com/Ackee-Blockchain/trident/pull/133) ) * fix/progress bar loop lock release ([#132](https://github.com/Ackee-Blockchain/trident/pull/132) ) * fix/fixed fuzz test generation with init-if-needed Anchor feature ([#131](https://github.com/Ackee-Blockchain/trident/pull/131) ) * fix/program client custom types ([#117](https://github.com/Ackee-Blockchain/trident/pull/117) ) * fix/check fuzz test name collision by checking the name against HashSet ([#114](https://github.com/Ackee-Blockchain/trident/pull/114) ) \[0.5.0\] - 2023-08-28[#](https://ackee.xyz/trident/docs/0.7.0/CHANGELOG/#050-2023-08-28 "Permanent link") ----------------------------------------------------------------------------------------------------------- **Added** * cli: Added trident subcommand `fuzz` to run and debug fuzz tests using honggfuzz-rs. * cli: Added trident `--skip-fuzzer` option for `init` subcommand to skip generation of fuzz test templates. * client: Added new Cargo feature `fuzzing` that enables optional dependencies related to fuzz testing. \[0.4.1\] - 2023-08-21[#](https://ackee.xyz/trident/docs/0.7.0/CHANGELOG/#041-2023-08-21 "Permanent link") ----------------------------------------------------------------------------------------------------------- **Changed** * Upgrade Solana (`=1.16.6`) and Anchor framework (`=0.28.0`) versions. **Fixed** * Implemented Anchor Client logic was not able to work with newer version of Anchor. Fixed with `async_rpc` and `async` feature. * Trident init IDL Parse Error on newer version of Rust, fixed with updated `accounts` token. \[0.3.0\] - 2022-09-23[#](https://ackee.xyz/trident/docs/0.7.0/CHANGELOG/#030-2022-09-23 "Permanent link") ----------------------------------------------------------------------------------------------------------- **Changed** * Upgrade Solana (`~1.10`) and Anchor framework (`~0.25`) versions **Added** * Custom Solana RPC error reporter. If the Solana RPC error is thrown, the error code, message and data (logs) are reported to the output. * Custom imports in the `.program_client`. User is able to import custom types and structures into program client. The import part of the code would not be re-generated. \[0.2.0\] - 2022-07-27[#](https://ackee.xyz/trident/docs/0.7.0/CHANGELOG/#020-2022-07-27 "Permanent link") ----------------------------------------------------------------------------------------------------------- **Added** * Trident is now configurable. This requires `Trident.toml` file to exist in the project's root directory - without this file the execution will fail. To solve this re-run `trident init` or just create an empty `Trident.toml` file in the project's root directory. Back to top --- # Changelog - Trident [Skip to content](https://ackee.xyz/trident/docs/0.11.1/basics/CHANGELOG/#changelog) Changelog[#](https://ackee.xyz/trident/docs/0.11.1/basics/CHANGELOG/#changelog "Permanent link") ================================================================================================= All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) , and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html) (SemVer). **Note**: Version 0 of Semantic Versioning is handled differently from version 1 and above. The minor version will be incremented upon a breaking change and the patch version will be incremented for features. \[dev\] - Unreleased[#](https://ackee.xyz/trident/docs/0.11.1/basics/CHANGELOG/#dev-unreleased "Permanent link") ----------------------------------------------------------------------------------------------------------------- **Added** **Removed** **Changed** \[0.11.1\] - 2025-10-21[#](https://ackee.xyz/trident/docs/0.11.1/basics/CHANGELOG/#0111-2025-10-21 "Permanent link") --------------------------------------------------------------------------------------------------------------------- **Added** **Removed** * Removed lld linker ([394](https://github.com/Ackee-Blockchain/trident/pull/394) ) **Changed** \[0.11.0\] - 2025-08-14[#](https://ackee.xyz/trident/docs/0.11.1/basics/CHANGELOG/#0110-2025-08-14 "Permanent link") --------------------------------------------------------------------------------------------------------------------- **Added** * Add server for displaying content of fuzzing artifacts ([347](https://github.com/Ackee-Blockchain/trident/pull/347) ) * Add fuzz artifacts directory to the fuzz test folder ([343](https://github.com/Ackee-Blockchain/trident/pull/343) ) * Added state monitoring support for fuzzing metrics ([341](https://github.com/Ackee-Blockchain/trident/pull/341) ) * Added dashboard support for fuzzing metrics ([340](https://github.com/Ackee-Blockchain/trident/pull/340) ) * Code coverage tracking support enabled and configured via Trident.toml. Coverage data can be visualized using the VS Code extension [330](https://github.com/Ackee-Blockchain/trident/pull/330) * Added features to enable syscalls in fuzzing ([329](https://github.com/Ackee-Blockchain/trident/pull/329) ) * Add `--skip-build` flag to only initialize fuzz test without building the project ([325](https://github.com/Ackee-Blockchain/trident/pull/325) ) * Add support for space, lamports and owner to TridentAccounts macro ([320](https://github.com/Ackee-Blockchain/trident/pull/320) ) **Removed** **Changed** * FuzzTest fields are now aggregated into Trident struct ([339](https://github.com/Ackee-Blockchain/trident/pull/339) ) * Add support for reproducible fuzzing with thread-specific seeds ([332](https://github.com/Ackee-Blockchain/trident/pull/332) ) * Move Trident.toml into trident-tests folder ([328](https://github.com/Ackee-Blockchain/trident/pull/328) ) * Conversion from AFL and Honggfuzz into Manually Guided Fuzzing ([324](https://github.com/Ackee-Blockchain/trident/pull/324) ) * Update template generation to use tera ([326](https://github.com/Ackee-Blockchain/trident/pull/326) ) \[0.10.0\] - 2025-03-13[#](https://ackee.xyz/trident/docs/0.11.1/basics/CHANGELOG/#0100-2025-03-13 "Permanent link") --------------------------------------------------------------------------------------------------------------------- **Added** * TransactionSelector allows to select and execute random transaction with hooks and without hooks ([297](https://github.com/Ackee-Blockchain/trident/pull/297) ) * Added "random\_tail" attribute to TridentFlowExecutor macro to allow random tail generation ([296](https://github.com/Ackee-Blockchain/trident/pull/296) ) * Added support for seeds constraint for accounts structs ([284](https://github.com/Ackee-Blockchain/trident/pull/284) ) * Additional methods accessing the AccountsStorage and creating corresponding accounts are now optional ("token","vote", "stake") ([279](https://github.com/Ackee-Blockchain/trident/pull/279) ) * Derive macros now use own syn parser for better extensibility and UX ([275](https://github.com/Ackee-Blockchain/trident/pull/275) ) * Program ID inside test\_fuzz.rs file is now automatically filled in is present in the program IDL ([272](https://github.com/Ackee-Blockchain/trident/pull/272) ) * Added additional attributes to TridentAccounts, mut and signer ([268](https://github.com/Ackee-Blockchain/trident/pull/268) ) * Users can now specify a program for which they want to add or initialize a fuzz test using `--program-name` flag ([273](https://github.com/Ackee-Blockchain/trident/pull/273) ) * Allow custom test name specification in fuzz test creation with `--test-name` flag ([274](https://github.com/Ackee-Blockchain/trident/pull/274) ) **Removed** * The DisplayIx macro is now removed, Debug trait was implemented for instruction inputs ([281](https://github.com/Ackee-Blockchain/trident/pull/281) ) **Changed** * FuzzTestExecutor and FlowExecutor are grouped together and FuzzTest has client as generic instead of TridentSVM ([294](https://github.com/Ackee-Blockchain/trident/pull/294) ) * Changed Transaction sequence logic ([289](https://github.com/Ackee-Blockchain/trident/pull/289) ) * AccountsStorages are simplified, no types are required to define ([276](https://github.com/Ackee-Blockchain/trident/pull/276) ) * Trident Architecture changes containing multiple features and improvements (details in the PR)([267](https://github.com/Ackee-Blockchain/trident/pull/267) ) * get or create token account methods fixed for native token accounts ([262](https://github.com/Ackee-Blockchain/trident/pull/262) ) \[0.9.1\] - 2025-02-03[#](https://ackee.xyz/trident/docs/0.11.1/basics/CHANGELOG/#091-2025-02-03 "Permanent link") ------------------------------------------------------------------------------------------------------------------- **Added** * added warp to time manipulation ([259](https://github.com/Ackee-Blockchain/trident/pull/259) ) * added methods to check if account storage is empty ([258](https://github.com/Ackee-Blockchain/trident/pull/258) ) * added support for post-instruction behavior ([257](https://github.com/Ackee-Blockchain/trident/pull/257) ) **Removed** **Changed** \[0.9.0\] - 2025-01-15[#](https://ackee.xyz/trident/docs/0.11.1/basics/CHANGELOG/#090-2025-01-15 "Permanent link") ------------------------------------------------------------------------------------------------------------------- **Added** * added support for composite accounts ([245](https://github.com/Ackee-Blockchain/trident/pull/245) ) * Trident SVM + AFL (see the PR for more details) ([234](https://github.com/Ackee-Blockchain/trident/pull/234) ) **Removed** * removed fuzz\_iteration from test\_fuzz.rs ([243](https://github.com/Ackee-Blockchain/trident/pull/243) ) **Changed** * renamed Config to TridentConfig ([246](https://github.com/Ackee-Blockchain/trident/pull/246) ) * errors are simplified and transaction error contains only transaction error ([244](https://github.com/Ackee-Blockchain/trident/pull/244) ) \[0.8.1\] - 2024-11-14[#](https://ackee.xyz/trident/docs/0.11.1/basics/CHANGELOG/#081-2024-11-14 "Permanent link") ------------------------------------------------------------------------------------------------------------------- **Removed** * removed unnecessary deserialization with AccountsSnapshots, to deserialize data implementation AccountDeserialize can be used ([221](https://github.com/Ackee-Blockchain/trident/pull/221) ) **Changed** * improve AccountsStorage module structure and remove unnecessary methods in FuzzClient ([223](https://github.com/Ackee-Blockchain/trident/pull/223) ) * improve manipulations with AccountsStorages in get\_accounts() function ([219](https://github.com/Ackee-Blockchain/trident/pull/219) ) **Added** * add pre\_sequence!, middle\_sequence! and post\_sequence! for easier sequence definition ([220](https://github.com/Ackee-Blockchain/trident/pull/220) ) * add/ add support for Clock sysvar manipulations with the client(i.e. warp to slot/epoch and forward in time) ([217](https://github.com/Ackee-Blockchain/trident/pull/217) ) \[0.8.0\] - 2024-10-21[#](https://ackee.xyz/trident/docs/0.11.1/basics/CHANGELOG/#080-2024-10-21 "Permanent link") ------------------------------------------------------------------------------------------------------------------- **Added** * impr/ allow to specify programs and accounts in the Trident Manifest ([207](https://github.com/Ackee-Blockchain/trident/pull/207) ) * impr/ added get\_program\_id function to the IxOps and FuzzTestExecutor ([199](https://github.com/Ackee-Blockchain/trident/pull/199) ) **Changed** * impr/ improve init command, modify program manifest automatically, add init force, add howto subcommand ([208](https://github.com/Ackee-Blockchain/trident/pull/208) ) * impr/ allow to derive AccountsSnapshots for empty Account Context ([209](https://github.com/Ackee-Blockchain/trident/pull/209) ) * impr/ fuzz flags are read at start of fuzzing session from Config instead of env variable and transaction dispatch was added to increase FuzzTestExecutor readability ([204](https://github.com/Ackee-Blockchain/trident/pull/204) ) * impr/ allow various instructions to be generated in case of multiple programs in the Anchor workspace ([200](https://github.com/Ackee-Blockchain/trident/pull/200) ) * feat/ option to add account into Fuzz Test environment with base64 data ([197](https://github.com/Ackee-Blockchain/trident/pull/197) ) * impr/ instead of parsing source code and creating our IDL, read anchor IDL ([198](https://github.com/Ackee-Blockchain/trident/pull/196) ) **Removed** * del/remove integration tests supported by Trident, this feature adds more unnecessary overhead compared to its value ([196](https://github.com/Ackee-Blockchain/trident/pull/198) ) \[0.7.0\] - 2024-08-14[#](https://ackee.xyz/trident/docs/0.11.1/basics/CHANGELOG/#070-2024-08-14 "Permanent link") ------------------------------------------------------------------------------------------------------------------- **Added** * impr/ add feature flag to the AccountsSnapshots macro ([183](https://github.com/Ackee-Blockchain/trident/pull/183) ) * feat/ add Support for CPI ([182](https://github.com/Ackee-Blockchain/trident/pull/182) ) * feat/ add option to initialize Trident with Macro/File (for Snapshots) option based on preference ([179](https://github.com/Ackee-Blockchain/trident/pull/179) ) * feat/create AccountsSnapshots derive macro for Snapshots creation ([#177](https://github.com/Ackee-Blockchain/trident/pull/177) ) * feat/fuzzing moved to separate crate trident-fuzz ([#175](https://github.com/Ackee-Blockchain/trident/pull/175) ) * feat/unify dependencies provided by the Trident ([#172](https://github.com/Ackee-Blockchain/trident/pull/172) ) * feat/fuzzer-stats-logging, an optional statistics output for fuzzing session ([#144](https://github.com/Ackee-Blockchain/trident/pull/144) ) **Fixed** * fix/in case of fuzzing failure throw error instead of only printing message ([#167](https://github.com/Ackee-Blockchain/trident/pull/167) ) * fix/snapshot's zeroed account as optional ([#170](https://github.com/Ackee-Blockchain/trident/pull/170) ) **Removed** * del/remove localnet subcommand ([178](https://github.com/Ackee-Blockchain/trident/pull/178) ) * del/remove unnecessary fuzzing feature as trident is mainly fuzzer ([#176](https://github.com/Ackee-Blockchain/trident/pull/176) ) * del/remove Trident explorer ([#171](https://github.com/Ackee-Blockchain/trident/pull/171) ) \[0.6.0\] - 2024-05-20[#](https://ackee.xyz/trident/docs/0.11.1/basics/CHANGELOG/#060-2024-05-20 "Permanent link") ------------------------------------------------------------------------------------------------------------------- **Added** * feat/anchor 0.30.0 support ([#148](https://github.com/Ackee-Blockchain/trident/pull/148) ) * fix/allow to process duplicate transactions ([#147](https://github.com/Ackee-Blockchain/trident/pull/147) ) * feat/possibility to implement custom transaction error handling ([#145](https://github.com/Ackee-Blockchain/trident/pull/145) ) * feat/support of automatically obtaining fully qualified paths of Data Accounts Custom types for `accounts_snapshots.rs` ([#141](https://github.com/Ackee-Blockchain/trident/pull/141) ) * feat/allow direct accounts manipulation and storage ([#142](https://github.com/Ackee-Blockchain/trident/pull/142) ) * feat/support of non-corresponding instruction and context names ([#130](https://github.com/Ackee-Blockchain/trident/pull/130) ) * feat/refactored and improved program flow during init and build, added activity indicator ([#129](https://github.com/Ackee-Blockchain/trident/pull/129) ) * feat/allow solana versions up to v1.17.\* and pin Rust 1.77 nightly compiler ([#128](https://github.com/Ackee-Blockchain/trident/pull/128) ) * feat/new init command option to initialize fuzz or poc tests only ([#124](https://github.com/Ackee-Blockchain/trident/pull/124) ) * feat/debug-mode detailed output ([#125](https://github.com/Ackee-Blockchain/trident/pull/125) ) * feat/anchor 0.29.0 support ([#121](https://github.com/Ackee-Blockchain/trident/pull/121) ) * doc/add help comment + update documentation ([#120](https://github.com/Ackee-Blockchain/trident/pull/120) ) * feat/fuzzer error handling ([#118](https://github.com/Ackee-Blockchain/trident/pull/118) ) * feat/convert fuzz Pubkey to AccountId ([#116](https://github.com/Ackee-Blockchain/trident/pull/116) ) * feat/additional anchor types ([#115](https://github.com/Ackee-Blockchain/trident/pull/115) ) * feat/import ToAccountInfo trait in fuzzing prelude ([#113](https://github.com/Ackee-Blockchain/trident/pull/113) ) * test/added code generation and macros tests ([#112](https://github.com/Ackee-Blockchain/trident/pull/112) ) * feat/fuzzer framework core, macros, helpers, templates, and examples. ([#111](https://github.com/Ackee-Blockchain/trident/pull/111) ) * feat/improved trident-tests folder structure for PoC and Fuzz Tests ([#109](https://github.com/Ackee-Blockchain/trident/pull/109) ) * feat/support for additional fuzzer parameters in Trident.toml config file ([#107](https://github.com/Ackee-Blockchain/trident/pull/107) ) * feat/possibility to pass params to the fuzzer via Trident.toml config file ([#106](https://github.com/Ackee-Blockchain/trident/pull/106) ) * feat/client now reads by default keypair from default location ([#105](https://github.com/Ackee-Blockchain/trident/pull/105) ) * feat/added new --exit-code option to return corresponding exit code based on fuzz test result ([#104](https://github.com/Ackee-Blockchain/trident/pull/104) ) * feat/removed/updated deprecated functions, removed allow deprecated macros ([#103](https://github.com/Ackee-Blockchain/trident/pull/103) ) * feat/added new function to read keypair file generated by Anchor ([#102](https://github.com/Ackee-Blockchain/trident/pull/102) ) * feat/clean command ([#101](https://github.com/Ackee-Blockchain/trident/pull/101) ) * feat/improved program\_client generated code ([#100](https://github.com/Ackee-Blockchain/trident/pull/100) ) * feat/automatically add hfuzz\_target to .gitignore file ([#99](https://github.com/Ackee-Blockchain/trident/pull/99) ) * feat/support for dynamic templates. ([#98](https://github.com/Ackee-Blockchain/trident/pull/98) ) **Fixed** * fix/refactored fuzz test executor error handling ([#127](https://github.com/Ackee-Blockchain/trident/pull/127) ) * fix/warn user on composite accounts and continue fuzz test generation ([#133](https://github.com/Ackee-Blockchain/trident/pull/133) ) * fix/progress bar loop lock release ([#132](https://github.com/Ackee-Blockchain/trident/pull/132) ) * fix/fixed fuzz test generation with init-if-needed Anchor feature ([#131](https://github.com/Ackee-Blockchain/trident/pull/131) ) * fix/program client custom types ([#117](https://github.com/Ackee-Blockchain/trident/pull/117) ) * fix/check fuzz test name collision by checking the name against HashSet ([#114](https://github.com/Ackee-Blockchain/trident/pull/114) ) \[0.5.0\] - 2023-08-28[#](https://ackee.xyz/trident/docs/0.11.1/basics/CHANGELOG/#050-2023-08-28 "Permanent link") ------------------------------------------------------------------------------------------------------------------- **Added** * cli: Added trident subcommand `fuzz` to run and debug fuzz tests using honggfuzz-rs. * cli: Added trident `--skip-fuzzer` option for `init` subcommand to skip generation of fuzz test templates. * client: Added new Cargo feature `fuzzing` that enables optional dependencies related to fuzz testing. \[0.4.1\] - 2023-08-21[#](https://ackee.xyz/trident/docs/0.11.1/basics/CHANGELOG/#041-2023-08-21 "Permanent link") ------------------------------------------------------------------------------------------------------------------- **Changed** * Upgrade Solana (`=1.16.6`) and Anchor framework (`=0.28.0`) versions. **Fixed** * Implemented Anchor Client logic was not able to work with newer version of Anchor. Fixed with `async_rpc` and `async` feature. * Trident init IDL Parse Error on newer version of Rust, fixed with updated `accounts` token. \[0.3.0\] - 2022-09-23[#](https://ackee.xyz/trident/docs/0.11.1/basics/CHANGELOG/#030-2022-09-23 "Permanent link") ------------------------------------------------------------------------------------------------------------------- **Changed** * Upgrade Solana (`~1.10`) and Anchor framework (`~0.25`) versions **Added** * Custom Solana RPC error reporter. If the Solana RPC error is thrown, the error code, message and data (logs) are reported to the output. * Custom imports in the `.program_client`. User is able to import custom types and structures into program client. The import part of the code would not be re-generated. \[0.2.0\] - 2022-07-27[#](https://ackee.xyz/trident/docs/0.11.1/basics/CHANGELOG/#020-2022-07-27 "Permanent link") ------------------------------------------------------------------------------------------------------------------- **Added** * Trident is now configurable. This requires `Trident.toml` file to exist in the project's root directory - without this file the execution will fail. To solve this re-run `trident init` or just create an empty `Trident.toml` file in the project's root directory. Back to top --- # FAQ - Trident [Skip to content](https://ackee.xyz/trident/docs/0.11.1/basics/faq/#faq) FAQ[#](https://ackee.xyz/trident/docs/0.11.1/basics/faq/#faq "Permanent link") =============================================================================== _Is Trident supported only with Anchor?_ * Currently yes, Trident under the hood obtains data from the IDL generated by Anchor. _I created the Fuzz Test, what should I do next?_ * Start here [Start Fuzzing](https://ackee.xyz/trident/docs/0.11.1/start-fuzzing/) . _Is Trident open-source?_ * Yes, here [Trident](https://github.com/Ackee-Blockchain/trident) . _I would like to report an Issue with Trident, what should I do?_ * Create [issue](https://github.com/Ackee-Blockchain/trident/issues) . _Is Trident deployed on Mainnet / Devnet / Testnet?_ * No, Trident is Fuzz Testing Framework, not Solana Program. _What type of Fuzzer is Trident?_ * Currently, we refer to it as _"coverage guided gray box fuzzer"_. Back to top --- # Installation - Trident [Skip to content](https://ackee.xyz/trident/docs/0.6.0/home/home-installation/#installation) Installation[#](https://ackee.xyz/trident/docs/0.6.0/home/home-installation/#installation "Permanent link") ============================================================================================================ Dependencies[#](https://ackee.xyz/trident/docs/0.6.0/home/home-installation/#dependencies "Permanent link") ------------------------------------------------------------------------------------------------------------ Check [supported versions](https://ackee.xyz/trident/docs/0.6.0/home/home-installation/#supported-versions) section for further details. * Install [Rust](https://www.rust-lang.org/tools/install) * Install [Solana tool suite](https://docs.solana.com/cli/install-solana-cli-tools) * Install [Anchor](https://www.anchor-lang.com/docs/installation) * Install [Honggfuzz-rs](https://github.com/rust-fuzz/honggfuzz-rs#how-to-use-this-crate) for fuzz testing Installation[#](https://ackee.xyz/trident/docs/0.6.0/home/home-installation/#installation_1 "Permanent link") -------------------------------------------------------------------------------------------------------------- `[](https://ackee.xyz/trident/docs/0.6.0/home/home-installation/#__codelineno-0-1) cargo install trident-cli [](https://ackee.xyz/trident/docs/0.6.0/home/home-installation/#__codelineno-0-2)[](https://ackee.xyz/trident/docs/0.6.0/home/home-installation/#__codelineno-0-3) # or the specific version [](https://ackee.xyz/trident/docs/0.6.0/home/home-installation/#__codelineno-0-4)[](https://ackee.xyz/trident/docs/0.6.0/home/home-installation/#__codelineno-0-5) cargo install --version trident-cli` ### Supported versions[#](https://ackee.xyz/trident/docs/0.6.0/home/home-installation/#supported-versions "Permanent link") * We support `Anchor` and `Solana` versions specified in the table below. | Trident CLI | Anchor | Solana | Rust | | --- | --- | --- | --- | | `v0.6.0` | `>=0.29.*`1 | `^1.17` | `nightly` | | `v0.5.0` | `~0.28.*` | `=1.16.6` | | | `v0.4.0` | `~0.27.*` | `>=1.15` | | | `v0.3.0` | `~0.25.*` | `>=1.10` | | | `v0.2.0` | `~0.24.*` | `>=1.9` | | 1. To use Trident with Anchor 0.29.0, run the following commands from your project's root directory after Trident initialization: `[](https://ackee.xyz/trident/docs/0.6.0/home/home-installation/#__codelineno-1-1) cargo update [[email protected]](https://ackee.xyz/cdn-cgi/l/email-protection) --precise 0.29.0 [](https://ackee.xyz/trident/docs/0.6.0/home/home-installation/#__codelineno-1-2) cargo update [[email protected]](https://ackee.xyz/cdn-cgi/l/email-protection) --precise 0.29.0` Back to top --- # Docker Image - Trident [Skip to content](https://ackee.xyz/trident/docs/0.7.0/getting-started/docker-image/#docker-image) Docker Image[#](https://ackee.xyz/trident/docs/0.7.0/getting-started/docker-image/#docker-image "Permanent link") ================================================================================================================== TBD Back to top --- # Run - Trident [Skip to content](https://ackee.xyz/trident/docs/0.7.0/integration-tests/poc-run/#run) Run[#](https://ackee.xyz/trident/docs/0.7.0/integration-tests/poc-run/#run "Permanent link") ============================================================================================= Once you have finished the implementation of the Integration Test, you can run the Test as follows: `[](https://ackee.xyz/trident/docs/0.7.0/integration-tests/poc-run/#__codelineno-0-1) trident test` Skipping tests[#](https://ackee.xyz/trident/docs/0.7.0/integration-tests/poc-run/#skipping-tests "Permanent link") ------------------------------------------------------------------------------------------------------------------- * You can add the `#[ignore]` macro to skip the test. `[](https://ackee.xyz/trident/docs/0.7.0/integration-tests/poc-run/#__codelineno-1-1) #[trident_test] [](https://ackee.xyz/trident/docs/0.7.0/integration-tests/poc-run/#__codelineno-1-2) #[ignore] [](https://ackee.xyz/trident/docs/0.7.0/integration-tests/poc-run/#__codelineno-1-3) async fn test() {}` Back to top --- # Introduction - Trident [Skip to content](https://ackee.xyz/trident/docs/0.6.0/fuzzing/fuzzing-introduction/#introduction) Introduction[#](https://ackee.xyz/trident/docs/0.6.0/fuzzing/fuzzing-introduction/#introduction "Permanent link") ================================================================================================================== Fuzzing is a software testing technique that involves providing invalid, unexpected, or random data as inputs to a computer program. The aim is to uncover bugs and vulnerabilities that might not be detected with conventional testing strategies. Trident[#](https://ackee.xyz/trident/docs/0.6.0/fuzzing/fuzzing-introduction/#trident "Permanent link") ======================================================================================================== The `Trident` testing framework equips developers with tools to efficiently develop fuzz tests for Anchor-based programs. It streamlines the fuzz testing process through automation and comprehensive support: * Automatically parses Anchor-based programs to generate necessary implementations for deserializing instruction accounts. * Generates templates for developers to customize according to the specific needs of their fuzz test scenarios. * Offers derive macros to effortlessly implement required traits, reducing manual coding efforts. * Includes a bank client and helper functions for simplified account management during testing. * Provides a Command-Line Interface (CLI) for executing and debugging fuzz tests with ease. `Trident` is built for customization, enabling developers to tailor their fuzz tests by adjusting: * **Execution Order of Instructions**: Test different sequences and their effects on the program to uncover sequence-related vulnerabilities. * **Instruction Parameters**: Identify how variations in inputs influence program behavior, testing for robustness against a wide range of data. * **Instruction Accounts**: Explore the impact of different account states on the software's functionality, ensuring comprehensive account testing. * **Comprehensive Testing**: Conduct thorough and effective fuzz testing by combining any of the above aspects. This framework supports a detailed and methodical approach to fuzz testing, facilitating the identification and remediation of potential vulnerabilities in software applications. Back to top --- # Start Fuzzing - Trident [Skip to content](https://ackee.xyz/trident/docs/0.10.0/start-fuzzing/#start-fuzzing) Start Fuzzing[#](https://ackee.xyz/trident/docs/0.10.0/start-fuzzing/#start-fuzzing "Permanent link") ====================================================================================================== To start writting fuzz tests, you need to initialize Trident in your Anchor-based workspace. `[](https://ackee.xyz/trident/docs/0.10.0/start-fuzzing/#__codelineno-0-1) trident init` If you have already initialized Trident, you can add a new fuzz test using: `[](https://ackee.xyz/trident/docs/0.10.0/start-fuzzing/#__codelineno-1-1) trident fuzz add` Trident creates a new fuzz test template in the `trident-tests` directory, with the following structure: `[](https://ackee.xyz/trident/docs/0.10.0/start-fuzzing/#__codelineno-2-1) project-root [](https://ackee.xyz/trident/docs/0.10.0/start-fuzzing/#__codelineno-2-2) ├── trident-tests [](https://ackee.xyz/trident/docs/0.10.0/start-fuzzing/#__codelineno-2-3) │ ├── fuzz_0 # particular fuzz test [](https://ackee.xyz/trident/docs/0.10.0/start-fuzzing/#__codelineno-2-4) │ │ ├── instructions # instructions folder [](https://ackee.xyz/trident/docs/0.10.0/start-fuzzing/#__codelineno-2-5) │ │ ├── transactions # transactions folder [](https://ackee.xyz/trident/docs/0.10.0/start-fuzzing/#__codelineno-2-6) │ │ ├── test_fuzz.rs # the binary target of your fuzz test [](https://ackee.xyz/trident/docs/0.10.0/start-fuzzing/#__codelineno-2-7) │ │ ├── types.rs # the types of your fuzz test [](https://ackee.xyz/trident/docs/0.10.0/start-fuzzing/#__codelineno-2-8) │ │ └── fuzz_instructions.rs # the definition of your fuzz test [](https://ackee.xyz/trident/docs/0.10.0/start-fuzzing/#__codelineno-2-9) │ ├── fuzz_1 [](https://ackee.xyz/trident/docs/0.10.0/start-fuzzing/#__codelineno-2-10) │ ├── fuzz_X # possible multiple fuzz tests [](https://ackee.xyz/trident/docs/0.10.0/start-fuzzing/#__codelineno-2-11) │ ├── fuzzing # compilations and crashes folder [](https://ackee.xyz/trident/docs/0.10.0/start-fuzzing/#__codelineno-2-12) │ └── Cargo.toml [](https://ackee.xyz/trident/docs/0.10.0/start-fuzzing/#__codelineno-2-13) ├── Trident.toml [](https://ackee.xyz/trident/docs/0.10.0/start-fuzzing/#__codelineno-2-14) └── ...` `Instructions` folder contains the `instructions` that can be used in the fuzz test. `Transactions` folder contains the `transactions` that will be used during the fuzzing, each transaction can contain `one` or `multiple instructions`, based on the developers choice. By default there is only one instruction in each transaction. Back to top --- # Start Fuzzing - Trident [Skip to content](https://ackee.xyz/trident/docs/dev/start-fuzzing/#start-fuzzing) Start Fuzzing[#](https://ackee.xyz/trident/docs/dev/start-fuzzing/#start-fuzzing "Permanent link") =================================================================================================== To start writing fuzz tests, you need to initialize Trident in your Anchor-based workspace. `[](https://ackee.xyz/trident/docs/dev/start-fuzzing/#__codelineno-0-1) trident init` If you have already initialized Trident, you can add a new fuzz test using: `[](https://ackee.xyz/trident/docs/dev/start-fuzzing/#__codelineno-1-1) trident fuzz add` Trident creates a new fuzz test template in the `trident-tests` directory, with the following structure: `[](https://ackee.xyz/trident/docs/dev/start-fuzzing/#__codelineno-2-1) project-root [](https://ackee.xyz/trident/docs/dev/start-fuzzing/#__codelineno-2-2) ├── trident-tests [](https://ackee.xyz/trident/docs/dev/start-fuzzing/#__codelineno-2-3) │ ├── fuzz_0 # particular fuzz test [](https://ackee.xyz/trident/docs/dev/start-fuzzing/#__codelineno-2-4) │ │ ├── instructions # instructions folder [](https://ackee.xyz/trident/docs/dev/start-fuzzing/#__codelineno-2-5) │ │ ├── transactions # transactions folder [](https://ackee.xyz/trident/docs/dev/start-fuzzing/#__codelineno-2-6) │ │ ├── test_fuzz.rs # the binary target of your fuzz test [](https://ackee.xyz/trident/docs/dev/start-fuzzing/#__codelineno-2-7) │ │ ├── types.rs # the types of your fuzz test [](https://ackee.xyz/trident/docs/dev/start-fuzzing/#__codelineno-2-8) │ │ └── fuzz_instructions.rs # the definition of your fuzz test [](https://ackee.xyz/trident/docs/dev/start-fuzzing/#__codelineno-2-9) │ ├── fuzz_1 [](https://ackee.xyz/trident/docs/dev/start-fuzzing/#__codelineno-2-10) │ ├── fuzz_X # possible multiple fuzz tests [](https://ackee.xyz/trident/docs/dev/start-fuzzing/#__codelineno-2-11) │ ├── fuzzing # compilations and crashes folder [](https://ackee.xyz/trident/docs/dev/start-fuzzing/#__codelineno-2-12) │ ├── Cargo.toml [](https://ackee.xyz/trident/docs/dev/start-fuzzing/#__codelineno-2-13) │ └── Trident.toml [](https://ackee.xyz/trident/docs/dev/start-fuzzing/#__codelineno-2-14) └── ...` `Instructions` folder contains the `instructions` that can be used in the fuzz test. `Transactions` folder contains the `transactions` that will be used during the fuzzing, each transaction can contain `one` or `multiple instructions`, based on the developer's choice. By default there is only one instruction in each transaction. Back to top --- # Examples - Trident [Skip to content](https://ackee.xyz/trident/docs/0.7.0/integration-tests/poc-examples/#examples) Examples[#](https://ackee.xyz/trident/docs/0.7.0/integration-tests/poc-examples/#examples "Permanent link") ============================================================================================================ * [Escrow](https://github.com/Ackee-Blockchain/trident/tree/master/examples/integration-tests/escrow) * [Turnstile](https://github.com/Ackee-Blockchain/trident/tree/master/examples/integration-tests/turnstile) Back to top --- # Get Help - Trident [Skip to content](https://ackee.xyz/trident/docs/0.11.1/basics/get-help/#get-help) Get Help[#](https://ackee.xyz/trident/docs/0.11.1/basics/get-help/#get-help "Permanent link") ============================================================================================== Need help writing Fuzz Tests? Do not hesitate to join our [Discord server](https://discord.gg/3czRpmGmeC) ! Back to top --- # Trident Advanced - Trident [Skip to content](https://ackee.xyz/trident/docs/0.10.0/trident-advanced/#trident-advanced) Trident Advanced[#](https://ackee.xyz/trident/docs/0.10.0/trident-advanced/#trident-advanced "Permanent link") =============================================================================================================== This section contains advanced customization options for Trident. Transaction-related[#](https://ackee.xyz/trident/docs/0.10.0/trident-advanced/#transaction-related "Permanent link") --------------------------------------------------------------------------------------------------------------------- * [Transaction Hooks](https://ackee.xyz/trident/docs/0.10.0/trident-advanced/trident-transactions/transaction-hooks/) * [Multi-Instruction Transactions](https://ackee.xyz/trident/docs/0.10.0/trident-advanced/trident-transactions/multi-instruction-transactions/) * [Fuzzing Flows](https://ackee.xyz/trident/docs/0.10.0/trident-advanced/trident-transactions/trident-fuzzing-flows/) Back to top --- # Trident Advanced - Trident [Skip to content](https://ackee.xyz/trident/docs/dev/trident-advanced/#trident-advanced) Trident Advanced[#](https://ackee.xyz/trident/docs/dev/trident-advanced/#trident-advanced "Permanent link") ============================================================================================================ This section contains advanced customization options for Trident. Transaction-related[#](https://ackee.xyz/trident/docs/dev/trident-advanced/#transaction-related "Permanent link") ------------------------------------------------------------------------------------------------------------------ * [Transaction Hooks](https://ackee.xyz/trident/docs/dev/trident-advanced/trident-transactions/transaction-hooks/) - Add custom logic to the transaction execution process * [Multi-Instruction Transactions](https://ackee.xyz/trident/docs/dev/trident-advanced/trident-transactions/multi-instruction-transactions/) - Execute multiple instructions in a single transaction Analysis & Visualization[#](https://ackee.xyz/trident/docs/dev/trident-advanced/#analysis-visualization "Permanent link") -------------------------------------------------------------------------------------------------------------------------- * [Code Coverage](https://ackee.xyz/trident/docs/dev/trident-advanced/code-coverage/) - Measure code coverage of the fuzzed program * [Dashboard](https://ackee.xyz/trident/docs/dev/trident-advanced/dashboard/) - Visualize fuzzing metrics in a dashboard * [Regression Testing](https://ackee.xyz/trident/docs/dev/trident-advanced/regression/) - Compare two regression test results Back to top --- # Run and Debug - Trident [Skip to content](https://ackee.xyz/trident/docs/0.6.0/fuzzing/fuzzing-run-debug/#run-and-debug) Run and Debug[#](https://ackee.xyz/trident/docs/0.6.0/fuzzing/fuzzing-run-debug/#run-and-debug "Permanent link") ================================================================================================================= Run[#](https://ackee.xyz/trident/docs/0.6.0/fuzzing/fuzzing-run-debug/#run "Permanent link") --------------------------------------------------------------------------------------------- Once you have finished the implementation of the Fuzz Test, you can run the Test as follows: `[](https://ackee.xyz/trident/docs/0.6.0/fuzzing/fuzzing-run-debug/#__codelineno-0-1) # Replace with the name of particular [](https://ackee.xyz/trident/docs/0.6.0/fuzzing/fuzzing-run-debug/#__codelineno-0-2) # fuzz test (for example: "fuzz_0") [](https://ackee.xyz/trident/docs/0.6.0/fuzzing/fuzzing-run-debug/#__codelineno-0-3) trident fuzz run ` Under the hood Trident uses [honggfuzz-rs](https://github.com/rust-fuzz/honggfuzz-rs) . You can pass [supported parameters](https://github.com/Ackee-Blockchain/trident/blob/develop/examples/fuzz_example0/Trident.toml) via the **Trident.toml** configuration file. For example: `[](https://ackee.xyz/trident/docs/0.6.0/fuzzing/fuzzing-run-debug/#__codelineno-1-1) # Content of Trident.toml [](https://ackee.xyz/trident/docs/0.6.0/fuzzing/fuzzing-run-debug/#__codelineno-1-2) [fuzz] [](https://ackee.xyz/trident/docs/0.6.0/fuzzing/fuzzing-run-debug/#__codelineno-1-3) # Timeout in seconds (default: 10) [](https://ackee.xyz/trident/docs/0.6.0/fuzzing/fuzzing-run-debug/#__codelineno-1-4) timeout = 10 [](https://ackee.xyz/trident/docs/0.6.0/fuzzing/fuzzing-run-debug/#__codelineno-1-5) # Number of fuzzing iterations (default: 0 [no limit]) [](https://ackee.xyz/trident/docs/0.6.0/fuzzing/fuzzing-run-debug/#__codelineno-1-6) iterations = 10000 [](https://ackee.xyz/trident/docs/0.6.0/fuzzing/fuzzing-run-debug/#__codelineno-1-7) # Number of concurrent fuzzing threads (default: 0 [number of CPUs / 2]) [](https://ackee.xyz/trident/docs/0.6.0/fuzzing/fuzzing-run-debug/#__codelineno-1-8) threads = 0 [](https://ackee.xyz/trident/docs/0.6.0/fuzzing/fuzzing-run-debug/#__codelineno-1-9) # Don't close children's stdin, stdout, [](https://ackee.xyz/trident/docs/0.6.0/fuzzing/fuzzing-run-debug/#__codelineno-1-10) # stderr; can be noisy (default: false) [](https://ackee.xyz/trident/docs/0.6.0/fuzzing/fuzzing-run-debug/#__codelineno-1-11) keep_output = false [](https://ackee.xyz/trident/docs/0.6.0/fuzzing/fuzzing-run-debug/#__codelineno-1-12) # Disable ANSI console; use simple log output (default: false) [](https://ackee.xyz/trident/docs/0.6.0/fuzzing/fuzzing-run-debug/#__codelineno-1-13) verbose = false [](https://ackee.xyz/trident/docs/0.6.0/fuzzing/fuzzing-run-debug/#__codelineno-1-14) # Exit upon seeing the first crash (default: false) [](https://ackee.xyz/trident/docs/0.6.0/fuzzing/fuzzing-run-debug/#__codelineno-1-15) exit_upon_crash = true [](https://ackee.xyz/trident/docs/0.6.0/fuzzing/fuzzing-run-debug/#__codelineno-1-16) # Maximal number of mutations per one run (default: 6) [](https://ackee.xyz/trident/docs/0.6.0/fuzzing/fuzzing-run-debug/#__codelineno-1-17) mutations_per_run = 6 [](https://ackee.xyz/trident/docs/0.6.0/fuzzing/fuzzing-run-debug/#__codelineno-1-18) # Target compilation directory, [](https://ackee.xyz/trident/docs/0.6.0/fuzzing/fuzzing-run-debug/#__codelineno-1-19) # (default: "" ["trident-tests/fuzz_tests/fuzzing/hfuzz_target"]). [](https://ackee.xyz/trident/docs/0.6.0/fuzzing/fuzzing-run-debug/#__codelineno-1-20) # To not clash with cargo build's default target directory. [](https://ackee.xyz/trident/docs/0.6.0/fuzzing/fuzzing-run-debug/#__codelineno-1-21) cargo_target_dir = "" [](https://ackee.xyz/trident/docs/0.6.0/fuzzing/fuzzing-run-debug/#__codelineno-1-22) # Honggfuzz working directory, [](https://ackee.xyz/trident/docs/0.6.0/fuzzing/fuzzing-run-debug/#__codelineno-1-23) # (default: "" ["trident-tests/fuzz_tests/fuzzing/hfuzz_workspace"]). [](https://ackee.xyz/trident/docs/0.6.0/fuzzing/fuzzing-run-debug/#__codelineno-1-24) hfuzz_workspace = "" [](https://ackee.xyz/trident/docs/0.6.0/fuzzing/fuzzing-run-debug/#__codelineno-1-25) # Directory where crashes are saved to (default: "" [workspace directory]) [](https://ackee.xyz/trident/docs/0.6.0/fuzzing/fuzzing-run-debug/#__codelineno-1-26) crashdir = "" [](https://ackee.xyz/trident/docs/0.6.0/fuzzing/fuzzing-run-debug/#__codelineno-1-27) # Input file extension (e.g. 'swf'), (default: "" ['fuzz']) [](https://ackee.xyz/trident/docs/0.6.0/fuzzing/fuzzing-run-debug/#__codelineno-1-28) extension = "" [](https://ackee.xyz/trident/docs/0.6.0/fuzzing/fuzzing-run-debug/#__codelineno-1-29) # Number of seconds this fuzzing session will last (default: 0 [no limit]) [](https://ackee.xyz/trident/docs/0.6.0/fuzzing/fuzzing-run-debug/#__codelineno-1-30) run_time = 0 [](https://ackee.xyz/trident/docs/0.6.0/fuzzing/fuzzing-run-debug/#__codelineno-1-31) # Maximal size of files processed by the fuzzer [](https://ackee.xyz/trident/docs/0.6.0/fuzzing/fuzzing-run-debug/#__codelineno-1-32) # in bytes (default: 1048576 = 1MB) [](https://ackee.xyz/trident/docs/0.6.0/fuzzing/fuzzing-run-debug/#__codelineno-1-33) max_file_size = 1048576 [](https://ackee.xyz/trident/docs/0.6.0/fuzzing/fuzzing-run-debug/#__codelineno-1-34) # Save all test-cases (not only the unique ones) by [](https://ackee.xyz/trident/docs/0.6.0/fuzzing/fuzzing-run-debug/#__codelineno-1-35) # appending the current time-stamp to the filenames (default: false) [](https://ackee.xyz/trident/docs/0.6.0/fuzzing/fuzzing-run-debug/#__codelineno-1-36) save_all = false` Or you can pass any parameter via [environment variables](https://github.com/rust-fuzz/honggfuzz-rs#environment-variables) . A list of hongfuzz parameters can be found in honggfuzz [usage documentation](https://github.com/google/honggfuzz/blob/master/docs/USAGE.md#cmdline---help) . The parameters passed via **environment variables** have **higher priority**. For example: `[](https://ackee.xyz/trident/docs/0.6.0/fuzzing/fuzzing-run-debug/#__codelineno-2-1) # Time-out: 10 secs [](https://ackee.xyz/trident/docs/0.6.0/fuzzing/fuzzing-run-debug/#__codelineno-2-2) # Number of concurrent fuzzing threads: 1 [](https://ackee.xyz/trident/docs/0.6.0/fuzzing/fuzzing-run-debug/#__codelineno-2-3) # Number of fuzzing iterations: 10000 [](https://ackee.xyz/trident/docs/0.6.0/fuzzing/fuzzing-run-debug/#__codelineno-2-4) # Display Solana logs in the terminal [](https://ackee.xyz/trident/docs/0.6.0/fuzzing/fuzzing-run-debug/#__codelineno-2-5) HFUZZ_RUN_ARGS="-t 10 -n 1 -N 10000 -Q" trident fuzz run ` Debug[#](https://ackee.xyz/trident/docs/0.6.0/fuzzing/fuzzing-run-debug/#debug "Permanent link") ------------------------------------------------------------------------------------------------- To debug your program with values from a crash file: `[](https://ackee.xyz/trident/docs/0.6.0/fuzzing/fuzzing-run-debug/#__codelineno-3-1) # fuzzer will run the with the specified [](https://ackee.xyz/trident/docs/0.6.0/fuzzing/fuzzing-run-debug/#__codelineno-3-2) trident fuzz run-debug [](https://ackee.xyz/trident/docs/0.6.0/fuzzing/fuzzing-run-debug/#__codelineno-3-3) # for example: [](https://ackee.xyz/trident/docs/0.6.0/fuzzing/fuzzing-run-debug/#__codelineno-3-4) trident fuzz run-debug fuzz_0 trident-tests/fuzz_tests/fuzzing/fuzz_0/cr1.fuzz` Back to top --- # Fuzz Test Lifecycle - Trident [Skip to content](https://ackee.xyz/trident/docs/0.6.0/fuzzing/fuzzing-lifecycle/#fuzz-test-lifecycle) Fuzz Test Lifecycle[#](https://ackee.xyz/trident/docs/0.6.0/fuzzing/fuzzing-lifecycle/#fuzz-test-lifecycle "Permanent link") ============================================================================================================================= In the sequence diagram below you can see a simplified fuzz test lifecycle. Some diagram states are labeled with emojis: * ⚡ Mandatory methods that must be implemented by the user. * 👤 Optional methods that can be implemented by the user. Lifecycle[#](https://ackee.xyz/trident/docs/0.6.0/fuzzing/fuzzing-lifecycle/#lifecycle "Permanent link") --------------------------------------------------------------------------------------------------------- 1. The fuzzer is running until: 1. The maximal number of iterations is reached (if specified). 2. A crash was detected and the `exit_upon_crash` parameter was set. 3. User interrupted the test manually (for example by hitting `CTRL+C`). 2. In each iteration, the fuzzer generates a sequence of random instructions to execute. 1. User can optionally customize how the instructions are generated and can specify the instructions that should be executed at the beginning (`pre_ixs`), in the middle (`ixs`) and at the end (`post_ixs`) of each iteration. This can be useful for example if your program needs an initialization or you want to fuzz some specific program state. 3. For each instruction: 1. User defined mandatory method `get_accounts()` is called to collect necessary instruction accounts. 2. User defined mandatory method `get_data()` is called to collect instruction data. 3. A snapshot of all instruction accounts before the instruction execution is saved. 4. The instruction is executed. 5. A snapshot of all instruction accounts after the instruction execution is saved. 6. User defined optional method `check()` is called to check accounts data and evaluate invariants. fuzzer\_iterations = 0 fuzzer\_iterations = 0 fuzzer\_iterations <  max\_iterations fuzzer\_iterations <... done done create pre-instruction  accounts snapshots create pre-instruction... execute instruction execute instruction create post-instruction  accounts snapshots create post-instruction... check invariants 👤 check invariants 👤 fuzzer\_iterations++ fuzzer\_iterations++Generate instructions pre\_ixs 👤 pre\_ixs 👤 ixs 👤 ixs 👤 post\_ixs 👤 post\_ixs 👤 end end for ix in instructions for ix in instructions get instruction accounts ⚡ get instruction accounts ⚡ get instruction data ⚡ get instruction data ⚡ next ix next ixText is not SVG - cannot display Back to top --- # Writing fuzz test - Trident [Skip to content](https://ackee.xyz/trident/docs/0.11.1/start-fuzzing/writting-fuzz-test/#writing-fuzz-test) Writing fuzz test[#](https://ackee.xyz/trident/docs/0.11.1/start-fuzzing/writting-fuzz-test/#writing-fuzz-test "Permanent link") ================================================================================================================================= Trident is Manually Guided fuzzing framework for Solana programs. In order to start fuzzing, you need to guide the fuzzer by specifying what are the expected inputs to instruction or the expected sequences of instructions to execute. **Why is this important?** Letting the fuzzer to generate completely random instruction inputs and completely random sequences of instruction would lead in most case * to transaction failures, which would mean the fuzzer is not properly fuzzing the logic within the program; and * executing irrelevant random instruction sequences, which would again lead to transaction failures. Guide the fuzzer[#](https://ackee.xyz/trident/docs/0.11.1/start-fuzzing/writting-fuzz-test/#guide-the-fuzzer "Permanent link") ------------------------------------------------------------------------------------------------------------------------------- Start with properly configuring different types of instruction inputs: * [Instruction Data](https://ackee.xyz/trident/docs/0.11.1/start-fuzzing/writting-fuzz-test/instruction-data/) * [Instruction Accounts](https://ackee.xyz/trident/docs/0.11.1/start-fuzzing/writting-fuzz-test/instruction-accounts/) * [Fuzzing Flows](https://ackee.xyz/trident/docs/0.11.1/start-fuzzing/writting-fuzz-test/fuzzing-flows/) * (Optional) [Remaining Accounts](https://ackee.xyz/trident/docs/0.11.1/start-fuzzing/writting-fuzz-test/remaining-accounts/) Back to top --- # Current limitations - Trident [Skip to content](https://ackee.xyz/trident/docs/0.6.0/fuzzing/fuzzing-current-limitations/#current-limitations) Current limitations[#](https://ackee.xyz/trident/docs/0.6.0/fuzzing/fuzzing-current-limitations/#current-limitations "Permanent link") ======================================================================================================================================= This section summarizes some known limitations in the current development stage. Further development will be focused on resolving these limitations. * Only fuzzing of one program without CPIs to other custom programs is supported. * Remaining accounts in check methods are not supported. * Composite accounts are not supported (however it is possible to generate a fuzz test and finish the composite accounts deserialization manually). Back to top --- # Fuzzing Examples - Trident [Skip to content](https://ackee.xyz/trident/docs/0.6.0/fuzzing/fuzzing-examples/#fuzzing-examples) Fuzzing Examples[#](https://ackee.xyz/trident/docs/0.6.0/fuzzing/fuzzing-examples/#fuzzing-examples "Permanent link") ====================================================================================================================== ### Hello World! Example[#](https://ackee.xyz/trident/docs/0.6.0/fuzzing/fuzzing-examples/#hello-world-example "Permanent link") * [hello\_world](https://github.com/Ackee-Blockchain/trident/tree/master/examples/fuzz-tests/hello_world) ### Possible vulnerabilities and bugs[#](https://ackee.xyz/trident/docs/0.6.0/fuzzing/fuzzing-examples/#possible-vulnerabilities-and-bugs "Permanent link") * [unchecked-arithmetic-0](https://github.com/Ackee-Blockchain/trident/tree/master/examples/fuzz-tests/unchecked-arithmetic-0) * [incorrect-ix-sequence-1](https://github.com/Ackee-Blockchain/trident/tree/master/examples/fuzz-tests/incorrect-ix-sequence-1) * [unauthorized-access-2](https://github.com/Ackee-Blockchain/trident/tree/master/examples/fuzz-tests/unauthorized-access-2) * [incorrect-integer-arithmetic-3](https://github.com/Ackee-Blockchain/trident/tree/master/examples/fuzz-tests/incorrect-integer-arithmetic-3) ### Example usage of Arbitrary Trait with Custom Data type as Instruction parameter[#](https://ackee.xyz/trident/docs/0.6.0/fuzzing/fuzzing-examples/#example-usage-of-arbitrary-trait-with-custom-data-type-as-instruction-parameter "Permanent link") * [arbitrary-custom-types-4](https://github.com/Ackee-Blockchain/trident/tree/master/examples/fuzz-tests/arbitrary-custom-types-4) ### Example usage of limiting the Instruction data structure with the Arbitrary trait[#](https://ackee.xyz/trident/docs/0.6.0/fuzzing/fuzzing-examples/#example-usage-of-limiting-the-instruction-data-structure-with-the-arbitrary-trait "Permanent link") * [arbitrary-limit-inputs-5](https://github.com/Ackee-Blockchain/trident/tree/master/examples/fuzz-tests/arbitrary-limit-inputs-5) Back to top --- # Trident API & Macro Reference - Trident [Skip to content](https://ackee.xyz/trident/docs/0.10.0/trident-api-macro/#trident-api-macro-reference) Trident API & Macro Reference[#](https://ackee.xyz/trident/docs/0.10.0/trident-api-macro/#trident-api-macro-reference "Permanent link") ======================================================================================================================================== This section contains the API and macro reference for Trident. Trident's Fuzz Client[#](https://ackee.xyz/trident/docs/0.10.0/trident-api-macro/#tridents-fuzz-client "Permanent link") ------------------------------------------------------------------------------------------------------------------------- FuzzClient represents the fuzzing environment and provides methods to interact with the fuzzing environment. * [FuzzClient](https://ackee.xyz/trident/docs/0.10.0/trident-api-macro/trident-fuzz-client/) Trident Macros[#](https://ackee.xyz/trident/docs/0.10.0/trident-api-macro/#trident-macros "Permanent link") ------------------------------------------------------------------------------------------------------------ Trident macros are used to define required methods for fuzzing. * [TridentTransaction](https://ackee.xyz/trident/docs/0.10.0/trident-api-macro/trident-macros/trident-transaction/) * [TridentInstruction](https://ackee.xyz/trident/docs/0.10.0/trident-api-macro/trident-macros/trident-instruction/) * [TridentAccounts](https://ackee.xyz/trident/docs/0.10.0/trident-api-macro/trident-macros/trident-accounts/) * [TridentRemainingAccounts](https://ackee.xyz/trident/docs/0.10.0/trident-api-macro/trident-macros/trident-remaining-accounts/) * [TridentFlowExecutor](https://ackee.xyz/trident/docs/0.10.0/trident-api-macro/trident-macros/trident-flow-executor/) * [TridentSelector](https://ackee.xyz/trident/docs/0.10.0/trident-api-macro/trident-macros/trident-selector/) Trident Types[#](https://ackee.xyz/trident/docs/0.10.0/trident-api-macro/#trident-types "Permanent link") ---------------------------------------------------------------------------------------------------------- Trident types represent the types utilized during fuzzing. * [FuzzTransactions](https://ackee.xyz/trident/docs/0.10.0/trident-api-macro/trident-types/fuzz-transactions/) * [FuzzAccounts](https://ackee.xyz/trident/docs/0.10.0/trident-api-macro/trident-types/fuzz-accounts/) * [TridentAccount](https://ackee.xyz/trident/docs/0.10.0/trident-api-macro/trident-types/trident-account/) * [TridentPubkey](https://ackee.xyz/trident/docs/0.10.0/trident-api-macro/trident-types/trident-pubkey/) * [CustomTypes](https://ackee.xyz/trident/docs/0.10.0/trident-api-macro/trident-types/custom-types/) Back to top --- # Trident API & Macro Reference - Trident [Skip to content](https://ackee.xyz/trident/docs/dev/trident-api-macro/#trident-api-macro-reference) Trident API & Macro Reference[#](https://ackee.xyz/trident/docs/dev/trident-api-macro/#trident-api-macro-reference "Permanent link") ===================================================================================================================================== This section contains the API and macro reference for Trident. Trident[#](https://ackee.xyz/trident/docs/dev/trident-api-macro/#trident "Permanent link") ------------------------------------------------------------------------------------------- The Trident struct is the main entry point for fuzzing. It provides methods to interact with the fuzzing environment. * [Trident](https://ackee.xyz/trident/docs/dev/trident-api-macro/trident/trident/) Trident's Fuzz Client[#](https://ackee.xyz/trident/docs/dev/trident-api-macro/#tridents-fuzz-client "Permanent link") ---------------------------------------------------------------------------------------------------------------------- FuzzClient represents the API to interact with the client. * [FuzzClient](https://ackee.xyz/trident/docs/dev/trident-api-macro/trident-fuzz-client/fuzz-client-trait/) Trident Accounts attributes[#](https://ackee.xyz/trident/docs/dev/trident-api-macro/#trident-accounts-attributes "Permanent link") ----------------------------------------------------------------------------------------------------------------------------------- Trident Accounts attributes help to define accounts used in the fuzzing environment. * [TridentAccounts](https://ackee.xyz/trident/docs/dev/trident-api-macro/attributes-for-accounts/account-attributes/) Hooks[#](https://ackee.xyz/trident/docs/dev/trident-api-macro/#hooks "Permanent link") --------------------------------------------------------------------------------------- Transaction Hooks are used to customize what should be done before the transaction is executed, after it is executed and to check if the changes are valid with invariant checks. * [TransactionHooks](https://ackee.xyz/trident/docs/dev/trident-api-macro/hooks/transaction-hooks/) Instruction Hooks are used to customize instruction data and accounts if the Trident Accounts attributes are not enough. * [InstructionHooks](https://ackee.xyz/trident/docs/dev/trident-api-macro/hooks/instruction-hooks/) Trident Macros[#](https://ackee.xyz/trident/docs/dev/trident-api-macro/#trident-macros "Permanent link") --------------------------------------------------------------------------------------------------------- Trident macros are used to define required methods for fuzzing. * [TridentTransaction](https://ackee.xyz/trident/docs/dev/trident-api-macro/trident-macros/trident-transaction/) * [TridentInstruction](https://ackee.xyz/trident/docs/dev/trident-api-macro/trident-macros/trident-instruction/) * [TridentAccounts](https://ackee.xyz/trident/docs/dev/trident-api-macro/trident-macros/trident-accounts/) * [TridentRemainingAccounts](https://ackee.xyz/trident/docs/dev/trident-api-macro/trident-macros/trident-remaining-accounts/) * [TridentFlowExecutor](https://ackee.xyz/trident/docs/dev/trident-api-macro/trident-macros/trident-flow-executor/) Trident Types[#](https://ackee.xyz/trident/docs/dev/trident-api-macro/#trident-types "Permanent link") ------------------------------------------------------------------------------------------------------- Trident types represent the types utilized during fuzzing. * [FuzzAccounts](https://ackee.xyz/trident/docs/dev/trident-api-macro/trident-types/fuzz-accounts/) * [TridentAccount](https://ackee.xyz/trident/docs/dev/trident-api-macro/trident-types/trident-account/) * [TridentPubkey](https://ackee.xyz/trident/docs/dev/trident-api-macro/trident-types/trident-pubkey/) * [CustomTypes](https://ackee.xyz/trident/docs/dev/trident-api-macro/trident-types/custom-types/) Back to top --- # Executing the Fuzz Test - Trident [Skip to content](https://ackee.xyz/trident/docs/0.11.1/start-fuzzing/executing-fuzz-test/#executing-the-fuzz-test) Executing the Fuzz Test[#](https://ackee.xyz/trident/docs/0.11.1/start-fuzzing/executing-fuzz-test/#executing-the-fuzz-test "Permanent link") ============================================================================================================================================== To execute the fuzz test, navigate to the `trident-tests` directory and run the following command to execute the fuzz test: `[](https://ackee.xyz/trident/docs/0.11.1/start-fuzzing/executing-fuzz-test/#__codelineno-0-1) trident fuzz run [](https://ackee.xyz/trident/docs/0.11.1/start-fuzzing/executing-fuzz-test/#__codelineno-0-2) # for example: [](https://ackee.xyz/trident/docs/0.11.1/start-fuzzing/executing-fuzz-test/#__codelineno-0-3) # trident fuzz run fuzz_0 [](https://ackee.xyz/trident/docs/0.11.1/start-fuzzing/executing-fuzz-test/#__codelineno-0-4) # seed is optional, if not provided, a random seed will be used` Directory Note Execute fuzz tests from the `trident-tests` directory. Solana Logs In case you want to see the logs of the fuzzed transactions, prefix the command with `TRIDENT_LOG=1`. `[](https://ackee.xyz/trident/docs/0.11.1/start-fuzzing/executing-fuzz-test/#__codelineno-1-1) TRIDENT_LOG=1 trident fuzz run ` For the output reference and additional options such as debugging the found issues, check out [Commands](https://ackee.xyz/trident/docs/0.11.1/basics/commands/) . For the additional customization through the `trident.toml` file, check out the [Trident Manifest](https://ackee.xyz/trident/docs/0.11.1/trident-manifest/) page. Back to top --- # Run - Trident [Skip to content](https://ackee.xyz/trident/docs/0.6.0/integration-tests/poc-run/#run) Run[#](https://ackee.xyz/trident/docs/0.6.0/integration-tests/poc-run/#run "Permanent link") ============================================================================================= Once you have finished the implementation of the Integration Test, you can run the Test as follows: `[](https://ackee.xyz/trident/docs/0.6.0/integration-tests/poc-run/#__codelineno-0-1) trident test` Skipping tests[#](https://ackee.xyz/trident/docs/0.6.0/integration-tests/poc-run/#skipping-tests "Permanent link") ------------------------------------------------------------------------------------------------------------------- * You can add the `#[ignore]` macro to skip the test. `[](https://ackee.xyz/trident/docs/0.6.0/integration-tests/poc-run/#__codelineno-1-1) #[trident_test] [](https://ackee.xyz/trident/docs/0.6.0/integration-tests/poc-run/#__codelineno-1-2) #[ignore] [](https://ackee.xyz/trident/docs/0.6.0/integration-tests/poc-run/#__codelineno-1-3) async fn test() {}` Back to top --- # Introduction - Trident [Skip to content](https://ackee.xyz/trident/docs/0.6.0/integration-tests/poc-introduction/#introduction) Introduction[#](https://ackee.xyz/trident/docs/0.6.0/integration-tests/poc-introduction/#introduction "Permanent link") ======================================================================================================================== Trident supports writing Integration Tests in Rust. marcinv@XPS15:~/Work/tooling/trident/examples/turnstile$ marcinv@XPS15:~/Work/tooling/trident/examples/turnstile$ t marcinv@XPS15:~/Work/tooling/trident/examples/turnstile$ tr marcinv@XPS15:~/Work/tooling/trident/examples/turnstile$ tri marcinv@XPS15:~/Work/tooling/trident/examples/turnstile$ trid marcinv@XPS15:~/Work/tooling/trident/examples/turnstile$ tride marcinv@XPS15:~/Work/tooling/trident/examples/turnstile$ triden marcinv@XPS15:~/Work/tooling/trident/examples/turnstile$ trident marcinv@XPS15:~/Work/tooling/trident/examples/turnstile$ trident marcinv@XPS15:~/Work/tooling/trident/examples/turnstile$ trident marcinv@XPS15:~/Work/tooling/trident/examples/turnstile$ trident t marcinv@XPS15:~/Work/tooling/trident/examples/turnstile$ trident te marcinv@XPS15:~/Work/tooling/trident/examples/turnstile$ trident tes marcinv@XPS15:~/Work/tooling/trident/examples/turnstile$ trident test marcinv@XPS15:~/Work/tooling/trident/examples/turnstile$ trident test Finished test \[unoptimized + debuginfo\] target(s) in 0.17s Running unittests src/lib.rs (target/debug/deps/program\_client-35df7129a7acbd48)running 0 teststest result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s Running tests/test.rs (target/debug/deps/test-e1d41610f5897c1f)running 2 tests\-------------- TEST START --------------program\_keypair(1).pubkey = Po1RaS8BEDbNcn5oXsFryAeQ6Wn8fvmE111DJaKCgPCWaiting for fees to stabilize 1...test test\_unhappy\_path ... okWaiting for fees to stabilize 2...test test\_happy\_path ... oktest result: ok. 2 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 14.89s Running unittests src/lib.rs (target/debug/deps/turnstile-451803623b25a701)running 1 testtest test\_id ... oktest result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s Doc-tests program\_clientmarcinv@XPS15:~/Work/tooling/trident/examples/turnstile$ exit Back to top --- # Code Coverage - Trident [Skip to content](https://ackee.xyz/trident/docs/0.11.1/trident-advanced/code-coverage/#code-coverage) Code Coverage[#](https://ackee.xyz/trident/docs/0.11.1/trident-advanced/code-coverage/#code-coverage "Permanent link") ======================================================================================================================= Trident's code coverage feature analyzes which parts of your Solana program are tested during fuzzing sessions, helping you identify untested code paths and improve test effectiveness. Your browser does not support the video tag. Key features: * **Real-time Analysis**: Monitor coverage as fuzzing progresses * **Multiple Formats**: Generate reports in JSON and HTML formats * **VS Code Integration**: Visualize coverage directly in your IDE using [Solana VS Code extension](https://marketplace.visualstudio.com/items?itemName=AckeeBlockchain.solana) * **Detailed Reporting**: Get insights into line coverage, branch coverage, and execution paths Gathering Coverage Data[#](https://ackee.xyz/trident/docs/0.11.1/trident-advanced/code-coverage/#gathering-coverage-data "Permanent link") ------------------------------------------------------------------------------------------------------------------------------------------- 1. Enable coverage in the [Trident manifest](https://ackee.xyz/trident/docs/0.11.1/trident-manifest/#fuzzing-coverage) 2. Deploy your program through the [entrypoint](https://ackee.xyz/trident/docs/0.11.1/trident-manifest/#entrypoint-deployment) 3. Run the fuzz test Viewing Coverage Reports[#](https://ackee.xyz/trident/docs/0.11.1/trident-advanced/code-coverage/#viewing-coverage-reports "Permanent link") --------------------------------------------------------------------------------------------------------------------------------------------- You have two options for displaying coverage data: generate an HTML report for browser viewing, or generate a JSON report for VS Code integration. ### Live Coverage Updates[#](https://ackee.xyz/trident/docs/0.11.1/trident-advanced/code-coverage/#live-coverage-updates "Permanent link") For real-time coverage monitoring during fuzzing: 1. Set `format = "json"` in the [Trident manifest](https://ackee.xyz/trident/docs/0.11.1/trident-manifest/#fuzzing-coverage) 2. Set `loopcount` to a value other than `0` e.g., `5` for frequent updates, for more info check out [Trident manifest](https://ackee.xyz/trident/docs/0.11.1/trident-manifest/#entrypoint-deployment) 3. Install the [Solana VS Code extension](https://marketplace.visualstudio.com/items?itemName=AckeeBlockchain.solana) 4. Choose one of these options: * **Automatic**: Set `attach_extension = true` in the [Trident manifest](https://ackee.xyz/trident/docs/0.11.1/trident-manifest/#fuzzing-coverage) to automatically show live updates while the fuzz test is running * **Manual**: Use the command `Solana: Show Code Coverage` and select the "Attach to active fuzzing session" option ### Post-Session Coverage Analysis[#](https://ackee.xyz/trident/docs/0.11.1/trident-advanced/code-coverage/#post-session-coverage-analysis "Permanent link") 1. Set `format = "json"` in the [Trident manifest](https://ackee.xyz/trident/docs/0.11.1/trident-manifest/#fuzzing-coverage) before running the fuzz test 2. Run the fuzz test 3. Install the [Solana VS Code extension](https://marketplace.visualstudio.com/items?itemName=AckeeBlockchain.solana) 4. Run the VS Code command `Solana: Show Code Coverage` and select the "Load generated JSON report" option ### HTML Report[#](https://ackee.xyz/trident/docs/0.11.1/trident-advanced/code-coverage/#html-report "Permanent link") 1. Set `format = "html"` in the [Trident manifest](https://ackee.xyz/trident/docs/0.11.1/trident-manifest/#fuzzing-coverage) before running the fuzz test 2. Run the fuzz test 3. After the fuzz test finishes, the HTML report will be stored in the `-coverage-report` folder 4. Open the HTML report in your browser Back to top --- # Examples - Trident [Skip to content](https://ackee.xyz/trident/docs/0.6.0/integration-tests/poc-examples/#examples) Examples[#](https://ackee.xyz/trident/docs/0.6.0/integration-tests/poc-examples/#examples "Permanent link") ============================================================================================================ * [Escrow](https://github.com/Ackee-Blockchain/trident/tree/master/examples/integration-tests/escrow) * [Turnstile](https://github.com/Ackee-Blockchain/trident/tree/master/examples/integration-tests/turnstile) Back to top --- # Trident Manifest - Trident [Skip to content](https://ackee.xyz/trident/docs/0.10.0/trident-manifest/#trident-manifest) Trident Manifest[#](https://ackee.xyz/trident/docs/0.10.0/trident-manifest/#trident-manifest "Permanent link") =============================================================================================================== Trident supports its own Trident Manifest, called `Trident.toml`. This section describe all possible configuration fields. Back to top --- # Trident Manifest - Trident [Skip to content](https://ackee.xyz/trident/docs/dev/trident-manifest/#trident-manifest) Trident Manifest[#](https://ackee.xyz/trident/docs/dev/trident-manifest/#trident-manifest "Permanent link") ============================================================================================================ Trident supports its own Trident Manifest, called `Trident.toml`. This section describes all possible configuration fields. Fuzzing Metrics[#](https://ackee.xyz/trident/docs/dev/trident-manifest/#fuzzing-metrics "Permanent link") ---------------------------------------------------------------------------------------------------------- `[](https://ackee.xyz/trident/docs/dev/trident-manifest/#__codelineno-0-1) [fuzz.metrics] [](https://ackee.xyz/trident/docs/dev/trident-manifest/#__codelineno-0-2) enabled = true [](https://ackee.xyz/trident/docs/dev/trident-manifest/#__codelineno-0-3) dashboard = false [](https://ackee.xyz/trident/docs/dev/trident-manifest/#__codelineno-0-4) json = false` * `enabled` - Trident will show and save statistics after the fuzzing session. * `dashboard` - Trident will save a HTML dashboard after the fuzzing session. * `json` - Trident will save a JSON file after the fuzzing session. * * * Regression testing[#](https://ackee.xyz/trident/docs/dev/trident-manifest/#regression-testing "Permanent link") ---------------------------------------------------------------------------------------------------------------- `[](https://ackee.xyz/trident/docs/dev/trident-manifest/#__codelineno-1-1) [fuzz.regression] [](https://ackee.xyz/trident/docs/dev/trident-manifest/#__codelineno-1-2) enabled = true` * `enabled` - Trident will save a JSON file with all monitored states after the fuzzing session. Regression testing * Keep in mind that the feature hashes contents of accounts, if the contents are dependant for example on time, the final hash might not be the same as the one from the first fuzzing session. * * * Fuzzing Coverage[#](https://ackee.xyz/trident/docs/dev/trident-manifest/#fuzzing-coverage "Permanent link") ------------------------------------------------------------------------------------------------------------ `[](https://ackee.xyz/trident/docs/dev/trident-manifest/#__codelineno-2-1) [fuzz.coverage] [](https://ackee.xyz/trident/docs/dev/trident-manifest/#__codelineno-2-2) enable = true # default: false [](https://ackee.xyz/trident/docs/dev/trident-manifest/#__codelineno-2-3) server_port = 58432 # default: 58432 [](https://ackee.xyz/trident/docs/dev/trident-manifest/#__codelineno-2-4) loopcount = 5 # default: 0 [](https://ackee.xyz/trident/docs/dev/trident-manifest/#__codelineno-2-5) format = "json" # default: "json" [](https://ackee.xyz/trident/docs/dev/trident-manifest/#__codelineno-2-6) attach_extension = true # default: false` The coverage configuration enables code coverage analysis during fuzzing sessions, providing insights into which parts of your program are being tested. * `enable` - When set to `true`, Trident collects code coverage data throughout the fuzzing session and generates a comprehensive report upon completion. * `server_port` - Specifies the HTTP server port used for communication between Trident and the [Solana VS Code extension](https://marketplace.visualstudio.com/items?itemName=AckeeBlockchain.solana) . * `loopcount` - Defines the number of execution flows processed before generating an intermediate coverage data file. Lower values provide more frequent coverage updates at the cost of performance. When set to `0`, coverage files are only generated at the end of the fuzzing session. * `format` - Determines the output format for coverage reports. Trident supports both `json` and `html` formats. * `attach_extension` - Enables real-time coverage visualization in VS Code when the extension is active. This feature requires `loopcount` to be greater than `0` and `format` to be set to `json`. Warning Coverage is only gathered for the programs deployed through an entrypoint! Entrypoint deployment guide 1. Comment out the program in `Trident.toml` `[](https://ackee.xyz/trident/docs/dev/trident-manifest/#__codelineno-3-1) # [[fuzz.programs]] [](https://ackee.xyz/trident/docs/dev/trident-manifest/#__codelineno-3-2) # address = "example_address" [](https://ackee.xyz/trident/docs/dev/trident-manifest/#__codelineno-3-3) # program = "../target/deploy/example_program.so"` 2. Add the program dependency to `Cargo.toml` `[](https://ackee.xyz/trident/docs/dev/trident-manifest/#__codelineno-4-1) [dependencies.example_program] [](https://ackee.xyz/trident/docs/dev/trident-manifest/#__codelineno-4-2) path = "../programs/example_program"` 3. Add `syscall-v1` or `syscall-v2` feature depending on the version of `solana-program`. Programs written for `solana-program` v1.x should use `syscall-v1`, programs written for `solana-program` v2.x should use `syscall-v2` feature. `[](https://ackee.xyz/trident/docs/dev/trident-manifest/#__codelineno-5-1) [dependencies.trident-fuzz] [](https://ackee.xyz/trident/docs/dev/trident-manifest/#__codelineno-5-2) features = ["syscall-v2"]` 4. Import the programs entrypoint in `test_fuzz.rs` `[](https://ackee.xyz/trident/docs/dev/trident-manifest/#__codelineno-6-1) use example_program::entry as example_entrypoint;` 5. Deploy the entrypoint in `test_fuzz.rs` `[](https://ackee.xyz/trident/docs/dev/trident-manifest/#__codelineno-7-1) impl FuzzTest { [](https://ackee.xyz/trident/docs/dev/trident-manifest/#__codelineno-7-2) fn new() -> Self { [](https://ackee.xyz/trident/docs/dev/trident-manifest/#__codelineno-7-3) let mut trident = Trident::default(); [](https://ackee.xyz/trident/docs/dev/trident-manifest/#__codelineno-7-4) [](https://ackee.xyz/trident/docs/dev/trident-manifest/#__codelineno-7-5) // Deploy through the entrypoint [](https://ackee.xyz/trident/docs/dev/trident-manifest/#__codelineno-7-6) let program = TridentEntrypoint::new(example_program::ID, None, processor!(example_entrypoint)); [](https://ackee.xyz/trident/docs/dev/trident-manifest/#__codelineno-7-7) trident.get_client().deploy_entrypoint(program); [](https://ackee.xyz/trident/docs/dev/trident-manifest/#__codelineno-7-8) [](https://ackee.xyz/trident/docs/dev/trident-manifest/#__codelineno-7-9) Self { [](https://ackee.xyz/trident/docs/dev/trident-manifest/#__codelineno-7-10) trident, [](https://ackee.xyz/trident/docs/dev/trident-manifest/#__codelineno-7-11) fuzz_accounts: FuzzAccounts::default(), [](https://ackee.xyz/trident/docs/dev/trident-manifest/#__codelineno-7-12) } [](https://ackee.xyz/trident/docs/dev/trident-manifest/#__codelineno-7-13) } [](https://ackee.xyz/trident/docs/dev/trident-manifest/#__codelineno-7-14) ...` * * * Programs[#](https://ackee.xyz/trident/docs/dev/trident-manifest/#programs "Permanent link") -------------------------------------------------------------------------------------------- * Use dumped program from desired cluster, during fuzzing. `[](https://ackee.xyz/trident/docs/dev/trident-manifest/#__codelineno-8-1) [[fuzz.programs]] [](https://ackee.xyz/trident/docs/dev/trident-manifest/#__codelineno-8-2) address = "metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s" [](https://ackee.xyz/trident/docs/dev/trident-manifest/#__codelineno-8-3) upgrade_authority = "account address goes here" [](https://ackee.xyz/trident/docs/dev/trident-manifest/#__codelineno-8-4) program = "metaplex-program/metaplex-token-metadata.so"` * * * Accounts[#](https://ackee.xyz/trident/docs/dev/trident-manifest/#accounts "Permanent link") -------------------------------------------------------------------------------------------- * Use dumped accounts from desired cluster, during fuzzing. `[](https://ackee.xyz/trident/docs/dev/trident-manifest/#__codelineno-9-1) [[fuzz.accounts]] [](https://ackee.xyz/trident/docs/dev/trident-manifest/#__codelineno-9-2) address = "6YG3J7PaxyMnnbU67ifyrgF3BzNzc7cD8hPkqK6ATweE" [](https://ackee.xyz/trident/docs/dev/trident-manifest/#__codelineno-9-3) filename = "tests/accounts/core_bridge_mainnet/guardian_set_5_mock.json"` * * * Back to top --- # TridentSVM - Trident [Skip to content](https://ackee.xyz/trident/docs/dev/trident-svm/#tridentsvm) TridentSVM[#](https://ackee.xyz/trident/docs/dev/trident-svm/#tridentsvm "Permanent link") =========================================================================================== TridentSVM is a fast execution and accounts storage environment which is utilized within the Trident. Github repository: [Trident SVM](https://github.com/Ackee-Blockchain/trident-svm) TridentSVM uses [Anza's SVM API](https://www.anza.xyz/blog/anzas-new-svm-api) Back to top --- # Trident SVM - Trident [Skip to content](https://ackee.xyz/trident/docs/0.10.0/trident-svm/#trident-svm) Trident SVM[#](https://ackee.xyz/trident/docs/0.10.0/trident-svm/#trident-svm "Permanent link") ================================================================================================ TridentSVM is a fast execution and accounts storage environment which is utilized within the Trident. Github repository: [Trident SVM](https://github.com/Ackee-Blockchain/trident-svm) TridentSVM uses [Anza's SVM API](https://www.anza.xyz/blog/anzas-new-svm-api) Back to top --- # Installation - Trident [Skip to content](https://ackee.xyz/trident/docs/0.8.1/installation/installation/#installation) Installation[#](https://ackee.xyz/trident/docs/0.8.1/installation/installation/#installation "Permanent link") =============================================================================================================== Important **Prerequisite** It is expected that you have installed: * Rust ([Install Rust](https://www.rust-lang.org/tools/install) ) * Solana CLI ([Install Solana CLI](https://docs.solanalabs.com/cli/install) ) * Anchor Framework ([Install Anchor](https://www.anchor-lang.com/docs/installation) ) For supported versions check the [Supported Versions](https://ackee.xyz/trident/docs/0.8.1/installation/installation/#supported-versions) Install System Dependencies[#](https://ackee.xyz/trident/docs/0.8.1/installation/installation/#install-system-dependencies "Permanent link") --------------------------------------------------------------------------------------------------------------------------------------------- Update your package list and install the required packages: `[](https://ackee.xyz/trident/docs/0.8.1/installation/installation/#__codelineno-0-1) sudo apt-get update [](https://ackee.xyz/trident/docs/0.8.1/installation/installation/#__codelineno-0-2) sudo apt-get install -y \ [](https://ackee.xyz/trident/docs/0.8.1/installation/installation/#__codelineno-0-3) curl \ [](https://ackee.xyz/trident/docs/0.8.1/installation/installation/#__codelineno-0-4) git \ [](https://ackee.xyz/trident/docs/0.8.1/installation/installation/#__codelineno-0-5) build-essential \ [](https://ackee.xyz/trident/docs/0.8.1/installation/installation/#__codelineno-0-6) pkg-config \ [](https://ackee.xyz/trident/docs/0.8.1/installation/installation/#__codelineno-0-7) libssl-dev \ [](https://ackee.xyz/trident/docs/0.8.1/installation/installation/#__codelineno-0-8) npm \ [](https://ackee.xyz/trident/docs/0.8.1/installation/installation/#__codelineno-0-9) vim \ [](https://ackee.xyz/trident/docs/0.8.1/installation/installation/#__codelineno-0-10) nano \ [](https://ackee.xyz/trident/docs/0.8.1/installation/installation/#__codelineno-0-11) wget \ [](https://ackee.xyz/trident/docs/0.8.1/installation/installation/#__codelineno-0-12) binutils-dev \ [](https://ackee.xyz/trident/docs/0.8.1/installation/installation/#__codelineno-0-13) libunwind-dev \ [](https://ackee.xyz/trident/docs/0.8.1/installation/installation/#__codelineno-0-14) lldb` Install Hongfuzz[#](https://ackee.xyz/trident/docs/0.8.1/installation/installation/#install-hongfuzz "Permanent link") ----------------------------------------------------------------------------------------------------------------------- Install honggfuzz `[](https://ackee.xyz/trident/docs/0.8.1/installation/installation/#__codelineno-1-1) cargo install honggfuzz` Install Trident[#](https://ackee.xyz/trident/docs/0.8.1/installation/installation/#install-trident "Permanent link") --------------------------------------------------------------------------------------------------------------------- `[](https://ackee.xyz/trident/docs/0.8.1/installation/installation/#__codelineno-2-1) cargo install trident-cli` Supported versions[#](https://ackee.xyz/trident/docs/0.8.1/installation/installation/#supported-versions "Permanent link") --------------------------------------------------------------------------------------------------------------------------- | **_Trident CLI_** | **_Anchor_** | **_Solana_** | **_Rust_** | **_Honggfuzz_** | | --- | --- | --- | --- | --- | | **_`develop`_** | `0.30.1` | `^1.17.4` | `nightly` | `0.5.56` | | **_`0.8.*`_** | `0.30.1` | `^1.17.4` | `nightly` | `0.5.56` | | **_`0.7.0`_** | `>=0.29.*`1 | `^1.17.4` | `nightly` | `0.5.56` | | **_`0.6.0`_** | `>=0.29.*`1 | `^1.17` | `nightly` | `0.5.55` | | **_`0.5.0`_** | `~0.28.*` | `=1.16.6` | \- | \- | | **_`0.4.0`_** | `~0.27.*` | `>=1.15` | \- | \- | | **_`0.3.0`_** | `~0.25.*` | `>=1.10` | \- | \- | | **_`0.2.0`_** | `~0.24.*` | `>=1.9` | \- | \- | 1. To use Trident with Anchor 0.29.0, run the following commands from your project's root directory after Trident initialization: `[](https://ackee.xyz/trident/docs/0.8.1/installation/installation/#__codelineno-3-1) cargo update [[email protected]](https://ackee.xyz/cdn-cgi/l/email-protection) --precise 0.29.0 [](https://ackee.xyz/trident/docs/0.8.1/installation/installation/#__codelineno-3-2) cargo update [[email protected]](https://ackee.xyz/cdn-cgi/l/email-protection) --precise 0.29.0` Back to top --- # Dashboard - Trident [Skip to content](https://ackee.xyz/trident/docs/0.11.1/trident-advanced/dashboard/#dashboard) Dashboard[#](https://ackee.xyz/trident/docs/0.11.1/trident-advanced/dashboard/#dashboard "Permanent link") =========================================================================================================== The Trident Dashboard provides a web-based interface for visualizing fuzzing session results through interactive charts and comprehensive statistics. Your browser does not support the video tag. Features: * **Session Statistics**: View execution counts, success rates, and performance metrics * **Interactive Charts**: Explore results through dynamic visualizations * **Browser Access**: Open in any web browser without additional software * **Comprehensive Analysis**: Insights into instruction coverage and account interactions Viewing the Dashboard[#](https://ackee.xyz/trident/docs/0.11.1/trident-advanced/dashboard/#viewing-the-dashboard "Permanent link") ----------------------------------------------------------------------------------------------------------------------------------- 1. Open another terminal window and execute `trident server` from the fuzz-tests directory. 2. Open your browser and navigate to the provided URL (typically `http://localhost:8080`). 3. Enable the dashboard in the [Trident manifest](https://ackee.xyz/trident/docs/0.11.1/trident-manifest/#fuzzing-metrics) by setting `dashboard = true`. `[](https://ackee.xyz/trident/docs/0.11.1/trident-advanced/dashboard/#__codelineno-0-1) [fuzz.metrics] [](https://ackee.xyz/trident/docs/0.11.1/trident-advanced/dashboard/#__codelineno-0-2) enabled = true [](https://ackee.xyz/trident/docs/0.11.1/trident-advanced/dashboard/#__codelineno-0-3) dashboard = true` 4. Run the fuzz test to generate dashboard data. Monitoring custom fuzzing metrics[#](https://ackee.xyz/trident/docs/0.11.1/trident-advanced/dashboard/#monitoring-custom-fuzzing-metrics "Permanent link") ----------------------------------------------------------------------------------------------------------------------------------------------------------- Trident allows you to monitor custom fuzzing metrics. If your program expects integer instruction inputs, it is possible to collect data on the randomly generated values and display them in the dashboard. To do this, you need to add `trident.add_histogram_metric` to the `#[init]`, `#[flow]` or `#[end]` functions. The following code snippet shows how the `InitializeFnTransaction` instruction input is monitored; the statistics will be displayed in the dashboard. `[](https://ackee.xyz/trident/docs/0.11.1/trident-advanced/dashboard/#__codelineno-1-1) #[flow_executor] [](https://ackee.xyz/trident/docs/0.11.1/trident-advanced/dashboard/#__codelineno-1-2) impl FuzzTest { [](https://ackee.xyz/trident/docs/0.11.1/trident-advanced/dashboard/#__codelineno-1-3) fn new() -> Self { [](https://ackee.xyz/trident/docs/0.11.1/trident-advanced/dashboard/#__codelineno-1-4) Self { [](https://ackee.xyz/trident/docs/0.11.1/trident-advanced/dashboard/#__codelineno-1-5) trident: Trident::default(), [](https://ackee.xyz/trident/docs/0.11.1/trident-advanced/dashboard/#__codelineno-1-6) fuzz_accounts: FuzzAccounts::default(), [](https://ackee.xyz/trident/docs/0.11.1/trident-advanced/dashboard/#__codelineno-1-7) } [](https://ackee.xyz/trident/docs/0.11.1/trident-advanced/dashboard/#__codelineno-1-8) } [](https://ackee.xyz/trident/docs/0.11.1/trident-advanced/dashboard/#__codelineno-1-9) [](https://ackee.xyz/trident/docs/0.11.1/trident-advanced/dashboard/#__codelineno-1-10) #[init] [](https://ackee.xyz/trident/docs/0.11.1/trident-advanced/dashboard/#__codelineno-1-11) fn start(&mut self) { [](https://ackee.xyz/trident/docs/0.11.1/trident-advanced/dashboard/#__codelineno-1-12) let mut ix = InitializeFnTransaction::build(&mut self.trident, &mut self.fuzz_accounts); [](https://ackee.xyz/trident/docs/0.11.1/trident-advanced/dashboard/#__codelineno-1-13) [](https://ackee.xyz/trident/docs/0.11.1/trident-advanced/dashboard/#__codelineno-1-14) self.trident.execute_transaction(&mut ix, Some("Init")); [](https://ackee.xyz/trident/docs/0.11.1/trident-advanced/dashboard/#__codelineno-1-15) } [](https://ackee.xyz/trident/docs/0.11.1/trident-advanced/dashboard/#__codelineno-1-16) [](https://ackee.xyz/trident/docs/0.11.1/trident-advanced/dashboard/#__codelineno-1-17) #[flow(weight = 5)] [](https://ackee.xyz/trident/docs/0.11.1/trident-advanced/dashboard/#__codelineno-1-18) fn flow1(&mut self) { [](https://ackee.xyz/trident/docs/0.11.1/trident-advanced/dashboard/#__codelineno-1-19) let mut ix = InitializeFnTransaction::build(&mut self.trident, &mut self.fuzz_accounts); [](https://ackee.xyz/trident/docs/0.11.1/trident-advanced/dashboard/#__codelineno-1-20) self.trident.execute_transaction(&mut ix, Some("Flow1")); [](https://ackee.xyz/trident/docs/0.11.1/trident-advanced/dashboard/#__codelineno-1-21) [](https://ackee.xyz/trident/docs/0.11.1/trident-advanced/dashboard/#__codelineno-1-22) // Add the histogram metric to the dashboard [](https://ackee.xyz/trident/docs/0.11.1/trident-advanced/dashboard/#__codelineno-1-23) self.trident [](https://ackee.xyz/trident/docs/0.11.1/trident-advanced/dashboard/#__codelineno-1-24) .add_histogram_metric("flow1_metric", ix.instruction.data.input as f64); [](https://ackee.xyz/trident/docs/0.11.1/trident-advanced/dashboard/#__codelineno-1-25) } [](https://ackee.xyz/trident/docs/0.11.1/trident-advanced/dashboard/#__codelineno-1-26) [](https://ackee.xyz/trident/docs/0.11.1/trident-advanced/dashboard/#__codelineno-1-27) #[flow(weight = 5)] [](https://ackee.xyz/trident/docs/0.11.1/trident-advanced/dashboard/#__codelineno-1-28) fn flow2(&mut self) { [](https://ackee.xyz/trident/docs/0.11.1/trident-advanced/dashboard/#__codelineno-1-29) //.... [](https://ackee.xyz/trident/docs/0.11.1/trident-advanced/dashboard/#__codelineno-1-30) } [](https://ackee.xyz/trident/docs/0.11.1/trident-advanced/dashboard/#__codelineno-1-31) #[flow(weight = 90)] [](https://ackee.xyz/trident/docs/0.11.1/trident-advanced/dashboard/#__codelineno-1-32) fn flow3(&mut self) { [](https://ackee.xyz/trident/docs/0.11.1/trident-advanced/dashboard/#__codelineno-1-33) //.... [](https://ackee.xyz/trident/docs/0.11.1/trident-advanced/dashboard/#__codelineno-1-34) } [](https://ackee.xyz/trident/docs/0.11.1/trident-advanced/dashboard/#__codelineno-1-35) #[end] [](https://ackee.xyz/trident/docs/0.11.1/trident-advanced/dashboard/#__codelineno-1-36) fn cleanup(&mut self) -> Result<(), FuzzingError> { [](https://ackee.xyz/trident/docs/0.11.1/trident-advanced/dashboard/#__codelineno-1-37) //.... [](https://ackee.xyz/trident/docs/0.11.1/trident-advanced/dashboard/#__codelineno-1-38) } [](https://ackee.xyz/trident/docs/0.11.1/trident-advanced/dashboard/#__codelineno-1-39) }` Back to top --- # Trident examples - Trident Trident examples ================ * **Hello World!** * * * Hello World example with Trident. [Hello World!](https://github.com/Ackee-Blockchain/trident/tree/develop/examples/hello_world) * **Cross-Program Invocation** * * * Trident supports Cross-Program Invocation, you can fuzz your programs and create NFTs at the same time. [Simple CPI](https://github.com/Ackee-Blockchain/trident/tree/develop/examples/cpi) [CPI with Metaplex Metadata Program](https://github.com/Ackee-Blockchain/trident/tree/develop/examples/metaplex) * **Benchmarking** * * * Trident contains benchmarks of [Daedaluzz: A Benchmark Generator for Smart-Contract Fuzzers](https://github.com/Consensys/daedaluzz) rewritten in Rust. [Trident Benchmark](https://github.com/Ackee-Blockchain/trident/tree/develop/examples/trident-benchmark) * **Fuzzing Pipeline** * * * Trident provides a fuzzing pipeline that can be used to fuzz your programs. [Fuzzing pipeline](https://github.com/Ackee-Blockchain/trident/blob/master/.github/workflows/fuzz.yml) Back to top --- # Trident Examples - Trident [Skip to content](https://ackee.xyz/trident/docs/0.10.0/trident-examples/trident-examples/#trident-examples) Trident Examples[#](https://ackee.xyz/trident/docs/0.10.0/trident-examples/trident-examples/#trident-examples "Permanent link") ================================================================================================================================ * **Hello World!** * * * Hello World example with Trident. [Hello World!](https://github.com/Ackee-Blockchain/trident/tree/0.10.0/examples/hello_world) * **Possible vulnerabilities and bugs** * * * Check the possible attack vectors and bugs that can be detected using Trident. [Unchecked Arithmetic](https://github.com/Ackee-Blockchain/trident/tree/0.10.0/examples/common_issues/unchecked-arithmetic-0) [Incorrect Instruction Sequence](https://github.com/Ackee-Blockchain/trident/tree/0.10.0/examples/common_issues/incorrect-ix-sequence-1) [Unauthorized Access](https://github.com/Ackee-Blockchain/trident/tree/0.10.0/examples/common_issues/unauthorized-access-2) [Incorrect Integer Arithmetic](https://github.com/Ackee-Blockchain/trident/tree/0.10.0/examples/common_issues/incorrect-integer-arithmetic-3) * **Customize with Arbitrary** * * * You can use Arbitrary crate to your advantage and limit or customize the data that are sent to the instructions. [Custom Data Types](https://github.com/Ackee-Blockchain/trident/tree/0.10.0/examples/common_issues/arbitrary-custom-types-4) [Limiting Instructions Inputs](https://github.com/Ackee-Blockchain/trident/tree/0.10.0/examples/common_issues/arbitrary-limit-inputs-5) * **Cross-Program Invocation** * * * Trident supports Cross-Program Invocation, you can fuzz your programs and create NFTs at the same time. [Simple CPI](https://github.com/Ackee-Blockchain/trident/tree/0.10.0/examples/cpi/simple-cpi-6) [CPI with Metaplex Metadata Program](https://github.com/Ackee-Blockchain/trident/tree/0.10.0/examples/cpi/cpi-metaplex-7) * **Benchmarking** * * * Trident contains benchmarks of [Daedaluzz: A Benchmark Generator for Smart-Contract Fuzzers](https://github.com/Consensys/daedaluzz) rewritten in Rust. [Trident Benchmark](https://github.com/Ackee-Blockchain/trident/tree/0.10.0/examples/trident-benchmark) Back to top --- # Writing fuzz test - Trident [Skip to content](https://ackee.xyz/trident/docs/0.8.1/writing-fuzz-test/writing-fuzz-test/#initialize-trident) Writing fuzz test ================= Initialize Trident[#](https://ackee.xyz/trident/docs/0.8.1/writing-fuzz-test/writing-fuzz-test/#initialize-trident "Permanent link") ------------------------------------------------------------------------------------------------------------------------------------- Initialize Trident in the Anchor-based workspace. `[](https://ackee.xyz/trident/docs/0.8.1/writing-fuzz-test/writing-fuzz-test/#__codelineno-0-1) trident init` Info Trident under the hood * Builds the Anchor-based project. * Reads the generated IDL. * Based on the IDL creates the fuzzing template. Tip If you have Trident already initialized, you can add new fuzz test using `trident fuzz add`. Fill the Fuzz test Template[#](https://ackee.xyz/trident/docs/0.8.1/writing-fuzz-test/writing-fuzz-test/#fill-the-fuzz-test-template "Permanent link") ------------------------------------------------------------------------------------------------------------------------------------------------------- ### Define Fuzz Accounts[#](https://ackee.xyz/trident/docs/0.8.1/writing-fuzz-test/writing-fuzz-test/#define-fuzz-accounts "Permanent link") Define `AccountsStorage` type for each Account you would like to use. Important Keep in mind: * You do not need to specify every `AccountStorage`, some accounts do not necessarily need to be stored in their corresponding storage. * For example `System Program` does not need to be stored, rather can be used from the `solana_sdk`. * If you are about to Initialize `Mint` or `Token Account` in your Solana Program. * use `Keypair` or `PdaStore` (not `MintStore` or `TokenStore`). * If you are going to initialize `Associated Token Account` in your Solana Program. * use `PdaStore`. * You can rename `FuzzAccounts` fields to whatever you want. The default names were generated based on the Program's `IDL`. `[](https://ackee.xyz/trident/docs/0.8.1/writing-fuzz-test/writing-fuzz-test/#__codelineno-1-1) #[doc = r" Use AccountsStorage where T can be one of:"] [](https://ackee.xyz/trident/docs/0.8.1/writing-fuzz-test/writing-fuzz-test/#__codelineno-1-2) #[doc = r" Keypair, PdaStore, TokenStore, MintStore, ProgramStore"] [](https://ackee.xyz/trident/docs/0.8.1/writing-fuzz-test/writing-fuzz-test/#__codelineno-1-3) #[derive(Default)] [](https://ackee.xyz/trident/docs/0.8.1/writing-fuzz-test/writing-fuzz-test/#__codelineno-1-4) pub struct FuzzAccounts { [](https://ackee.xyz/trident/docs/0.8.1/writing-fuzz-test/writing-fuzz-test/#__codelineno-1-5) author: AccountsStorage, [](https://ackee.xyz/trident/docs/0.8.1/writing-fuzz-test/writing-fuzz-test/#__codelineno-1-6) hello_world_account: AccountsStorage, [](https://ackee.xyz/trident/docs/0.8.1/writing-fuzz-test/writing-fuzz-test/#__codelineno-1-7) // No need to fuzz system_program [](https://ackee.xyz/trident/docs/0.8.1/writing-fuzz-test/writing-fuzz-test/#__codelineno-1-8) // system_program: AccountsStorage, [](https://ackee.xyz/trident/docs/0.8.1/writing-fuzz-test/writing-fuzz-test/#__codelineno-1-9) }` Tip For more details about the `AccountsStorage` check [AccountsStorage](https://ackee.xyz/trident/docs/0.8.1/features/account-storages/) . ### Implement Fuzz Instructions[#](https://ackee.xyz/trident/docs/0.8.1/writing-fuzz-test/writing-fuzz-test/#implement-fuzz-instructions "Permanent link") Each Instruction in the Fuzz Test has to have defined the following functions: * `get_program_id()` * Specifies to which program the Instruction belongs. This function is **automatically defined** and should not need any updates. The importance is such that if you have multiple programs in your workspace, Trident can generate Instruction Sequences of Instruction corresponding to different programs. * `get_data()` * Specifies what Instruction inputs are send to the Program Instructions. * `get_accounts()` * Specifies what Accounts are send to the Program Instructions. Tip * For more info about how to write these functions, check the [Fuzz Instructions](https://ackee.xyz/trident/docs/0.8.1/features/fuzz-instructions/) . * For the examples how to write these functions, check the [Examples](https://ackee.xyz/trident/docs/0.8.1/examples/examples/) . Execute[#](https://ackee.xyz/trident/docs/0.8.1/writing-fuzz-test/writing-fuzz-test/#execute "Permanent link") --------------------------------------------------------------------------------------------------------------- ### Run Fuzz Test[#](https://ackee.xyz/trident/docs/0.8.1/writing-fuzz-test/writing-fuzz-test/#run-fuzz-test "Permanent link") To execute the desired fuzz test using the Honggfuzz, run: `[](https://ackee.xyz/trident/docs/0.8.1/writing-fuzz-test/writing-fuzz-test/#__codelineno-2-1) # Replace with the name of particular [](https://ackee.xyz/trident/docs/0.8.1/writing-fuzz-test/writing-fuzz-test/#__codelineno-2-2) # fuzz test (for example: "fuzz_0") [](https://ackee.xyz/trident/docs/0.8.1/writing-fuzz-test/writing-fuzz-test/#__codelineno-2-3) trident fuzz run-hfuzz ` ### Debug Fuzz Test[#](https://ackee.xyz/trident/docs/0.8.1/writing-fuzz-test/writing-fuzz-test/#debug-fuzz-test "Permanent link") To debug your program using Honggfuzz with values from a crash file: `[](https://ackee.xyz/trident/docs/0.8.1/writing-fuzz-test/writing-fuzz-test/#__codelineno-3-1) # fuzzer will run the with the specified [](https://ackee.xyz/trident/docs/0.8.1/writing-fuzz-test/writing-fuzz-test/#__codelineno-3-2) trident fuzz debug-hfuzz ` Tip By default, the crashfiles are stored in the * `trident-tests/fuzz_tests/fuzzing/honggfuzz/hfuzz_workspace/` for Hongfuzz and Tip For more info about the fuzzing outputs chech the [Commands](https://ackee.xyz/trident/docs/0.8.1/commands/commands/) Back to top --- # Regression testing - Trident [Skip to content](https://ackee.xyz/trident/docs/0.11.1/trident-advanced/regression/#regression-testing) Regression testing[#](https://ackee.xyz/trident/docs/0.11.1/trident-advanced/regression/#regression-testing "Permanent link") ============================================================================================================================== Regression testing is the process of re-running tests to ensure that previously working functionality still works after code changes. Trident allows for regression testing by specifying which accounts should be included in the regression test, generating a JSON file format with all monitored state and providing a subcommand to compare two regression test results. Regression test setup[#](https://ackee.xyz/trident/docs/0.11.1/trident-advanced/regression/#regression-test-setup "Permanent link") ------------------------------------------------------------------------------------------------------------------------------------ 1. First, decide which account(s) should be included in the regression test. 2. Add the accounts for tracking, this can be done as shown in the following code snippet. Check the `add_to_regression` method. `[](https://ackee.xyz/trident/docs/0.11.1/trident-advanced/regression/#__codelineno-0-1) #[flow_executor] [](https://ackee.xyz/trident/docs/0.11.1/trident-advanced/regression/#__codelineno-0-2) impl FuzzTest { [](https://ackee.xyz/trident/docs/0.11.1/trident-advanced/regression/#__codelineno-0-3) fn new() -> Self { [](https://ackee.xyz/trident/docs/0.11.1/trident-advanced/regression/#__codelineno-0-4) Self { [](https://ackee.xyz/trident/docs/0.11.1/trident-advanced/regression/#__codelineno-0-5) trident: Trident::default(), [](https://ackee.xyz/trident/docs/0.11.1/trident-advanced/regression/#__codelineno-0-6) fuzz_accounts: FuzzAccounts::default(), [](https://ackee.xyz/trident/docs/0.11.1/trident-advanced/regression/#__codelineno-0-7) } [](https://ackee.xyz/trident/docs/0.11.1/trident-advanced/regression/#__codelineno-0-8) } [](https://ackee.xyz/trident/docs/0.11.1/trident-advanced/regression/#__codelineno-0-9) [](https://ackee.xyz/trident/docs/0.11.1/trident-advanced/regression/#__codelineno-0-10) #[init] [](https://ackee.xyz/trident/docs/0.11.1/trident-advanced/regression/#__codelineno-0-11) fn start(&mut self) { [](https://ackee.xyz/trident/docs/0.11.1/trident-advanced/regression/#__codelineno-0-12) let mut ix = InitializeFnTransaction::build(&mut self.trident, &mut self.fuzz_accounts); [](https://ackee.xyz/trident/docs/0.11.1/trident-advanced/regression/#__codelineno-0-13) [](https://ackee.xyz/trident/docs/0.11.1/trident-advanced/regression/#__codelineno-0-14) self.trident.execute_transaction(&mut ix, Some("Init")); [](https://ackee.xyz/trident/docs/0.11.1/trident-advanced/regression/#__codelineno-0-15) [](https://ackee.xyz/trident/docs/0.11.1/trident-advanced/regression/#__codelineno-0-16) // Add the account to the regression test [](https://ackee.xyz/trident/docs/0.11.1/trident-advanced/regression/#__codelineno-0-17) self.trident.add_to_regression( [](https://ackee.xyz/trident/docs/0.11.1/trident-advanced/regression/#__codelineno-0-18) &ix.instruction.accounts.hello_world_account.pubkey(), [](https://ackee.xyz/trident/docs/0.11.1/trident-advanced/regression/#__codelineno-0-19) "hello_world_account", [](https://ackee.xyz/trident/docs/0.11.1/trident-advanced/regression/#__codelineno-0-20) ); [](https://ackee.xyz/trident/docs/0.11.1/trident-advanced/regression/#__codelineno-0-21) } [](https://ackee.xyz/trident/docs/0.11.1/trident-advanced/regression/#__codelineno-0-22) [](https://ackee.xyz/trident/docs/0.11.1/trident-advanced/regression/#__codelineno-0-23) #[flow(weight = 5)] [](https://ackee.xyz/trident/docs/0.11.1/trident-advanced/regression/#__codelineno-0-24) fn flow1(&mut self) { [](https://ackee.xyz/trident/docs/0.11.1/trident-advanced/regression/#__codelineno-0-25) // This flow will be executed 60% of the time [](https://ackee.xyz/trident/docs/0.11.1/trident-advanced/regression/#__codelineno-0-26) let mut ix = InitializeFnTransaction::build(&mut self.trident, &mut self.fuzz_accounts); [](https://ackee.xyz/trident/docs/0.11.1/trident-advanced/regression/#__codelineno-0-27) self.trident.execute_transaction(&mut ix, Some("Flow1")); [](https://ackee.xyz/trident/docs/0.11.1/trident-advanced/regression/#__codelineno-0-28) } [](https://ackee.xyz/trident/docs/0.11.1/trident-advanced/regression/#__codelineno-0-29) [](https://ackee.xyz/trident/docs/0.11.1/trident-advanced/regression/#__codelineno-0-30) #[flow(weight = 5)] [](https://ackee.xyz/trident/docs/0.11.1/trident-advanced/regression/#__codelineno-0-31) fn flow2(&mut self) { [](https://ackee.xyz/trident/docs/0.11.1/trident-advanced/regression/#__codelineno-0-32) // This flow will be executed 40% of the time [](https://ackee.xyz/trident/docs/0.11.1/trident-advanced/regression/#__codelineno-0-33) let mut ix = InitializeFnTransaction::build(&mut self.trident, &mut self.fuzz_accounts); [](https://ackee.xyz/trident/docs/0.11.1/trident-advanced/regression/#__codelineno-0-34) self.trident.execute_transaction(&mut ix, Some("Flow2")); [](https://ackee.xyz/trident/docs/0.11.1/trident-advanced/regression/#__codelineno-0-35) } [](https://ackee.xyz/trident/docs/0.11.1/trident-advanced/regression/#__codelineno-0-36) #[flow(weight = 90)] [](https://ackee.xyz/trident/docs/0.11.1/trident-advanced/regression/#__codelineno-0-37) fn flow3(&mut self) { [](https://ackee.xyz/trident/docs/0.11.1/trident-advanced/regression/#__codelineno-0-38) // This flow will be executed 40% of the time [](https://ackee.xyz/trident/docs/0.11.1/trident-advanced/regression/#__codelineno-0-39) let mut ix = InitializeFnTransaction::build(&mut self.trident, &mut self.fuzz_accounts); [](https://ackee.xyz/trident/docs/0.11.1/trident-advanced/regression/#__codelineno-0-40) self.trident.execute_transaction(&mut ix, Some("Flow3")); [](https://ackee.xyz/trident/docs/0.11.1/trident-advanced/regression/#__codelineno-0-41) } [](https://ackee.xyz/trident/docs/0.11.1/trident-advanced/regression/#__codelineno-0-42) [](https://ackee.xyz/trident/docs/0.11.1/trident-advanced/regression/#__codelineno-0-43) #[end] [](https://ackee.xyz/trident/docs/0.11.1/trident-advanced/regression/#__codelineno-0-44) fn cleanup(&mut self) -> Result<(), FuzzingError> { [](https://ackee.xyz/trident/docs/0.11.1/trident-advanced/regression/#__codelineno-0-45) // This method will be called after all flows have been executed [](https://ackee.xyz/trident/docs/0.11.1/trident-advanced/regression/#__codelineno-0-46) Ok(()) [](https://ackee.xyz/trident/docs/0.11.1/trident-advanced/regression/#__codelineno-0-47) } [](https://ackee.xyz/trident/docs/0.11.1/trident-advanced/regression/#__codelineno-0-48) } [](https://ackee.xyz/trident/docs/0.11.1/trident-advanced/regression/#__codelineno-0-49)[](https://ackee.xyz/trident/docs/0.11.1/trident-advanced/regression/#__codelineno-0-50) fn main() { [](https://ackee.xyz/trident/docs/0.11.1/trident-advanced/regression/#__codelineno-0-51) FuzzTest::fuzz(1000, 100); [](https://ackee.xyz/trident/docs/0.11.1/trident-advanced/regression/#__codelineno-0-52) }` 3. Enable the regression test in the [Trident manifest](https://ackee.xyz/trident/docs/0.11.1/trident-manifest/#fuzzing-metrics) by setting: `[](https://ackee.xyz/trident/docs/0.11.1/trident-advanced/regression/#__codelineno-1-1) [fuzz.regression] [](https://ackee.xyz/trident/docs/0.11.1/trident-advanced/regression/#__codelineno-1-2) enabled = true` 4. Run the fuzz test to generate the regression test data. 5. Run the same fuzz test with the same MASTER SEED on a different version of the program. 6. Run the following command to compare the generated JSON files. `[](https://ackee.xyz/trident/docs/0.11.1/trident-advanced/regression/#__codelineno-2-1) trident compare ` Back to top --- # Installation - Trident [Skip to content](https://ackee.xyz/trident/docs/dev/basics/installation/#installation) Installation[#](https://ackee.xyz/trident/docs/dev/basics/installation/#installation "Permanent link") ======================================================================================================= Trident requires the following prerequisites: Prerequisites Before proceeding, ensure you have installed: * [Rust](https://www.rust-lang.org/tools/install) (stable version) * [Solana CLI](https://solana.com/docs/intro/installation) * [Anchor](https://www.anchor-lang.com/docs/installation) Check out [supported versions](https://ackee.xyz/trident/docs/dev/basics/installation/#supported-versions) for version compatibility. Install Trident[#](https://ackee.xyz/trident/docs/dev/basics/installation/#install-trident "Permanent link") ------------------------------------------------------------------------------------------------------------- `[](https://ackee.xyz/trident/docs/dev/basics/installation/#__codelineno-0-1) cargo install trident-cli` You can also use the `version` flag to install a specific version: `[](https://ackee.xyz/trident/docs/dev/basics/installation/#__codelineno-1-1) cargo install trident-cli --version x.y.z` Install cargo-llvm-cov[#](https://ackee.xyz/trident/docs/dev/basics/installation/#install-cargo-llvm-cov "Permanent link") --------------------------------------------------------------------------------------------------------------------------- To enable code coverage tracking during fuzzing, install [cargo-llvm-cov](https://github.com/taiki-e/cargo-llvm-cov) : `[](https://ackee.xyz/trident/docs/dev/basics/installation/#__codelineno-2-1) cargo +stable install cargo-llvm-cov --locked` Supported versions[#](https://ackee.xyz/trident/docs/dev/basics/installation/#supported-versions "Permanent link") ------------------------------------------------------------------------------------------------------------------- Version Table Legend * \= Develop branch * \= Released version * `-` = Not required/supported | **Version Type** | **Anchor** | **Solana** | **Rust** | **Honggfuzz** | **AFL** | | --- | --- | --- | --- | --- | --- | | Development | `>=0.29.0` | `>=1.17.3` | `1.86` | `-` | `-` | | **Current (0.11.x)** | `>=0.29.0` | `>=1.17.3` | `1.86` | `-` | `-` | | **0.10.x** | `>=0.29.0 < 0.31.0` | `>=1.17.3 < 2.1` | `nightly` | `0.5.56` | `0.15.11` | | **0.9.x** | `>=0.29.0 < 0.31.0` | `>=1.17.3 < 2.1` | `nightly` | `0.5.56` | `0.15.11` | | **0.8.x** | `0.30.1` | `^1.17.4` | `nightly` | `0.5.56` | `-` | | **0.7.x** | `>=0.29.*` | `^1.17.4` | `nightly` | `0.5.56` | `-` | | **0.6.x** | `>=0.29.*` | `^1.17` | `nightly` | `0.5.55` | `-` | | **0.5.x** | `~0.28.*` | `=1.16.6` | `-` | `-` | `-` | | **0.4.x** | `~0.27.*` | `>=1.15` | `-` | `-` | `-` | | **0.3.x** | `~0.25.*` | `>=1.10` | `-` | `-` | `-` | | **0.2.x** | `~0.24.*` | `>=1.9` | `-` | `-` | `-` | Back to top --- # Installation - Trident [Skip to content](https://ackee.xyz/trident/docs/0.10.0/basics/installation/#installation) Installation[#](https://ackee.xyz/trident/docs/0.10.0/basics/installation/#installation "Permanent link") ========================================================================================================== Trident requires the following prerequisites: Prerequisites Before proceeding, ensure you have installed: * [Rust](https://www.rust-lang.org/tools/install) (stable version) * [Solana CLI](https://solana.com/docs/intro/installation) * [Anchor](https://www.anchor-lang.com/docs/installation) Check out [supported versions](https://ackee.xyz/trident/docs/0.10.0/basics/installation/#supported-versions) for version compatibility. Install system dependencies[#](https://ackee.xyz/trident/docs/0.10.0/basics/installation/#install-system-dependencies "Permanent link") ---------------------------------------------------------------------------------------------------------------------------------------- Update your package list: `[](https://ackee.xyz/trident/docs/0.10.0/basics/installation/#__codelineno-0-1) sudo apt update [](https://ackee.xyz/trident/docs/0.10.0/basics/installation/#__codelineno-0-2) sudo apt upgrade` Install the required packages: `[](https://ackee.xyz/trident/docs/0.10.0/basics/installation/#__codelineno-1-1) sudo apt install build-essential [](https://ackee.xyz/trident/docs/0.10.0/basics/installation/#__codelineno-1-2) sudo apt-get install binutils-dev [](https://ackee.xyz/trident/docs/0.10.0/basics/installation/#__codelineno-1-3) sudo apt-get install libunwind-dev` Install Trident[#](https://ackee.xyz/trident/docs/0.10.0/basics/installation/#install-trident "Permanent link") ---------------------------------------------------------------------------------------------------------------- `[](https://ackee.xyz/trident/docs/0.10.0/basics/installation/#__codelineno-2-1) cargo install trident-cli` You can also use the `version` flag to install a specific version: `[](https://ackee.xyz/trident/docs/0.10.0/basics/installation/#__codelineno-3-1) cargo install trident-cli --version x.y.z` Install Hongfuzz and AFL[#](https://ackee.xyz/trident/docs/0.10.0/basics/installation/#install-hongfuzz-and-afl "Permanent link") ---------------------------------------------------------------------------------------------------------------------------------- `[](https://ackee.xyz/trident/docs/0.10.0/basics/installation/#__codelineno-4-1) cargo install honggfuzz [](https://ackee.xyz/trident/docs/0.10.0/basics/installation/#__codelineno-4-2) cargo install cargo-afl` To install a specific version use the following commands: `[](https://ackee.xyz/trident/docs/0.10.0/basics/installation/#__codelineno-5-1) cargo install honggfuzz --version x.y.z [](https://ackee.xyz/trident/docs/0.10.0/basics/installation/#__codelineno-5-2) cargo install cargo-afl --version x.y.z` Supported versions[#](https://ackee.xyz/trident/docs/0.10.0/basics/installation/#supported-versions "Permanent link") ---------------------------------------------------------------------------------------------------------------------- Version Table Legend * \= Develop branch * \= Released version * `-` = Not required/supported | **Version Type** | **Anchor** | **Solana** | **Rust** | **Honggfuzz** | **AFL** | | --- | --- | --- | --- | --- | --- | | Development | `>=0.29.0 < 0.31.0` | `>=1.17.3 < 2.1` | `nightly` | `0.5.56` | `0.15.11` | | **Current (0.10.x)** | `>=0.29.0 < 0.31.0` | `>=1.17.3 < 2.1` | `nightly` | `0.5.56` | `0.15.11` | | **0.9.x** | `>=0.29.0 < 0.31.0` | `>=1.17.3 < 2.1` | `nightly` | `0.5.56` | `0.15.11` | | **0.8.x** | `0.30.1` | `^1.17.4` | `nightly` | `0.5.56` | `-` | | **0.7.x** | `>=0.29.*` | `^1.17.4` | `nightly` | `0.5.56` | `-` | | **0.6.x** | `>=0.29.*` | `^1.17` | `nightly` | `0.5.55` | `-` | | **0.5.x** | `~0.28.*` | `=1.16.6` | `-` | `-` | `-` | | **0.4.x** | `~0.27.*` | `>=1.15` | `-` | `-` | `-` | | **0.3.x** | `~0.25.*` | `>=1.10` | `-` | `-` | `-` | | **0.2.x** | `~0.24.*` | `>=1.9` | `-` | `-` | `-` | Back to top --- # Commands - Trident [Skip to content](https://ackee.xyz/trident/docs/dev/basics/commands/#commands) Commands[#](https://ackee.xyz/trident/docs/dev/basics/commands/#commands "Permanent link") =========================================================================================== Trident CLI supports the following commands: `trident init`[#](https://ackee.xyz/trident/docs/dev/basics/commands/#trident-init "Permanent link") ----------------------------------------------------------------------------------------------------- Initializes Trident Workspace and generates new Fuzz Test Template. Creates the following structure: `[](https://ackee.xyz/trident/docs/dev/basics/commands/#__codelineno-0-1) project-root [](https://ackee.xyz/trident/docs/dev/basics/commands/#__codelineno-0-2) ├── trident-tests [](https://ackee.xyz/trident/docs/dev/basics/commands/#__codelineno-0-3) │ ├── fuzz_0 # particular fuzz test [](https://ackee.xyz/trident/docs/dev/basics/commands/#__codelineno-0-4) │ │ ├── instructions # instructions folder [](https://ackee.xyz/trident/docs/dev/basics/commands/#__codelineno-0-5) │ │ ├── transactions # transactions folder [](https://ackee.xyz/trident/docs/dev/basics/commands/#__codelineno-0-6) │ │ ├── test_fuzz.rs # the binary target of your fuzz test [](https://ackee.xyz/trident/docs/dev/basics/commands/#__codelineno-0-7) │ │ ├── types.rs # the types of your fuzz test [](https://ackee.xyz/trident/docs/dev/basics/commands/#__codelineno-0-8) │ │ └── fuzz_instructions.rs # the definition of your fuzz test [](https://ackee.xyz/trident/docs/dev/basics/commands/#__codelineno-0-9) │ ├── fuzz_1 [](https://ackee.xyz/trident/docs/dev/basics/commands/#__codelineno-0-10) │ ├── fuzz_X # possible multiple fuzz tests [](https://ackee.xyz/trident/docs/dev/basics/commands/#__codelineno-0-11) │ ├── fuzzing # compilations and crashes folder [](https://ackee.xyz/trident/docs/dev/basics/commands/#__codelineno-0-12) │ ├── Cargo.toml [](https://ackee.xyz/trident/docs/dev/basics/commands/#__codelineno-0-13) │ └── Trident.toml # Configuration file located in trident-tests directory [](https://ackee.xyz/trident/docs/dev/basics/commands/#__codelineno-0-14) └── ...` #### Options[#](https://ackee.xyz/trident/docs/dev/basics/commands/#options "Permanent link") * `-f, --force` - Force Trident initialization. Trident dependencies will be updated based on the version of Trident CLI. * `-s, --skip-build` - Skip building the program before initializing Trident. * `-p, --program-name ` - Specify the name of the program for which fuzz test will be generated. * `-t, --test-name ` - Name of the fuzz test to initialize. * * * `trident how`[#](https://ackee.xyz/trident/docs/dev/basics/commands/#trident-how "Permanent link") --------------------------------------------------------------------------------------------------- Show the HowTo message about writing fuzz tests. * * * `trident fuzz`[#](https://ackee.xyz/trident/docs/dev/basics/commands/#trident-fuzz "Permanent link") ----------------------------------------------------------------------------------------------------- Run fuzz subcommands. With fuzz subcommands you can add new fuzz test template or you can run fuzz test on already initialized one. **Examples:** `[](https://ackee.xyz/trident/docs/dev/basics/commands/#__codelineno-1-1) trident fuzz add [](https://ackee.xyz/trident/docs/dev/basics/commands/#__codelineno-1-2) trident fuzz run fuzz_0 [](https://ackee.xyz/trident/docs/dev/basics/commands/#__codelineno-1-3) trident fuzz debug ` ### `trident fuzz add`[#](https://ackee.xyz/trident/docs/dev/basics/commands/#trident-fuzz-add "Permanent link") Generate new Fuzz Test template. #### Options[#](https://ackee.xyz/trident/docs/dev/basics/commands/#options_1 "Permanent link") * `-p, --program-name ` - Specify the name of the program for which the fuzz test will be generated. * `-t, --test-name ` - Name of the fuzz test to add. * `-s, --skip-build` - Skip building the program before adding new fuzz test. * * * ### `trident fuzz run `[#](https://ackee.xyz/trident/docs/dev/basics/commands/#trident-fuzz-run-fuzz_target "Permanent link") Directory Note Execute fuzz tests from the `trident-tests` directory. Solana Logs In case you want to see the logs of the fuzzed transactions, prefix the command with `TRIDENT_LOG=1`. `[](https://ackee.xyz/trident/docs/dev/basics/commands/#__codelineno-2-1) TRIDENT_LOG=1 trident fuzz run ` Runs the specified Fuzz Target using Trident's Manually Guided Fuzzing (e.g., fuzz\_0). #### Arguments[#](https://ackee.xyz/trident/docs/dev/basics/commands/#arguments "Permanent link") * `` - Name of the desired fuzz template to execute (for example fuzz\_0). * `[seed]` - Master seed used for fuzzing, if not provided it will be generated randomly. #### Options[#](https://ackee.xyz/trident/docs/dev/basics/commands/#options_2 "Permanent link") * `-w, --with-exit-code` - Run the fuzzing with exit code, i.e. if it discovers crash the Trident will exit with exit code 1. * * * ### `trident fuzz debug `[#](https://ackee.xyz/trident/docs/dev/basics/commands/#trident-fuzz-debug-fuzz_target-seed "Permanent link") Debug crashes by analyzing specific crash files using the provided seed. #### Arguments[#](https://ackee.xyz/trident/docs/dev/basics/commands/#arguments_1 "Permanent link") * `` - Name of the desired fuzz template to execute (for example fuzz\_0). * `` - Master seed of the desired fuzz template to execute. Debug Output The debug output includes: 1. Transaction logs 2. Instruction data structures 3. Panic/Crash information * * * `trident clean`[#](https://ackee.xyz/trident/docs/dev/basics/commands/#trident-clean "Permanent link") ------------------------------------------------------------------------------------------------------- Clean build target, additionally perform `anchor clean`. * * * `trident server`[#](https://ackee.xyz/trident/docs/dev/basics/commands/#trident-server "Permanent link") --------------------------------------------------------------------------------------------------------- Starts the Trident Server, in order to make it easier to visualize the fuzzing dashboard, more info in the [dashboard](https://ackee.xyz/trident/docs/dev/trident-advanced/dashboard/) section. * * * `trident compare`[#](https://ackee.xyz/trident/docs/dev/basics/commands/#trident-compare "Permanent link") ----------------------------------------------------------------------------------------------------------- Allows you to compare two fuzzing regression results. More info in the [regression](https://ackee.xyz/trident/docs/dev/trident-advanced/regression/) section. * * * Back to top --- # Commands - Trident [Skip to content](https://ackee.xyz/trident/docs/0.10.0/basics/commands/#commands) Commands[#](https://ackee.xyz/trident/docs/0.10.0/basics/commands/#commands "Permanent link") ============================================================================================== Trident CLI supports the following commands: `trident init`[#](https://ackee.xyz/trident/docs/0.10.0/basics/commands/#trident-init "Permanent link") -------------------------------------------------------------------------------------------------------- Initializes Trident Workspace and generates new Fuzz Test Template. Creates the following structure: `[](https://ackee.xyz/trident/docs/0.10.0/basics/commands/#__codelineno-0-1) project-root [](https://ackee.xyz/trident/docs/0.10.0/basics/commands/#__codelineno-0-2) ├── trident-tests [](https://ackee.xyz/trident/docs/0.10.0/basics/commands/#__codelineno-0-3) │ ├── fuzz_0 # particular fuzz test [](https://ackee.xyz/trident/docs/0.10.0/basics/commands/#__codelineno-0-4) │ │ ├── instructions # instructions folder [](https://ackee.xyz/trident/docs/0.10.0/basics/commands/#__codelineno-0-5) │ │ ├── transactions # transactions folder [](https://ackee.xyz/trident/docs/0.10.0/basics/commands/#__codelineno-0-6) │ │ ├── test_fuzz.rs # the binary target of your fuzz test [](https://ackee.xyz/trident/docs/0.10.0/basics/commands/#__codelineno-0-7) │ │ ├── types.rs # the types of your fuzz test [](https://ackee.xyz/trident/docs/0.10.0/basics/commands/#__codelineno-0-8) │ │ └── fuzz_instructions.rs # the definition of your fuzz test [](https://ackee.xyz/trident/docs/0.10.0/basics/commands/#__codelineno-0-9) │ ├── fuzz_1 [](https://ackee.xyz/trident/docs/0.10.0/basics/commands/#__codelineno-0-10) │ ├── fuzz_X # possible multiple fuzz tests [](https://ackee.xyz/trident/docs/0.10.0/basics/commands/#__codelineno-0-11) │ ├── fuzzing # compilations and crashes folder [](https://ackee.xyz/trident/docs/0.10.0/basics/commands/#__codelineno-0-12) │ └── Cargo.toml [](https://ackee.xyz/trident/docs/0.10.0/basics/commands/#__codelineno-0-13) ├── Trident.toml [](https://ackee.xyz/trident/docs/0.10.0/basics/commands/#__codelineno-0-14) └── ...` #### Options[#](https://ackee.xyz/trident/docs/0.10.0/basics/commands/#options "Permanent link") * `-f, --force` - Force Trident initialization. Updates Trident dependencies based on the CLI version. * `-p, --program-name ` - Specify the program name for which the fuzz test will be generated. * `-t, --test-name ` - Specify a custom name for the fuzz test to initialize. * * * `trident how`[#](https://ackee.xyz/trident/docs/0.10.0/basics/commands/#trident-how "Permanent link") ------------------------------------------------------------------------------------------------------ Print How To message about writing fuzz tests. * * * `trident fuzz`[#](https://ackee.xyz/trident/docs/0.10.0/basics/commands/#trident-fuzz "Permanent link") -------------------------------------------------------------------------------------------------------- Fuzzing-related commands with various subcommands: ### `trident fuzz run-afl `[#](https://ackee.xyz/trident/docs/0.10.0/basics/commands/#trident-fuzz-run-afl-fuzz_target "Permanent link") Directory Note Execute fuzz tests from the `trident-tests` directory. Solana Logs In case you want to see the logs of the fuzzed transactions, prefix the command with `TRIDENT_LOG=1`. `[](https://ackee.xyz/trident/docs/0.10.0/basics/commands/#__codelineno-1-1) TRIDENT_LOG=1 trident fuzz run-afl ` Runs AFL on the specified Fuzz Target (e.g., fuzz\_0). * * * ### `trident fuzz run-hfuzz `[#](https://ackee.xyz/trident/docs/0.10.0/basics/commands/#trident-fuzz-run-hfuzz-fuzz_target "Permanent link") Directory Note Execute fuzz tests from the `trident-tests` directory. Solana Logs In case you want to see the logs of the fuzzed transactions, prefix the command with `TRIDENT_LOG=1`. `[](https://ackee.xyz/trident/docs/0.10.0/basics/commands/#__codelineno-2-1) TRIDENT_LOG=1 trident fuzz run-hfuzz ` Runs Honggfuzz on the specified Fuzz Target (e.g., fuzz\_0). The output includes: 1. **Iterations**: Number of fuzzing iterations completed 2. **Mode**: Feedback Driven Mode - generates data based on coverage progress 3. **Speed**: Average iterations per second 4. **Crashes**: Number of detected crashes (panics or failed invariant checks) `[](https://ackee.xyz/trident/docs/0.10.0/basics/commands/#__codelineno-3-1) ------------------------[ 0 days 00 hrs 00 mins 01 secs ]---------------------- [](https://ackee.xyz/trident/docs/0.10.0/basics/commands/#__codelineno-3-2) Iterations : 688 (out of: 1000 [68%]) [](https://ackee.xyz/trident/docs/0.10.0/basics/commands/#__codelineno-3-3) Mode [3/3] : Feedback Driven Mode [](https://ackee.xyz/trident/docs/0.10.0/basics/commands/#__codelineno-3-4) Target : .../release/fuzz_0 [](https://ackee.xyz/trident/docs/0.10.0/basics/commands/#__codelineno-3-5) Threads : 16, CPUs: 32, CPU%: 1262% [39%/CPU] [](https://ackee.xyz/trident/docs/0.10.0/basics/commands/#__codelineno-3-6) Speed : 680/sec [avg: 688] [](https://ackee.xyz/trident/docs/0.10.0/basics/commands/#__codelineno-3-7) Crashes : 1 [unique: 1, blocklist: 0, verified: 0] [](https://ackee.xyz/trident/docs/0.10.0/basics/commands/#__codelineno-3-8) Timeouts : 0 [10 sec] [](https://ackee.xyz/trident/docs/0.10.0/basics/commands/#__codelineno-3-9) Corpus Size : 98, max: 1048576 bytes, init: 0 files [](https://ackee.xyz/trident/docs/0.10.0/basics/commands/#__codelineno-3-10) Coverage : edge: 10345/882951 [1%] pc: 163 cmp: 622547` * * * ### `trident fuzz debug-afl `[#](https://ackee.xyz/trident/docs/0.10.0/basics/commands/#trident-fuzz-debug-afl-fuzz_target-crash_file_path "Permanent link") Debug AFL crashes by analyzing specific crash files. * * * ### `trident fuzz debug-hfuzz `[#](https://ackee.xyz/trident/docs/0.10.0/basics/commands/#trident-fuzz-debug-hfuzz-fuzz_target-crash_file_path "Permanent link") Debug Honggfuzz crashes by analyzing specific crash files. Debug Output The debug output currently includes verbose lldb information. It shows: 1. Transaction logs 2. Instruction data structures 3. Panic/Crash information * * * ### `trident fuzz add`[#](https://ackee.xyz/trident/docs/0.10.0/basics/commands/#trident-fuzz-add "Permanent link") Directory Note This commands needs to be executed from the project root directory. Adds a new Fuzz Test Template. #### Options[#](https://ackee.xyz/trident/docs/0.10.0/basics/commands/#options_1 "Permanent link") * `-p, --program-name ` - Specify the program name for which the fuzz test will be generated. * `-t, --test-name ` - Specify a custom name for the fuzz test to add. * * * `trident clean`[#](https://ackee.xyz/trident/docs/0.10.0/basics/commands/#trident-clean "Permanent link") ---------------------------------------------------------------------------------------------------------- Executes `anchor clean` and cleans Honggfuzz targets while preserving crashfiles and fuzzing inputs. Back to top --- # FAQ - Trident [Skip to content](https://ackee.xyz/trident/docs/dev/basics/faq/#faq) FAQ[#](https://ackee.xyz/trident/docs/dev/basics/faq/#faq "Permanent link") ============================================================================ _Is Trident supported only with Anchor?_ * Currently yes, Trident under the hood obtains data from the IDL generated by Anchor. _I created the Fuzz Test, what should I do next?_ * Start here [Start Fuzzing](https://ackee.xyz/trident/docs/dev/start-fuzzing/) . _Is Trident open-source?_ * Yes, here [Trident](https://github.com/Ackee-Blockchain/trident) . _I would like to report an Issue with Trident, what should I do?_ * Create [issue](https://github.com/Ackee-Blockchain/trident/issues) . _Is Trident deployed on Mainnet / Devnet / Testnet?_ * No, Trident is Fuzz Testing Framework, not Solana Program. _What type of Fuzzer is Trident?_ * Currently, we refer to it as _"coverage guided gray box fuzzer"_. Back to top --- # Get Help - Trident [Skip to content](https://ackee.xyz/trident/docs/dev/basics/get-help/#get-help) Get Help[#](https://ackee.xyz/trident/docs/dev/basics/get-help/#get-help "Permanent link") =========================================================================================== Need help writing Fuzz Tests? Do not hesitate to join our [Discord server](https://discord.gg/3czRpmGmeC) ! Back to top --- # Changelog - Trident [Skip to content](https://ackee.xyz/trident/docs/dev/basics/CHANGELOG/#changelog) Changelog[#](https://ackee.xyz/trident/docs/dev/basics/CHANGELOG/#changelog "Permanent link") ============================================================================================== All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) , and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html) (SemVer). **Note**: Version 0 of Semantic Versioning is handled differently from version 1 and above. The minor version will be incremented upon a breaking change and the patch version will be incremented for features. \[dev\] - Unreleased[#](https://ackee.xyz/trident/docs/dev/basics/CHANGELOG/#dev-unreleased "Permanent link") -------------------------------------------------------------------------------------------------------------- **Added** **Removed** **Changed** \[0.11.1\] - 2025-10-21[#](https://ackee.xyz/trident/docs/dev/basics/CHANGELOG/#0111-2025-10-21 "Permanent link") ------------------------------------------------------------------------------------------------------------------ **Added** **Removed** * Removed lld linker ([394](https://github.com/Ackee-Blockchain/trident/pull/394) ) **Changed** \[0.11.0\] - 2025-08-14[#](https://ackee.xyz/trident/docs/dev/basics/CHANGELOG/#0110-2025-08-14 "Permanent link") ------------------------------------------------------------------------------------------------------------------ **Added** * Add server for displaying content of fuzzing artifacts ([347](https://github.com/Ackee-Blockchain/trident/pull/347) ) * Add fuzz artifacts directory to the fuzz test folder ([343](https://github.com/Ackee-Blockchain/trident/pull/343) ) * Added state monitoring support for fuzzing metrics ([341](https://github.com/Ackee-Blockchain/trident/pull/341) ) * Added dashboard support for fuzzing metrics ([340](https://github.com/Ackee-Blockchain/trident/pull/340) ) * Code coverage tracking support enabled and configured via Trident.toml. Coverage data can be visualized using the VS Code extension [330](https://github.com/Ackee-Blockchain/trident/pull/330) * Added features to enable syscalls in fuzzing ([329](https://github.com/Ackee-Blockchain/trident/pull/329) ) * Add `--skip-build` flag to only initialize fuzz test without building the project ([325](https://github.com/Ackee-Blockchain/trident/pull/325) ) * Add support for space, lamports and owner to TridentAccounts macro ([320](https://github.com/Ackee-Blockchain/trident/pull/320) ) **Removed** **Changed** * FuzzTest fields are now aggregated into Trident struct ([339](https://github.com/Ackee-Blockchain/trident/pull/339) ) * Add support for reproducible fuzzing with thread-specific seeds ([332](https://github.com/Ackee-Blockchain/trident/pull/332) ) * Move Trident.toml into trident-tests folder ([328](https://github.com/Ackee-Blockchain/trident/pull/328) ) * Conversion from AFL and Honggfuzz into Manually Guided Fuzzing ([324](https://github.com/Ackee-Blockchain/trident/pull/324) ) * Update template generation to use tera ([326](https://github.com/Ackee-Blockchain/trident/pull/326) ) \[0.10.0\] - 2025-03-13[#](https://ackee.xyz/trident/docs/dev/basics/CHANGELOG/#0100-2025-03-13 "Permanent link") ------------------------------------------------------------------------------------------------------------------ **Added** * TransactionSelector allows to select and execute random transaction with hooks and without hooks ([297](https://github.com/Ackee-Blockchain/trident/pull/297) ) * Added "random\_tail" attribute to TridentFlowExecutor macro to allow random tail generation ([296](https://github.com/Ackee-Blockchain/trident/pull/296) ) * Added support for seeds constraint for accounts structs ([284](https://github.com/Ackee-Blockchain/trident/pull/284) ) * Additional methods accessing the AccountsStorage and creating corresponding accounts are now optional ("token","vote", "stake") ([279](https://github.com/Ackee-Blockchain/trident/pull/279) ) * Derive macros now use own syn parser for better extensibility and UX ([275](https://github.com/Ackee-Blockchain/trident/pull/275) ) * Program ID inside test\_fuzz.rs file is now automatically filled in is present in the program IDL ([272](https://github.com/Ackee-Blockchain/trident/pull/272) ) * Added additional attributes to TridentAccounts, mut and signer ([268](https://github.com/Ackee-Blockchain/trident/pull/268) ) * Users can now specify a program for which they want to add or initialize a fuzz test using `--program-name` flag ([273](https://github.com/Ackee-Blockchain/trident/pull/273) ) * Allow custom test name specification in fuzz test creation with `--test-name` flag ([274](https://github.com/Ackee-Blockchain/trident/pull/274) ) **Removed** * The DisplayIx macro is now removed, Debug trait was implemented for instruction inputs ([281](https://github.com/Ackee-Blockchain/trident/pull/281) ) **Changed** * FuzzTestExecutor and FlowExecutor are grouped together and FuzzTest has client as generic instead of TridentSVM ([294](https://github.com/Ackee-Blockchain/trident/pull/294) ) * Changed Transaction sequence logic ([289](https://github.com/Ackee-Blockchain/trident/pull/289) ) * AccountsStorages are simplified, no types are required to define ([276](https://github.com/Ackee-Blockchain/trident/pull/276) ) * Trident Architecture changes containing multiple features and improvements (details in the PR)([267](https://github.com/Ackee-Blockchain/trident/pull/267) ) * get or create token account methods fixed for native token accounts ([262](https://github.com/Ackee-Blockchain/trident/pull/262) ) \[0.9.1\] - 2025-02-03[#](https://ackee.xyz/trident/docs/dev/basics/CHANGELOG/#091-2025-02-03 "Permanent link") ---------------------------------------------------------------------------------------------------------------- **Added** * added warp to time manipulation ([259](https://github.com/Ackee-Blockchain/trident/pull/259) ) * added methods to check if account storage is empty ([258](https://github.com/Ackee-Blockchain/trident/pull/258) ) * added support for post-instruction behavior ([257](https://github.com/Ackee-Blockchain/trident/pull/257) ) **Removed** **Changed** \[0.9.0\] - 2025-01-15[#](https://ackee.xyz/trident/docs/dev/basics/CHANGELOG/#090-2025-01-15 "Permanent link") ---------------------------------------------------------------------------------------------------------------- **Added** * added support for composite accounts ([245](https://github.com/Ackee-Blockchain/trident/pull/245) ) * Trident SVM + AFL (see the PR for more details) ([234](https://github.com/Ackee-Blockchain/trident/pull/234) ) **Removed** * removed fuzz\_iteration from test\_fuzz.rs ([243](https://github.com/Ackee-Blockchain/trident/pull/243) ) **Changed** * renamed Config to TridentConfig ([246](https://github.com/Ackee-Blockchain/trident/pull/246) ) * errors are simplified and transaction error contains only transaction error ([244](https://github.com/Ackee-Blockchain/trident/pull/244) ) \[0.8.1\] - 2024-11-14[#](https://ackee.xyz/trident/docs/dev/basics/CHANGELOG/#081-2024-11-14 "Permanent link") ---------------------------------------------------------------------------------------------------------------- **Removed** * removed unnecessary deserialization with AccountsSnapshots, to deserialize data implementation AccountDeserialize can be used ([221](https://github.com/Ackee-Blockchain/trident/pull/221) ) **Changed** * improve AccountsStorage module structure and remove unnecessary methods in FuzzClient ([223](https://github.com/Ackee-Blockchain/trident/pull/223) ) * improve manipulations with AccountsStorages in get\_accounts() function ([219](https://github.com/Ackee-Blockchain/trident/pull/219) ) **Added** * add pre\_sequence!, middle\_sequence! and post\_sequence! for easier sequence definition ([220](https://github.com/Ackee-Blockchain/trident/pull/220) ) * add/ add support for Clock sysvar manipulations with the client(i.e. warp to slot/epoch and forward in time) ([217](https://github.com/Ackee-Blockchain/trident/pull/217) ) \[0.8.0\] - 2024-10-21[#](https://ackee.xyz/trident/docs/dev/basics/CHANGELOG/#080-2024-10-21 "Permanent link") ---------------------------------------------------------------------------------------------------------------- **Added** * impr/ allow to specify programs and accounts in the Trident Manifest ([207](https://github.com/Ackee-Blockchain/trident/pull/207) ) * impr/ added get\_program\_id function to the IxOps and FuzzTestExecutor ([199](https://github.com/Ackee-Blockchain/trident/pull/199) ) **Changed** * impr/ improve init command, modify program manifest automatically, add init force, add howto subcommand ([208](https://github.com/Ackee-Blockchain/trident/pull/208) ) * impr/ allow to derive AccountsSnapshots for empty Account Context ([209](https://github.com/Ackee-Blockchain/trident/pull/209) ) * impr/ fuzz flags are read at start of fuzzing session from Config instead of env variable and transaction dispatch was added to increase FuzzTestExecutor readability ([204](https://github.com/Ackee-Blockchain/trident/pull/204) ) * impr/ allow various instructions to be generated in case of multiple programs in the Anchor workspace ([200](https://github.com/Ackee-Blockchain/trident/pull/200) ) * feat/ option to add account into Fuzz Test environment with base64 data ([197](https://github.com/Ackee-Blockchain/trident/pull/197) ) * impr/ instead of parsing source code and creating our IDL, read anchor IDL ([198](https://github.com/Ackee-Blockchain/trident/pull/196) ) **Removed** * del/remove integration tests supported by Trident, this feature adds more unnecessary overhead compared to its value ([196](https://github.com/Ackee-Blockchain/trident/pull/198) ) \[0.7.0\] - 2024-08-14[#](https://ackee.xyz/trident/docs/dev/basics/CHANGELOG/#070-2024-08-14 "Permanent link") ---------------------------------------------------------------------------------------------------------------- **Added** * impr/ add feature flag to the AccountsSnapshots macro ([183](https://github.com/Ackee-Blockchain/trident/pull/183) ) * feat/ add Support for CPI ([182](https://github.com/Ackee-Blockchain/trident/pull/182) ) * feat/ add option to initialize Trident with Macro/File (for Snapshots) option based on preference ([179](https://github.com/Ackee-Blockchain/trident/pull/179) ) * feat/create AccountsSnapshots derive macro for Snapshots creation ([#177](https://github.com/Ackee-Blockchain/trident/pull/177) ) * feat/fuzzing moved to separate crate trident-fuzz ([#175](https://github.com/Ackee-Blockchain/trident/pull/175) ) * feat/unify dependencies provided by the Trident ([#172](https://github.com/Ackee-Blockchain/trident/pull/172) ) * feat/fuzzer-stats-logging, an optional statistics output for fuzzing session ([#144](https://github.com/Ackee-Blockchain/trident/pull/144) ) **Fixed** * fix/in case of fuzzing failure throw error instead of only printing message ([#167](https://github.com/Ackee-Blockchain/trident/pull/167) ) * fix/snapshot's zeroed account as optional ([#170](https://github.com/Ackee-Blockchain/trident/pull/170) ) **Removed** * del/remove localnet subcommand ([178](https://github.com/Ackee-Blockchain/trident/pull/178) ) * del/remove unnecessary fuzzing feature as trident is mainly fuzzer ([#176](https://github.com/Ackee-Blockchain/trident/pull/176) ) * del/remove Trident explorer ([#171](https://github.com/Ackee-Blockchain/trident/pull/171) ) \[0.6.0\] - 2024-05-20[#](https://ackee.xyz/trident/docs/dev/basics/CHANGELOG/#060-2024-05-20 "Permanent link") ---------------------------------------------------------------------------------------------------------------- **Added** * feat/anchor 0.30.0 support ([#148](https://github.com/Ackee-Blockchain/trident/pull/148) ) * fix/allow to process duplicate transactions ([#147](https://github.com/Ackee-Blockchain/trident/pull/147) ) * feat/possibility to implement custom transaction error handling ([#145](https://github.com/Ackee-Blockchain/trident/pull/145) ) * feat/support of automatically obtaining fully qualified paths of Data Accounts Custom types for `accounts_snapshots.rs` ([#141](https://github.com/Ackee-Blockchain/trident/pull/141) ) * feat/allow direct accounts manipulation and storage ([#142](https://github.com/Ackee-Blockchain/trident/pull/142) ) * feat/support of non-corresponding instruction and context names ([#130](https://github.com/Ackee-Blockchain/trident/pull/130) ) * feat/refactored and improved program flow during init and build, added activity indicator ([#129](https://github.com/Ackee-Blockchain/trident/pull/129) ) * feat/allow solana versions up to v1.17.\* and pin Rust 1.77 nightly compiler ([#128](https://github.com/Ackee-Blockchain/trident/pull/128) ) * feat/new init command option to initialize fuzz or poc tests only ([#124](https://github.com/Ackee-Blockchain/trident/pull/124) ) * feat/debug-mode detailed output ([#125](https://github.com/Ackee-Blockchain/trident/pull/125) ) * feat/anchor 0.29.0 support ([#121](https://github.com/Ackee-Blockchain/trident/pull/121) ) * doc/add help comment + update documentation ([#120](https://github.com/Ackee-Blockchain/trident/pull/120) ) * feat/fuzzer error handling ([#118](https://github.com/Ackee-Blockchain/trident/pull/118) ) * feat/convert fuzz Pubkey to AccountId ([#116](https://github.com/Ackee-Blockchain/trident/pull/116) ) * feat/additional anchor types ([#115](https://github.com/Ackee-Blockchain/trident/pull/115) ) * feat/import ToAccountInfo trait in fuzzing prelude ([#113](https://github.com/Ackee-Blockchain/trident/pull/113) ) * test/added code generation and macros tests ([#112](https://github.com/Ackee-Blockchain/trident/pull/112) ) * feat/fuzzer framework core, macros, helpers, templates, and examples. ([#111](https://github.com/Ackee-Blockchain/trident/pull/111) ) * feat/improved trident-tests folder structure for PoC and Fuzz Tests ([#109](https://github.com/Ackee-Blockchain/trident/pull/109) ) * feat/support for additional fuzzer parameters in Trident.toml config file ([#107](https://github.com/Ackee-Blockchain/trident/pull/107) ) * feat/possibility to pass params to the fuzzer via Trident.toml config file ([#106](https://github.com/Ackee-Blockchain/trident/pull/106) ) * feat/client now reads by default keypair from default location ([#105](https://github.com/Ackee-Blockchain/trident/pull/105) ) * feat/added new --exit-code option to return corresponding exit code based on fuzz test result ([#104](https://github.com/Ackee-Blockchain/trident/pull/104) ) * feat/removed/updated deprecated functions, removed allow deprecated macros ([#103](https://github.com/Ackee-Blockchain/trident/pull/103) ) * feat/added new function to read keypair file generated by Anchor ([#102](https://github.com/Ackee-Blockchain/trident/pull/102) ) * feat/clean command ([#101](https://github.com/Ackee-Blockchain/trident/pull/101) ) * feat/improved program\_client generated code ([#100](https://github.com/Ackee-Blockchain/trident/pull/100) ) * feat/automatically add hfuzz\_target to .gitignore file ([#99](https://github.com/Ackee-Blockchain/trident/pull/99) ) * feat/support for dynamic templates. ([#98](https://github.com/Ackee-Blockchain/trident/pull/98) ) **Fixed** * fix/refactored fuzz test executor error handling ([#127](https://github.com/Ackee-Blockchain/trident/pull/127) ) * fix/warn user on composite accounts and continue fuzz test generation ([#133](https://github.com/Ackee-Blockchain/trident/pull/133) ) * fix/progress bar loop lock release ([#132](https://github.com/Ackee-Blockchain/trident/pull/132) ) * fix/fixed fuzz test generation with init-if-needed Anchor feature ([#131](https://github.com/Ackee-Blockchain/trident/pull/131) ) * fix/program client custom types ([#117](https://github.com/Ackee-Blockchain/trident/pull/117) ) * fix/check fuzz test name collision by checking the name against HashSet ([#114](https://github.com/Ackee-Blockchain/trident/pull/114) ) \[0.5.0\] - 2023-08-28[#](https://ackee.xyz/trident/docs/dev/basics/CHANGELOG/#050-2023-08-28 "Permanent link") ---------------------------------------------------------------------------------------------------------------- **Added** * cli: Added trident subcommand `fuzz` to run and debug fuzz tests using honggfuzz-rs. * cli: Added trident `--skip-fuzzer` option for `init` subcommand to skip generation of fuzz test templates. * client: Added new Cargo feature `fuzzing` that enables optional dependencies related to fuzz testing. \[0.4.1\] - 2023-08-21[#](https://ackee.xyz/trident/docs/dev/basics/CHANGELOG/#041-2023-08-21 "Permanent link") ---------------------------------------------------------------------------------------------------------------- **Changed** * Upgrade Solana (`=1.16.6`) and Anchor framework (`=0.28.0`) versions. **Fixed** * Implemented Anchor Client logic was not able to work with newer version of Anchor. Fixed with `async_rpc` and `async` feature. * Trident init IDL Parse Error on newer version of Rust, fixed with updated `accounts` token. \[0.3.0\] - 2022-09-23[#](https://ackee.xyz/trident/docs/dev/basics/CHANGELOG/#030-2022-09-23 "Permanent link") ---------------------------------------------------------------------------------------------------------------- **Changed** * Upgrade Solana (`~1.10`) and Anchor framework (`~0.25`) versions **Added** * Custom Solana RPC error reporter. If the Solana RPC error is thrown, the error code, message and data (logs) are reported to the output. * Custom imports in the `.program_client`. User is able to import custom types and structures into program client. The import part of the code would not be re-generated. \[0.2.0\] - 2022-07-27[#](https://ackee.xyz/trident/docs/dev/basics/CHANGELOG/#020-2022-07-27 "Permanent link") ---------------------------------------------------------------------------------------------------------------- **Added** * Trident is now configurable. This requires `Trident.toml` file to exist in the project's root directory - without this file the execution will fail. To solve this re-run `trident init` or just create an empty `Trident.toml` file in the project's root directory. Back to top --- # Commands - Trident [Skip to content](https://ackee.xyz/trident/docs/0.8.1/commands/commands/#trident-init) Commands ======== * * * trident init[#](https://ackee.xyz/trident/docs/0.8.1/commands/commands/#trident-init "Permanent link") ------------------------------------------------------------------------------------------------------- * This command Initializes Trident Workspace and generates new Fuzz Test Template. * The command will generate the following folder structure: `[](https://ackee.xyz/trident/docs/0.8.1/commands/commands/#__codelineno-0-1) project-root [](https://ackee.xyz/trident/docs/0.8.1/commands/commands/#__codelineno-0-2) ├── trident-tests [](https://ackee.xyz/trident/docs/0.8.1/commands/commands/#__codelineno-0-3) │ ├── fuzz_tests # fuzz tests folder [](https://ackee.xyz/trident/docs/0.8.1/commands/commands/#__codelineno-0-4) │ │ ├── fuzz_0 # particular fuzz test [](https://ackee.xyz/trident/docs/0.8.1/commands/commands/#__codelineno-0-5) │ │ │ ├── test_fuzz.rs # the binary target of your fuzz test [](https://ackee.xyz/trident/docs/0.8.1/commands/commands/#__codelineno-0-6) │ │ │ └── fuzz_instructions.rs # the definition of your fuzz test [](https://ackee.xyz/trident/docs/0.8.1/commands/commands/#__codelineno-0-7) │ │ ├── fuzz_1 [](https://ackee.xyz/trident/docs/0.8.1/commands/commands/#__codelineno-0-8) │ │ ├── fuzz_X # possible multiple fuzz tests [](https://ackee.xyz/trident/docs/0.8.1/commands/commands/#__codelineno-0-9) │ │ ├── fuzzing # compilations and crashes folder [](https://ackee.xyz/trident/docs/0.8.1/commands/commands/#__codelineno-0-10) │ │ └── Cargo.toml [](https://ackee.xyz/trident/docs/0.8.1/commands/commands/#__codelineno-0-11) ├── Trident.toml [](https://ackee.xyz/trident/docs/0.8.1/commands/commands/#__codelineno-0-12) └── ...` * * * trident how[#](https://ackee.xyz/trident/docs/0.8.1/commands/commands/#trident-how "Permanent link") ----------------------------------------------------------------------------------------------------- * Print How To message about how to start writting fuzz tests. * * * trident fuzz[#](https://ackee.xyz/trident/docs/0.8.1/commands/commands/#trident-fuzz "Permanent link") ------------------------------------------------------------------------------------------------------- * Behavior depends on the subcommands. ### trident fuzz run-hfuzz[#](https://ackee.xyz/trident/docs/0.8.1/commands/commands/#trident-fuzz-run-hfuzz "Permanent link") * Run Honggfuzz on the specified Fuzz Target (i.e. the Fuzz Template, for example fuzz\_0). #### Output[#](https://ackee.xyz/trident/docs/0.8.1/commands/commands/#output "Permanent link") Important The output provided by Honggfuzz is as follows: 1. Number of Fuzzing Iterations. 2. Feedback Driven Mode = Honggfuzz generates data based on the feedback (i.e. feedback based on Coverage progress). 3. Average Iterations per second. 4. Number of crashes it found (**panics** or failed **invariant checks**). `[](https://ackee.xyz/trident/docs/0.8.1/commands/commands/#__codelineno-1-1) ------------------------[ 0 days 00 hrs 00 mins 01 secs ]---------------------- [](https://ackee.xyz/trident/docs/0.8.1/commands/commands/#__codelineno-1-2) Iterations : 688 (out of: 1000 [68%]) # -- 1. -- [](https://ackee.xyz/trident/docs/0.8.1/commands/commands/#__codelineno-1-3) Mode [3/3] : Feedback Driven Mode # -- 2. -- [](https://ackee.xyz/trident/docs/0.8.1/commands/commands/#__codelineno-1-4) Target : trident-tests/fuzz_tests/fuzzing.....wn-linux-gnu/release/fuzz_0 [](https://ackee.xyz/trident/docs/0.8.1/commands/commands/#__codelineno-1-5) Threads : 16, CPUs: 32, CPU%: 1262% [39%/CPU] [](https://ackee.xyz/trident/docs/0.8.1/commands/commands/#__codelineno-1-6) Speed : 680/sec [avg: 688] # -- 3. -- [](https://ackee.xyz/trident/docs/0.8.1/commands/commands/#__codelineno-1-7) Crashes : 1 [unique: 1, blocklist: 0, verified: 0] # -- 4. -- [](https://ackee.xyz/trident/docs/0.8.1/commands/commands/#__codelineno-1-8) Timeouts : 0 [10 sec] [](https://ackee.xyz/trident/docs/0.8.1/commands/commands/#__codelineno-1-9) Corpus Size : 98, max: 1048576 bytes, init: 0 files [](https://ackee.xyz/trident/docs/0.8.1/commands/commands/#__codelineno-1-10) Cov Update : 0 days 00 hrs 00 mins 00 secs ago [](https://ackee.xyz/trident/docs/0.8.1/commands/commands/#__codelineno-1-11) Coverage : edge: 10345/882951 [1%] pc: 163 cmp: 622547 [](https://ackee.xyz/trident/docs/0.8.1/commands/commands/#__codelineno-1-12) ---------------------------------- [ LOGS ] ------------------/ honggfuzz 2.6 /-` ### trident fuzz debug-hfuzz[#](https://ackee.xyz/trident/docs/0.8.1/commands/commands/#trident-fuzz-debug-hfuzz "Permanent link") * Run Honggfuzz debug on the specified Fuzz Target (i.e. the Fuzz Template, for example fuzz\_0), with specified crash file, to see where the crash file found an issue. #### Output[#](https://ackee.xyz/trident/docs/0.8.1/commands/commands/#output_1 "Permanent link") Important The debug output is at current development stage really verbose and contains lldb parts. We are working on improving this experience. In the picture below you can see an example of provided debug output. 1. Series of Transaction Logs 2. Structures of data send within the Instructions 3. **Panic** or **Crash**, based on if the Fuzzing panicked within the Solana Program or Invariant Check failed. ![alt text](https://ackee.xyz/trident/docs/0.8.1/images/run-debug.png) ### trident fuzz add[#](https://ackee.xyz/trident/docs/0.8.1/commands/commands/#trident-fuzz-add "Permanent link") * Adds new Fuzz Test Template. * * * trident clean[#](https://ackee.xyz/trident/docs/0.8.1/commands/commands/#trident-clean "Permanent link") --------------------------------------------------------------------------------------------------------- * Calls `anchor clean` and cleans targets created by the underlying Honggfuzz. Crashfiles and Fuzzing Inputs are preserved. Back to top --- # FAQ - Trident [Skip to content](https://ackee.xyz/trident/docs/0.10.0/basics/faq/#faq) FAQ[#](https://ackee.xyz/trident/docs/0.10.0/basics/faq/#faq "Permanent link") =============================================================================== _Is Trident supported only with Anchor?_ * Currently yes, Trident under the hood obtains data from the IDL generated by Anchor. _I created the Fuzz Test, what should I do next?_ * Start here [Start Fuzzing](https://ackee.xyz/trident/docs/0.10.0/start-fuzzing/) . _Is Trident open-source?_ * Yes, here [Trident](https://github.com/Ackee-Blockchain/trident) . _I would like to report an Issue with Trident, what should I do?_ * Create [issue](https://github.com/Ackee-Blockchain/trident/issues) . _Is Trident deployed on Mainnet / Devnet / Testenet?_ * No, Trident is Fuzz Testing Framework, not Solana Program. _What type of Fuzzer is Trident?_ * Currently, we refer to it as _"coverage guided gray box fuzzer"_. Back to top --- # Trident Features - Trident [Skip to content](https://ackee.xyz/trident/docs/0.8.1/features/features/#trident-features) Trident Features[#](https://ackee.xyz/trident/docs/0.8.1/features/features/#trident-features "Permanent link") =============================================================================================================== Trident contains multiple features to enhance the fuzzing experience and increase ability to discover bugs. * **AccountStorages** * * * Initialize, store and re-use random Accounts. [**AccountStorages**](https://ackee.xyz/trident/docs/0.8.1/features/account-storages/) * **FuzzInstructions** * * * All available Program Instructions as FuzzInstructions Variants. [**FuzzInstructions**](https://ackee.xyz/trident/docs/0.8.1/features/fuzz-instructions/) * **Custom Instruction Sequences** * * * Specify Instruction Sequqnces you would like to executed instead of completely random execution order. [**Custom Instruction Sequences**](https://ackee.xyz/trident/docs/0.8.1/features/instructions-sequences/) * **Invariant Checks** * * * Allows to compare Account contents before and after the Instruction was successfully executed. [**Invariant Checks**](https://ackee.xyz/trident/docs/0.8.1/features/invariant-checks/) * **Genesis Accounts** * * * Specify genesis Accounts that will be included in the Fuzzing Environment. Use Mainnet Programs or dumped Accounts. [**Genesis**](https://ackee.xyz/trident/docs/0.8.1/features/genesis-accounts/) * **Fuzzing Statistics** * * * Show Fuzzing Statistics after the Fuzzing Session ended. [**Fuzzing Statistics**](https://ackee.xyz/trident/docs/0.8.1/features/fuzzing-statistics/) * **Arbitrary Data** * * * Customize structure of Instruction Input arguments. [**Arbitrary Data**](https://ackee.xyz/trident/docs/0.8.1/features/arbitrary-data/) * **Trident Manifest** * * * Customize Fuzzing experience with the Trident Manifest. [**Trident Manifest**](https://ackee.xyz/trident/docs/0.8.1/features/trident-manifest/) * **Custom Error Handlers** * * * Continue Instruction Sequence in case of Instruction Error was returned or specify custom behavior based on the returned error. [**Custom Error Handlers**](https://ackee.xyz/trident/docs/0.8.1/features/error-handlers/) Back to top --- # Get Help - Trident [Skip to content](https://ackee.xyz/trident/docs/0.10.0/basics/get-help/#get-help) Get Help[#](https://ackee.xyz/trident/docs/0.10.0/basics/get-help/#get-help "Permanent link") ============================================================================================== Need help writing Fuzz Tests? Do not hesitate to join our [Discord server](https://discord.gg/3czRpmGmeC) ! Back to top --- # Changelog - Trident [Skip to content](https://ackee.xyz/trident/docs/0.10.0/basics/CHANGELOG/#changelog) Changelog[#](https://ackee.xyz/trident/docs/0.10.0/basics/CHANGELOG/#changelog "Permanent link") ================================================================================================= All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) , and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html) (SemVer). **Note**: Version 0 of Semantic Versioning is handled differently from version 1 and above. The minor version will be incremented upon a breaking change and the patch version will be incremented for features. \[dev\] - Unreleased[#](https://ackee.xyz/trident/docs/0.10.0/basics/CHANGELOG/#dev-unreleased "Permanent link") ----------------------------------------------------------------------------------------------------------------- **Added** **Removed** **Changed** \[0.10.0\] - 2025-03-13[#](https://ackee.xyz/trident/docs/0.10.0/basics/CHANGELOG/#0100-2025-03-13 "Permanent link") --------------------------------------------------------------------------------------------------------------------- **Added** * TransactionSelector allows to select and execute random transaction with hooks and without hooks ([297](https://github.com/Ackee-Blockchain/trident/pull/297) ) * Added "random\_tail" attribute to TridentFlowExecutor macro to allow random tail generation ([296](https://github.com/Ackee-Blockchain/trident/pull/296) ) * Added support for seeds constraint for accounts structs ([284](https://github.com/Ackee-Blockchain/trident/pull/284) ) * Additional methods accessing the AccountsStorage and creating corresponding accounts are now optional ("token","vote", "stake") ([279](https://github.com/Ackee-Blockchain/trident/pull/279) ) * Derive macros now use own syn parser for better extensibility and UX ([275](https://github.com/Ackee-Blockchain/trident/pull/275) ) * Program ID inside test\_fuzz.rs file is now automatically filled in is present in the program IDL ([272](https://github.com/Ackee-Blockchain/trident/pull/272) ) * Added additional attributes to TridentAccounts, mut and signer ([268](https://github.com/Ackee-Blockchain/trident/pull/268) ) * Users can now specify a program for which they want to add or initialize a fuzz test using `--program-name` flag ([273](https://github.com/Ackee-Blockchain/trident/pull/273) ) * Allow custom test name specification in fuzz test creation with `--test-name` flag ([274](https://github.com/Ackee-Blockchain/trident/pull/274) ) **Removed** * The DisplayIx macro is now removed, Debug trait was implemented for instruction inputs ([281](https://github.com/Ackee-Blockchain/trident/pull/281) ) **Changed** * FuzzTestExecutor and FlowExecutor are grouped together and FuzzTest has client as generic instead of TridentSVM ([294](https://github.com/Ackee-Blockchain/trident/pull/294) ) * Changed Transaction sequence logic ([289](https://github.com/Ackee-Blockchain/trident/pull/289) ) * AccountsStorages are simplified, no types are required to define ([276](https://github.com/Ackee-Blockchain/trident/pull/276) ) * Trident Architecture changes containing multiple features and improvements (details in the PR)([267](https://github.com/Ackee-Blockchain/trident/pull/267) ) * get or create token account methods fixed for native token accounts ([262](https://github.com/Ackee-Blockchain/trident/pull/262) ) \[0.9.1\] - 2025-02-03[#](https://ackee.xyz/trident/docs/0.10.0/basics/CHANGELOG/#091-2025-02-03 "Permanent link") ------------------------------------------------------------------------------------------------------------------- **Added** * added warp to time manipulation ([259](https://github.com/Ackee-Blockchain/trident/pull/259) ) * added methods to check if account storage is empty ([258](https://github.com/Ackee-Blockchain/trident/pull/258) ) * added support for post-instruction behavior ([257](https://github.com/Ackee-Blockchain/trident/pull/257) ) **Removed** **Changed** \[0.9.0\] - 2025-01-15[#](https://ackee.xyz/trident/docs/0.10.0/basics/CHANGELOG/#090-2025-01-15 "Permanent link") ------------------------------------------------------------------------------------------------------------------- **Added** * added support for composite accounts ([245](https://github.com/Ackee-Blockchain/trident/pull/245) ) * Trident SVM + AFL (see the PR for more details) ([234](https://github.com/Ackee-Blockchain/trident/pull/234) ) **Removed** * removed fuzz\_iteration from test\_fuzz.rs ([243](https://github.com/Ackee-Blockchain/trident/pull/243) ) **Changed** * renamed Config to TridentConfig ([246](https://github.com/Ackee-Blockchain/trident/pull/246) ) * errors are simplified and transaction error contains only transaction error ([244](https://github.com/Ackee-Blockchain/trident/pull/244) ) \[0.8.1\] - 2024-11-14[#](https://ackee.xyz/trident/docs/0.10.0/basics/CHANGELOG/#081-2024-11-14 "Permanent link") ------------------------------------------------------------------------------------------------------------------- **Removed** * removed unnecesarry deserialization with AccountsSnapshots, to deserialize data implementation AccountDeserialize can be used ([221](https://github.com/Ackee-Blockchain/trident/pull/221) ) **Changed** * improve AccountsStorage module structure and remove unnecessary methods in FuzzClient ([223](https://github.com/Ackee-Blockchain/trident/pull/223) ) * improve manipulations with AccountsStorages in get\_accounts() function ([219](https://github.com/Ackee-Blockchain/trident/pull/219) ) **Added** * add pre\_sequence!, middle\_sequence! and post\_sequence! for easier sequence definition ([220](https://github.com/Ackee-Blockchain/trident/pull/220) ) * add/ add support for Clock sysvar manipulations with the client(i.e. warp to slot/epoch and forward in time) ([217](https://github.com/Ackee-Blockchain/trident/pull/217) ) \[0.8.0\] - 2024-10-21[#](https://ackee.xyz/trident/docs/0.10.0/basics/CHANGELOG/#080-2024-10-21 "Permanent link") ------------------------------------------------------------------------------------------------------------------- **Added** * impr/ allow to specify programs and accounts in the Trident Manifest ([207](https://github.com/Ackee-Blockchain/trident/pull/207) ) * impr/ added get\_program\_id function to the IxOps and FuzzTestExecutor ([199](https://github.com/Ackee-Blockchain/trident/pull/199) ) **Changed** * impr/ improve init command, modify program manifest automatically, add init force, add howto subcommand ([208](https://github.com/Ackee-Blockchain/trident/pull/208) ) * impr/ allow to derive AccountsSnapshots for empty Account Context ([209](https://github.com/Ackee-Blockchain/trident/pull/209) ) * impr/ fuzz flags are read at start of fuzzing session from Config instead of env variable and transaction dispatch was added to increase FuzzTestExecutor readability ([204](https://github.com/Ackee-Blockchain/trident/pull/204) ) * impr/ allow various instructions to be generated in case of multiple programs in the Anchor workspace ([200](https://github.com/Ackee-Blockchain/trident/pull/200) ) * feat/ option to add account into Fuzz Test environment with base64 data ([197](https://github.com/Ackee-Blockchain/trident/pull/197) ) * impr/ instead of parsing source code and creating our IDL, read anchor IDL ([198](https://github.com/Ackee-Blockchain/trident/pull/196) ) **Removed** * del/remove integration tests supported by Trident, this feature adds more unnecessary overhead compared to its value ([196](https://github.com/Ackee-Blockchain/trident/pull/198) ) \[0.7.0\] - 2024-08-14[#](https://ackee.xyz/trident/docs/0.10.0/basics/CHANGELOG/#070-2024-08-14 "Permanent link") ------------------------------------------------------------------------------------------------------------------- **Added** * impr/ add feature flag to the AccountsSnapshots macro ([183](https://github.com/Ackee-Blockchain/trident/pull/183) ) * feat/ add Support for CPI ([182](https://github.com/Ackee-Blockchain/trident/pull/182) ) * feat/ add option to initialize Trident with Macro/File (for Snapshots) option based on preference ([179](https://github.com/Ackee-Blockchain/trident/pull/179) ) * feat/create AccountsSnapshots derive macro for Snapshots creation ([#177](https://github.com/Ackee-Blockchain/trident/pull/177) ) * feat/fuzzing moved to separate crate trident-fuzz ([#175](https://github.com/Ackee-Blockchain/trident/pull/175) ) * feat/unify dependencies provided by the Trident ([#172](https://github.com/Ackee-Blockchain/trident/pull/172) ) * feat/fuzzer-stats-logging, an optional statistics output for fuzzing session ([#144](https://github.com/Ackee-Blockchain/trident/pull/144) ) **Fixed** * fix/in case of fuzzing failure throw error instead of only printing message ([#167](https://github.com/Ackee-Blockchain/trident/pull/167) ) * fix/snapshot's zeroed account as optional ([#170](https://github.com/Ackee-Blockchain/trident/pull/170) ) **Removed** * del/remove localnet subcommand ([178](https://github.com/Ackee-Blockchain/trident/pull/178) ) * del/remove unnecessary fuzzing feature as trident is mainly fuzzer ([#176](https://github.com/Ackee-Blockchain/trident/pull/176) ) * del/remove Trident explorer ([#171](https://github.com/Ackee-Blockchain/trident/pull/171) ) \[0.6.0\] - 2024-05-20[#](https://ackee.xyz/trident/docs/0.10.0/basics/CHANGELOG/#060-2024-05-20 "Permanent link") ------------------------------------------------------------------------------------------------------------------- **Added** * feat/anchor 0.30.0 support ([#148](https://github.com/Ackee-Blockchain/trident/pull/148) ) * fix/allow to process duplicate transactions ([#147](https://github.com/Ackee-Blockchain/trident/pull/147) ) * feat/possibility to implement custom transaction error handling ([#145](https://github.com/Ackee-Blockchain/trident/pull/145) ) * feat/support of automatically obtaining fully qualified paths of Data Accounts Custom types for `accounts_snapshots.rs` ([#141](https://github.com/Ackee-Blockchain/trident/pull/141) ) * feat/allow direct accounts manipulation and storage ([#142](https://github.com/Ackee-Blockchain/trident/pull/142) ) * feat/support of non-corresponding instruction and context names ([#130](https://github.com/Ackee-Blockchain/trident/pull/130) ) * feat/refactored and improved program flow during init and build, added activity indicator ([#129](https://github.com/Ackee-Blockchain/trident/pull/129) ) * feat/allow solana versions up to v1.17.\* and pin Rust 1.77 nightly compiler ([#128](https://github.com/Ackee-Blockchain/trident/pull/128) ) * feat/new init command option to initialize fuzz or poc tests only ([#124](https://github.com/Ackee-Blockchain/trident/pull/124) ) * feat/debug-mode detailed output ([#125](https://github.com/Ackee-Blockchain/trident/pull/125) ) * feat/anchor 0.29.0 support ([#121](https://github.com/Ackee-Blockchain/trident/pull/121) ) * doc/add help comment + update documentation ([#120](https://github.com/Ackee-Blockchain/trident/pull/120) ) * feat/fuzzer error handling ([#118](https://github.com/Ackee-Blockchain/trident/pull/118) ) * feat/convert fuzz Pubkey to AccountId ([#116](https://github.com/Ackee-Blockchain/trident/pull/116) ) * feat/additional anchor types ([#115](https://github.com/Ackee-Blockchain/trident/pull/115) ) * feat/import ToAccountInfo trait in fuzzing prelude ([#113](https://github.com/Ackee-Blockchain/trident/pull/113) ) * test/added code generation and macros tests ([#112](https://github.com/Ackee-Blockchain/trident/pull/112) ) * feat/fuzzer framework core, macros, helpers, templates, and examples. ([#111](https://github.com/Ackee-Blockchain/trident/pull/111) ) * feat/improved trident-tests folder structure for PoC and Fuzz Tests ([#109](https://github.com/Ackee-Blockchain/trident/pull/109) ) * feat/support for additional fuzzer parameters in Trident.toml config file ([#107](https://github.com/Ackee-Blockchain/trident/pull/107) ) * feat/posibility to pass params to the fuzzer via Trident.toml config file ([#106](https://github.com/Ackee-Blockchain/trident/pull/106) ) * feat/client now reads by default keypair from default location ([#105](https://github.com/Ackee-Blockchain/trident/pull/105) ) * feat/added new --exit-code option to return corresponding exit code based on fuzz test result ([#104](https://github.com/Ackee-Blockchain/trident/pull/104) ) * feat/removed/updated deprecated functions, removed allow deprecated macros ([#103](https://github.com/Ackee-Blockchain/trident/pull/103) ) * feat/added new function to read keypair file generated by Anchor ([#102](https://github.com/Ackee-Blockchain/trident/pull/102) ) * feat/clean command ([#101](https://github.com/Ackee-Blockchain/trident/pull/101) ) * feat/improved program\_client generated code ([#100](https://github.com/Ackee-Blockchain/trident/pull/100) ) * feat/automatically add hfuzz\_target to .gitignore file ([#99](https://github.com/Ackee-Blockchain/trident/pull/99) ) * feat/support for dynamic templates. ([#98](https://github.com/Ackee-Blockchain/trident/pull/98) ) **Fixed** * fix/refactored fuzz test executor error handling ([#127](https://github.com/Ackee-Blockchain/trident/pull/127) ) * fix/warn user on composite accounts and continue fuzz test generation ([#133](https://github.com/Ackee-Blockchain/trident/pull/133) ) * fix/progress bar loop lock release ([#132](https://github.com/Ackee-Blockchain/trident/pull/132) ) * fix/fixed fuzz test generation with init-if-needed Anchor feature ([#131](https://github.com/Ackee-Blockchain/trident/pull/131) ) * fix/program client custom types ([#117](https://github.com/Ackee-Blockchain/trident/pull/117) ) * fix/check fuzz test name collision by checking the name against HashSet ([#114](https://github.com/Ackee-Blockchain/trident/pull/114) ) \[0.5.0\] - 2023-08-28[#](https://ackee.xyz/trident/docs/0.10.0/basics/CHANGELOG/#050-2023-08-28 "Permanent link") ------------------------------------------------------------------------------------------------------------------- **Added** * cli: Added trident subcommand `fuzz` to run and debug fuzz tests using honggfuzz-rs. * cli: Added trident `--skip-fuzzer` option for `init` subcommand to skip generation of fuzz test templates. * client: Added new Cargo feature `fuzzing` that enables optional dependencies related to fuzz testing. \[0.4.1\] - 2023-08-21[#](https://ackee.xyz/trident/docs/0.10.0/basics/CHANGELOG/#041-2023-08-21 "Permanent link") ------------------------------------------------------------------------------------------------------------------- **Changed** * Upgrade Solana (`=1.16.6`) and Anchor framework (`=0.28.0`) versions. **Fixed** * Implemented Anchor Client logic was not able to work with newer version of Anchor. Fixed with `async_rpc` and `async` feature. * Trident init IDL Parse Error on newer version of Rust, fixed with updated `accounts` token. \[0.3.0\] - 2022-09-23[#](https://ackee.xyz/trident/docs/0.10.0/basics/CHANGELOG/#030-2022-09-23 "Permanent link") ------------------------------------------------------------------------------------------------------------------- **Changed** * Upgrade Solana (`~1.10`) and Anchor framework (`~0.25`) versions **Added** * Custom Solana RPC error reporter. If the Solana RPC error is thrown, the error code, message and data (logs) are reported to the output. * Custom imports in the `.program_client`. User is able to import custom types and structures into program client. The import part of the code would not be re-generated. \[0.2.0\] - 2022-07-27[#](https://ackee.xyz/trident/docs/0.10.0/basics/CHANGELOG/#020-2022-07-27 "Permanent link") ------------------------------------------------------------------------------------------------------------------- **Added** * Trident is now configurable. This requires `Trident.toml` file to exist in the project's root directory - without this file the execution will fail. To solve this re-run `trident init` or just create an empty `Trident.toml` file in the project's root directory. Back to top --- # Trident by Examples - Trident [Skip to content](https://ackee.xyz/trident/docs/0.8.1/examples/examples/#trident-by-examples) Trident by Examples[#](https://ackee.xyz/trident/docs/0.8.1/examples/examples/#trident-by-examples "Permanent link") ===================================================================================================================== * **Hello World!** * * * Hello World example with Trident. [Hello World!](https://github.com/Ackee-Blockchain/trident/tree/master/examples/fuzz-tests/hello_world) * **Possible vulnerabilities and bugs** * * * Check the possible attack vectors and bugs that can be detected using Trident. [Unchecked Arithmetic](https://github.com/Ackee-Blockchain/trident/tree/master/examples/fuzz-tests/unchecked-arithmetic-0) [Incorrect Instruction Sequence](https://github.com/Ackee-Blockchain/trident/tree/master/examples/fuzz-tests/incorrect-ix-sequence-1) [Unauthorized Access](https://github.com/Ackee-Blockchain/trident/tree/master/examples/fuzz-tests/unauthorized-access-2) [Incorrect Integer Arithmetic](https://github.com/Ackee-Blockchain/trident/tree/master/examples/fuzz-tests/incorrect-integer-arithmetic-3) * **Customize with Arbitrary** * * * You can use Arbitrary crate to your advantage and limit or customize the data that are sent to the instructions. [Custom Data Types](https://github.com/Ackee-Blockchain/trident/tree/master/examples/fuzz-tests/arbitrary-custom-types-4) [Limiting Instructions Inputs](https://github.com/Ackee-Blockchain/trident/tree/master/examples/fuzz-tests/arbitrary-limit-inputs-5) * **Cross-Program Invocation** * * * Trident supports Cross-Program Invocation, you can fuzz your programs and create NFTs at the same time. [Simple CPI](https://github.com/Ackee-Blockchain/trident/tree/master/examples/fuzz-tests/simple-cpi-6) [CPI with Metaplex Metadata Program](https://github.com/Ackee-Blockchain/trident/tree/master/examples/fuzz-tests/cpi-metaplex-7) Back to top --- # Writing fuzz test - Trident [Skip to content](https://ackee.xyz/trident/docs/dev/start-fuzzing/writting-fuzz-test/#writing-fuzz-test) Writing fuzz test[#](https://ackee.xyz/trident/docs/dev/start-fuzzing/writting-fuzz-test/#writing-fuzz-test "Permanent link") ============================================================================================================================== Trident is Manually Guided fuzzing framework for Solana programs. In order to start fuzzing, you need to guide the fuzzer by specifying what are the expected inputs to instruction or the expected sequences of instructions to execute. **Why is this important?** Letting the fuzzer to generate completely random instruction inputs and completely random sequences of instruction would lead in most case * to transaction failures, which would mean the fuzzer is not properly fuzzing the logic within the program; and * executing irrelevant random instruction sequences, which would again lead to transaction failures. Guide the fuzzer[#](https://ackee.xyz/trident/docs/dev/start-fuzzing/writting-fuzz-test/#guide-the-fuzzer "Permanent link") ---------------------------------------------------------------------------------------------------------------------------- Start with properly configuring different types of instruction inputs: * [Instruction Data](https://ackee.xyz/trident/docs/dev/start-fuzzing/writting-fuzz-test/instruction-data/) * [Instruction Accounts](https://ackee.xyz/trident/docs/dev/start-fuzzing/writting-fuzz-test/instruction-accounts/) * [Fuzzing Flows](https://ackee.xyz/trident/docs/dev/start-fuzzing/writting-fuzz-test/fuzzing-flows/) * (Optional) [Remaining Accounts](https://ackee.xyz/trident/docs/dev/start-fuzzing/writting-fuzz-test/remaining-accounts/) Back to top --- # Executing the Fuzz Test - Trident [Skip to content](https://ackee.xyz/trident/docs/dev/start-fuzzing/executing-fuzz-test/#executing-the-fuzz-test) Executing the Fuzz Test[#](https://ackee.xyz/trident/docs/dev/start-fuzzing/executing-fuzz-test/#executing-the-fuzz-test "Permanent link") =========================================================================================================================================== To execute the fuzz test, navigate to the `trident-tests` directory and run the following command to execute the fuzz test: `[](https://ackee.xyz/trident/docs/dev/start-fuzzing/executing-fuzz-test/#__codelineno-0-1) trident fuzz run [](https://ackee.xyz/trident/docs/dev/start-fuzzing/executing-fuzz-test/#__codelineno-0-2) # for example: [](https://ackee.xyz/trident/docs/dev/start-fuzzing/executing-fuzz-test/#__codelineno-0-3) # trident fuzz run fuzz_0 [](https://ackee.xyz/trident/docs/dev/start-fuzzing/executing-fuzz-test/#__codelineno-0-4) # seed is optional, if not provided, a random seed will be used` Directory Note Execute fuzz tests from the `trident-tests` directory. Solana Logs In case you want to see the logs of the fuzzed transactions, prefix the command with `TRIDENT_LOG=1`. `[](https://ackee.xyz/trident/docs/dev/start-fuzzing/executing-fuzz-test/#__codelineno-1-1) TRIDENT_LOG=1 trident fuzz run ` For the output reference and additional options such as debugging the found issues, check out [Commands](https://ackee.xyz/trident/docs/dev/basics/commands/) . For the additional customization through the `trident.toml` file, check out the [Trident Manifest](https://ackee.xyz/trident/docs/dev/trident-manifest/) page. Back to top --- # Writing fuzz test - Trident [Skip to content](https://ackee.xyz/trident/docs/0.10.0/start-fuzzing/writting-fuzz-test/#writing-fuzz-test) Writing fuzz test[#](https://ackee.xyz/trident/docs/0.10.0/start-fuzzing/writting-fuzz-test/#writing-fuzz-test "Permanent link") ================================================================================================================================= In order to start fuzzing, you need to guide the fuzzer to use correct and meaningful instruction inputs. Trident generates random data for instruction executions. However, allowing the fuzzer to generate completely random account addresses would lead to numerous failed transactions, making the fuzzing process ineffective. Each program instruction has a corresponding file in the instructions directory. Instructions consist of two main components: * Instruction Accounts * Instruction Data * (Optional) Remaining Accounts Guide the Instruction Inputs[#](https://ackee.xyz/trident/docs/0.10.0/start-fuzzing/writting-fuzz-test/#guide-the-instruction-inputs "Permanent link") ------------------------------------------------------------------------------------------------------------------------------------------------------- Start with properly configuring different types of instruction inputs: * [Instruction Accounts](https://ackee.xyz/trident/docs/0.10.0/start-fuzzing/writting-fuzz-test/instruction-accounts/) * [Instruction Data](https://ackee.xyz/trident/docs/0.10.0/start-fuzzing/writting-fuzz-test/instruction-data/) * (Optional) [Remaining Accounts](https://ackee.xyz/trident/docs/0.10.0/start-fuzzing/writting-fuzz-test/remaining-accounts/) Back to top --- # FAQ - Trident [Skip to content](https://ackee.xyz/trident/docs/0.8.1/faq/faq/#faq) FAQ[#](https://ackee.xyz/trident/docs/0.8.1/faq/faq/#faq "Permanent link") =========================================================================== ### Is Trident supported only with Anchor ?[#](https://ackee.xyz/trident/docs/0.8.1/faq/faq/#is-trident-supported-only-with-anchor "Permanent link") * Currently yes, Trident under the hood obtains data from the IDL generated by Anchor. ### I created the Fuzz Test what should I do next ?[#](https://ackee.xyz/trident/docs/0.8.1/faq/faq/#i-created-the-fuzz-test-what-should-i-do-next "Permanent link") * Start here [Writing Fuzz Tests](https://ackee.xyz/trident/docs/0.8.1/writing-fuzz-test/writing-fuzz-test/) . For additional features check [Features](https://ackee.xyz/trident/docs/0.8.1/features/features/) . If you are not sure about anything check [Get Help](https://ackee.xyz/trident/docs/0.8.1/get-help/get-help/) ### My program Instruction contains custom type such as Struct or Enum on its input, but it does not derive Arbitrary.[#](https://ackee.xyz/trident/docs/0.8.1/faq/faq/#my-program-instruction-contains-custom-type-such-as-struct-or-enum-on-its-input-but-it-does-not-derive-arbitrary "Permanent link") * In this case you need to specify same type in the Fuzz Test (with the same fields). And implement From Trait to convert to your type. Check [Custom Data Types](https://ackee.xyz/trident/docs/0.8.1/features/arbitrary-data/#custom-data-types) or [Examples of Arbitrary](https://ackee.xyz/trident/docs/0.8.1/examples/examples/) . ### Is Trident open-source ?[#](https://ackee.xyz/trident/docs/0.8.1/faq/faq/#is-trident-open-source "Permanent link") * Yes, here [Trident](https://github.com/Ackee-Blockchain/trident) ### I would like to report Issue with Trident, what should I do ?[#](https://ackee.xyz/trident/docs/0.8.1/faq/faq/#i-would-like-to-report-issue-with-trident-what-should-i-do "Permanent link") * Write Issue [Issues](https://github.com/Ackee-Blockchain/trident/issues) ### Is Trident deployed on Mainnet / Devnet / Testenet ?[#](https://ackee.xyz/trident/docs/0.8.1/faq/faq/#is-trident-deployed-on-mainnet-devnet-testenet "Permanent link") * No, Trident is Fuzz Testing Framework, not Solana Program. ### What type of Fuzzer Trident is ?[#](https://ackee.xyz/trident/docs/0.8.1/faq/faq/#what-type-of-fuzzer-trident-is "Permanent link") * Currently, we refer to it as _"coverage guided gray box fuzzer"_. Back to top --- # Executing the Fuzz Test - Trident [Skip to content](https://ackee.xyz/trident/docs/0.10.0/start-fuzzing/executing-fuzz-test/#executing-the-fuzz-test) Executing the Fuzz Test[#](https://ackee.xyz/trident/docs/0.10.0/start-fuzzing/executing-fuzz-test/#executing-the-fuzz-test "Permanent link") ============================================================================================================================================== To execute the fuzz test, navigate to the `trident-tests` directory and run the following command to execute the fuzz test using Honggfuzz: `[](https://ackee.xyz/trident/docs/0.10.0/start-fuzzing/executing-fuzz-test/#__codelineno-0-1) trident fuzz run-hfuzz [](https://ackee.xyz/trident/docs/0.10.0/start-fuzzing/executing-fuzz-test/#__codelineno-0-2) # for example: [](https://ackee.xyz/trident/docs/0.10.0/start-fuzzing/executing-fuzz-test/#__codelineno-0-3) # trident fuzz run-hfuzz fuzz_0` To execute the fuzz test using AFL, run the following command: `[](https://ackee.xyz/trident/docs/0.10.0/start-fuzzing/executing-fuzz-test/#__codelineno-1-1) trident fuzz run-afl [](https://ackee.xyz/trident/docs/0.10.0/start-fuzzing/executing-fuzz-test/#__codelineno-1-2) # for example: [](https://ackee.xyz/trident/docs/0.10.0/start-fuzzing/executing-fuzz-test/#__codelineno-1-3) # trident fuzz run-afl fuzz_0` Directory Note Execute fuzz tests from the `trident-tests` directory. Solana Logs In case you want to see the logs of the fuzzed transactions, prefix the command with `TRIDENT_LOG=1`. `[](https://ackee.xyz/trident/docs/0.10.0/start-fuzzing/executing-fuzz-test/#__codelineno-2-1) TRIDENT_LOG=1 trident fuzz run-afl [](https://ackee.xyz/trident/docs/0.10.0/start-fuzzing/executing-fuzz-test/#__codelineno-2-2) TRIDENT_LOG=1 trident fuzz run-hfuzz ` For the output reference and additional options such as debugging the found issues, check out [Commands](https://ackee.xyz/trident/docs/0.10.0/basics/commands/) . Back to top --- # Code Coverage - Trident [Skip to content](https://ackee.xyz/trident/docs/dev/trident-advanced/code-coverage/#code-coverage) Code Coverage[#](https://ackee.xyz/trident/docs/dev/trident-advanced/code-coverage/#code-coverage "Permanent link") ==================================================================================================================== Trident's code coverage feature analyzes which parts of your Solana program are tested during fuzzing sessions, helping you identify untested code paths and improve test effectiveness. Your browser does not support the video tag. Key features: * **Real-time Analysis**: Monitor coverage as fuzzing progresses * **Multiple Formats**: Generate reports in JSON and HTML formats * **VS Code Integration**: Visualize coverage directly in your IDE using [Solana VS Code extension](https://marketplace.visualstudio.com/items?itemName=AckeeBlockchain.solana) * **Detailed Reporting**: Get insights into line coverage, branch coverage, and execution paths Gathering Coverage Data[#](https://ackee.xyz/trident/docs/dev/trident-advanced/code-coverage/#gathering-coverage-data "Permanent link") ---------------------------------------------------------------------------------------------------------------------------------------- 1. Enable coverage in the [Trident manifest](https://ackee.xyz/trident/docs/dev/trident-manifest/#fuzzing-coverage) 2. Deploy your program through the [entrypoint](https://ackee.xyz/trident/docs/dev/trident-manifest/#entrypoint-deployment) 3. Run the fuzz test Viewing Coverage Reports[#](https://ackee.xyz/trident/docs/dev/trident-advanced/code-coverage/#viewing-coverage-reports "Permanent link") ------------------------------------------------------------------------------------------------------------------------------------------ You have two options for displaying coverage data: generate an HTML report for browser viewing, or generate a JSON report for VS Code integration. ### Live Coverage Updates[#](https://ackee.xyz/trident/docs/dev/trident-advanced/code-coverage/#live-coverage-updates "Permanent link") For real-time coverage monitoring during fuzzing: 1. Set `format = "json"` in the [Trident manifest](https://ackee.xyz/trident/docs/dev/trident-manifest/#fuzzing-coverage) 2. Set `loopcount` to a value other than `0` e.g., `5` for frequent updates, for more info check out [Trident manifest](https://ackee.xyz/trident/docs/dev/trident-manifest/#entrypoint-deployment) 3. Install the [Solana VS Code extension](https://marketplace.visualstudio.com/items?itemName=AckeeBlockchain.solana) 4. Choose one of these options: * **Automatic**: Set `attach_extension = true` in the [Trident manifest](https://ackee.xyz/trident/docs/dev/trident-manifest/#fuzzing-coverage) to automatically show live updates while the fuzz test is running * **Manual**: Use the command `Solana: Show Code Coverage` and select the "Attach to active fuzzing session" option ### Post-Session Coverage Analysis[#](https://ackee.xyz/trident/docs/dev/trident-advanced/code-coverage/#post-session-coverage-analysis "Permanent link") 1. Set `format = "json"` in the [Trident manifest](https://ackee.xyz/trident/docs/dev/trident-manifest/#fuzzing-coverage) before running the fuzz test 2. Run the fuzz test 3. Install the [Solana VS Code extension](https://marketplace.visualstudio.com/items?itemName=AckeeBlockchain.solana) 4. Run the VS Code command `Solana: Show Code Coverage` and select the "Load generated JSON report" option ### HTML Report[#](https://ackee.xyz/trident/docs/dev/trident-advanced/code-coverage/#html-report "Permanent link") 1. Set `format = "html"` in the [Trident manifest](https://ackee.xyz/trident/docs/dev/trident-manifest/#fuzzing-coverage) before running the fuzz test 2. Run the fuzz test 3. After the fuzz test finishes, the HTML report will be stored in the `-coverage-report` folder 4. Open the HTML report in your browser Back to top --- # Get Help - Trident [Skip to content](https://ackee.xyz/trident/docs/0.8.1/get-help/get-help/#get-help) Get Help[#](https://ackee.xyz/trident/docs/0.8.1/get-help/get-help/#get-help "Permanent link") =============================================================================================== Need help writing Fuzz Tests? Do not hesitate to join our [Discord server](https://discord.gg/3czRpmGmeC) ! Back to top --- # Trident's Fuzz Client - Trident [Skip to content](https://ackee.xyz/trident/docs/0.10.0/trident-api-macro/trident-fuzz-client/#tridents-fuzz-client) Trident's Fuzz Client[#](https://ackee.xyz/trident/docs/0.10.0/trident-api-macro/trident-fuzz-client/#tridents-fuzz-client "Permanent link") ============================================================================================================================================= Trident's Client (`FuzzClient`) is a wrapper around the [TridentSVM](https://ackee.xyz/trident/docs/0.10.0/trident-svm/) that provides methods to manipulate with the execution environment during fuzzing. This section describes the methods that are available in the `FuzzClient`. Trident Client Methods[#](https://ackee.xyz/trident/docs/0.10.0/trident-api-macro/trident-fuzz-client/#trident-client-methods "Permanent link") ------------------------------------------------------------------------------------------------------------------------------------------------ ### `new_client`[#](https://ackee.xyz/trident/docs/0.10.0/trident-api-macro/trident-fuzz-client/#new_client "Permanent link") Creates a new instance of the fuzzing client with the specified programs and configuration. `[](https://ackee.xyz/trident/docs/0.10.0/trident-api-macro/trident-fuzz-client/#__codelineno-0-1) fn new_client(programs: &[ProgramEntrypoint], config: &TridentConfig) -> Self` * * * ### `deploy_native_program`[#](https://ackee.xyz/trident/docs/0.10.0/trident-api-macro/trident-fuzz-client/#deploy_native_program "Permanent link") Deploys a native program to the fuzzing client. `[](https://ackee.xyz/trident/docs/0.10.0/trident-api-macro/trident-fuzz-client/#__codelineno-1-1) fn deploy_native_program(program: ProgramEntrypoint)` * * * ### `get_sysvar`[#](https://ackee.xyz/trident/docs/0.10.0/trident-api-macro/trident-fuzz-client/#get_sysvar "Permanent link") Retrieves `Sysvars` like `Rent`, `Clock`, etc. `[](https://ackee.xyz/trident/docs/0.10.0/trident-api-macro/trident-fuzz-client/#__codelineno-2-1) fn get_sysvar() -> T` * * * ### `warp_to_epoch`[#](https://ackee.xyz/trident/docs/0.10.0/trident-api-macro/trident-fuzz-client/#warp_to_epoch "Permanent link") Advances the fuzz test to a specific epoch. `[](https://ackee.xyz/trident/docs/0.10.0/trident-api-macro/trident-fuzz-client/#__codelineno-3-1) fn warp_to_epoch(warp_epoch: u64)` * * * ### `warp_to_slot`[#](https://ackee.xyz/trident/docs/0.10.0/trident-api-macro/trident-fuzz-client/#warp_to_slot "Permanent link") Advances the fuzz test to a specific slot. `[](https://ackee.xyz/trident/docs/0.10.0/trident-api-macro/trident-fuzz-client/#__codelineno-4-1) fn warp_to_slot(warp_slot: u64)` * * * ### `warp_to_timestamp`[#](https://ackee.xyz/trident/docs/0.10.0/trident-api-macro/trident-fuzz-client/#warp_to_timestamp "Permanent link") Sets the fuzz test to a specific timestamp. `[](https://ackee.xyz/trident/docs/0.10.0/trident-api-macro/trident-fuzz-client/#__codelineno-5-1) fn warp_to_timestamp(warp_timestamp: i64)` * * * ### `forward_in_time`[#](https://ackee.xyz/trident/docs/0.10.0/trident-api-macro/trident-fuzz-client/#forward_in_time "Permanent link") Advances the fuzz test by the specified number of seconds. `[](https://ackee.xyz/trident/docs/0.10.0/trident-api-macro/trident-fuzz-client/#__codelineno-6-1) fn forward_in_time(seconds: i64)` * * * ### `set_account_custom`[#](https://ackee.xyz/trident/docs/0.10.0/trident-api-macro/trident-fuzz-client/#set_account_custom "Permanent link") Creates or overwrites an account at the specified address, bypassing normal runtime checks. `[](https://ackee.xyz/trident/docs/0.10.0/trident-api-macro/trident-fuzz-client/#__codelineno-7-1) fn set_account_custom(address: &Pubkey, account: &AccountSharedData)` * * * ### `get_account`[#](https://ackee.xyz/trident/docs/0.10.0/trident-api-macro/trident-fuzz-client/#get_account "Permanent link") Retrieves the account data at the specified address. `[](https://ackee.xyz/trident/docs/0.10.0/trident-api-macro/trident-fuzz-client/#__codelineno-8-1) fn get_account(key: &Pubkey) -> AccountSharedData` * * * ### `payer`[#](https://ackee.xyz/trident/docs/0.10.0/trident-api-macro/trident-fuzz-client/#payer "Permanent link") Returns the keypair of the client's payer account. `[](https://ackee.xyz/trident/docs/0.10.0/trident-api-macro/trident-fuzz-client/#__codelineno-9-1) fn payer() -> Keypair` * * * ### `clear_accounts`[#](https://ackee.xyz/trident/docs/0.10.0/trident-api-macro/trident-fuzz-client/#clear_accounts "Permanent link") Removes temporary accounts created during the fuzzing iteration. Warning This method is called internally by Trident (after each fuzzing iteration, to reset state to default). `[](https://ackee.xyz/trident/docs/0.10.0/trident-api-macro/trident-fuzz-client/#__codelineno-10-1) fn clear_accounts()` * * * ### `get_last_blockhash`[#](https://ackee.xyz/trident/docs/0.10.0/trident-api-macro/trident-fuzz-client/#get_last_blockhash "Permanent link") Retrieves the most recent blockhash. Warning Currently, this method is not implemented and call to this method will result in a panic. `[](https://ackee.xyz/trident/docs/0.10.0/trident-api-macro/trident-fuzz-client/#__codelineno-11-1) fn get_last_blockhash() -> Hash` * * * ### `process_instructions`[#](https://ackee.xyz/trident/docs/0.10.0/trident-api-macro/trident-fuzz-client/#process_instructions "Permanent link") Executes a set of instructions and waits for them to be either finalized or rejected. Warning This method is called internally by Trident, no need for manual invocation. `[](https://ackee.xyz/trident/docs/0.10.0/trident-api-macro/trident-fuzz-client/#__codelineno-12-1) fn process_instructions(instructions: &[Instruction]) -> Result<(), TransactionError>` Back to top --- # Dashboard - Trident [Skip to content](https://ackee.xyz/trident/docs/dev/trident-advanced/dashboard/#dashboard) Dashboard[#](https://ackee.xyz/trident/docs/dev/trident-advanced/dashboard/#dashboard "Permanent link") ======================================================================================================== The Trident Dashboard provides a web-based interface for visualizing fuzzing session results through interactive charts and comprehensive statistics. Your browser does not support the video tag. Features: * **Session Statistics**: View execution counts, success rates, and performance metrics * **Interactive Charts**: Explore results through dynamic visualizations * **Browser Access**: Open in any web browser without additional software * **Comprehensive Analysis**: Insights into instruction coverage and account interactions Viewing the Dashboard[#](https://ackee.xyz/trident/docs/dev/trident-advanced/dashboard/#viewing-the-dashboard "Permanent link") -------------------------------------------------------------------------------------------------------------------------------- 1. Open another terminal window and execute `trident server` from the fuzz-tests directory. 2. Open your browser and navigate to the provided URL (typically `http://localhost:8080`). 3. Enable the dashboard in the [Trident manifest](https://ackee.xyz/trident/docs/dev/trident-manifest/#fuzzing-metrics) by setting `dashboard = true`. `[](https://ackee.xyz/trident/docs/dev/trident-advanced/dashboard/#__codelineno-0-1) [fuzz.metrics] [](https://ackee.xyz/trident/docs/dev/trident-advanced/dashboard/#__codelineno-0-2) enabled = true [](https://ackee.xyz/trident/docs/dev/trident-advanced/dashboard/#__codelineno-0-3) dashboard = true` 4. Run the fuzz test to generate dashboard data. Monitoring custom fuzzing metrics[#](https://ackee.xyz/trident/docs/dev/trident-advanced/dashboard/#monitoring-custom-fuzzing-metrics "Permanent link") -------------------------------------------------------------------------------------------------------------------------------------------------------- Trident allows you to monitor custom fuzzing metrics. If your program expects integer instruction inputs, it is possible to collect data on the randomly generated values and display them in the dashboard. To do this, you need to add `trident.add_histogram_metric` to the `#[init]`, `#[flow]` or `#[end]` functions. The following code snippet shows how the `InitializeFnTransaction` instruction input is monitored; the statistics will be displayed in the dashboard. `[](https://ackee.xyz/trident/docs/dev/trident-advanced/dashboard/#__codelineno-1-1) #[flow_executor] [](https://ackee.xyz/trident/docs/dev/trident-advanced/dashboard/#__codelineno-1-2) impl FuzzTest { [](https://ackee.xyz/trident/docs/dev/trident-advanced/dashboard/#__codelineno-1-3) fn new() -> Self { [](https://ackee.xyz/trident/docs/dev/trident-advanced/dashboard/#__codelineno-1-4) Self { [](https://ackee.xyz/trident/docs/dev/trident-advanced/dashboard/#__codelineno-1-5) trident: Trident::default(), [](https://ackee.xyz/trident/docs/dev/trident-advanced/dashboard/#__codelineno-1-6) fuzz_accounts: FuzzAccounts::default(), [](https://ackee.xyz/trident/docs/dev/trident-advanced/dashboard/#__codelineno-1-7) } [](https://ackee.xyz/trident/docs/dev/trident-advanced/dashboard/#__codelineno-1-8) } [](https://ackee.xyz/trident/docs/dev/trident-advanced/dashboard/#__codelineno-1-9) [](https://ackee.xyz/trident/docs/dev/trident-advanced/dashboard/#__codelineno-1-10) #[init] [](https://ackee.xyz/trident/docs/dev/trident-advanced/dashboard/#__codelineno-1-11) fn start(&mut self) { [](https://ackee.xyz/trident/docs/dev/trident-advanced/dashboard/#__codelineno-1-12) let mut ix = InitializeFnTransaction::build(&mut self.trident, &mut self.fuzz_accounts); [](https://ackee.xyz/trident/docs/dev/trident-advanced/dashboard/#__codelineno-1-13) [](https://ackee.xyz/trident/docs/dev/trident-advanced/dashboard/#__codelineno-1-14) self.trident.execute_transaction(&mut ix, Some("Init")); [](https://ackee.xyz/trident/docs/dev/trident-advanced/dashboard/#__codelineno-1-15) } [](https://ackee.xyz/trident/docs/dev/trident-advanced/dashboard/#__codelineno-1-16) [](https://ackee.xyz/trident/docs/dev/trident-advanced/dashboard/#__codelineno-1-17) #[flow(weight = 5)] [](https://ackee.xyz/trident/docs/dev/trident-advanced/dashboard/#__codelineno-1-18) fn flow1(&mut self) { [](https://ackee.xyz/trident/docs/dev/trident-advanced/dashboard/#__codelineno-1-19) let mut ix = InitializeFnTransaction::build(&mut self.trident, &mut self.fuzz_accounts); [](https://ackee.xyz/trident/docs/dev/trident-advanced/dashboard/#__codelineno-1-20) self.trident.execute_transaction(&mut ix, Some("Flow1")); [](https://ackee.xyz/trident/docs/dev/trident-advanced/dashboard/#__codelineno-1-21) [](https://ackee.xyz/trident/docs/dev/trident-advanced/dashboard/#__codelineno-1-22) // Add the histogram metric to the dashboard [](https://ackee.xyz/trident/docs/dev/trident-advanced/dashboard/#__codelineno-1-23) self.trident [](https://ackee.xyz/trident/docs/dev/trident-advanced/dashboard/#__codelineno-1-24) .add_histogram_metric("flow1_metric", ix.instruction.data.input as f64); [](https://ackee.xyz/trident/docs/dev/trident-advanced/dashboard/#__codelineno-1-25) } [](https://ackee.xyz/trident/docs/dev/trident-advanced/dashboard/#__codelineno-1-26) [](https://ackee.xyz/trident/docs/dev/trident-advanced/dashboard/#__codelineno-1-27) #[flow(weight = 5)] [](https://ackee.xyz/trident/docs/dev/trident-advanced/dashboard/#__codelineno-1-28) fn flow2(&mut self) { [](https://ackee.xyz/trident/docs/dev/trident-advanced/dashboard/#__codelineno-1-29) //.... [](https://ackee.xyz/trident/docs/dev/trident-advanced/dashboard/#__codelineno-1-30) } [](https://ackee.xyz/trident/docs/dev/trident-advanced/dashboard/#__codelineno-1-31) #[flow(weight = 90)] [](https://ackee.xyz/trident/docs/dev/trident-advanced/dashboard/#__codelineno-1-32) fn flow3(&mut self) { [](https://ackee.xyz/trident/docs/dev/trident-advanced/dashboard/#__codelineno-1-33) //.... [](https://ackee.xyz/trident/docs/dev/trident-advanced/dashboard/#__codelineno-1-34) } [](https://ackee.xyz/trident/docs/dev/trident-advanced/dashboard/#__codelineno-1-35) #[end] [](https://ackee.xyz/trident/docs/dev/trident-advanced/dashboard/#__codelineno-1-36) fn cleanup(&mut self) -> Result<(), FuzzingError> { [](https://ackee.xyz/trident/docs/dev/trident-advanced/dashboard/#__codelineno-1-37) //.... [](https://ackee.xyz/trident/docs/dev/trident-advanced/dashboard/#__codelineno-1-38) } [](https://ackee.xyz/trident/docs/dev/trident-advanced/dashboard/#__codelineno-1-39) }` Back to top --- # Regression testing - Trident [Skip to content](https://ackee.xyz/trident/docs/dev/trident-advanced/regression/#regression-testing) Regression testing[#](https://ackee.xyz/trident/docs/dev/trident-advanced/regression/#regression-testing "Permanent link") =========================================================================================================================== Regression testing is the process of re-running tests to ensure that previously working functionality still works after code changes. Trident allows for regression testing by specifying which accounts should be included in the regression test, generating a JSON file format with all monitored state and providing a subcommand to compare two regression test results. Regression test setup[#](https://ackee.xyz/trident/docs/dev/trident-advanced/regression/#regression-test-setup "Permanent link") --------------------------------------------------------------------------------------------------------------------------------- 1. First, decide which account(s) should be included in the regression test. 2. Add the accounts for tracking, this can be done as shown in the following code snippet. Check the `add_to_regression` method. `[](https://ackee.xyz/trident/docs/dev/trident-advanced/regression/#__codelineno-0-1) #[flow_executor] [](https://ackee.xyz/trident/docs/dev/trident-advanced/regression/#__codelineno-0-2) impl FuzzTest { [](https://ackee.xyz/trident/docs/dev/trident-advanced/regression/#__codelineno-0-3) fn new() -> Self { [](https://ackee.xyz/trident/docs/dev/trident-advanced/regression/#__codelineno-0-4) Self { [](https://ackee.xyz/trident/docs/dev/trident-advanced/regression/#__codelineno-0-5) trident: Trident::default(), [](https://ackee.xyz/trident/docs/dev/trident-advanced/regression/#__codelineno-0-6) fuzz_accounts: FuzzAccounts::default(), [](https://ackee.xyz/trident/docs/dev/trident-advanced/regression/#__codelineno-0-7) } [](https://ackee.xyz/trident/docs/dev/trident-advanced/regression/#__codelineno-0-8) } [](https://ackee.xyz/trident/docs/dev/trident-advanced/regression/#__codelineno-0-9) [](https://ackee.xyz/trident/docs/dev/trident-advanced/regression/#__codelineno-0-10) #[init] [](https://ackee.xyz/trident/docs/dev/trident-advanced/regression/#__codelineno-0-11) fn start(&mut self) { [](https://ackee.xyz/trident/docs/dev/trident-advanced/regression/#__codelineno-0-12) let mut ix = InitializeFnTransaction::build(&mut self.trident, &mut self.fuzz_accounts); [](https://ackee.xyz/trident/docs/dev/trident-advanced/regression/#__codelineno-0-13) [](https://ackee.xyz/trident/docs/dev/trident-advanced/regression/#__codelineno-0-14) self.trident.execute_transaction(&mut ix, Some("Init")); [](https://ackee.xyz/trident/docs/dev/trident-advanced/regression/#__codelineno-0-15) [](https://ackee.xyz/trident/docs/dev/trident-advanced/regression/#__codelineno-0-16) // Add the account to the regression test [](https://ackee.xyz/trident/docs/dev/trident-advanced/regression/#__codelineno-0-17) self.trident.add_to_regression( [](https://ackee.xyz/trident/docs/dev/trident-advanced/regression/#__codelineno-0-18) &ix.instruction.accounts.hello_world_account.pubkey(), [](https://ackee.xyz/trident/docs/dev/trident-advanced/regression/#__codelineno-0-19) "hello_world_account", [](https://ackee.xyz/trident/docs/dev/trident-advanced/regression/#__codelineno-0-20) ); [](https://ackee.xyz/trident/docs/dev/trident-advanced/regression/#__codelineno-0-21) } [](https://ackee.xyz/trident/docs/dev/trident-advanced/regression/#__codelineno-0-22) [](https://ackee.xyz/trident/docs/dev/trident-advanced/regression/#__codelineno-0-23) #[flow(weight = 5)] [](https://ackee.xyz/trident/docs/dev/trident-advanced/regression/#__codelineno-0-24) fn flow1(&mut self) { [](https://ackee.xyz/trident/docs/dev/trident-advanced/regression/#__codelineno-0-25) // This flow will be executed 60% of the time [](https://ackee.xyz/trident/docs/dev/trident-advanced/regression/#__codelineno-0-26) let mut ix = InitializeFnTransaction::build(&mut self.trident, &mut self.fuzz_accounts); [](https://ackee.xyz/trident/docs/dev/trident-advanced/regression/#__codelineno-0-27) self.trident.execute_transaction(&mut ix, Some("Flow1")); [](https://ackee.xyz/trident/docs/dev/trident-advanced/regression/#__codelineno-0-28) } [](https://ackee.xyz/trident/docs/dev/trident-advanced/regression/#__codelineno-0-29) [](https://ackee.xyz/trident/docs/dev/trident-advanced/regression/#__codelineno-0-30) #[flow(weight = 5)] [](https://ackee.xyz/trident/docs/dev/trident-advanced/regression/#__codelineno-0-31) fn flow2(&mut self) { [](https://ackee.xyz/trident/docs/dev/trident-advanced/regression/#__codelineno-0-32) // This flow will be executed 40% of the time [](https://ackee.xyz/trident/docs/dev/trident-advanced/regression/#__codelineno-0-33) let mut ix = InitializeFnTransaction::build(&mut self.trident, &mut self.fuzz_accounts); [](https://ackee.xyz/trident/docs/dev/trident-advanced/regression/#__codelineno-0-34) self.trident.execute_transaction(&mut ix, Some("Flow2")); [](https://ackee.xyz/trident/docs/dev/trident-advanced/regression/#__codelineno-0-35) } [](https://ackee.xyz/trident/docs/dev/trident-advanced/regression/#__codelineno-0-36) #[flow(weight = 90)] [](https://ackee.xyz/trident/docs/dev/trident-advanced/regression/#__codelineno-0-37) fn flow3(&mut self) { [](https://ackee.xyz/trident/docs/dev/trident-advanced/regression/#__codelineno-0-38) // This flow will be executed 40% of the time [](https://ackee.xyz/trident/docs/dev/trident-advanced/regression/#__codelineno-0-39) let mut ix = InitializeFnTransaction::build(&mut self.trident, &mut self.fuzz_accounts); [](https://ackee.xyz/trident/docs/dev/trident-advanced/regression/#__codelineno-0-40) self.trident.execute_transaction(&mut ix, Some("Flow3")); [](https://ackee.xyz/trident/docs/dev/trident-advanced/regression/#__codelineno-0-41) } [](https://ackee.xyz/trident/docs/dev/trident-advanced/regression/#__codelineno-0-42) [](https://ackee.xyz/trident/docs/dev/trident-advanced/regression/#__codelineno-0-43) #[end] [](https://ackee.xyz/trident/docs/dev/trident-advanced/regression/#__codelineno-0-44) fn cleanup(&mut self) -> Result<(), FuzzingError> { [](https://ackee.xyz/trident/docs/dev/trident-advanced/regression/#__codelineno-0-45) // This method will be called after all flows have been executed [](https://ackee.xyz/trident/docs/dev/trident-advanced/regression/#__codelineno-0-46) Ok(()) [](https://ackee.xyz/trident/docs/dev/trident-advanced/regression/#__codelineno-0-47) } [](https://ackee.xyz/trident/docs/dev/trident-advanced/regression/#__codelineno-0-48) } [](https://ackee.xyz/trident/docs/dev/trident-advanced/regression/#__codelineno-0-49)[](https://ackee.xyz/trident/docs/dev/trident-advanced/regression/#__codelineno-0-50) fn main() { [](https://ackee.xyz/trident/docs/dev/trident-advanced/regression/#__codelineno-0-51) FuzzTest::fuzz(1000, 100); [](https://ackee.xyz/trident/docs/dev/trident-advanced/regression/#__codelineno-0-52) }` 3. Enable the regression test in the [Trident manifest](https://ackee.xyz/trident/docs/dev/trident-manifest/#fuzzing-metrics) by setting: `[](https://ackee.xyz/trident/docs/dev/trident-advanced/regression/#__codelineno-1-1) [fuzz.regression] [](https://ackee.xyz/trident/docs/dev/trident-advanced/regression/#__codelineno-1-2) enabled = true` 4. Run the fuzz test to generate the regression test data. 5. Run the same fuzz test with the same MASTER SEED on a different version of the program. 6. Run the following command to compare the generated JSON files. `[](https://ackee.xyz/trident/docs/dev/trident-advanced/regression/#__codelineno-2-1) trident compare ` Back to top --- # Changelog - Trident [Skip to content](https://ackee.xyz/trident/docs/0.8.1/CHANGELOG/#changelog) Changelog[#](https://ackee.xyz/trident/docs/0.8.1/CHANGELOG/#changelog "Permanent link") ========================================================================================= All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) , and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html) (SemVer). **Note**: Version 0 of Semantic Versioning is handled differently from version 1 and above. The minor version will be incremented upon a breaking change and the patch version will be incremented for features. \[dev\] - Unreleased[#](https://ackee.xyz/trident/docs/0.8.1/CHANGELOG/#dev-unreleased "Permanent link") --------------------------------------------------------------------------------------------------------- \[0.8.1\] - 2024-11-14[#](https://ackee.xyz/trident/docs/0.8.1/CHANGELOG/#081-2024-11-14 "Permanent link") ----------------------------------------------------------------------------------------------------------- **Removed** * removed unnecesarry deserialization with AccountsSnapshots, to deserialize data implementation AccountDeserialize can be used ([221](https://github.com/Ackee-Blockchain/trident/pull/221) ) **Changed** * improve AccountsStorage module structure and remove unnecessary methods in FuzzClient ([223](https://github.com/Ackee-Blockchain/trident/pull/223) ) * improve manipulations with AccountsStorages in get\_accounts() function ([219](https://github.com/Ackee-Blockchain/trident/pull/219) ) **Added** * add pre\_sequence!, middle\_sequence! and post\_sequence! for easier sequence definition ([220](https://github.com/Ackee-Blockchain/trident/pull/220) ) * add/ add support for Clock sysvar manipulations with the client(i.e. warp to slot/epoch and forward in time) ([217](https://github.com/Ackee-Blockchain/trident/pull/217) ) \[0.8.0\] - 2024-10-21[#](https://ackee.xyz/trident/docs/0.8.1/CHANGELOG/#080-2024-10-21 "Permanent link") ----------------------------------------------------------------------------------------------------------- **Added** * impr/ allow to specify programs and accounts in the Trident Manifest ([207](https://github.com/Ackee-Blockchain/trident/pull/207) ) * impr/ added get\_program\_id function to the IxOps and FuzzTestExecutor ([199](https://github.com/Ackee-Blockchain/trident/pull/199) ) **Changed** * impr/ improve init command, modify program manifest automatically, add init force, add howto subcommand ([208](https://github.com/Ackee-Blockchain/trident/pull/208) ) * impr/ allow to derive AccountsSnapshots for empty Account Context ([209](https://github.com/Ackee-Blockchain/trident/pull/209) ) * impr/ fuzz flags are read at start of fuzzing session from Config instead of env variable and transaction dispatch was added to increase FuzzTestExecutor readability ([204](https://github.com/Ackee-Blockchain/trident/pull/204) ) * impr/ allow various instructions to be generated in case of multiple programs in the Anchor workspace ([200](https://github.com/Ackee-Blockchain/trident/pull/200) ) * feat/ option to add account into Fuzz Test environment with base64 data ([197](https://github.com/Ackee-Blockchain/trident/pull/197) ) * impr/ instead of parsing source code and creating our IDL, read anchor IDL ([198](https://github.com/Ackee-Blockchain/trident/pull/196) ) **Removed** * del/remove integration tests supported by Trident, this feature adds more unnecessary overhead compared to its value ([196](https://github.com/Ackee-Blockchain/trident/pull/198) ) \[0.7.0\] - 2024-08-14[#](https://ackee.xyz/trident/docs/0.8.1/CHANGELOG/#070-2024-08-14 "Permanent link") ----------------------------------------------------------------------------------------------------------- **Added** * impr/ add feature flag to the AccountsSnapshots macro ([183](https://github.com/Ackee-Blockchain/trident/pull/183) ) * feat/ add Support for CPI ([182](https://github.com/Ackee-Blockchain/trident/pull/182) ) * feat/ add option to initialize Trident with Macro/File (for Snapshots) option based on preference ([179](https://github.com/Ackee-Blockchain/trident/pull/179) ) * feat/create AccountsSnapshots derive macro for Snapshots creation ([#177](https://github.com/Ackee-Blockchain/trident/pull/177) ) * feat/fuzzing moved to separate crate trident-fuzz ([#175](https://github.com/Ackee-Blockchain/trident/pull/175) ) * feat/unify dependencies provided by the Trident ([#172](https://github.com/Ackee-Blockchain/trident/pull/172) ) * feat/fuzzer-stats-logging, an optional statistics output for fuzzing session ([#144](https://github.com/Ackee-Blockchain/trident/pull/144) ) **Fixed** * fix/in case of fuzzing failure throw error instead of only printing message ([#167](https://github.com/Ackee-Blockchain/trident/pull/167) ) * fix/snapshot's zeroed account as optional ([#170](https://github.com/Ackee-Blockchain/trident/pull/170) ) **Removed** * del/remove localnet subcommand ([178](https://github.com/Ackee-Blockchain/trident/pull/178) ) * del/remove unnecessary fuzzing feature as trident is mainly fuzzer ([#176](https://github.com/Ackee-Blockchain/trident/pull/176) ) * del/remove Trident explorer ([#171](https://github.com/Ackee-Blockchain/trident/pull/171) ) \[0.6.0\] - 2024-05-20[#](https://ackee.xyz/trident/docs/0.8.1/CHANGELOG/#060-2024-05-20 "Permanent link") ----------------------------------------------------------------------------------------------------------- **Added** * feat/anchor 0.30.0 support ([#148](https://github.com/Ackee-Blockchain/trident/pull/148) ) * fix/allow to process duplicate transactions ([#147](https://github.com/Ackee-Blockchain/trident/pull/147) ) * feat/possibility to implement custom transaction error handling ([#145](https://github.com/Ackee-Blockchain/trident/pull/145) ) * feat/support of automatically obtaining fully qualified paths of Data Accounts Custom types for `accounts_snapshots.rs` ([#141](https://github.com/Ackee-Blockchain/trident/pull/141) ) * feat/allow direct accounts manipulation and storage ([#142](https://github.com/Ackee-Blockchain/trident/pull/142) ) * feat/support of non-corresponding instruction and context names ([#130](https://github.com/Ackee-Blockchain/trident/pull/130) ) * feat/refactored and improved program flow during init and build, added activity indicator ([#129](https://github.com/Ackee-Blockchain/trident/pull/129) ) * feat/allow solana versions up to v1.17.\* and pin Rust 1.77 nightly compiler ([#128](https://github.com/Ackee-Blockchain/trident/pull/128) ) * feat/new init command option to initialize fuzz or poc tests only ([#124](https://github.com/Ackee-Blockchain/trident/pull/124) ) * feat/debug-mode detailed output ([#125](https://github.com/Ackee-Blockchain/trident/pull/125) ) * feat/anchor 0.29.0 support ([#121](https://github.com/Ackee-Blockchain/trident/pull/121) ) * doc/add help comment + update documentation ([#120](https://github.com/Ackee-Blockchain/trident/pull/120) ) * feat/fuzzer error handling ([#118](https://github.com/Ackee-Blockchain/trident/pull/118) ) * feat/convert fuzz Pubkey to AccountId ([#116](https://github.com/Ackee-Blockchain/trident/pull/116) ) * feat/additional anchor types ([#115](https://github.com/Ackee-Blockchain/trident/pull/115) ) * feat/import ToAccountInfo trait in fuzzing prelude ([#113](https://github.com/Ackee-Blockchain/trident/pull/113) ) * test/added code generation and macros tests ([#112](https://github.com/Ackee-Blockchain/trident/pull/112) ) * feat/fuzzer framework core, macros, helpers, templates, and examples. ([#111](https://github.com/Ackee-Blockchain/trident/pull/111) ) * feat/improved trident-tests folder structure for PoC and Fuzz Tests ([#109](https://github.com/Ackee-Blockchain/trident/pull/109) ) * feat/support for additional fuzzer parameters in Trident.toml config file ([#107](https://github.com/Ackee-Blockchain/trident/pull/107) ) * feat/posibility to pass params to the fuzzer via Trident.toml config file ([#106](https://github.com/Ackee-Blockchain/trident/pull/106) ) * feat/client now reads by default keypair from default location ([#105](https://github.com/Ackee-Blockchain/trident/pull/105) ) * feat/added new --exit-code option to return corresponding exit code based on fuzz test result ([#104](https://github.com/Ackee-Blockchain/trident/pull/104) ) * feat/removed/updated deprecated functions, removed allow deprecated macros ([#103](https://github.com/Ackee-Blockchain/trident/pull/103) ) * feat/added new function to read keypair file generated by Anchor ([#102](https://github.com/Ackee-Blockchain/trident/pull/102) ) * feat/clean command ([#101](https://github.com/Ackee-Blockchain/trident/pull/101) ) * feat/improved program\_client generated code ([#100](https://github.com/Ackee-Blockchain/trident/pull/100) ) * feat/automatically add hfuzz\_target to .gitignore file ([#99](https://github.com/Ackee-Blockchain/trident/pull/99) ) * feat/support for dynamic templates. ([#98](https://github.com/Ackee-Blockchain/trident/pull/98) ) **Fixed** * fix/refactored fuzz test executor error handling ([#127](https://github.com/Ackee-Blockchain/trident/pull/127) ) * fix/warn user on composite accounts and continue fuzz test generation ([#133](https://github.com/Ackee-Blockchain/trident/pull/133) ) * fix/progress bar loop lock release ([#132](https://github.com/Ackee-Blockchain/trident/pull/132) ) * fix/fixed fuzz test generation with init-if-needed Anchor feature ([#131](https://github.com/Ackee-Blockchain/trident/pull/131) ) * fix/program client custom types ([#117](https://github.com/Ackee-Blockchain/trident/pull/117) ) * fix/check fuzz test name collision by checking the name against HashSet ([#114](https://github.com/Ackee-Blockchain/trident/pull/114) ) \[0.5.0\] - 2023-08-28[#](https://ackee.xyz/trident/docs/0.8.1/CHANGELOG/#050-2023-08-28 "Permanent link") ----------------------------------------------------------------------------------------------------------- **Added** * cli: Added trident subcommand `fuzz` to run and debug fuzz tests using honggfuzz-rs. * cli: Added trident `--skip-fuzzer` option for `init` subcommand to skip generation of fuzz test templates. * client: Added new Cargo feature `fuzzing` that enables optional dependencies related to fuzz testing. \[0.4.1\] - 2023-08-21[#](https://ackee.xyz/trident/docs/0.8.1/CHANGELOG/#041-2023-08-21 "Permanent link") ----------------------------------------------------------------------------------------------------------- **Changed** * Upgrade Solana (`=1.16.6`) and Anchor framework (`=0.28.0`) versions. **Fixed** * Implemented Anchor Client logic was not able to work with newer version of Anchor. Fixed with `async_rpc` and `async` feature. * Trident init IDL Parse Error on newer version of Rust, fixed with updated `accounts` token. \[0.3.0\] - 2022-09-23[#](https://ackee.xyz/trident/docs/0.8.1/CHANGELOG/#030-2022-09-23 "Permanent link") ----------------------------------------------------------------------------------------------------------- **Changed** * Upgrade Solana (`~1.10`) and Anchor framework (`~0.25`) versions **Added** * Custom Solana RPC error reporter. If the Solana RPC error is thrown, the error code, message and data (logs) are reported to the output. * Custom imports in the `.program_client`. User is able to import custom types and structures into program client. The import part of the code would not be re-generated. \[0.2.0\] - 2022-07-27[#](https://ackee.xyz/trident/docs/0.8.1/CHANGELOG/#020-2022-07-27 "Permanent link") ----------------------------------------------------------------------------------------------------------- **Added** * Trident is now configurable. This requires `Trident.toml` file to exist in the project's root directory - without this file the execution will fail. To solve this re-run `trident init` or just create an empty `Trident.toml` file in the project's root directory. Back to top --- # General Configuration - Trident [Skip to content](https://ackee.xyz/trident/docs/0.10.0/trident-manifest/general/#general-configuration) General Configuration[#](https://ackee.xyz/trident/docs/0.10.0/trident-manifest/general/#general-configuration "Permanent link") ================================================================================================================================= `programs`[#](https://ackee.xyz/trident/docs/0.10.0/trident-manifest/general/#programs "Permanent link") --------------------------------------------------------------------------------------------------------- * Use dumped program from desired cluster, during fuzzing. `[](https://ackee.xyz/trident/docs/0.10.0/trident-manifest/general/#__codelineno-0-1) [[fuzz.programs]] [](https://ackee.xyz/trident/docs/0.10.0/trident-manifest/general/#__codelineno-0-2) address = "metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s" [](https://ackee.xyz/trident/docs/0.10.0/trident-manifest/general/#__codelineno-0-3) program = "metaplex-program/metaplex-token-metadata.so"` * * * `accounts`[#](https://ackee.xyz/trident/docs/0.10.0/trident-manifest/general/#accounts "Permanent link") --------------------------------------------------------------------------------------------------------- * Use dumped accounts from desired cluster, during fuzzing. `[](https://ackee.xyz/trident/docs/0.10.0/trident-manifest/general/#__codelineno-1-1) [[fuzz.accounts]] [](https://ackee.xyz/trident/docs/0.10.0/trident-manifest/general/#__codelineno-1-2) address = "6YG3J7PaxyMnnbU67ifyrgF3BzNzc7cD8hPkqK6ATweE" [](https://ackee.xyz/trident/docs/0.10.0/trident-manifest/general/#__codelineno-1-3) filename = "tests/accounts/core_bridge_mainnet/guardian_set_5_mock.json"` * * * `fuzzing_with_stats`[#](https://ackee.xyz/trident/docs/0.10.0/trident-manifest/general/#fuzzing_with_stats "Permanent link") ----------------------------------------------------------------------------------------------------------------------------- * Trident will show statistics after the fuzzing session. This option forces use of honggfuzz parameter `keep_output` as true in order to be able to catch fuzzer stdout. `(default: false)` Statistics Support Limitation Fuzzing with stats is currently not supported with `AFL`. `[](https://ackee.xyz/trident/docs/0.10.0/trident-manifest/general/#__codelineno-2-1) [fuzz] [](https://ackee.xyz/trident/docs/0.10.0/trident-manifest/general/#__codelineno-2-2) fuzzing_with_stats = true` * * * `allow_duplicate_txs`[#](https://ackee.xyz/trident/docs/0.10.0/trident-manifest/general/#allow_duplicate_txs "Permanent link") ------------------------------------------------------------------------------------------------------------------------------- * Allow processing of duplicate transactions. Setting to true might speed up fuzzing but can cause false positive crashes. `(default: false)` Transaction Validity Check With swtich from `ProgramTest` to `TridentSVM`, there is no check for the transactions validity, so this check currently does nothing. `[](https://ackee.xyz/trident/docs/0.10.0/trident-manifest/general/#__codelineno-3-1) [fuzz] [](https://ackee.xyz/trident/docs/0.10.0/trident-manifest/general/#__codelineno-3-2) allow_duplicate_txs = false` Back to top --- # AFL Configuration - Trident [Skip to content](https://ackee.xyz/trident/docs/0.10.0/trident-manifest/afl/#afl-configuration) AFL Configuration[#](https://ackee.xyz/trident/docs/0.10.0/trident-manifest/afl/#afl-configuration "Permanent link") ===================================================================================================================== `run_time`[#](https://ackee.xyz/trident/docs/0.10.0/trident-manifest/afl/#run_time "Permanent link") ----------------------------------------------------------------------------------------------------- * Number of seconds this fuzzing session will last. `(default: 0 [no limit])` `[](https://ackee.xyz/trident/docs/0.10.0/trident-manifest/afl/#__codelineno-0-1) [afl] [](https://ackee.xyz/trident/docs/0.10.0/trident-manifest/afl/#__codelineno-0-2) run_time = 0` * * * `iterations`[#](https://ackee.xyz/trident/docs/0.10.0/trident-manifest/afl/#iterations "Permanent link") --------------------------------------------------------------------------------------------------------- * Number of fuzzing iterations. `(default: 0 [no limit])` `[](https://ackee.xyz/trident/docs/0.10.0/trident-manifest/afl/#__codelineno-1-1) [afl] [](https://ackee.xyz/trident/docs/0.10.0/trident-manifest/afl/#__codelineno-1-2) iterations = 0` * * * `cargo_target_dir`[#](https://ackee.xyz/trident/docs/0.10.0/trident-manifest/afl/#cargo_target_dir "Permanent link") --------------------------------------------------------------------------------------------------------------------- * Target compilation directory, to not clash with cargo build's default target directory. `(default: "" ["trident-tests/fuzz_tests/fuzzing/afl/afl_target"])` `[](https://ackee.xyz/trident/docs/0.10.0/trident-manifest/afl/#__codelineno-2-1) [afl] [](https://ackee.xyz/trident/docs/0.10.0/trident-manifest/afl/#__codelineno-2-2) cargo_target_dir = ""` * * * `afl_workspace_in`[#](https://ackee.xyz/trident/docs/0.10.0/trident-manifest/afl/#afl_workspace_in "Permanent link") --------------------------------------------------------------------------------------------------------------------- * AFL working input directory. `(default: "" ["trident-tests/fuzz_tests/fuzzing/afl/afl_workspace/in"])` `[](https://ackee.xyz/trident/docs/0.10.0/trident-manifest/afl/#__codelineno-3-1) [afl] [](https://ackee.xyz/trident/docs/0.10.0/trident-manifest/afl/#__codelineno-3-2) afl_workspace_in = ""` * * * `afl_workspace_out`[#](https://ackee.xyz/trident/docs/0.10.0/trident-manifest/afl/#afl_workspace_out "Permanent link") ----------------------------------------------------------------------------------------------------------------------- * AFL working output directory. `(default: "" ["trident-tests/fuzz_tests/fuzzing/afl/afl_workspace/out"])` `[](https://ackee.xyz/trident/docs/0.10.0/trident-manifest/afl/#__codelineno-4-1) [afl] [](https://ackee.xyz/trident/docs/0.10.0/trident-manifest/afl/#__codelineno-4-2) afl_workspace_out = ""` * * * `seeds`[#](https://ackee.xyz/trident/docs/0.10.0/trident-manifest/afl/#seeds "Permanent link") ----------------------------------------------------------------------------------------------- * Predefined inputs to the AFL. You can specify multiple input seeds. Seed Generation Priority `bytes_count` has precedence before `seed`, in that case if both are specified. Seed is generated as random array of `bytes_count` bytes. * `file_name` * Filename under which the test input is generated, the location of file is `afl_workspace_in` directory. `(default: "" ["trident-seed"])` * `seed` * String used as seed. `(default: "" ["trident"])` * `override_file` * If the file already exists at specific location, select if override. `(default: false)` * `bytes_count` * Number of randomly generated bytes. `[](https://ackee.xyz/trident/docs/0.10.0/trident-manifest/afl/#__codelineno-5-1) [[afl.seeds]] [](https://ackee.xyz/trident/docs/0.10.0/trident-manifest/afl/#__codelineno-5-2) file_name = "" [](https://ackee.xyz/trident/docs/0.10.0/trident-manifest/afl/#__codelineno-5-3) seed = "" [](https://ackee.xyz/trident/docs/0.10.0/trident-manifest/afl/#__codelineno-5-4) override_file = true [](https://ackee.xyz/trident/docs/0.10.0/trident-manifest/afl/#__codelineno-5-5) bytes_count = 20` Back to top --- # Honggfuzz Configuration - Trident [Skip to content](https://ackee.xyz/trident/docs/0.10.0/trident-manifest/honggfuzz/#honggfuzz-configuration) Honggfuzz Configuration[#](https://ackee.xyz/trident/docs/0.10.0/trident-manifest/honggfuzz/#honggfuzz-configuration "Permanent link") ======================================================================================================================================= `run_time`[#](https://ackee.xyz/trident/docs/0.10.0/trident-manifest/honggfuzz/#run_time "Permanent link") ----------------------------------------------------------------------------------------------------------- * Number of seconds this fuzzing session will last. `(default: 0 [no limit])` `[](https://ackee.xyz/trident/docs/0.10.0/trident-manifest/honggfuzz/#__codelineno-0-1) [honggfuzz] [](https://ackee.xyz/trident/docs/0.10.0/trident-manifest/honggfuzz/#__codelineno-0-2) run_time = 0` * * * `iterations`[#](https://ackee.xyz/trident/docs/0.10.0/trident-manifest/honggfuzz/#iterations "Permanent link") --------------------------------------------------------------------------------------------------------------- * Number of fuzzing iterations. `(default: 0 [no limit])` `[](https://ackee.xyz/trident/docs/0.10.0/trident-manifest/honggfuzz/#__codelineno-1-1) [honggfuzz] [](https://ackee.xyz/trident/docs/0.10.0/trident-manifest/honggfuzz/#__codelineno-1-2) iterations = 0` * * * `threads`[#](https://ackee.xyz/trident/docs/0.10.0/trident-manifest/honggfuzz/#threads "Permanent link") --------------------------------------------------------------------------------------------------------- * Number of concurrent fuzzing threads. `(default: 0 [number of CPUs / 2])` `[](https://ackee.xyz/trident/docs/0.10.0/trident-manifest/honggfuzz/#__codelineno-2-1) ```bash [](https://ackee.xyz/trident/docs/0.10.0/trident-manifest/honggfuzz/#__codelineno-2-2) [honggfuzz] [](https://ackee.xyz/trident/docs/0.10.0/trident-manifest/honggfuzz/#__codelineno-2-3) threads = 0` * * * `keep_output`[#](https://ackee.xyz/trident/docs/0.10.0/trident-manifest/honggfuzz/#keep_output "Permanent link") ----------------------------------------------------------------------------------------------------------------- * Don't close children's stdin, stdout, stderr; can be noisy. `(default: false)` `[](https://ackee.xyz/trident/docs/0.10.0/trident-manifest/honggfuzz/#__codelineno-3-1) [honggfuzz] [](https://ackee.xyz/trident/docs/0.10.0/trident-manifest/honggfuzz/#__codelineno-3-2) keep_output = false` * * * `verbose`[#](https://ackee.xyz/trident/docs/0.10.0/trident-manifest/honggfuzz/#verbose "Permanent link") --------------------------------------------------------------------------------------------------------- * Disable ANSI console; use simple log output. `(default: false)` `[](https://ackee.xyz/trident/docs/0.10.0/trident-manifest/honggfuzz/#__codelineno-4-1) [honggfuzz] [](https://ackee.xyz/trident/docs/0.10.0/trident-manifest/honggfuzz/#__codelineno-4-2) verbose = false` * * * `exit_upon_crash`[#](https://ackee.xyz/trident/docs/0.10.0/trident-manifest/honggfuzz/#exit_upon_crash "Permanent link") ------------------------------------------------------------------------------------------------------------------------- * Exit upon seeing the first crash. `(default: false)` `[](https://ackee.xyz/trident/docs/0.10.0/trident-manifest/honggfuzz/#__codelineno-5-1) [honggfuzz] [](https://ackee.xyz/trident/docs/0.10.0/trident-manifest/honggfuzz/#__codelineno-5-2) exit_upon_crash = false` * * * `mutations_per_run`[#](https://ackee.xyz/trident/docs/0.10.0/trident-manifest/honggfuzz/#mutations_per_run "Permanent link") ----------------------------------------------------------------------------------------------------------------------------- * Maximal number of mutations per one run. `(default: 6)` `[](https://ackee.xyz/trident/docs/0.10.0/trident-manifest/honggfuzz/#__codelineno-6-1) [honggfuzz] [](https://ackee.xyz/trident/docs/0.10.0/trident-manifest/honggfuzz/#__codelineno-6-2) mutations_per_run = 6` * * * `cargo_target_dir`[#](https://ackee.xyz/trident/docs/0.10.0/trident-manifest/honggfuzz/#cargo_target_dir "Permanent link") --------------------------------------------------------------------------------------------------------------------------- * Target compilation directory, to not clash with cargo build's default target directory. `(default: "" ["trident-tests/fuzzing/honggfuzz/hfuzz_target"])` `[](https://ackee.xyz/trident/docs/0.10.0/trident-manifest/honggfuzz/#__codelineno-7-1) [honggfuzz] [](https://ackee.xyz/trident/docs/0.10.0/trident-manifest/honggfuzz/#__codelineno-7-2) cargo_target_dir = ""` * * * `hfuzz_workspace`[#](https://ackee.xyz/trident/docs/0.10.0/trident-manifest/honggfuzz/#hfuzz_workspace "Permanent link") ------------------------------------------------------------------------------------------------------------------------- * Honggfuzz working directory. `(default: "" ["trident-tests/fuzzing/honggfuzz/hfuzz_workspace"])` `[](https://ackee.xyz/trident/docs/0.10.0/trident-manifest/honggfuzz/#__codelineno-8-1) [honggfuzz] [](https://ackee.xyz/trident/docs/0.10.0/trident-manifest/honggfuzz/#__codelineno-8-2) hfuzz_workspace = ""` * * * `crashdir`[#](https://ackee.xyz/trident/docs/0.10.0/trident-manifest/honggfuzz/#crashdir "Permanent link") ----------------------------------------------------------------------------------------------------------- * Directory where crashes are saved to. `(default: "" [workspace directory])` `[](https://ackee.xyz/trident/docs/0.10.0/trident-manifest/honggfuzz/#__codelineno-9-1) [honggfuzz] [](https://ackee.xyz/trident/docs/0.10.0/trident-manifest/honggfuzz/#__codelineno-9-2) crashdir = ""` * * * `extension`[#](https://ackee.xyz/trident/docs/0.10.0/trident-manifest/honggfuzz/#extension "Permanent link") ------------------------------------------------------------------------------------------------------------- * Input file extension. `(default: "" ['fuzz'])` `[](https://ackee.xyz/trident/docs/0.10.0/trident-manifest/honggfuzz/#__codelineno-10-1) [honggfuzz] [](https://ackee.xyz/trident/docs/0.10.0/trident-manifest/honggfuzz/#__codelineno-10-2) extension = "fuzz"` * * * `timeout`[#](https://ackee.xyz/trident/docs/0.10.0/trident-manifest/honggfuzz/#timeout "Permanent link") --------------------------------------------------------------------------------------------------------- * Timeout in seconds. This will terminate the fuzzing thread if it's running for more than this time. `(default: 10)` `[](https://ackee.xyz/trident/docs/0.10.0/trident-manifest/honggfuzz/#__codelineno-11-1) [honggfuzz] [](https://ackee.xyz/trident/docs/0.10.0/trident-manifest/honggfuzz/#__codelineno-11-2) timeout = 10` * * * `max_file_size`[#](https://ackee.xyz/trident/docs/0.10.0/trident-manifest/honggfuzz/#max_file_size "Permanent link") --------------------------------------------------------------------------------------------------------------------- * Maximal size of files processed by the fuzzer in bytes. `(default: 1048576 = 1MB)` `[](https://ackee.xyz/trident/docs/0.10.0/trident-manifest/honggfuzz/#__codelineno-12-1) [honggfuzz] [](https://ackee.xyz/trident/docs/0.10.0/trident-manifest/honggfuzz/#__codelineno-12-2) max_file_size = 1048576` * * * `save_all`[#](https://ackee.xyz/trident/docs/0.10.0/trident-manifest/honggfuzz/#save_all "Permanent link") ----------------------------------------------------------------------------------------------------------- * Save all test-cases (not only the unique ones) by appending the current time-stamp to the filenames. `(default: false)` `[](https://ackee.xyz/trident/docs/0.10.0/trident-manifest/honggfuzz/#__codelineno-13-1) [honggfuzz] [](https://ackee.xyz/trident/docs/0.10.0/trident-manifest/honggfuzz/#__codelineno-13-2) save_all = false` Back to top --- # Fuzzing Statistics - Trident [Skip to content](https://ackee.xyz/trident/docs/0.8.1/features/fuzzing-statistics/#fuzzing-statistics) Fuzzing Statistics[#](https://ackee.xyz/trident/docs/0.8.1/features/fuzzing-statistics/#fuzzing-statistics "Permanent link") ============================================================================================================================= Trident allows you to see statistics after the fuzzing session ended. Important In order to show statistics set `fuzzing_with_stats` within the `Trident.toml` to `true`. `[](https://ackee.xyz/trident/docs/0.8.1/features/fuzzing-statistics/#__codelineno-0-1) [fuzz] [](https://ackee.xyz/trident/docs/0.8.1/features/fuzzing-statistics/#__codelineno-0-2) # ... [](https://ackee.xyz/trident/docs/0.8.1/features/fuzzing-statistics/#__codelineno-0-3) fuzzing_with_stats = true [](https://ackee.xyz/trident/docs/0.8.1/features/fuzzing-statistics/#__codelineno-0-4) # ...` Available Statistics[#](https://ackee.xyz/trident/docs/0.8.1/features/fuzzing-statistics/#available-statistics "Permanent link") --------------------------------------------------------------------------------------------------------------------------------- ### Simple[#](https://ackee.xyz/trident/docs/0.8.1/features/fuzzing-statistics/#simple "Permanent link") * Number of invocations of each instruction during the fuzzing session. * Number of successful invocations of each instruction during the fuzzing session. * Number of failed invariants checks for each instruction during the fuzzing session. Note Keep in mind that the number of fuzz iterations does not directly correspond to the total number of invocations. In one fuzz iteration, the fuzzer might be unable to deserialize fuzz data into instructions, causing the entire iteration to be skipped. On the other hand this is expected behavior as the underlying data are randomly (with coverage feedback) generated, so the Honggfuzz will not necessarily find appropriate data each iteration. Tip Consider checking the [Examples](https://ackee.xyz/trident/docs/0.8.1/examples/examples/) section for more tips. Back to top --- # Invariant Checks - Trident [Skip to content](https://ackee.xyz/trident/docs/0.8.1/features/invariant-checks/#invariant-checks) Invariant Checks[#](https://ackee.xyz/trident/docs/0.8.1/features/invariant-checks/#invariant-checks "Permanent link") ======================================================================================================================= Trident allows you to (optionally) specify Invariant Checks for each Instruction. The Invariant Check will be called after the Instruction was successfully invoked. Within the Invariant Check you can compare the contents of Accounts before and after the Instruction was called. Important Returning error in the Invariant Check is considered as detected undesired behavior (i.e. issue/crash detected). `[](https://ackee.xyz/trident/docs/0.8.1/features/invariant-checks/#__codelineno-0-1) fn check( [](https://ackee.xyz/trident/docs/0.8.1/features/invariant-checks/#__codelineno-0-2) &self, [](https://ackee.xyz/trident/docs/0.8.1/features/invariant-checks/#__codelineno-0-3) _pre_ix: &[SnapshotAccount], [](https://ackee.xyz/trident/docs/0.8.1/features/invariant-checks/#__codelineno-0-4) post_ix: &[SnapshotAccount], [](https://ackee.xyz/trident/docs/0.8.1/features/invariant-checks/#__codelineno-0-5) _ix_data: Self::IxData, [](https://ackee.xyz/trident/docs/0.8.1/features/invariant-checks/#__codelineno-0-6) ) -> Result<(), FuzzingError> { [](https://ackee.xyz/trident/docs/0.8.1/features/invariant-checks/#__codelineno-0-7) if let Ok(hello_world_account) = [](https://ackee.xyz/trident/docs/0.8.1/features/invariant-checks/#__codelineno-0-8) hello_world::StoreHelloWorld::try_deserialize(&mut post_ix[1].data()) [](https://ackee.xyz/trident/docs/0.8.1/features/invariant-checks/#__codelineno-0-9) { [](https://ackee.xyz/trident/docs/0.8.1/features/invariant-checks/#__codelineno-0-10) if hello_world_account.input == 253 { [](https://ackee.xyz/trident/docs/0.8.1/features/invariant-checks/#__codelineno-0-11) return Err(FuzzingError::Custom(1)); [](https://ackee.xyz/trident/docs/0.8.1/features/invariant-checks/#__codelineno-0-12) } [](https://ackee.xyz/trident/docs/0.8.1/features/invariant-checks/#__codelineno-0-13) } [](https://ackee.xyz/trident/docs/0.8.1/features/invariant-checks/#__codelineno-0-14) Ok(()) [](https://ackee.xyz/trident/docs/0.8.1/features/invariant-checks/#__codelineno-0-15) }` Important Order of accounts within the array is the same as the order of accounts on the instruction input of your program. Account Deserialization[#](https://ackee.xyz/trident/docs/0.8.1/features/invariant-checks/#account-deserialization "Permanent link") ------------------------------------------------------------------------------------------------------------------------------------- The `SnapshotAccount` provides methods to obtain parts of the account (e.g. address, its data, owner etc.). If you want to deserialize data into struct defined within your program (or within for example `anchor-spl`), you can use approach from source code above, meaning utilze `try_deserialize` generated by anchor within your program. Tip Consider checking the [Examples](https://ackee.xyz/trident/docs/0.8.1/examples/examples/) section for more tips. Back to top --- # Instructions Sequences - Trident [Skip to content](https://ackee.xyz/trident/docs/0.8.1/features/instructions-sequences/#instructions-sequences) Instructions Sequences[#](https://ackee.xyz/trident/docs/0.8.1/features/instructions-sequences/#instructions-sequences "Permanent link") ========================================================================================================================================= Trident allows you to specify **custom Instruction squences** you would like to execute. Possible Instruction sequences are split into 3 parts * **pre-Instructions** * **Instructions** * **post-Instructions** For example if you program always needs to start with some kind of Initialization instruction, you can specify this Initialize Instruction using the `pre_sequence()` macro as shown in the source code below. ``[](https://ackee.xyz/trident/docs/0.8.1/features/instructions-sequences/#__codelineno-0-1) // test_fuzz.rs [](https://ackee.xyz/trident/docs/0.8.1/features/instructions-sequences/#__codelineno-0-2)[](https://ackee.xyz/trident/docs/0.8.1/features/instructions-sequences/#__codelineno-0-3) /// ... [](https://ackee.xyz/trident/docs/0.8.1/features/instructions-sequences/#__codelineno-0-4)[](https://ackee.xyz/trident/docs/0.8.1/features/instructions-sequences/#__codelineno-0-5) struct InstructionsSequence; [](https://ackee.xyz/trident/docs/0.8.1/features/instructions-sequences/#__codelineno-0-6) /// Define instruction sequences for invocation. [](https://ackee.xyz/trident/docs/0.8.1/features/instructions-sequences/#__codelineno-0-7) /// `pre` runs at the start, `middle` in the middle, and `post` at the end. [](https://ackee.xyz/trident/docs/0.8.1/features/instructions-sequences/#__codelineno-0-8) /// For example, to call `InitializeFn`, `UpdateFn` and then `WithdrawFn` during [](https://ackee.xyz/trident/docs/0.8.1/features/instructions-sequences/#__codelineno-0-9) /// each fuzzing iteration: [](https://ackee.xyz/trident/docs/0.8.1/features/instructions-sequences/#__codelineno-0-10) /// ``` [](https://ackee.xyz/trident/docs/0.8.1/features/instructions-sequences/#__codelineno-0-11) /// impl FuzzDataBuilder for InstructionsSequence { [](https://ackee.xyz/trident/docs/0.8.1/features/instructions-sequences/#__codelineno-0-12) /// pre_sequence!(InitializeFn,UpdateFn); [](https://ackee.xyz/trident/docs/0.8.1/features/instructions-sequences/#__codelineno-0-13) /// middle_sequence!(WithdrawFn); [](https://ackee.xyz/trident/docs/0.8.1/features/instructions-sequences/#__codelineno-0-14) ///} [](https://ackee.xyz/trident/docs/0.8.1/features/instructions-sequences/#__codelineno-0-15) /// ``` [](https://ackee.xyz/trident/docs/0.8.1/features/instructions-sequences/#__codelineno-0-16) /// For more details, see: https://ackee.xyz/trident/docs/dev/features/instructions-sequences/#instructions-sequences [](https://ackee.xyz/trident/docs/0.8.1/features/instructions-sequences/#__codelineno-0-17) impl FuzzDataBuilder for InstructionsSequence { [](https://ackee.xyz/trident/docs/0.8.1/features/instructions-sequences/#__codelineno-0-18) pre_sequence!(InitializeFn); [](https://ackee.xyz/trident/docs/0.8.1/features/instructions-sequences/#__codelineno-0-19) middle_sequence!(); [](https://ackee.xyz/trident/docs/0.8.1/features/instructions-sequences/#__codelineno-0-20) post_sequence!(); [](https://ackee.xyz/trident/docs/0.8.1/features/instructions-sequences/#__codelineno-0-21) } [](https://ackee.xyz/trident/docs/0.8.1/features/instructions-sequences/#__codelineno-0-22)[](https://ackee.xyz/trident/docs/0.8.1/features/instructions-sequences/#__codelineno-0-23) /// ...`` Tip * The arguments to the macro are variants of `FuzzInstruction` specified in `fuzz_instructions.rs`. * Empty macro parameters (such as `middle_sequence!()`), will skip that section, meaning no instructions will be executed during the section. * If no macro is defined for a section, a random instruction sequence will be generated for the section. Manual trait override[#](https://ackee.xyz/trident/docs/0.8.1/features/instructions-sequences/#manual-trait-override "Permanent link") --------------------------------------------------------------------------------------------------------------------------------------- It is not necessary to use the macro as explained above. The trait implementation (i.e., the methods) can be implemented manually, as shown in the code below. This approach allows for greater customization if needed. The rules are the same as described above. `[](https://ackee.xyz/trident/docs/0.8.1/features/instructions-sequences/#__codelineno-1-1) // test_fuzz.rs [](https://ackee.xyz/trident/docs/0.8.1/features/instructions-sequences/#__codelineno-1-2)[](https://ackee.xyz/trident/docs/0.8.1/features/instructions-sequences/#__codelineno-1-3) // do not forget to include the required structures [](https://ackee.xyz/trident/docs/0.8.1/features/instructions-sequences/#__codelineno-1-4) use fuzz_instructions::InitVesting; [](https://ackee.xyz/trident/docs/0.8.1/features/instructions-sequences/#__codelineno-1-5) use fuzz_instructions::WithdrawUnlocked; [](https://ackee.xyz/trident/docs/0.8.1/features/instructions-sequences/#__codelineno-1-6)[](https://ackee.xyz/trident/docs/0.8.1/features/instructions-sequences/#__codelineno-1-7) impl FuzzDataBuilder for MyFuzzData { [](https://ackee.xyz/trident/docs/0.8.1/features/instructions-sequences/#__codelineno-1-8) fn pre_ixs( [](https://ackee.xyz/trident/docs/0.8.1/features/instructions-sequences/#__codelineno-1-9) u: &mut arbitrary::Unstructured [](https://ackee.xyz/trident/docs/0.8.1/features/instructions-sequences/#__codelineno-1-10) ) -> arbitrary::Result> { [](https://ackee.xyz/trident/docs/0.8.1/features/instructions-sequences/#__codelineno-1-11) let init_ix = [](https://ackee.xyz/trident/docs/0.8.1/features/instructions-sequences/#__codelineno-1-12) FuzzInstruction::InitVesting(InitVesting::arbitrary(u)?); [](https://ackee.xyz/trident/docs/0.8.1/features/instructions-sequences/#__codelineno-1-13) [](https://ackee.xyz/trident/docs/0.8.1/features/instructions-sequences/#__codelineno-1-14) Ok(vec![init_ix]) [](https://ackee.xyz/trident/docs/0.8.1/features/instructions-sequences/#__codelineno-1-15) } [](https://ackee.xyz/trident/docs/0.8.1/features/instructions-sequences/#__codelineno-1-16) fn ixs( [](https://ackee.xyz/trident/docs/0.8.1/features/instructions-sequences/#__codelineno-1-17) u: &mut arbitrary::Unstructured [](https://ackee.xyz/trident/docs/0.8.1/features/instructions-sequences/#__codelineno-1-18) ) -> arbitrary::Result> { [](https://ackee.xyz/trident/docs/0.8.1/features/instructions-sequences/#__codelineno-1-19) let withdraw_ix = [](https://ackee.xyz/trident/docs/0.8.1/features/instructions-sequences/#__codelineno-1-20) FuzzInstruction::WithdrawUnlocked(WithdrawUnlocked::arbitrary(u)?); [](https://ackee.xyz/trident/docs/0.8.1/features/instructions-sequences/#__codelineno-1-21) [](https://ackee.xyz/trident/docs/0.8.1/features/instructions-sequences/#__codelineno-1-22) Ok(vec![withdraw_ix]) [](https://ackee.xyz/trident/docs/0.8.1/features/instructions-sequences/#__codelineno-1-23) } [](https://ackee.xyz/trident/docs/0.8.1/features/instructions-sequences/#__codelineno-1-24) fn post_ixs( [](https://ackee.xyz/trident/docs/0.8.1/features/instructions-sequences/#__codelineno-1-25) _u: &mut arbitrary::Unstructured [](https://ackee.xyz/trident/docs/0.8.1/features/instructions-sequences/#__codelineno-1-26) ) -> arbitrary::Result> { [](https://ackee.xyz/trident/docs/0.8.1/features/instructions-sequences/#__codelineno-1-27) Ok(vec![]) [](https://ackee.xyz/trident/docs/0.8.1/features/instructions-sequences/#__codelineno-1-28) } [](https://ackee.xyz/trident/docs/0.8.1/features/instructions-sequences/#__codelineno-1-29) }` Tip Consider checking the [Examples](https://ackee.xyz/trident/docs/0.8.1/examples/examples/) section for more tips. Back to top --- # Genesis - Trident [Skip to content](https://ackee.xyz/trident/docs/0.8.1/features/genesis-accounts/#genesis) Genesis[#](https://ackee.xyz/trident/docs/0.8.1/features/genesis-accounts/#genesis "Permanent link") ===================================================================================================== Genesis Programs[#](https://ackee.xyz/trident/docs/0.8.1/features/genesis-accounts/#genesis-programs "Permanent link") ----------------------------------------------------------------------------------------------------------------------- Trident allows you to use Cross Program Invocation of both Native and SBF programs. ### Native[#](https://ackee.xyz/trident/docs/0.8.1/features/genesis-accounts/#native "Permanent link") In case of multiple programs within the Anchor Workspace. Make sure that all of the programs you would like to call Cross Program Invocation to are included in the initial state of the Fuzz Test Environment. Important Source code below: * `fuzzing_program_callee` is included in the `ProgramTestClientBlocking` * `fuzzing_program_caller` is included in the `ProgramTestClientBlocking` `[](https://ackee.xyz/trident/docs/0.8.1/features/genesis-accounts/#__codelineno-0-1) // test_fuzz.rs [](https://ackee.xyz/trident/docs/0.8.1/features/genesis-accounts/#__codelineno-0-2)[](https://ackee.xyz/trident/docs/0.8.1/features/genesis-accounts/#__codelineno-0-3) fn fuzz_iteration + std::fmt::Display, U>( [](https://ackee.xyz/trident/docs/0.8.1/features/genesis-accounts/#__codelineno-0-4) fuzz_data: FuzzData [](https://ackee.xyz/trident/docs/0.8.1/features/genesis-accounts/#__codelineno-0-5) ) { [](https://ackee.xyz/trident/docs/0.8.1/features/genesis-accounts/#__codelineno-0-6) let fuzzing_program_callee = FuzzingProgram::new( [](https://ackee.xyz/trident/docs/0.8.1/features/genesis-accounts/#__codelineno-0-7) PROGRAM_NAME_CALLEE, [](https://ackee.xyz/trident/docs/0.8.1/features/genesis-accounts/#__codelineno-0-8) &PROGRAM_ID_CALLEE, [](https://ackee.xyz/trident/docs/0.8.1/features/genesis-accounts/#__codelineno-0-9) processor!(convert_entry!(entry_callee)), [](https://ackee.xyz/trident/docs/0.8.1/features/genesis-accounts/#__codelineno-0-10) ); [](https://ackee.xyz/trident/docs/0.8.1/features/genesis-accounts/#__codelineno-0-11) [](https://ackee.xyz/trident/docs/0.8.1/features/genesis-accounts/#__codelineno-0-12) let fuzzing_program_caller = FuzzingProgram::new( [](https://ackee.xyz/trident/docs/0.8.1/features/genesis-accounts/#__codelineno-0-13) PROGRAM_NAME_CALLER, [](https://ackee.xyz/trident/docs/0.8.1/features/genesis-accounts/#__codelineno-0-14) &PROGRAM_ID_CALLER, [](https://ackee.xyz/trident/docs/0.8.1/features/genesis-accounts/#__codelineno-0-15) processor!(convert_entry!(entry_caller)), [](https://ackee.xyz/trident/docs/0.8.1/features/genesis-accounts/#__codelineno-0-16) ); [](https://ackee.xyz/trident/docs/0.8.1/features/genesis-accounts/#__codelineno-0-17) [](https://ackee.xyz/trident/docs/0.8.1/features/genesis-accounts/#__codelineno-0-18) let mut client = [](https://ackee.xyz/trident/docs/0.8.1/features/genesis-accounts/#__codelineno-0-19) ProgramTestClientBlocking::new( [](https://ackee.xyz/trident/docs/0.8.1/features/genesis-accounts/#__codelineno-0-20) &[fuzzing_program_callee, fuzzing_program_caller], [](https://ackee.xyz/trident/docs/0.8.1/features/genesis-accounts/#__codelineno-0-21) &[] [](https://ackee.xyz/trident/docs/0.8.1/features/genesis-accounts/#__codelineno-0-22) ).unwrap(); [](https://ackee.xyz/trident/docs/0.8.1/features/genesis-accounts/#__codelineno-0-23) [](https://ackee.xyz/trident/docs/0.8.1/features/genesis-accounts/#__codelineno-0-24) let _ = fuzz_data.run_with_runtime(&mut client); [](https://ackee.xyz/trident/docs/0.8.1/features/genesis-accounts/#__codelineno-0-25) }` ### SBF[#](https://ackee.xyz/trident/docs/0.8.1/features/genesis-accounts/#sbf "Permanent link") In case of SBF targets, compiled or dumped from whatever cluster. You can also use these within the Fuzz Tests. Tip If you want to obtain Program from Mainnet use `[](https://ackee.xyz/trident/docs/0.8.1/features/genesis-accounts/#__codelineno-1-1) # -u m specifies to dump from mainnet [](https://ackee.xyz/trident/docs/0.8.1/features/genesis-accounts/#__codelineno-1-2) solana program dump -u m .so` Important * To include the SBF target in the Fuzz Test for CPI, specify address and path to the program in the `Trident.toml`. * Including these types of programs will lead to performance decline of Trident. `[](https://ackee.xyz/trident/docs/0.8.1/features/genesis-accounts/#__codelineno-2-1) [[fuzz.programs]] [](https://ackee.xyz/trident/docs/0.8.1/features/genesis-accounts/#__codelineno-2-2) address = "metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s" [](https://ackee.xyz/trident/docs/0.8.1/features/genesis-accounts/#__codelineno-2-3) program = "metaplex-program/metaplex-token-metadata.so"` Genesis Accounts[#](https://ackee.xyz/trident/docs/0.8.1/features/genesis-accounts/#genesis-accounts "Permanent link") ----------------------------------------------------------------------------------------------------------------------- Trident allows you to include Accounts with data in base64 format. Tip If you want to obtain Account with `base64` data format, use `[](https://ackee.xyz/trident/docs/0.8.1/features/genesis-accounts/#__codelineno-3-1) # -u m specifies to dump from mainnet [](https://ackee.xyz/trident/docs/0.8.1/features/genesis-accounts/#__codelineno-3-2) solana account -u m
--output json` Important To include desired accounts in the fuzz testing environment, add then using the `Trident.toml`. `[](https://ackee.xyz/trident/docs/0.8.1/features/genesis-accounts/#__codelineno-4-1) [[fuzz.accounts]] [](https://ackee.xyz/trident/docs/0.8.1/features/genesis-accounts/#__codelineno-4-2) address = "6YG3J7PaxyMnnbU67ifyrgF3BzNzc7cD8hPkqK6ATweE" [](https://ackee.xyz/trident/docs/0.8.1/features/genesis-accounts/#__codelineno-4-3) filename = "tests/accounts/core_bridge_mainnet/guardian_set_5_mock.json"` Tip Consider checking the [Examples](https://ackee.xyz/trident/docs/0.8.1/examples/examples/) section for more tips. Back to top --- # Error Handler - Trident [Skip to content](https://ackee.xyz/trident/docs/0.8.1/features/error-handlers/#error-handler) Error Handler[#](https://ackee.xyz/trident/docs/0.8.1/features/error-handlers/#error-handler "Permanent link") =============================================================================================================== Trident allows you to specify custom error handler for each Instruction. This can be particularly helpful: * 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. Tip The default behavior of the function is that the error is returned. `[](https://ackee.xyz/trident/docs/0.8.1/features/error-handlers/#__codelineno-0-1) /// default implementation [](https://ackee.xyz/trident/docs/0.8.1/features/error-handlers/#__codelineno-0-2) fn tx_error_handler( [](https://ackee.xyz/trident/docs/0.8.1/features/error-handlers/#__codelineno-0-3) &self, [](https://ackee.xyz/trident/docs/0.8.1/features/error-handlers/#__codelineno-0-4) e: FuzzClientErrorWithOrigin, [](https://ackee.xyz/trident/docs/0.8.1/features/error-handlers/#__codelineno-0-5) ix_data: Self::IxData, [](https://ackee.xyz/trident/docs/0.8.1/features/error-handlers/#__codelineno-0-6) pre_ix_acc_infos: &[SnapshotAccount],, [](https://ackee.xyz/trident/docs/0.8.1/features/error-handlers/#__codelineno-0-7) ) -> Result<(), FuzzClientErrorWithOrigin> { [](https://ackee.xyz/trident/docs/0.8.1/features/error-handlers/#__codelineno-0-8) Err(e) [](https://ackee.xyz/trident/docs/0.8.1/features/error-handlers/#__codelineno-0-9) }` To omit the Error and continue with the next Instruction in the iteration, you can do `[](https://ackee.xyz/trident/docs/0.8.1/features/error-handlers/#__codelineno-1-1) /// default implementation [](https://ackee.xyz/trident/docs/0.8.1/features/error-handlers/#__codelineno-1-2) fn tx_error_handler( [](https://ackee.xyz/trident/docs/0.8.1/features/error-handlers/#__codelineno-1-3) &self, [](https://ackee.xyz/trident/docs/0.8.1/features/error-handlers/#__codelineno-1-4) e: FuzzClientErrorWithOrigin, [](https://ackee.xyz/trident/docs/0.8.1/features/error-handlers/#__codelineno-1-5) ix_data: Self::IxData, [](https://ackee.xyz/trident/docs/0.8.1/features/error-handlers/#__codelineno-1-6) pre_ix_acc_infos: &'info mut [Option>], [](https://ackee.xyz/trident/docs/0.8.1/features/error-handlers/#__codelineno-1-7) ) -> Result<(), FuzzClientErrorWithOrigin> { [](https://ackee.xyz/trident/docs/0.8.1/features/error-handlers/#__codelineno-1-8) Ok(()) [](https://ackee.xyz/trident/docs/0.8.1/features/error-handlers/#__codelineno-1-9) }` Back to top --- # Fuzz Instructions - Trident [Skip to content](https://ackee.xyz/trident/docs/0.8.1/features/fuzz-instructions/#fuzz-instructions) Fuzz Instructions[#](https://ackee.xyz/trident/docs/0.8.1/features/fuzz-instructions/#fuzz-instructions "Permanent link") ========================================================================================================================== Trident defines `FuzzInstruction` enum containing all available **Instructions** within your program. The enum variants additionally contains their corresponding structures for **Accounts** and **Input** arguments. `[](https://ackee.xyz/trident/docs/0.8.1/features/fuzz-instructions/#__codelineno-0-1) #[derive(Arbitrary, DisplayIx, FuzzTestExecutor, FuzzDeserialize)] [](https://ackee.xyz/trident/docs/0.8.1/features/fuzz-instructions/#__codelineno-0-2) pub enum FuzzInstruction { [](https://ackee.xyz/trident/docs/0.8.1/features/fuzz-instructions/#__codelineno-0-3) Initialize(Initialize), [](https://ackee.xyz/trident/docs/0.8.1/features/fuzz-instructions/#__codelineno-0-4) Update(Update), [](https://ackee.xyz/trident/docs/0.8.1/features/fuzz-instructions/#__codelineno-0-5) } [](https://ackee.xyz/trident/docs/0.8.1/features/fuzz-instructions/#__codelineno-0-6) #[derive(Arbitrary, Debug)] [](https://ackee.xyz/trident/docs/0.8.1/features/fuzz-instructions/#__codelineno-0-7) pub struct Initialize { [](https://ackee.xyz/trident/docs/0.8.1/features/fuzz-instructions/#__codelineno-0-8) pub accounts: InitializeAccounts, [](https://ackee.xyz/trident/docs/0.8.1/features/fuzz-instructions/#__codelineno-0-9) pub data: InitializeData, [](https://ackee.xyz/trident/docs/0.8.1/features/fuzz-instructions/#__codelineno-0-10) } [](https://ackee.xyz/trident/docs/0.8.1/features/fuzz-instructions/#__codelineno-0-11) #[derive(Arbitrary, Debug)] [](https://ackee.xyz/trident/docs/0.8.1/features/fuzz-instructions/#__codelineno-0-12) pub struct Update { [](https://ackee.xyz/trident/docs/0.8.1/features/fuzz-instructions/#__codelineno-0-13) pub accounts: UpdateAccounts, [](https://ackee.xyz/trident/docs/0.8.1/features/fuzz-instructions/#__codelineno-0-14) pub data: UpdateData, [](https://ackee.xyz/trident/docs/0.8.1/features/fuzz-instructions/#__codelineno-0-15) } [](https://ackee.xyz/trident/docs/0.8.1/features/fuzz-instructions/#__codelineno-0-16) // ...` Instruction behavior[#](https://ackee.xyz/trident/docs/0.8.1/features/fuzz-instructions/#instruction-behavior "Permanent link") -------------------------------------------------------------------------------------------------------------------------------- Each Instruction variant has to define `IxOps` trait containing the following methods: * [`get_program_id()`](https://ackee.xyz/trident/docs/0.8.1/features/fuzz-instructions/#get_program_id) (automatically implemented) * [`get_data()`](https://ackee.xyz/trident/docs/0.8.1/features/fuzz-instructions/#get_data) (required) * [`get_accounts()`](https://ackee.xyz/trident/docs/0.8.1/features/fuzz-instructions/#get_accounts) (required) * [`check()`](https://ackee.xyz/trident/docs/0.8.1/features/fuzz-instructions/#check) (optional) * [`tx_error_handler()`](https://ackee.xyz/trident/docs/0.8.1/features/fuzz-instructions/#tx_error_handler) (optional) * `deserialize_accounts()` (automatically implemented) `get_program_id()`[#](https://ackee.xyz/trident/docs/0.8.1/features/fuzz-instructions/#get_program_id "Permanent link") ------------------------------------------------------------------------------------------------------------------------ This method specifies **program ID** to which the Instruction corresponds. In case you have only one program in the Anchor Workspace it is not really important. The importance occurs when you have multiple programs in the Workspace and you want to call Instructions of every Program. In that case each Instruction Variant corresponds to its program by the Program ID. `get_data()`[#](https://ackee.xyz/trident/docs/0.8.1/features/fuzz-instructions/#get_data "Permanent link") ------------------------------------------------------------------------------------------------------------ This method specifies what the Instruction Input Data should look like. You can use completely random data generated by the fuzzer, such as: `[](https://ackee.xyz/trident/docs/0.8.1/features/fuzz-instructions/#__codelineno-1-1) fn get_data( [](https://ackee.xyz/trident/docs/0.8.1/features/fuzz-instructions/#__codelineno-1-2) &self, [](https://ackee.xyz/trident/docs/0.8.1/features/fuzz-instructions/#__codelineno-1-3) _client: &mut impl FuzzClient, [](https://ackee.xyz/trident/docs/0.8.1/features/fuzz-instructions/#__codelineno-1-4) _fuzz_accounts: &mut FuzzAccounts, [](https://ackee.xyz/trident/docs/0.8.1/features/fuzz-instructions/#__codelineno-1-5) ) -> Result { [](https://ackee.xyz/trident/docs/0.8.1/features/fuzz-instructions/#__codelineno-1-6) let data = hello_world::instruction::InitializeFn { [](https://ackee.xyz/trident/docs/0.8.1/features/fuzz-instructions/#__codelineno-1-7) input: self.data.input, [](https://ackee.xyz/trident/docs/0.8.1/features/fuzz-instructions/#__codelineno-1-8) }; [](https://ackee.xyz/trident/docs/0.8.1/features/fuzz-instructions/#__codelineno-1-9) Ok(data) [](https://ackee.xyz/trident/docs/0.8.1/features/fuzz-instructions/#__codelineno-1-10) }` You can also use always constant values `[](https://ackee.xyz/trident/docs/0.8.1/features/fuzz-instructions/#__codelineno-2-1) fn get_data( [](https://ackee.xyz/trident/docs/0.8.1/features/fuzz-instructions/#__codelineno-2-2) &self, [](https://ackee.xyz/trident/docs/0.8.1/features/fuzz-instructions/#__codelineno-2-3) _client: &mut impl FuzzClient, [](https://ackee.xyz/trident/docs/0.8.1/features/fuzz-instructions/#__codelineno-2-4) _fuzz_accounts: &mut FuzzAccounts, [](https://ackee.xyz/trident/docs/0.8.1/features/fuzz-instructions/#__codelineno-2-5) ) -> Result { [](https://ackee.xyz/trident/docs/0.8.1/features/fuzz-instructions/#__codelineno-2-6) let data = hello_world::instruction::InitializeFn { [](https://ackee.xyz/trident/docs/0.8.1/features/fuzz-instructions/#__codelineno-2-7) input: 5, [](https://ackee.xyz/trident/docs/0.8.1/features/fuzz-instructions/#__codelineno-2-8) }; [](https://ackee.xyz/trident/docs/0.8.1/features/fuzz-instructions/#__codelineno-2-9) Ok(data) [](https://ackee.xyz/trident/docs/0.8.1/features/fuzz-instructions/#__codelineno-2-10) }` Or you can customize the Data using the Arbitrary crate. Check [Arbitrary Data](https://ackee.xyz/trident/docs/0.8.1/features/arbitrary-data/) . ### Custom Data Types[#](https://ackee.xyz/trident/docs/0.8.1/features/fuzz-instructions/#custom-data-types "Permanent link") If you use Custom Types as Instruction data arguments, you may encounter a problem that the Custom Type does not implement * [Debug](https://doc.rust-lang.org/std/fmt/trait.Debug.html) trait * [Arbitrary](https://docs.rs/arbitrary/latest/arbitrary/trait.Arbitrary.html) trait ### Derive Debug and Arbitrary traits inside the Fuzz Test[#](https://ackee.xyz/trident/docs/0.8.1/features/fuzz-instructions/#derive-debug-and-arbitrary-traits-inside-the-fuzz-test "Permanent link") You can redefine the custom type within the `fuzz_instructions.rs` file, along with all the necessary traits. `[](https://ackee.xyz/trident/docs/0.8.1/features/fuzz-instructions/#__codelineno-3-1) // Redefine the Custom Type inside the fuzz_instructions.rs, [](https://ackee.xyz/trident/docs/0.8.1/features/fuzz-instructions/#__codelineno-3-2) // but this time with all of the required traits. [](https://ackee.xyz/trident/docs/0.8.1/features/fuzz-instructions/#__codelineno-3-3) #[derive(Arbitrary,Debug, Clone, Copy)] [](https://ackee.xyz/trident/docs/0.8.1/features/fuzz-instructions/#__codelineno-3-4) pub enum CustomEnumInputFuzz { [](https://ackee.xyz/trident/docs/0.8.1/features/fuzz-instructions/#__codelineno-3-5) InputVariant1, [](https://ackee.xyz/trident/docs/0.8.1/features/fuzz-instructions/#__codelineno-3-6) InputVariant2, [](https://ackee.xyz/trident/docs/0.8.1/features/fuzz-instructions/#__codelineno-3-7) InputVariant3, [](https://ackee.xyz/trident/docs/0.8.1/features/fuzz-instructions/#__codelineno-3-8) }` Then, you would also need to implement the [`std::convert::From`](https://doc.rust-lang.org/std/convert/trait.From.html) trait to enable conversion between the newly defined Custom Type and the Custom Type used within your program. Tip Consider checking the [Examples](https://ackee.xyz/trident/docs/0.8.1/examples/examples/) section for more tips. `get_accounts()`[#](https://ackee.xyz/trident/docs/0.8.1/features/fuzz-instructions/#get_accounts "Permanent link") -------------------------------------------------------------------------------------------------------------------- This method specifies how the **Accounts** for the corresponding Instruction should be resolved. You can use accounts stored within the **FuzzAccounts Account Storages**, or you can define custom Account using the **client**. There are two main functions to use within the `get_accounts()`: * [`get_or_create_account()`](https://ackee.xyz/trident/docs/0.8.1/features/fuzz-instructions/#get_or_create_account) * [`get()`](https://ackee.xyz/trident/docs/0.8.1/features/fuzz-instructions/#get) * [`set_custom()`](https://ackee.xyz/trident/docs/0.8.1/features/fuzz-instructions/#set_custom) ### `get_or_create_account()`[#](https://ackee.xyz/trident/docs/0.8.1/features/fuzz-instructions/#get_or_create_account "Permanent link") Insert a new record into AccountsStorage based on the `account_id`. If a record with the entered `account_id` already exists, it is returned, and no insertion is performed. Tip * This function is particularly useful for instructions that initialize accounts. Example: `[](https://ackee.xyz/trident/docs/0.8.1/features/fuzz-instructions/#__codelineno-4-1) let hello_world_account = fuzz_accounts.hello_world_account.get_or_create_account( [](https://ackee.xyz/trident/docs/0.8.1/features/fuzz-instructions/#__codelineno-4-2) self.accounts.hello_world_account, [](https://ackee.xyz/trident/docs/0.8.1/features/fuzz-instructions/#__codelineno-4-3) client, [](https://ackee.xyz/trident/docs/0.8.1/features/fuzz-instructions/#__codelineno-4-4) &[b"hello_world_seed"], [](https://ackee.xyz/trident/docs/0.8.1/features/fuzz-instructions/#__codelineno-4-5) &hello_world::ID, [](https://ackee.xyz/trident/docs/0.8.1/features/fuzz-instructions/#__codelineno-4-6) );` The code above will return the PDA from `hello_world`'s AccountsStorage if a record for the entered `account_id` exists. If not, the function will create a new record corresponding to the PDA derived from the provided seeds and return the PDA. ### `get()`[#](https://ackee.xyz/trident/docs/0.8.1/features/fuzz-instructions/#get "Permanent link") Retrieves a record from AccountsStorage based on the entered `account_id`. If no record exists for the `account_id`, a random public key is returned. Tip * This function is particularly useful for instructions other than those that perform initialization. Example: `[](https://ackee.xyz/trident/docs/0.8.1/features/fuzz-instructions/#__codelineno-5-1) let hello_world_account = fuzz_accounts [](https://ackee.xyz/trident/docs/0.8.1/features/fuzz-instructions/#__codelineno-5-2) .hello_world_account [](https://ackee.xyz/trident/docs/0.8.1/features/fuzz-instructions/#__codelineno-5-3) .get(self.accounts.hello_world_account);` The code above will return the PDA from `hello_world`'s AccountsStorage if a record for the entered `account_id` exists. If not, the function will return a random public key. ### `set_custom()`[#](https://ackee.xyz/trident/docs/0.8.1/features/fuzz-instructions/#set_custom "Permanent link") If the previous two functions are insufficient, you can use `set_custom()` to manually set an account with data you select. This function accepts `account_id`, which specifies the record in the corresponding AccountsStorage; `client`, which handles the insertion of AccountSharedData; the account's `address` (particularly helpful if a predefined address is needed); and `AccountSharedData`, which you can configure as needed. Tip `Example:` `[](https://ackee.xyz/trident/docs/0.8.1/features/fuzz-instructions/#__codelineno-6-1) let address = Keypair::new(); [](https://ackee.xyz/trident/docs/0.8.1/features/fuzz-instructions/#__codelineno-6-2) fuzz_accounts.hello_world_account.set_custom( [](https://ackee.xyz/trident/docs/0.8.1/features/fuzz-instructions/#__codelineno-6-3) self.accounts.hello_world_account, [](https://ackee.xyz/trident/docs/0.8.1/features/fuzz-instructions/#__codelineno-6-4) client, [](https://ackee.xyz/trident/docs/0.8.1/features/fuzz-instructions/#__codelineno-6-5) address.pubkey(), [](https://ackee.xyz/trident/docs/0.8.1/features/fuzz-instructions/#__codelineno-6-6) AccountSharedData::new(10 * LAMPORTS_PER_SOL, 0, &solana_sdk::system_program::ID), [](https://ackee.xyz/trident/docs/0.8.1/features/fuzz-instructions/#__codelineno-6-7) );` The code above will generate a new random keypair. The `set_account` function will insert the specified `AccountSharedData` into the client and create a record in the corresponding AccountsStorage based on the entered `account_id`. `check()`[#](https://ackee.xyz/trident/docs/0.8.1/features/fuzz-instructions/#check "Permanent link") ------------------------------------------------------------------------------------------------------ This method provides Invariant Check for the corresponding Instruction. Check [Invariant Checks](https://ackee.xyz/trident/docs/0.8.1/features/invariant-checks/) . `tx_error_handler()`[#](https://ackee.xyz/trident/docs/0.8.1/features/fuzz-instructions/#tx_error_handler "Permanent link") ---------------------------------------------------------------------------------------------------------------------------- This method provides Tx Error Handler for the corresponding Instruction. Check [Error Handler](https://ackee.xyz/trident/docs/0.8.1/features/error-handlers/) . Example[#](https://ackee.xyz/trident/docs/0.8.1/features/fuzz-instructions/#example "Permanent link") ------------------------------------------------------------------------------------------------------ Tip Consider checking the [Examples](https://ackee.xyz/trident/docs/0.8.1/examples/examples/) section for more tips. Back to top --- # Current limitations - Trident [Skip to content](https://ackee.xyz/trident/docs/0.8.1/features/limitations/#current-limitations) Current limitations[#](https://ackee.xyz/trident/docs/0.8.1/features/limitations/#current-limitations "Permanent link") ======================================================================================================================== This section summarizes some known limitations in the current development stage. Further development will be focused on resolving these limitations. * Remaining accounts in check methods are not supported. * Composite accounts are not supported. Back to top --- # Get Help - Trident [Skip to content](https://ackee.xyz/trident/docs/0.9.1/get-help/get-help/#get-help) Get Help[#](https://ackee.xyz/trident/docs/0.9.1/get-help/get-help/#get-help "Permanent link") =============================================================================================== Need help writing Fuzz Tests? Do not hesitate to join our [Discord server](https://discord.gg/3czRpmGmeC) ! Back to top --- # Arbitrary Data - Trident [Skip to content](https://ackee.xyz/trident/docs/0.8.1/features/arbitrary-data/#arbitrary-data) Arbitrary Data[#](https://ackee.xyz/trident/docs/0.8.1/features/arbitrary-data/#arbitrary-data "Permanent link") ================================================================================================================= Trident allows you to customize Instruction Data to provide structure. For example your Initialize Instruction expects two arguments `start_at` and `end_at` you know that in order for the Instruction to make sense, it is required that the `start_at` < `end_at`. Moreover, there should be significant difference between these two. This can be utilized with the **Arbitrary crate**. `[](https://ackee.xyz/trident/docs/0.8.1/features/arbitrary-data/#__codelineno-0-1) #[derive(Arbitrary, Debug)] [](https://ackee.xyz/trident/docs/0.8.1/features/arbitrary-data/#__codelineno-0-2) pub struct InitVestingData { [](https://ackee.xyz/trident/docs/0.8.1/features/arbitrary-data/#__codelineno-0-3) pub recipient: AccountId, [](https://ackee.xyz/trident/docs/0.8.1/features/arbitrary-data/#__codelineno-0-4) #[arbitrary( [](https://ackee.xyz/trident/docs/0.8.1/features/arbitrary-data/#__codelineno-0-5) with = |u: &mut arbitrary::Unstructured| u.int_in_range(1..=1_000_000) [](https://ackee.xyz/trident/docs/0.8.1/features/arbitrary-data/#__codelineno-0-6) )] [](https://ackee.xyz/trident/docs/0.8.1/features/arbitrary-data/#__codelineno-0-7) pub amount: u64, [](https://ackee.xyz/trident/docs/0.8.1/features/arbitrary-data/#__codelineno-0-8) // we want start_at smaller than end_at [](https://ackee.xyz/trident/docs/0.8.1/features/arbitrary-data/#__codelineno-0-9) // and for testing purposes we can run tests with times from the past [](https://ackee.xyz/trident/docs/0.8.1/features/arbitrary-data/#__codelineno-0-10) #[arbitrary( [](https://ackee.xyz/trident/docs/0.8.1/features/arbitrary-data/#__codelineno-0-11) with = |u: &mut arbitrary::Unstructured| u.int_in_range(0..=1_000_000) [](https://ackee.xyz/trident/docs/0.8.1/features/arbitrary-data/#__codelineno-0-12) )] [](https://ackee.xyz/trident/docs/0.8.1/features/arbitrary-data/#__codelineno-0-13) pub start_at: u64, [](https://ackee.xyz/trident/docs/0.8.1/features/arbitrary-data/#__codelineno-0-14) #[arbitrary( [](https://ackee.xyz/trident/docs/0.8.1/features/arbitrary-data/#__codelineno-0-15) with = |u: &mut arbitrary::Unstructured| u.int_in_range(1_001_001..=1_050_000) [](https://ackee.xyz/trident/docs/0.8.1/features/arbitrary-data/#__codelineno-0-16) )] [](https://ackee.xyz/trident/docs/0.8.1/features/arbitrary-data/#__codelineno-0-17) pub end_at: u64, [](https://ackee.xyz/trident/docs/0.8.1/features/arbitrary-data/#__codelineno-0-18) #[arbitrary( [](https://ackee.xyz/trident/docs/0.8.1/features/arbitrary-data/#__codelineno-0-19) with = |u: &mut arbitrary::Unstructured| u.int_in_range(1..=1000) [](https://ackee.xyz/trident/docs/0.8.1/features/arbitrary-data/#__codelineno-0-20) )] [](https://ackee.xyz/trident/docs/0.8.1/features/arbitrary-data/#__codelineno-0-21) pub interval: u64, [](https://ackee.xyz/trident/docs/0.8.1/features/arbitrary-data/#__codelineno-0-22) }` Implement Arbitrary[#](https://ackee.xyz/trident/docs/0.8.1/features/arbitrary-data/#implement-arbitrary "Permanent link") --------------------------------------------------------------------------------------------------------------------------- There are macros available to use with Arbitrary, however, it is possible to Implement the arbitrary function by yourself. `[](https://ackee.xyz/trident/docs/0.8.1/features/arbitrary-data/#__codelineno-1-1) // ------------------------------------------------------------------- [](https://ackee.xyz/trident/docs/0.8.1/features/arbitrary-data/#__codelineno-1-2) // ------------------------------------------------------------------- [](https://ackee.xyz/trident/docs/0.8.1/features/arbitrary-data/#__codelineno-1-3) // Implement Arbitrary [](https://ackee.xyz/trident/docs/0.8.1/features/arbitrary-data/#__codelineno-1-4) impl<'a> Arbitrary<'a> for InitVestingData { [](https://ackee.xyz/trident/docs/0.8.1/features/arbitrary-data/#__codelineno-1-5) fn arbitrary( [](https://ackee.xyz/trident/docs/0.8.1/features/arbitrary-data/#__codelineno-1-6) u: &mut arbitrary::Unstructured<'a> [](https://ackee.xyz/trident/docs/0.8.1/features/arbitrary-data/#__codelineno-1-7) ) -> arbitrary::Result { [](https://ackee.xyz/trident/docs/0.8.1/features/arbitrary-data/#__codelineno-1-8) // obtain AccountId [](https://ackee.xyz/trident/docs/0.8.1/features/arbitrary-data/#__codelineno-1-9) let recipient = AccountId::arbitrary(u)?; [](https://ackee.xyz/trident/docs/0.8.1/features/arbitrary-data/#__codelineno-1-10) [](https://ackee.xyz/trident/docs/0.8.1/features/arbitrary-data/#__codelineno-1-11) // limit the generated amount to the 1_000_000 [](https://ackee.xyz/trident/docs/0.8.1/features/arbitrary-data/#__codelineno-1-12) let amount = u.int_in_range(1..=1_000_000)?; [](https://ackee.xyz/trident/docs/0.8.1/features/arbitrary-data/#__codelineno-1-13) [](https://ackee.xyz/trident/docs/0.8.1/features/arbitrary-data/#__codelineno-1-14) // now we want to obtain [](https://ackee.xyz/trident/docs/0.8.1/features/arbitrary-data/#__codelineno-1-15) // - start_at [](https://ackee.xyz/trident/docs/0.8.1/features/arbitrary-data/#__codelineno-1-16) // - end_at [](https://ackee.xyz/trident/docs/0.8.1/features/arbitrary-data/#__codelineno-1-17) // - interval [](https://ackee.xyz/trident/docs/0.8.1/features/arbitrary-data/#__codelineno-1-18) // however we want to limit the data such that: [](https://ackee.xyz/trident/docs/0.8.1/features/arbitrary-data/#__codelineno-1-19) // - start_at < end_at [](https://ackee.xyz/trident/docs/0.8.1/features/arbitrary-data/#__codelineno-1-20) // - end_at - start_at > interval [](https://ackee.xyz/trident/docs/0.8.1/features/arbitrary-data/#__codelineno-1-21) // - interval has lower limit of 500 and upper limit of 1000. [](https://ackee.xyz/trident/docs/0.8.1/features/arbitrary-data/#__codelineno-1-22) [](https://ackee.xyz/trident/docs/0.8.1/features/arbitrary-data/#__codelineno-1-23) let start_at: u64 = u.int_in_range(1_000_000..=5_000_000)?; [](https://ackee.xyz/trident/docs/0.8.1/features/arbitrary-data/#__codelineno-1-24) let end_at: u64 = u.int_in_range(1_000_000..=5_000_000)?; [](https://ackee.xyz/trident/docs/0.8.1/features/arbitrary-data/#__codelineno-1-25) let interval: u64 = u.int_in_range(500..=1000)?; [](https://ackee.xyz/trident/docs/0.8.1/features/arbitrary-data/#__codelineno-1-26) [](https://ackee.xyz/trident/docs/0.8.1/features/arbitrary-data/#__codelineno-1-27) // ensure that start_at < end_at [](https://ackee.xyz/trident/docs/0.8.1/features/arbitrary-data/#__codelineno-1-28) if start_at >= end_at { [](https://ackee.xyz/trident/docs/0.8.1/features/arbitrary-data/#__codelineno-1-29) return Err(arbitrary::Error::IncorrectFormat); [](https://ackee.xyz/trident/docs/0.8.1/features/arbitrary-data/#__codelineno-1-30) } [](https://ackee.xyz/trident/docs/0.8.1/features/arbitrary-data/#__codelineno-1-31) [](https://ackee.xyz/trident/docs/0.8.1/features/arbitrary-data/#__codelineno-1-32) // ensure that end_at - start_at > interval [](https://ackee.xyz/trident/docs/0.8.1/features/arbitrary-data/#__codelineno-1-33) match end_at.checked_sub(start_at) { [](https://ackee.xyz/trident/docs/0.8.1/features/arbitrary-data/#__codelineno-1-34) Some(diff) => { [](https://ackee.xyz/trident/docs/0.8.1/features/arbitrary-data/#__codelineno-1-35) if diff <= interval { [](https://ackee.xyz/trident/docs/0.8.1/features/arbitrary-data/#__codelineno-1-36) return Err(arbitrary::Error::IncorrectFormat); [](https://ackee.xyz/trident/docs/0.8.1/features/arbitrary-data/#__codelineno-1-37) } [](https://ackee.xyz/trident/docs/0.8.1/features/arbitrary-data/#__codelineno-1-38) } [](https://ackee.xyz/trident/docs/0.8.1/features/arbitrary-data/#__codelineno-1-39) None => return Err(arbitrary::Error::IncorrectFormat), [](https://ackee.xyz/trident/docs/0.8.1/features/arbitrary-data/#__codelineno-1-40) } [](https://ackee.xyz/trident/docs/0.8.1/features/arbitrary-data/#__codelineno-1-41) [](https://ackee.xyz/trident/docs/0.8.1/features/arbitrary-data/#__codelineno-1-42) Ok(InitVestingData { [](https://ackee.xyz/trident/docs/0.8.1/features/arbitrary-data/#__codelineno-1-43) recipient, [](https://ackee.xyz/trident/docs/0.8.1/features/arbitrary-data/#__codelineno-1-44) amount, [](https://ackee.xyz/trident/docs/0.8.1/features/arbitrary-data/#__codelineno-1-45) start_at, [](https://ackee.xyz/trident/docs/0.8.1/features/arbitrary-data/#__codelineno-1-46) end_at, [](https://ackee.xyz/trident/docs/0.8.1/features/arbitrary-data/#__codelineno-1-47) interval, [](https://ackee.xyz/trident/docs/0.8.1/features/arbitrary-data/#__codelineno-1-48) }) [](https://ackee.xyz/trident/docs/0.8.1/features/arbitrary-data/#__codelineno-1-49) } [](https://ackee.xyz/trident/docs/0.8.1/features/arbitrary-data/#__codelineno-1-50) // ------------------------------------------------------------------- [](https://ackee.xyz/trident/docs/0.8.1/features/arbitrary-data/#__codelineno-1-51) // ------------------------------------------------------------------- [](https://ackee.xyz/trident/docs/0.8.1/features/arbitrary-data/#__codelineno-1-52) }` Tip Consider checking the [Examples](https://ackee.xyz/trident/docs/0.8.1/examples/examples/) section for more tips. Back to top --- # Trident by Examples - Trident [Skip to content](https://ackee.xyz/trident/docs/0.9.1/examples/examples/#trident-by-examples) Trident by Examples[#](https://ackee.xyz/trident/docs/0.9.1/examples/examples/#trident-by-examples "Permanent link") ===================================================================================================================== * **Hello World!** * * * Hello World example with Trident. [Hello World!](https://github.com/Ackee-Blockchain/trident/tree/0.9.1/examples/hello_world) * **Possible vulnerabilities and bugs** * * * Check the possible attack vectors and bugs that can be detected using Trident. [Unchecked Arithmetic](https://github.com/Ackee-Blockchain/trident/tree/0.9.1/examples/common_issues/unchecked-arithmetic-0) [Incorrect Instruction Sequence](https://github.com/Ackee-Blockchain/trident/tree/0.9.1/examples/common_issues/incorrect-ix-sequence-1) [Unauthorized Access](https://github.com/Ackee-Blockchain/trident/tree/0.9.1/examples/common_issues/unauthorized-access-2) [Incorrect Integer Arithmetic](https://github.com/Ackee-Blockchain/trident/tree/0.9.1/examples/common_issues/incorrect-integer-arithmetic-3) * **Customize with Arbitrary** * * * You can use Arbitrary crate to your advantage and limit or customize the data that are sent to the instructions. [Custom Data Types](https://github.com/Ackee-Blockchain/trident/tree/0.9.1/examples/common_issues/arbitrary-custom-types-4) [Limiting Instructions Inputs](https://github.com/Ackee-Blockchain/trident/tree/0.9.1/examples/common_issues/arbitrary-limit-inputs-5) * **Cross-Program Invocation** * * * Trident supports Cross-Program Invocation, you can fuzz your programs and create NFTs at the same time. [Simple CPI](https://github.com/Ackee-Blockchain/trident/tree/0.9.1/examples/cpi/simple-cpi-6) [CPI with Metaplex Metadata Program](https://github.com/Ackee-Blockchain/trident/tree/0.9.1/examples/cpi/cpi-metaplex-7) * **Benchmarking** * * * Trident contains benchmarks of [Daedaluzz: A Benchmark Generator for Smart-Contract Fuzzers](https://github.com/Consensys/daedaluzz) rewritten in Rust. [Trident Benchmark](https://github.com/Ackee-Blockchain/trident/tree/0.9.1/examples/trident-benchmark) Back to top --- # Commands - Trident [Skip to content](https://ackee.xyz/trident/docs/0.9.1/commands/commands/#trident-init) Commands ======== * * * trident init[#](https://ackee.xyz/trident/docs/0.9.1/commands/commands/#trident-init "Permanent link") ------------------------------------------------------------------------------------------------------- `[](https://ackee.xyz/trident/docs/0.9.1/commands/commands/#__codelineno-0-1) trident init` * This command Initializes Trident Workspace and generates new Fuzz Test Template. * The command will generate the following folder structure: `[](https://ackee.xyz/trident/docs/0.9.1/commands/commands/#__codelineno-1-1) project-root [](https://ackee.xyz/trident/docs/0.9.1/commands/commands/#__codelineno-1-2) ├── trident-tests [](https://ackee.xyz/trident/docs/0.9.1/commands/commands/#__codelineno-1-3) │ ├── fuzz_tests # fuzz tests folder [](https://ackee.xyz/trident/docs/0.9.1/commands/commands/#__codelineno-1-4) │ │ ├── fuzz_0 # particular fuzz test [](https://ackee.xyz/trident/docs/0.9.1/commands/commands/#__codelineno-1-5) │ │ │ ├── test_fuzz.rs # the binary target of your fuzz test [](https://ackee.xyz/trident/docs/0.9.1/commands/commands/#__codelineno-1-6) │ │ │ └── fuzz_instructions.rs # the definition of your fuzz test [](https://ackee.xyz/trident/docs/0.9.1/commands/commands/#__codelineno-1-7) │ │ ├── fuzz_1 [](https://ackee.xyz/trident/docs/0.9.1/commands/commands/#__codelineno-1-8) │ │ ├── fuzz_X # possible multiple fuzz tests [](https://ackee.xyz/trident/docs/0.9.1/commands/commands/#__codelineno-1-9) │ │ ├── fuzzing # compilations and crashes folder [](https://ackee.xyz/trident/docs/0.9.1/commands/commands/#__codelineno-1-10) │ │ └── Cargo.toml [](https://ackee.xyz/trident/docs/0.9.1/commands/commands/#__codelineno-1-11) ├── Trident.toml [](https://ackee.xyz/trident/docs/0.9.1/commands/commands/#__codelineno-1-12) └── ...` * * * trident how[#](https://ackee.xyz/trident/docs/0.9.1/commands/commands/#trident-how "Permanent link") ----------------------------------------------------------------------------------------------------- `[](https://ackee.xyz/trident/docs/0.9.1/commands/commands/#__codelineno-2-1) trident how` * Print How To message about how to start writting fuzz tests. * * * trident fuzz[#](https://ackee.xyz/trident/docs/0.9.1/commands/commands/#trident-fuzz "Permanent link") ------------------------------------------------------------------------------------------------------- `[](https://ackee.xyz/trident/docs/0.9.1/commands/commands/#__codelineno-3-1) trident fuzz ` * Behavior depends on the subcommands. ### trident fuzz run-afl[#](https://ackee.xyz/trident/docs/0.9.1/commands/commands/#trident-fuzz-run-afl "Permanent link") Warning To execute and debug fuzz tests, navigate to the `trident-tests` directory. `[](https://ackee.xyz/trident/docs/0.9.1/commands/commands/#__codelineno-4-1) trident fuzz run-afl ` * Run AFL on the specified Fuzz Target (i.e. the Fuzz Template, for example fuzz\_0). #### Output[#](https://ackee.xyz/trident/docs/0.9.1/commands/commands/#output "Permanent link") TBD ### trident fuzz run-hfuzz[#](https://ackee.xyz/trident/docs/0.9.1/commands/commands/#trident-fuzz-run-hfuzz "Permanent link") Warning To execute and debug fuzz tests, navigate to the `trident-tests` directory. `[](https://ackee.xyz/trident/docs/0.9.1/commands/commands/#__codelineno-5-1) trident fuzz run-hfuzz ` * Run Honggfuzz on the specified Fuzz Target (i.e. the Fuzz Template, for example fuzz\_0). #### Output[#](https://ackee.xyz/trident/docs/0.9.1/commands/commands/#output_1 "Permanent link") Important The output provided by Honggfuzz is as follows: 1. Number of Fuzzing Iterations. 2. Feedback Driven Mode = Honggfuzz generates data based on the feedback (i.e. feedback based on Coverage progress). 3. Average Iterations per second. 4. Number of crashes it found (**panics** or failed **invariant checks**). `[](https://ackee.xyz/trident/docs/0.9.1/commands/commands/#__codelineno-6-1) ------------------------[ 0 days 00 hrs 00 mins 01 secs ]---------------------- [](https://ackee.xyz/trident/docs/0.9.1/commands/commands/#__codelineno-6-2) Iterations : 688 (out of: 1000 [68%]) # -- 1. -- [](https://ackee.xyz/trident/docs/0.9.1/commands/commands/#__codelineno-6-3) Mode [3/3] : Feedback Driven Mode # -- 2. -- [](https://ackee.xyz/trident/docs/0.9.1/commands/commands/#__codelineno-6-4) Target : trident-tests/fuzz_tests/fuzzing.....wn-linux-gnu/release/fuzz_0 [](https://ackee.xyz/trident/docs/0.9.1/commands/commands/#__codelineno-6-5) Threads : 16, CPUs: 32, CPU%: 1262% [39%/CPU] [](https://ackee.xyz/trident/docs/0.9.1/commands/commands/#__codelineno-6-6) Speed : 680/sec [avg: 688] # -- 3. -- [](https://ackee.xyz/trident/docs/0.9.1/commands/commands/#__codelineno-6-7) Crashes : 1 [unique: 1, blocklist: 0, verified: 0] # -- 4. -- [](https://ackee.xyz/trident/docs/0.9.1/commands/commands/#__codelineno-6-8) Timeouts : 0 [10 sec] [](https://ackee.xyz/trident/docs/0.9.1/commands/commands/#__codelineno-6-9) Corpus Size : 98, max: 1048576 bytes, init: 0 files [](https://ackee.xyz/trident/docs/0.9.1/commands/commands/#__codelineno-6-10) Cov Update : 0 days 00 hrs 00 mins 00 secs ago [](https://ackee.xyz/trident/docs/0.9.1/commands/commands/#__codelineno-6-11) Coverage : edge: 10345/882951 [1%] pc: 163 cmp: 622547 [](https://ackee.xyz/trident/docs/0.9.1/commands/commands/#__codelineno-6-12) ---------------------------------- [ LOGS ] ------------------/ honggfuzz 2.6 /-` ### trident fuzz debug-afl[#](https://ackee.xyz/trident/docs/0.9.1/commands/commands/#trident-fuzz-debug-afl "Permanent link") `[](https://ackee.xyz/trident/docs/0.9.1/commands/commands/#__codelineno-7-1) trident fuzz debug-afl ` * Run AFL debug on the specified Fuzz Target (i.e. the Fuzz Template, for example fuzz\_0), with specified crash file, to see where the crash file found an issue. #### Output[#](https://ackee.xyz/trident/docs/0.9.1/commands/commands/#output_2 "Permanent link") TBD ### trident fuzz debug-hfuzz[#](https://ackee.xyz/trident/docs/0.9.1/commands/commands/#trident-fuzz-debug-hfuzz "Permanent link") `[](https://ackee.xyz/trident/docs/0.9.1/commands/commands/#__codelineno-8-1) trident fuzz debug-hfuzz ` * Run Honggfuzz debug on the specified Fuzz Target (i.e. the Fuzz Template, for example fuzz\_0), with specified crash file, to see where the crash file found an issue. #### Output[#](https://ackee.xyz/trident/docs/0.9.1/commands/commands/#output_3 "Permanent link") Important The debug output is at current development stage really verbose and contains lldb parts. We are working on improving this experience. In the picture below you can see an example of provided debug output. 1. Series of Transaction Logs 2. Structures of data send within the Instructions 3. **Panic** or **Crash**, based on if the Fuzzing panicked within the Solana Program or Invariant Check failed. ![alt text](https://ackee.xyz/trident/docs/0.9.1/images/run-debug.png) ### trident fuzz add[#](https://ackee.xyz/trident/docs/0.9.1/commands/commands/#trident-fuzz-add "Permanent link") `[](https://ackee.xyz/trident/docs/0.9.1/commands/commands/#__codelineno-9-1) trident fuzz add` * Adds new Fuzz Test Template. * * * trident clean[#](https://ackee.xyz/trident/docs/0.9.1/commands/commands/#trident-clean "Permanent link") --------------------------------------------------------------------------------------------------------- `[](https://ackee.xyz/trident/docs/0.9.1/commands/commands/#__codelineno-10-1) trident clean` * Calls `anchor clean` and cleans targets created by the underlying Honggfuzz. Crashfiles and Fuzzing Inputs are preserved. Back to top --- # Trident Manifest - Trident [Skip to content](https://ackee.xyz/trident/docs/0.8.1/features/trident-manifest/#trident-manifest) Trident Manifest[#](https://ackee.xyz/trident/docs/0.8.1/features/trident-manifest/#trident-manifest "Permanent link") ======================================================================================================================= You can pass supported parameters via the **Trident.toml** configuration file: \[fuzz\][#](https://ackee.xyz/trident/docs/0.8.1/features/trident-manifest/#fuzz "Permanent link") --------------------------------------------------------------------------------------------------- #### programs[#](https://ackee.xyz/trident/docs/0.8.1/features/trident-manifest/#programs "Permanent link") * Trident allows you to specify genesis programs (SBF targets) that will be included in the fuzzing environment in order to perform all desired Cross-Program-Invocations. * Including these types of programs will lead to performance decline of Trident. `[](https://ackee.xyz/trident/docs/0.8.1/features/trident-manifest/#__codelineno-0-1) [[fuzz.programs]] [](https://ackee.xyz/trident/docs/0.8.1/features/trident-manifest/#__codelineno-0-2) address = "metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s" [](https://ackee.xyz/trident/docs/0.8.1/features/trident-manifest/#__codelineno-0-3) program = "metaplex-program/metaplex-token-metadata.so"` * * * #### accounts[#](https://ackee.xyz/trident/docs/0.8.1/features/trident-manifest/#accounts "Permanent link") * Trident allwos you to specify genesis accounts to inlcude in the fuzzing environment. In most cases it is helpful to dump some accounts from mainnet and use then during testing. `[](https://ackee.xyz/trident/docs/0.8.1/features/trident-manifest/#__codelineno-1-1) [[fuzz.accounts]] [](https://ackee.xyz/trident/docs/0.8.1/features/trident-manifest/#__codelineno-1-2) address = "6YG3J7PaxyMnnbU67ifyrgF3BzNzc7cD8hPkqK6ATweE" [](https://ackee.xyz/trident/docs/0.8.1/features/trident-manifest/#__codelineno-1-3) filename = "tests/accounts/core_bridge_mainnet/guardian_set_5_mock.json"` * * * #### allow\_duplicate\_txs[#](https://ackee.xyz/trident/docs/0.8.1/features/trident-manifest/#allow_duplicate_txs "Permanent link") * Allow processing of duplicate transactions. Setting to true might speed up fuzzing but can cause false positive crashes (default: false) `[](https://ackee.xyz/trident/docs/0.8.1/features/trident-manifest/#__codelineno-2-1) [fuzz] [](https://ackee.xyz/trident/docs/0.8.1/features/trident-manifest/#__codelineno-2-2) # Allow processing of duplicate transactions. [](https://ackee.xyz/trident/docs/0.8.1/features/trident-manifest/#__codelineno-2-3) # Setting to true might speed up fuzzing but can cause [](https://ackee.xyz/trident/docs/0.8.1/features/trident-manifest/#__codelineno-2-4) # false positive crashes (default: false) [](https://ackee.xyz/trident/docs/0.8.1/features/trident-manifest/#__codelineno-2-5) allow_duplicate_txs = false` * * * #### fuzzing\_with\_stats[#](https://ackee.xyz/trident/docs/0.8.1/features/trident-manifest/#fuzzing_with_stats "Permanent link") * Trident will show statistics after the fuzzing session. This option forces use of honggfuzz parameter `keep_output` as true in order to be able to catch fuzzer stdout. (default: false) ``[](https://ackee.xyz/trident/docs/0.8.1/features/trident-manifest/#__codelineno-3-1) [fuzz] [](https://ackee.xyz/trident/docs/0.8.1/features/trident-manifest/#__codelineno-3-2) # Trident will show statistics after the fuzzing session. [](https://ackee.xyz/trident/docs/0.8.1/features/trident-manifest/#__codelineno-3-3) # This option forces use of honggfuzz parameter [](https://ackee.xyz/trident/docs/0.8.1/features/trident-manifest/#__codelineno-3-4) # `keep_output` as true in order to be able to catch fuzzer stdout. [](https://ackee.xyz/trident/docs/0.8.1/features/trident-manifest/#__codelineno-3-5) # (default: false) [](https://ackee.xyz/trident/docs/0.8.1/features/trident-manifest/#__codelineno-3-6) fuzzing_with_stats = true`` * * * \[honggfuzz\][#](https://ackee.xyz/trident/docs/0.8.1/features/trident-manifest/#honggfuzz "Permanent link") ------------------------------------------------------------------------------------------------------------- #### timeout[#](https://ackee.xyz/trident/docs/0.8.1/features/trident-manifest/#timeout "Permanent link") * Timeout in seconds (default: 10) `[](https://ackee.xyz/trident/docs/0.8.1/features/trident-manifest/#__codelineno-4-1) [honggfuzz] [](https://ackee.xyz/trident/docs/0.8.1/features/trident-manifest/#__codelineno-4-2) # Timeout in seconds (default: 10) [](https://ackee.xyz/trident/docs/0.8.1/features/trident-manifest/#__codelineno-4-3) timeout = 10` * * * #### iterations[#](https://ackee.xyz/trident/docs/0.8.1/features/trident-manifest/#iterations "Permanent link") * Number of fuzzing iterations (default: 0 \[no limit\]) `[](https://ackee.xyz/trident/docs/0.8.1/features/trident-manifest/#__codelineno-5-1) [honggfuzz] [](https://ackee.xyz/trident/docs/0.8.1/features/trident-manifest/#__codelineno-5-2) # Number of fuzzing iterations (default: 0 [no limit]) [](https://ackee.xyz/trident/docs/0.8.1/features/trident-manifest/#__codelineno-5-3) iterations = 0` * * * #### threads[#](https://ackee.xyz/trident/docs/0.8.1/features/trident-manifest/#threads "Permanent link") * Number of concurrent fuzzing threads (default: 0 \[number of CPUs / 2\]) `[](https://ackee.xyz/trident/docs/0.8.1/features/trident-manifest/#__codelineno-6-1) [honggfuzz] [](https://ackee.xyz/trident/docs/0.8.1/features/trident-manifest/#__codelineno-6-2) # Number of concurrent fuzzing threads (default: 0 [number of CPUs / 2]) [](https://ackee.xyz/trident/docs/0.8.1/features/trident-manifest/#__codelineno-6-3) threads = 0` * * * #### keep\_output[#](https://ackee.xyz/trident/docs/0.8.1/features/trident-manifest/#keep_output "Permanent link") * Don't close children's stdin, stdout, stderr; can be noisy (default: false) `[](https://ackee.xyz/trident/docs/0.8.1/features/trident-manifest/#__codelineno-7-1) [honggfuzz] [](https://ackee.xyz/trident/docs/0.8.1/features/trident-manifest/#__codelineno-7-2) # Don't close children's stdin, stdout, stderr; can be noisy (default: false) [](https://ackee.xyz/trident/docs/0.8.1/features/trident-manifest/#__codelineno-7-3) keep_output = false` * * * #### verbose[#](https://ackee.xyz/trident/docs/0.8.1/features/trident-manifest/#verbose "Permanent link") * Disable ANSI console; use simple log output (default: false) `[](https://ackee.xyz/trident/docs/0.8.1/features/trident-manifest/#__codelineno-8-1) [honggfuzz] [](https://ackee.xyz/trident/docs/0.8.1/features/trident-manifest/#__codelineno-8-2) # Disable ANSI console; use simple log output (default: false) [](https://ackee.xyz/trident/docs/0.8.1/features/trident-manifest/#__codelineno-8-3) verbose = false` * * * #### exit\_upon\_crash[#](https://ackee.xyz/trident/docs/0.8.1/features/trident-manifest/#exit_upon_crash "Permanent link") * Exit upon seeing the first crash (default: false) `[](https://ackee.xyz/trident/docs/0.8.1/features/trident-manifest/#__codelineno-9-1) [honggfuzz] [](https://ackee.xyz/trident/docs/0.8.1/features/trident-manifest/#__codelineno-9-2) # Exit upon seeing the first crash (default: false) [](https://ackee.xyz/trident/docs/0.8.1/features/trident-manifest/#__codelineno-9-3) exit_upon_crash = false` * * * #### mutations\_per\_run[#](https://ackee.xyz/trident/docs/0.8.1/features/trident-manifest/#mutations_per_run "Permanent link") * Maximal number of mutations per one run (default: 6) `[](https://ackee.xyz/trident/docs/0.8.1/features/trident-manifest/#__codelineno-10-1) [honggfuzz] [](https://ackee.xyz/trident/docs/0.8.1/features/trident-manifest/#__codelineno-10-2) # Maximal number of mutations per one run (default: 6) [](https://ackee.xyz/trident/docs/0.8.1/features/trident-manifest/#__codelineno-10-3) mutations_per_run = 6` * * * #### cargo\_target\_dir[#](https://ackee.xyz/trident/docs/0.8.1/features/trident-manifest/#cargo_target_dir "Permanent link") * Target compilation directory, (default: "" \["trident-tests/fuzz\_tests/fuzzing/honggfuzz/hfuzz\_target"\]). * To not clash with cargo build's default target directory. `[](https://ackee.xyz/trident/docs/0.8.1/features/trident-manifest/#__codelineno-11-1) [honggfuzz] [](https://ackee.xyz/trident/docs/0.8.1/features/trident-manifest/#__codelineno-11-2) # Target compilation directory, [](https://ackee.xyz/trident/docs/0.8.1/features/trident-manifest/#__codelineno-11-3) # (default: "" ["trident-tests/fuzz_tests/fuzzing/honggfuzz/hfuzz_target"]). [](https://ackee.xyz/trident/docs/0.8.1/features/trident-manifest/#__codelineno-11-4) # To not clash with cargo build's default target directory. [](https://ackee.xyz/trident/docs/0.8.1/features/trident-manifest/#__codelineno-11-5) cargo_target_dir = ""` * * * #### hfuzz\_workspace[#](https://ackee.xyz/trident/docs/0.8.1/features/trident-manifest/#hfuzz_workspace "Permanent link") * Honggfuzz working directory, (default: "" \["trident-tests/fuzz\_tests/fuzzing/honggfuzz/hfuzz\_workspace"\]). `[](https://ackee.xyz/trident/docs/0.8.1/features/trident-manifest/#__codelineno-12-1) [honggfuzz] [](https://ackee.xyz/trident/docs/0.8.1/features/trident-manifest/#__codelineno-12-2) # Honggfuzz working directory, [](https://ackee.xyz/trident/docs/0.8.1/features/trident-manifest/#__codelineno-12-3) # (default: "" ["trident-tests/fuzz_tests/fuzzing/honggfuzz/hfuzz_workspace"]). [](https://ackee.xyz/trident/docs/0.8.1/features/trident-manifest/#__codelineno-12-4) hfuzz_workspace = ""` * * * #### crashdir[#](https://ackee.xyz/trident/docs/0.8.1/features/trident-manifest/#crashdir "Permanent link") * Directory where crashes are saved to (default: "" \[workspace directory\]) `[](https://ackee.xyz/trident/docs/0.8.1/features/trident-manifest/#__codelineno-13-1) [honggfuzz] [](https://ackee.xyz/trident/docs/0.8.1/features/trident-manifest/#__codelineno-13-2) # Directory where crashes are saved to (default: "" [workspace directory]) [](https://ackee.xyz/trident/docs/0.8.1/features/trident-manifest/#__codelineno-13-3) crashdir = ""` * * * #### extension[#](https://ackee.xyz/trident/docs/0.8.1/features/trident-manifest/#extension "Permanent link") * Input file extension (e.g. 'swf'), (default: "" \['fuzz'\]) `[](https://ackee.xyz/trident/docs/0.8.1/features/trident-manifest/#__codelineno-14-1) [honggfuzz] [](https://ackee.xyz/trident/docs/0.8.1/features/trident-manifest/#__codelineno-14-2) # Input file extension (e.g. 'swf'), (default: "" ['fuzz']) [](https://ackee.xyz/trident/docs/0.8.1/features/trident-manifest/#__codelineno-14-3) extension = ""` * * * #### run\_time[#](https://ackee.xyz/trident/docs/0.8.1/features/trident-manifest/#run_time "Permanent link") * Number of seconds this fuzzing session will last (default: 0 \[no limit\]) `[](https://ackee.xyz/trident/docs/0.8.1/features/trident-manifest/#__codelineno-15-1) [honggfuzz] [](https://ackee.xyz/trident/docs/0.8.1/features/trident-manifest/#__codelineno-15-2) # Number of seconds this fuzzing session will last (default: 0 [no limit]) [](https://ackee.xyz/trident/docs/0.8.1/features/trident-manifest/#__codelineno-15-3) run_time = 0` * * * #### max\_file\_size[#](https://ackee.xyz/trident/docs/0.8.1/features/trident-manifest/#max_file_size "Permanent link") * Maximal size of files processed by the fuzzer in bytes (default: 1048576 = 1MB) `[](https://ackee.xyz/trident/docs/0.8.1/features/trident-manifest/#__codelineno-16-1) [honggfuzz] [](https://ackee.xyz/trident/docs/0.8.1/features/trident-manifest/#__codelineno-16-2) # Maximal size of files processed by the fuzzer in bytes [](https://ackee.xyz/trident/docs/0.8.1/features/trident-manifest/#__codelineno-16-3) # (default: 1048576 = 1MB) [](https://ackee.xyz/trident/docs/0.8.1/features/trident-manifest/#__codelineno-16-4) max_file_size = 1048576` * * * #### save\_all[#](https://ackee.xyz/trident/docs/0.8.1/features/trident-manifest/#save_all "Permanent link") * Save all test-cases (not only the unique ones) by appending the current time-stamp to the filenames (default: false) `[](https://ackee.xyz/trident/docs/0.8.1/features/trident-manifest/#__codelineno-17-1) [honggfuzz] [](https://ackee.xyz/trident/docs/0.8.1/features/trident-manifest/#__codelineno-17-2) # Save all test-cases [](https://ackee.xyz/trident/docs/0.8.1/features/trident-manifest/#__codelineno-17-3) # (not only the unique ones) by appending the current [](https://ackee.xyz/trident/docs/0.8.1/features/trident-manifest/#__codelineno-17-4) # time-stamp to the filename (default: false) [](https://ackee.xyz/trident/docs/0.8.1/features/trident-manifest/#__codelineno-17-5) save_all = false` Tip Consider checking the [Examples](https://ackee.xyz/trident/docs/0.8.1/examples/examples/) section for more tips. Back to top --- # FAQ - Trident [Skip to content](https://ackee.xyz/trident/docs/0.9.1/faq/faq/#faq) FAQ[#](https://ackee.xyz/trident/docs/0.9.1/faq/faq/#faq "Permanent link") =========================================================================== ### Is Trident supported only with Anchor ?[#](https://ackee.xyz/trident/docs/0.9.1/faq/faq/#is-trident-supported-only-with-anchor "Permanent link") * Currently yes, Trident under the hood obtains data from the IDL generated by Anchor. ### I created the Fuzz Test what should I do next ?[#](https://ackee.xyz/trident/docs/0.9.1/faq/faq/#i-created-the-fuzz-test-what-should-i-do-next "Permanent link") * Start here [Writing Fuzz Tests](https://ackee.xyz/trident/docs/0.9.1/writing-fuzz-test/writing-fuzz-test/) . For additional features check [Features](https://ackee.xyz/trident/docs/0.9.1/features/features/) . If you are not sure about anything check [Get Help](https://ackee.xyz/trident/docs/0.9.1/get-help/get-help/) ### My program Instruction contains custom type such as Struct or Enum on its input, but it does not derive Arbitrary.[#](https://ackee.xyz/trident/docs/0.9.1/faq/faq/#my-program-instruction-contains-custom-type-such-as-struct-or-enum-on-its-input-but-it-does-not-derive-arbitrary "Permanent link") * In this case you need to specify same type in the Fuzz Test (with the same fields). And implement From Trait to convert to your type. Check [Custom Data Types](https://ackee.xyz/trident/docs/0.9.1/features/customize-ix-data/) or [Examples of Arbitrary](https://ackee.xyz/trident/docs/0.9.1/examples/examples/) . ### Is Trident open-source ?[#](https://ackee.xyz/trident/docs/0.9.1/faq/faq/#is-trident-open-source "Permanent link") * Yes, here [Trident](https://github.com/Ackee-Blockchain/trident) ### I would like to report Issue with Trident, what should I do ?[#](https://ackee.xyz/trident/docs/0.9.1/faq/faq/#i-would-like-to-report-issue-with-trident-what-should-i-do "Permanent link") * Write Issue [Issues](https://github.com/Ackee-Blockchain/trident/issues) ### Is Trident deployed on Mainnet / Devnet / Testenet ?[#](https://ackee.xyz/trident/docs/0.9.1/faq/faq/#is-trident-deployed-on-mainnet-devnet-testenet "Permanent link") * No, Trident is Fuzz Testing Framework, not Solana Program. ### What type of Fuzzer Trident is ?[#](https://ackee.xyz/trident/docs/0.9.1/faq/faq/#what-type-of-fuzzer-trident-is "Permanent link") * Currently, we refer to it as _"coverage guided gray box fuzzer"_. Back to top --- # Writing fuzz test - Trident [Skip to content](https://ackee.xyz/trident/docs/0.9.1/writing-fuzz-test/writing-fuzz-test/#initialize-trident) Writing fuzz test ================= Initialize Trident[#](https://ackee.xyz/trident/docs/0.9.1/writing-fuzz-test/writing-fuzz-test/#initialize-trident "Permanent link") ------------------------------------------------------------------------------------------------------------------------------------- Initialize Trident in the Anchor-based workspace. `[](https://ackee.xyz/trident/docs/0.9.1/writing-fuzz-test/writing-fuzz-test/#__codelineno-0-1) trident init` Info Trident under the hood * Builds the Anchor-based project. * Reads the generated IDL. * Based on the IDL creates the fuzzing template. Tip If you have Trident already initialized, you can add a new fuzz test using `trident fuzz add`. Fill the Fuzz test Template[#](https://ackee.xyz/trident/docs/0.9.1/writing-fuzz-test/writing-fuzz-test/#fill-the-fuzz-test-template "Permanent link") ------------------------------------------------------------------------------------------------------------------------------------------------------- ### Define Fuzz Accounts[#](https://ackee.xyz/trident/docs/0.9.1/writing-fuzz-test/writing-fuzz-test/#define-fuzz-accounts "Permanent link") Define `AccountsStorage` type for each Account you would like to use. Important Keep in mind: * You do not need to specify every `AccountStorage`; some accounts do not necessarily need to be stored in their corresponding storage. * For example, `System Program` does not need to be stored and can be used from the `solana_sdk`. * You can rename `FuzzAccounts` fields to whatever you want. The default names were generated based on the Program's `IDL`. `[](https://ackee.xyz/trident/docs/0.9.1/writing-fuzz-test/writing-fuzz-test/#__codelineno-1-1) #[doc = r" Use AccountsStorage where T can be one of:"] [](https://ackee.xyz/trident/docs/0.9.1/writing-fuzz-test/writing-fuzz-test/#__codelineno-1-2) #[doc = r" Keypair, PdaStore, TokenStore, MintStore, ProgramStore"] [](https://ackee.xyz/trident/docs/0.9.1/writing-fuzz-test/writing-fuzz-test/#__codelineno-1-3) #[derive(Default)] [](https://ackee.xyz/trident/docs/0.9.1/writing-fuzz-test/writing-fuzz-test/#__codelineno-1-4) pub struct FuzzAccounts { [](https://ackee.xyz/trident/docs/0.9.1/writing-fuzz-test/writing-fuzz-test/#__codelineno-1-5) author: AccountsStorage, [](https://ackee.xyz/trident/docs/0.9.1/writing-fuzz-test/writing-fuzz-test/#__codelineno-1-6) hello_world_account: AccountsStorage, [](https://ackee.xyz/trident/docs/0.9.1/writing-fuzz-test/writing-fuzz-test/#__codelineno-1-7) // No need to fuzz system_program [](https://ackee.xyz/trident/docs/0.9.1/writing-fuzz-test/writing-fuzz-test/#__codelineno-1-8) // system_program: AccountsStorage, [](https://ackee.xyz/trident/docs/0.9.1/writing-fuzz-test/writing-fuzz-test/#__codelineno-1-9) }` Tip For more details about the `AccountsStorage`, check [AccountsStorage](https://ackee.xyz/trident/docs/0.9.1/features/account-storages/) . ### Implement Fuzz Instructions[#](https://ackee.xyz/trident/docs/0.9.1/writing-fuzz-test/writing-fuzz-test/#implement-fuzz-instructions "Permanent link") Each Instruction in the Fuzz Test must define the following functions: * `get_discriminator` * Defines Instruction Discriminator, which is used to identify the Instruction. * `get_program_id()` * Specifies to which program the Instruction belongs. This function is **automatically defined** and should not need any updates. The importance is such that if you have multiple programs in your workspace, Trident can generate Instruction Sequences corresponding to different programs. * `get_data()` * Specifies what Instruction inputs are sent to the Program Instructions. * `get_accounts()` * Specifies what Accounts are sent to the Program Instructions. Tip * For more info about how to write these functions, check the [Fuzz Instructions](https://ackee.xyz/trident/docs/0.9.1/features/fuzz-instructions/) . * For examples of how to write these functions, check the [Examples](https://ackee.xyz/trident/docs/0.9.1/examples/examples/) . Execute[#](https://ackee.xyz/trident/docs/0.9.1/writing-fuzz-test/writing-fuzz-test/#execute "Permanent link") --------------------------------------------------------------------------------------------------------------- Warning To execute and debug fuzz tests, navigate to the `trident-tests` directory. ### Run Fuzz Test[#](https://ackee.xyz/trident/docs/0.9.1/writing-fuzz-test/writing-fuzz-test/#run-fuzz-test "Permanent link") In principle there are two possible fuzzing engines that the Trident supports, [Honggfuzz](https://github.com/google/honggfuzz) and [AFL](https://aflplus.plus/) . To execute the desired fuzz test using the Honggfuzz, run the following command from the `trident-tests` directory: `[](https://ackee.xyz/trident/docs/0.9.1/writing-fuzz-test/writing-fuzz-test/#__codelineno-2-1) # Replace with the name of particular [](https://ackee.xyz/trident/docs/0.9.1/writing-fuzz-test/writing-fuzz-test/#__codelineno-2-2) # fuzz test (for example: "fuzz_0") [](https://ackee.xyz/trident/docs/0.9.1/writing-fuzz-test/writing-fuzz-test/#__codelineno-2-3) trident fuzz run-hfuzz ` To execute the desired fuzz test using the AFL, run the following command from the `trident-tests` directory: `[](https://ackee.xyz/trident/docs/0.9.1/writing-fuzz-test/writing-fuzz-test/#__codelineno-3-1) # Replace with the name of particular [](https://ackee.xyz/trident/docs/0.9.1/writing-fuzz-test/writing-fuzz-test/#__codelineno-3-2) # fuzz test (for example: "fuzz_0") [](https://ackee.xyz/trident/docs/0.9.1/writing-fuzz-test/writing-fuzz-test/#__codelineno-3-3) trident fuzz run-afl ` ### Debug Fuzz Test[#](https://ackee.xyz/trident/docs/0.9.1/writing-fuzz-test/writing-fuzz-test/#debug-fuzz-test "Permanent link") To debug your program using Honggfuzz with values from a crash file, run the following command from the `trident-tests` directory: `[](https://ackee.xyz/trident/docs/0.9.1/writing-fuzz-test/writing-fuzz-test/#__codelineno-4-1) # The fuzzer will run the with the specified [](https://ackee.xyz/trident/docs/0.9.1/writing-fuzz-test/writing-fuzz-test/#__codelineno-4-2) trident fuzz debug-hfuzz ` To debug your program using AFL with values from a crash file, run the following command from the `trident-tests` directory: `[](https://ackee.xyz/trident/docs/0.9.1/writing-fuzz-test/writing-fuzz-test/#__codelineno-5-1) # The fuzzer will run the with the specified [](https://ackee.xyz/trident/docs/0.9.1/writing-fuzz-test/writing-fuzz-test/#__codelineno-5-2) trident fuzz debug-afl ` Tip By default, the crash files are stored in: * `trident-tests/fuzzing/honggfuzz/hfuzz_workspace/` for Honggfuzz and * `trident-tests/fuzzing/afl/afl_workspace/out/default/crashes` for AFL. Tip For more info about the fuzzing outputs, check the [Commands](https://ackee.xyz/trident/docs/0.9.1/commands/commands/) . Back to top --- # Trident Features - Trident [Skip to content](https://ackee.xyz/trident/docs/0.9.1/features/features/#trident-features) Trident Features[#](https://ackee.xyz/trident/docs/0.9.1/features/features/#trident-features "Permanent link") =============================================================================================================== Trident contains multiple features to enhance the fuzzing experience and increase ability to discover bugs. * **AccountStorages** * * * Initialize, store and re-use random Accounts. [**AccountStorages**](https://ackee.xyz/trident/docs/0.9.1/features/account-storages/) * **FuzzInstructions** * * * All available Program Instructions as FuzzInstructions Variants. [**FuzzInstructions**](https://ackee.xyz/trident/docs/0.9.1/features/fuzz-instructions/) * **Custom Instruction Sequences** * * * Specify Instruction Sequqnces you would like to executed instead of completely random execution order. [**Custom Instruction Sequences**](https://ackee.xyz/trident/docs/0.9.1/features/instructions-sequences/) * **Invariant Checks** * * * Allows to compare Account contents before and after the Instruction was successfully executed. [**Invariant Checks**](https://ackee.xyz/trident/docs/0.9.1/features/invariant-checks/) * **Programs and Accounts** * * * Include programs and accounts from the desired cluster (Mainnet, Devnet, etc.). [**Programs and Accounts**](https://ackee.xyz/trident/docs/0.9.1/features/programs-n-accounts/) * **Fuzzing Statistics** * * * Show Fuzzing Statistics after the Fuzzing Session ended. [**Fuzzing Statistics**](https://ackee.xyz/trident/docs/0.9.1/features/fuzzing-statistics/) * **Customize Instruction Data** * * * Customize Instruction data, for example, to use integers from specific range. [**Customize Instruction Data**](https://ackee.xyz/trident/docs/0.9.1/features/customize-ix-data/) * **Trident Manifest** * * * Customize Fuzzing experience with the Trident Manifest. [**Trident Manifest**](https://ackee.xyz/trident/docs/0.9.1/features/trident-manifest/) * **Custom Error Handlers** * * * Continue Instruction Sequence in case of Instruction Error was returned or specify custom behavior based on the returned error. [**Custom Error Handlers**](https://ackee.xyz/trident/docs/0.9.1/features/error-handlers/) Back to top --- # Account Storages - Trident [Skip to content](https://ackee.xyz/trident/docs/0.9.1/features/account-storages/#account-storages) Account Storages[#](https://ackee.xyz/trident/docs/0.9.1/features/account-storages/#account-storages "Permanent link") ======================================================================================================================= Trident allows developers to generate random accounts for fuzzing. However, the fuzzer cannot generate account addresses completely randomly, as the address has 32 bytes; this means that the fuzzer will, in most cases, generate incorrect addresses. Thus, Trident generates random **AccountIDs** which are indexes to **Account Storages**. Each unique account contained within the Anchor-generated IDL has its own AccountStorage. The FuzzAccounts containing the Account Storages are global to all instructions. Important There are two types of Account Storages: * KeypairStore (dedicated for Keypairs) * PdaStore (dedicated for Program Derived Addresses) `[](https://ackee.xyz/trident/docs/0.9.1/features/account-storages/#__codelineno-0-1) pub struct FuzzAccounts { [](https://ackee.xyz/trident/docs/0.9.1/features/account-storages/#__codelineno-0-2) signer: AccountsStorage, [](https://ackee.xyz/trident/docs/0.9.1/features/account-storages/#__codelineno-0-3) some_pda: AccountsStorage, [](https://ackee.xyz/trident/docs/0.9.1/features/account-storages/#__codelineno-0-4) // ... [](https://ackee.xyz/trident/docs/0.9.1/features/account-storages/#__codelineno-0-5) }` Tip Keep in mind: * You do not need to specify every `AccountStorage`; some accounts do not necessarily need to be stored in their corresponding storage. * For example, the `System Program` does not need to be stored and can be used from the `solana_sdk` as a constant account address. * If you are going to initialize an `Associated Token Account` in your Solana Program, use `PdaStore`. * You can rename fields of `FuzzAccounts` to whatever you want. The default names are generated based on the Program's `IDL`. Account Storage Methods[#](https://ackee.xyz/trident/docs/0.9.1/features/account-storages/#account-storage-methods "Permanent link") ------------------------------------------------------------------------------------------------------------------------------------- There are multiple methods to interact with Account Storages. ### `get_or_create_account()`[#](https://ackee.xyz/trident/docs/0.9.1/features/account-storages/#get_or_create_account "Permanent link") Retrieves a record from AccountsStorage based on the entered `account_id`. If no record exists for the `account_id`, a new **empty** account is created. ### `get()`[#](https://ackee.xyz/trident/docs/0.9.1/features/account-storages/#get "Permanent link") Retrieves a record from AccountsStorage based on the entered `account_id`. If no record exists for the `account_id`, a random public key is returned. ### `get_or_create_token_account()`[#](https://ackee.xyz/trident/docs/0.9.1/features/account-storages/#get_or_create_token_account "Permanent link") Retrieves a record from AccountsStorage based on the entered `account_id`. If no record exists for the `account_id`, a new Token account is created. ### `get_or_create_mint_account()`[#](https://ackee.xyz/trident/docs/0.9.1/features/account-storages/#get_or_create_mint_account "Permanent link") Retrieves a record from AccountsStorage based on the entered `account_id`. If no record exists for the `account_id`, a new Mint account is created. ### `get_or_create_delegated_account()`[#](https://ackee.xyz/trident/docs/0.9.1/features/account-storages/#get_or_create_delegated_account "Permanent link") Retrieves a record from AccountsStorage based on the entered `account_id`. If no record exists for the `account_id`, a new Delegated account is created. ### `get_or_create_initialized_account()`[#](https://ackee.xyz/trident/docs/0.9.1/features/account-storages/#get_or_create_initialized_account "Permanent link") Retrieves a record from AccountsStorage based on the entered `account_id`. If no record exists for the `account_id`, a new Initialized account is created. ### `get_or_create_vote_account()`[#](https://ackee.xyz/trident/docs/0.9.1/features/account-storages/#get_or_create_vote_account "Permanent link") Retrieves a record from AccountsStorage based on the entered `account_id`. If no record exists for the `account_id`, a new Vote account is created. Tip Consider checking the [Examples](https://ackee.xyz/trident/docs/0.9.1/examples/examples/) section for more tips. Back to top --- # Changelog - Trident [Skip to content](https://ackee.xyz/trident/docs/0.9.1/CHANGELOG/#changelog) Changelog[#](https://ackee.xyz/trident/docs/0.9.1/CHANGELOG/#changelog "Permanent link") ========================================================================================= All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) , and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html) (SemVer). **Note**: Version 0 of Semantic Versioning is handled differently from version 1 and above. The minor version will be incremented upon a breaking change and the patch version will be incremented for features. \[dev\] - Unreleased[#](https://ackee.xyz/trident/docs/0.9.1/CHANGELOG/#dev-unreleased "Permanent link") --------------------------------------------------------------------------------------------------------- \[0.9.1\] - 2025-02-03[#](https://ackee.xyz/trident/docs/0.9.1/CHANGELOG/#091-2025-02-03 "Permanent link") ----------------------------------------------------------------------------------------------------------- **Added** * added warp to time manipulation ([259](https://github.com/Ackee-Blockchain/trident/pull/259) ) * added methods to check if account storage is empty ([258](https://github.com/Ackee-Blockchain/trident/pull/258) ) * added support for post-instruction behavior ([257](https://github.com/Ackee-Blockchain/trident/pull/257) ) **Removed** **Changed** \[0.9.0\] - 2025-01-15[#](https://ackee.xyz/trident/docs/0.9.1/CHANGELOG/#090-2025-01-15 "Permanent link") ----------------------------------------------------------------------------------------------------------- **Added** * added support for composite accounts ([245](https://github.com/Ackee-Blockchain/trident/pull/245) ) * Trident SVM + AFL (see the PR for more details) ([234](https://github.com/Ackee-Blockchain/trident/pull/234) ) **Removed** * removed fuzz\_iteration from test\_fuzz.rs ([243](https://github.com/Ackee-Blockchain/trident/pull/243) ) **Changed** * renamed Config to TridentConfig ([246](https://github.com/Ackee-Blockchain/trident/pull/246) ) * errors are simplified and transaction error contains only transaction error ([244](https://github.com/Ackee-Blockchain/trident/pull/244) ) \[0.8.1\] - 2024-11-14[#](https://ackee.xyz/trident/docs/0.9.1/CHANGELOG/#081-2024-11-14 "Permanent link") ----------------------------------------------------------------------------------------------------------- **Removed** * removed unnecesarry deserialization with AccountsSnapshots, to deserialize data implementation AccountDeserialize can be used ([221](https://github.com/Ackee-Blockchain/trident/pull/221) ) **Changed** * improve AccountsStorage module structure and remove unnecessary methods in FuzzClient ([223](https://github.com/Ackee-Blockchain/trident/pull/223) ) * improve manipulations with AccountsStorages in get\_accounts() function ([219](https://github.com/Ackee-Blockchain/trident/pull/219) ) **Added** * add pre\_sequence!, middle\_sequence! and post\_sequence! for easier sequence definition ([220](https://github.com/Ackee-Blockchain/trident/pull/220) ) * add/ add support for Clock sysvar manipulations with the client(i.e. warp to slot/epoch and forward in time) ([217](https://github.com/Ackee-Blockchain/trident/pull/217) ) \[0.8.0\] - 2024-10-21[#](https://ackee.xyz/trident/docs/0.9.1/CHANGELOG/#080-2024-10-21 "Permanent link") ----------------------------------------------------------------------------------------------------------- **Added** * impr/ allow to specify programs and accounts in the Trident Manifest ([207](https://github.com/Ackee-Blockchain/trident/pull/207) ) * impr/ added get\_program\_id function to the IxOps and FuzzTestExecutor ([199](https://github.com/Ackee-Blockchain/trident/pull/199) ) **Changed** * impr/ improve init command, modify program manifest automatically, add init force, add howto subcommand ([208](https://github.com/Ackee-Blockchain/trident/pull/208) ) * impr/ allow to derive AccountsSnapshots for empty Account Context ([209](https://github.com/Ackee-Blockchain/trident/pull/209) ) * impr/ fuzz flags are read at start of fuzzing session from Config instead of env variable and transaction dispatch was added to increase FuzzTestExecutor readability ([204](https://github.com/Ackee-Blockchain/trident/pull/204) ) * impr/ allow various instructions to be generated in case of multiple programs in the Anchor workspace ([200](https://github.com/Ackee-Blockchain/trident/pull/200) ) * feat/ option to add account into Fuzz Test environment with base64 data ([197](https://github.com/Ackee-Blockchain/trident/pull/197) ) * impr/ instead of parsing source code and creating our IDL, read anchor IDL ([198](https://github.com/Ackee-Blockchain/trident/pull/196) ) **Removed** * del/remove integration tests supported by Trident, this feature adds more unnecessary overhead compared to its value ([196](https://github.com/Ackee-Blockchain/trident/pull/198) ) \[0.7.0\] - 2024-08-14[#](https://ackee.xyz/trident/docs/0.9.1/CHANGELOG/#070-2024-08-14 "Permanent link") ----------------------------------------------------------------------------------------------------------- **Added** * impr/ add feature flag to the AccountsSnapshots macro ([183](https://github.com/Ackee-Blockchain/trident/pull/183) ) * feat/ add Support for CPI ([182](https://github.com/Ackee-Blockchain/trident/pull/182) ) * feat/ add option to initialize Trident with Macro/File (for Snapshots) option based on preference ([179](https://github.com/Ackee-Blockchain/trident/pull/179) ) * feat/create AccountsSnapshots derive macro for Snapshots creation ([#177](https://github.com/Ackee-Blockchain/trident/pull/177) ) * feat/fuzzing moved to separate crate trident-fuzz ([#175](https://github.com/Ackee-Blockchain/trident/pull/175) ) * feat/unify dependencies provided by the Trident ([#172](https://github.com/Ackee-Blockchain/trident/pull/172) ) * feat/fuzzer-stats-logging, an optional statistics output for fuzzing session ([#144](https://github.com/Ackee-Blockchain/trident/pull/144) ) **Fixed** * fix/in case of fuzzing failure throw error instead of only printing message ([#167](https://github.com/Ackee-Blockchain/trident/pull/167) ) * fix/snapshot's zeroed account as optional ([#170](https://github.com/Ackee-Blockchain/trident/pull/170) ) **Removed** * del/remove localnet subcommand ([178](https://github.com/Ackee-Blockchain/trident/pull/178) ) * del/remove unnecessary fuzzing feature as trident is mainly fuzzer ([#176](https://github.com/Ackee-Blockchain/trident/pull/176) ) * del/remove Trident explorer ([#171](https://github.com/Ackee-Blockchain/trident/pull/171) ) \[0.6.0\] - 2024-05-20[#](https://ackee.xyz/trident/docs/0.9.1/CHANGELOG/#060-2024-05-20 "Permanent link") ----------------------------------------------------------------------------------------------------------- **Added** * feat/anchor 0.30.0 support ([#148](https://github.com/Ackee-Blockchain/trident/pull/148) ) * fix/allow to process duplicate transactions ([#147](https://github.com/Ackee-Blockchain/trident/pull/147) ) * feat/possibility to implement custom transaction error handling ([#145](https://github.com/Ackee-Blockchain/trident/pull/145) ) * feat/support of automatically obtaining fully qualified paths of Data Accounts Custom types for `accounts_snapshots.rs` ([#141](https://github.com/Ackee-Blockchain/trident/pull/141) ) * feat/allow direct accounts manipulation and storage ([#142](https://github.com/Ackee-Blockchain/trident/pull/142) ) * feat/support of non-corresponding instruction and context names ([#130](https://github.com/Ackee-Blockchain/trident/pull/130) ) * feat/refactored and improved program flow during init and build, added activity indicator ([#129](https://github.com/Ackee-Blockchain/trident/pull/129) ) * feat/allow solana versions up to v1.17.\* and pin Rust 1.77 nightly compiler ([#128](https://github.com/Ackee-Blockchain/trident/pull/128) ) * feat/new init command option to initialize fuzz or poc tests only ([#124](https://github.com/Ackee-Blockchain/trident/pull/124) ) * feat/debug-mode detailed output ([#125](https://github.com/Ackee-Blockchain/trident/pull/125) ) * feat/anchor 0.29.0 support ([#121](https://github.com/Ackee-Blockchain/trident/pull/121) ) * doc/add help comment + update documentation ([#120](https://github.com/Ackee-Blockchain/trident/pull/120) ) * feat/fuzzer error handling ([#118](https://github.com/Ackee-Blockchain/trident/pull/118) ) * feat/convert fuzz Pubkey to AccountId ([#116](https://github.com/Ackee-Blockchain/trident/pull/116) ) * feat/additional anchor types ([#115](https://github.com/Ackee-Blockchain/trident/pull/115) ) * feat/import ToAccountInfo trait in fuzzing prelude ([#113](https://github.com/Ackee-Blockchain/trident/pull/113) ) * test/added code generation and macros tests ([#112](https://github.com/Ackee-Blockchain/trident/pull/112) ) * feat/fuzzer framework core, macros, helpers, templates, and examples. ([#111](https://github.com/Ackee-Blockchain/trident/pull/111) ) * feat/improved trident-tests folder structure for PoC and Fuzz Tests ([#109](https://github.com/Ackee-Blockchain/trident/pull/109) ) * feat/support for additional fuzzer parameters in Trident.toml config file ([#107](https://github.com/Ackee-Blockchain/trident/pull/107) ) * feat/posibility to pass params to the fuzzer via Trident.toml config file ([#106](https://github.com/Ackee-Blockchain/trident/pull/106) ) * feat/client now reads by default keypair from default location ([#105](https://github.com/Ackee-Blockchain/trident/pull/105) ) * feat/added new --exit-code option to return corresponding exit code based on fuzz test result ([#104](https://github.com/Ackee-Blockchain/trident/pull/104) ) * feat/removed/updated deprecated functions, removed allow deprecated macros ([#103](https://github.com/Ackee-Blockchain/trident/pull/103) ) * feat/added new function to read keypair file generated by Anchor ([#102](https://github.com/Ackee-Blockchain/trident/pull/102) ) * feat/clean command ([#101](https://github.com/Ackee-Blockchain/trident/pull/101) ) * feat/improved program\_client generated code ([#100](https://github.com/Ackee-Blockchain/trident/pull/100) ) * feat/automatically add hfuzz\_target to .gitignore file ([#99](https://github.com/Ackee-Blockchain/trident/pull/99) ) * feat/support for dynamic templates. ([#98](https://github.com/Ackee-Blockchain/trident/pull/98) ) **Fixed** * fix/refactored fuzz test executor error handling ([#127](https://github.com/Ackee-Blockchain/trident/pull/127) ) * fix/warn user on composite accounts and continue fuzz test generation ([#133](https://github.com/Ackee-Blockchain/trident/pull/133) ) * fix/progress bar loop lock release ([#132](https://github.com/Ackee-Blockchain/trident/pull/132) ) * fix/fixed fuzz test generation with init-if-needed Anchor feature ([#131](https://github.com/Ackee-Blockchain/trident/pull/131) ) * fix/program client custom types ([#117](https://github.com/Ackee-Blockchain/trident/pull/117) ) * fix/check fuzz test name collision by checking the name against HashSet ([#114](https://github.com/Ackee-Blockchain/trident/pull/114) ) \[0.5.0\] - 2023-08-28[#](https://ackee.xyz/trident/docs/0.9.1/CHANGELOG/#050-2023-08-28 "Permanent link") ----------------------------------------------------------------------------------------------------------- **Added** * cli: Added trident subcommand `fuzz` to run and debug fuzz tests using honggfuzz-rs. * cli: Added trident `--skip-fuzzer` option for `init` subcommand to skip generation of fuzz test templates. * client: Added new Cargo feature `fuzzing` that enables optional dependencies related to fuzz testing. \[0.4.1\] - 2023-08-21[#](https://ackee.xyz/trident/docs/0.9.1/CHANGELOG/#041-2023-08-21 "Permanent link") ----------------------------------------------------------------------------------------------------------- **Changed** * Upgrade Solana (`=1.16.6`) and Anchor framework (`=0.28.0`) versions. **Fixed** * Implemented Anchor Client logic was not able to work with newer version of Anchor. Fixed with `async_rpc` and `async` feature. * Trident init IDL Parse Error on newer version of Rust, fixed with updated `accounts` token. \[0.3.0\] - 2022-09-23[#](https://ackee.xyz/trident/docs/0.9.1/CHANGELOG/#030-2022-09-23 "Permanent link") ----------------------------------------------------------------------------------------------------------- **Changed** * Upgrade Solana (`~1.10`) and Anchor framework (`~0.25`) versions **Added** * Custom Solana RPC error reporter. If the Solana RPC error is thrown, the error code, message and data (logs) are reported to the output. * Custom imports in the `.program_client`. User is able to import custom types and structures into program client. The import part of the code would not be re-generated. \[0.2.0\] - 2022-07-27[#](https://ackee.xyz/trident/docs/0.9.1/CHANGELOG/#020-2022-07-27 "Permanent link") ----------------------------------------------------------------------------------------------------------- **Added** * Trident is now configurable. This requires `Trident.toml` file to exist in the project's root directory - without this file the execution will fail. To solve this re-run `trident init` or just create an empty `Trident.toml` file in the project's root directory. Back to top --- # Instructions Sequences - Trident [Skip to content](https://ackee.xyz/trident/docs/0.9.1/features/instructions-sequences/#instructions-sequences) Instructions Sequences[#](https://ackee.xyz/trident/docs/0.9.1/features/instructions-sequences/#instructions-sequences "Permanent link") ========================================================================================================================================= Trident allows you to specify **custom instruction sequences** that you would like to execute. Possible instruction sequences are divided into three parts: * **Pre-Instructions** * **Instructions** * **Post-Instructions** For example, if your program requires an Initialization instruction at the start, you can specify it using the `pre_sequence()` macro, as shown in the source code below. ``[](https://ackee.xyz/trident/docs/0.9.1/features/instructions-sequences/#__codelineno-0-1) // test_fuzz.rs [](https://ackee.xyz/trident/docs/0.9.1/features/instructions-sequences/#__codelineno-0-2)[](https://ackee.xyz/trident/docs/0.9.1/features/instructions-sequences/#__codelineno-0-3) /// ... [](https://ackee.xyz/trident/docs/0.9.1/features/instructions-sequences/#__codelineno-0-4)[](https://ackee.xyz/trident/docs/0.9.1/features/instructions-sequences/#__codelineno-0-5) struct InstructionsSequence; [](https://ackee.xyz/trident/docs/0.9.1/features/instructions-sequences/#__codelineno-0-6) /// Define instruction sequences for invocation. [](https://ackee.xyz/trident/docs/0.9.1/features/instructions-sequences/#__codelineno-0-7) /// `pre` runs at the start, `middle` in the middle, and `post` at the end. [](https://ackee.xyz/trident/docs/0.9.1/features/instructions-sequences/#__codelineno-0-8) /// For example, to call `InitializeFn`, `UpdateFn` and then `WithdrawFn` during [](https://ackee.xyz/trident/docs/0.9.1/features/instructions-sequences/#__codelineno-0-9) /// each fuzzing iteration: [](https://ackee.xyz/trident/docs/0.9.1/features/instructions-sequences/#__codelineno-0-10) /// ``` [](https://ackee.xyz/trident/docs/0.9.1/features/instructions-sequences/#__codelineno-0-11) /// impl FuzzDataBuilder for InstructionsSequence { [](https://ackee.xyz/trident/docs/0.9.1/features/instructions-sequences/#__codelineno-0-12) /// pre_sequence!(InitializeFn,UpdateFn); [](https://ackee.xyz/trident/docs/0.9.1/features/instructions-sequences/#__codelineno-0-13) /// middle_sequence!(WithdrawFn); [](https://ackee.xyz/trident/docs/0.9.1/features/instructions-sequences/#__codelineno-0-14) ///} [](https://ackee.xyz/trident/docs/0.9.1/features/instructions-sequences/#__codelineno-0-15) /// ``` [](https://ackee.xyz/trident/docs/0.9.1/features/instructions-sequences/#__codelineno-0-16) /// For more details, see: [](https://ackee.xyz/trident/docs/0.9.1/features/instructions-sequences/#__codelineno-0-17) /// https://ackee.xyz/trident/docs/dev/features/instructions-sequences/#instructions-sequences [](https://ackee.xyz/trident/docs/0.9.1/features/instructions-sequences/#__codelineno-0-18) impl FuzzDataBuilder for InstructionsSequence { [](https://ackee.xyz/trident/docs/0.9.1/features/instructions-sequences/#__codelineno-0-19) pre_sequence!(InitializeFn); [](https://ackee.xyz/trident/docs/0.9.1/features/instructions-sequences/#__codelineno-0-20) middle_sequence!(); [](https://ackee.xyz/trident/docs/0.9.1/features/instructions-sequences/#__codelineno-0-21) post_sequence!(); [](https://ackee.xyz/trident/docs/0.9.1/features/instructions-sequences/#__codelineno-0-22) } [](https://ackee.xyz/trident/docs/0.9.1/features/instructions-sequences/#__codelineno-0-23)[](https://ackee.xyz/trident/docs/0.9.1/features/instructions-sequences/#__codelineno-0-24) /// ...`` Tip * The arguments to the macro are variants of `FuzzInstruction` specified in `fuzz_instructions.rs`. * Empty macro parameters (such as `middle_sequence!()`) will skip that section, meaning no instructions will be executed during that phase. * If no macro is defined for a section, a random instruction sequence will be generated for that section. Manual Trait Override[#](https://ackee.xyz/trident/docs/0.9.1/features/instructions-sequences/#manual-trait-override "Permanent link") --------------------------------------------------------------------------------------------------------------------------------------- It is not necessary to use the macro as explained above. The trait implementation (i.e., the methods) can be implemented manually, allowing for greater customization if needed. The rules are the same as described above. `[](https://ackee.xyz/trident/docs/0.9.1/features/instructions-sequences/#__codelineno-1-1) // test_fuzz.rs [](https://ackee.xyz/trident/docs/0.9.1/features/instructions-sequences/#__codelineno-1-2)[](https://ackee.xyz/trident/docs/0.9.1/features/instructions-sequences/#__codelineno-1-3) // Do not forget to include the required structures [](https://ackee.xyz/trident/docs/0.9.1/features/instructions-sequences/#__codelineno-1-4) use fuzz_instructions::InitVesting; [](https://ackee.xyz/trident/docs/0.9.1/features/instructions-sequences/#__codelineno-1-5) use fuzz_instructions::WithdrawUnlocked; [](https://ackee.xyz/trident/docs/0.9.1/features/instructions-sequences/#__codelineno-1-6)[](https://ackee.xyz/trident/docs/0.9.1/features/instructions-sequences/#__codelineno-1-7) impl FuzzDataBuilder for MyFuzzData { [](https://ackee.xyz/trident/docs/0.9.1/features/instructions-sequences/#__codelineno-1-8) fn pre_ixs( [](https://ackee.xyz/trident/docs/0.9.1/features/instructions-sequences/#__codelineno-1-9) u: &mut arbitrary::Unstructured [](https://ackee.xyz/trident/docs/0.9.1/features/instructions-sequences/#__codelineno-1-10) ) -> arbitrary::Result> { [](https://ackee.xyz/trident/docs/0.9.1/features/instructions-sequences/#__codelineno-1-11) let init_ix = [](https://ackee.xyz/trident/docs/0.9.1/features/instructions-sequences/#__codelineno-1-12) FuzzInstruction::InitVesting(InitVesting::arbitrary(u)?); [](https://ackee.xyz/trident/docs/0.9.1/features/instructions-sequences/#__codelineno-1-13) [](https://ackee.xyz/trident/docs/0.9.1/features/instructions-sequences/#__codelineno-1-14) Ok(vec![init_ix]) [](https://ackee.xyz/trident/docs/0.9.1/features/instructions-sequences/#__codelineno-1-15) } [](https://ackee.xyz/trident/docs/0.9.1/features/instructions-sequences/#__codelineno-1-16) fn ixs( [](https://ackee.xyz/trident/docs/0.9.1/features/instructions-sequences/#__codelineno-1-17) u: &mut arbitrary::Unstructured [](https://ackee.xyz/trident/docs/0.9.1/features/instructions-sequences/#__codelineno-1-18) ) -> arbitrary::Result> { [](https://ackee.xyz/trident/docs/0.9.1/features/instructions-sequences/#__codelineno-1-19) let withdraw_ix = [](https://ackee.xyz/trident/docs/0.9.1/features/instructions-sequences/#__codelineno-1-20) FuzzInstruction::WithdrawUnlocked(WithdrawUnlocked::arbitrary(u)?); [](https://ackee.xyz/trident/docs/0.9.1/features/instructions-sequences/#__codelineno-1-21) [](https://ackee.xyz/trident/docs/0.9.1/features/instructions-sequences/#__codelineno-1-22) Ok(vec![withdraw_ix]) [](https://ackee.xyz/trident/docs/0.9.1/features/instructions-sequences/#__codelineno-1-23) } [](https://ackee.xyz/trident/docs/0.9.1/features/instructions-sequences/#__codelineno-1-24) fn post_ixs( [](https://ackee.xyz/trident/docs/0.9.1/features/instructions-sequences/#__codelineno-1-25) _u: &mut arbitrary::Unstructured [](https://ackee.xyz/trident/docs/0.9.1/features/instructions-sequences/#__codelineno-1-26) ) -> arbitrary::Result> { [](https://ackee.xyz/trident/docs/0.9.1/features/instructions-sequences/#__codelineno-1-27) Ok(vec![]) [](https://ackee.xyz/trident/docs/0.9.1/features/instructions-sequences/#__codelineno-1-28) } [](https://ackee.xyz/trident/docs/0.9.1/features/instructions-sequences/#__codelineno-1-29) }` Tip Consider checking the [Examples](https://ackee.xyz/trident/docs/0.9.1/examples/examples/) section for more tips on implementing instruction sequences effectively. Back to top --- # Fuzzing Statistics - Trident [Skip to content](https://ackee.xyz/trident/docs/0.9.1/features/fuzzing-statistics/#fuzzing-statistics) Fuzzing Statistics[#](https://ackee.xyz/trident/docs/0.9.1/features/fuzzing-statistics/#fuzzing-statistics "Permanent link") ============================================================================================================================= Trident allows you to see statistics after the fuzzing session ended. Important In order to show statistics set `fuzzing_with_stats` within the `Trident.toml` to `true`. `[](https://ackee.xyz/trident/docs/0.9.1/features/fuzzing-statistics/#__codelineno-0-1) [fuzz] [](https://ackee.xyz/trident/docs/0.9.1/features/fuzzing-statistics/#__codelineno-0-2) # ... [](https://ackee.xyz/trident/docs/0.9.1/features/fuzzing-statistics/#__codelineno-0-3) fuzzing_with_stats = true [](https://ackee.xyz/trident/docs/0.9.1/features/fuzzing-statistics/#__codelineno-0-4) # ...` Available Statistics[#](https://ackee.xyz/trident/docs/0.9.1/features/fuzzing-statistics/#available-statistics "Permanent link") --------------------------------------------------------------------------------------------------------------------------------- ### Simple[#](https://ackee.xyz/trident/docs/0.9.1/features/fuzzing-statistics/#simple "Permanent link") * Number of invocations of each instruction during the fuzzing session. * Number of successful invocations of each instruction during the fuzzing session. * Number of failed invariants checks for each instruction during the fuzzing session. Note Keep in mind that the number of fuzz iterations does not directly correspond to the total number of invocations. In one fuzz iteration, the fuzzer might be unable to deserialize fuzz data into instructions, causing the entire iteration to be skipped. On the other hand, this is expected behavior as the underlying data are randomly (with coverage feedback) generated, so the Honggfuzz will not necessarily find appropriate data each iteration. Tip Consider checking the [Examples](https://ackee.xyz/trident/docs/0.9.1/examples/examples/) section for more tips. Back to top --- # Invariant Checks - Trident [Skip to content](https://ackee.xyz/trident/docs/0.9.1/features/invariant-checks/#invariant-checks) Invariant Checks[#](https://ackee.xyz/trident/docs/0.9.1/features/invariant-checks/#invariant-checks "Permanent link") ======================================================================================================================= Trident allows you to (optionally) specify invariant checks for each Instruction. The invariant check will be called after the Instruction has been successfully invoked. Within the invariant check, you can compare the contents of accounts before and after the Instruction. Important Returning an error in the Invariant Check is considered a detection of undesired behavior (i.e., issue/crash detected). `[](https://ackee.xyz/trident/docs/0.9.1/features/invariant-checks/#__codelineno-0-1) fn check( [](https://ackee.xyz/trident/docs/0.9.1/features/invariant-checks/#__codelineno-0-2) &self, [](https://ackee.xyz/trident/docs/0.9.1/features/invariant-checks/#__codelineno-0-3) pre_ix: &[SnapshotAccount], [](https://ackee.xyz/trident/docs/0.9.1/features/invariant-checks/#__codelineno-0-4) post_ix: &[SnapshotAccount], [](https://ackee.xyz/trident/docs/0.9.1/features/invariant-checks/#__codelineno-0-5) ix_data: Vec, [](https://ackee.xyz/trident/docs/0.9.1/features/invariant-checks/#__codelineno-0-6) ) -> Result<(), FuzzingError> { [](https://ackee.xyz/trident/docs/0.9.1/features/invariant-checks/#__codelineno-0-7) if let Ok(hello_world_account) = [](https://ackee.xyz/trident/docs/0.9.1/features/invariant-checks/#__codelineno-0-8) StoreHelloWorld::deserialize(&mut post_ix[1].data_no_discriminator()) [](https://ackee.xyz/trident/docs/0.9.1/features/invariant-checks/#__codelineno-0-9) { [](https://ackee.xyz/trident/docs/0.9.1/features/invariant-checks/#__codelineno-0-10) if hello_world_account.input == 253 { [](https://ackee.xyz/trident/docs/0.9.1/features/invariant-checks/#__codelineno-0-11) return Err(FuzzingError::Custom(1)); [](https://ackee.xyz/trident/docs/0.9.1/features/invariant-checks/#__codelineno-0-12) } [](https://ackee.xyz/trident/docs/0.9.1/features/invariant-checks/#__codelineno-0-13) } [](https://ackee.xyz/trident/docs/0.9.1/features/invariant-checks/#__codelineno-0-14) Ok(()) [](https://ackee.xyz/trident/docs/0.9.1/features/invariant-checks/#__codelineno-0-15) }` Important The order of accounts within the array is the same as the order of accounts in the instruction input of your program. Account Deserialization[#](https://ackee.xyz/trident/docs/0.9.1/features/invariant-checks/#account-deserialization "Permanent link") ------------------------------------------------------------------------------------------------------------------------------------- The `SnapshotAccount` provides methods to obtain parts of the account (e.g., address, its data, owner, etc.). If you want to deserialize data into a struct defined within your program, ensure that the struct is present in the fuzz test template and has derived the `BorshDeserialize` and `BorshSerialize` traits, as shown in the example below: `[](https://ackee.xyz/trident/docs/0.9.1/features/invariant-checks/#__codelineno-1-1) #[derive(Debug, BorshDeserialize, BorshSerialize, Clone)] [](https://ackee.xyz/trident/docs/0.9.1/features/invariant-checks/#__codelineno-1-2) pub struct StoreHelloWorld { [](https://ackee.xyz/trident/docs/0.9.1/features/invariant-checks/#__codelineno-1-3) recipient: Pubkey, [](https://ackee.xyz/trident/docs/0.9.1/features/invariant-checks/#__codelineno-1-4) input: u8, [](https://ackee.xyz/trident/docs/0.9.1/features/invariant-checks/#__codelineno-1-5) }` Tip Consider checking the [Examples](https://ackee.xyz/trident/docs/0.9.1/examples/examples/) section for more tips. Back to top --- # Programs and Accounts - Trident [Skip to content](https://ackee.xyz/trident/docs/0.9.1/features/programs-n-accounts/#programs-and-accounts) Programs and Accounts[#](https://ackee.xyz/trident/docs/0.9.1/features/programs-n-accounts/#programs-and-accounts "Permanent link") ==================================================================================================================================== Trident allows for usage of programs and accounts from the desired cluster (Mainnet, Devnet, etc.). ### Include Mainnet Programs[#](https://ackee.xyz/trident/docs/0.9.1/features/programs-n-accounts/#include-mainnet-programs "Permanent link") In case you want to include programs from Mainnet, you can do so by specifying the address and path to the program in the `Trident.toml`. `[](https://ackee.xyz/trident/docs/0.9.1/features/programs-n-accounts/#__codelineno-0-1) [[fuzz.programs]] [](https://ackee.xyz/trident/docs/0.9.1/features/programs-n-accounts/#__codelineno-0-2) address = "metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s" [](https://ackee.xyz/trident/docs/0.9.1/features/programs-n-accounts/#__codelineno-0-3) program = "metaplex-program/metaplex-token-metadata.so"` Tip If you want to dump a program from Mainnet, use `[](https://ackee.xyz/trident/docs/0.9.1/features/programs-n-accounts/#__codelineno-1-1) # -u m specifies to dump from mainnet [](https://ackee.xyz/trident/docs/0.9.1/features/programs-n-accounts/#__codelineno-1-2) solana program dump -u m .so` ### Include Mainnet Accounts[#](https://ackee.xyz/trident/docs/0.9.1/features/programs-n-accounts/#include-mainnet-accounts "Permanent link") In case you want to include accounts from Mainnet, you can do so by specifying the address and path to the account in the `Trident.toml`. `[](https://ackee.xyz/trident/docs/0.9.1/features/programs-n-accounts/#__codelineno-2-1) [[fuzz.accounts]] [](https://ackee.xyz/trident/docs/0.9.1/features/programs-n-accounts/#__codelineno-2-2) address = "6YG3J7PaxyMnnbU67ifyrgF3BzNzc7cD8hPkqK6ATweE" [](https://ackee.xyz/trident/docs/0.9.1/features/programs-n-accounts/#__codelineno-2-3) filename = "tests/accounts/core_bridge_mainnet/guardian_set_5_mock.json"` Tip If you want to obtain an account with `base64` data format, use `[](https://ackee.xyz/trident/docs/0.9.1/features/programs-n-accounts/#__codelineno-3-1) # -u m specifies to dump from mainnet [](https://ackee.xyz/trident/docs/0.9.1/features/programs-n-accounts/#__codelineno-3-2) solana account -u m
--output json` ### Include Programs Through the Entrypoint[#](https://ackee.xyz/trident/docs/0.9.1/features/programs-n-accounts/#include-programs-through-the-entrypoint "Permanent link") There is another way to include programs in the Fuzz Test Environment. Including programs through the entrypoint is better for fuzzing, as the program is built together with the fuzz test, so that it will contain instrumentation which helps the fuzzer to better cover all possible program branches. However, the source code is required to do so. You can include additional programs using the program entrypoint, as shown in the example below: `[](https://ackee.xyz/trident/docs/0.9.1/features/programs-n-accounts/#__codelineno-4-1) // test_fuzz.rs [](https://ackee.xyz/trident/docs/0.9.1/features/programs-n-accounts/#__codelineno-4-2)[](https://ackee.xyz/trident/docs/0.9.1/features/programs-n-accounts/#__codelineno-4-3) use callee::entry as entry_callee; [](https://ackee.xyz/trident/docs/0.9.1/features/programs-n-accounts/#__codelineno-4-4) use caller::entry as entry_caller; [](https://ackee.xyz/trident/docs/0.9.1/features/programs-n-accounts/#__codelineno-4-5)[](https://ackee.xyz/trident/docs/0.9.1/features/programs-n-accounts/#__codelineno-4-6) // ... [](https://ackee.xyz/trident/docs/0.9.1/features/programs-n-accounts/#__codelineno-4-7)[](https://ackee.xyz/trident/docs/0.9.1/features/programs-n-accounts/#__codelineno-4-8) fn main() { [](https://ackee.xyz/trident/docs/0.9.1/features/programs-n-accounts/#__codelineno-4-9) // Program 1 [](https://ackee.xyz/trident/docs/0.9.1/features/programs-n-accounts/#__codelineno-4-10) let program_callee = ProgramEntrypoint::new( [](https://ackee.xyz/trident/docs/0.9.1/features/programs-n-accounts/#__codelineno-4-11) pubkey!("HJR1TK8bgrUWzysdpS1pBGBYKF7zi1tU9cS4qj8BW8ZL"), [](https://ackee.xyz/trident/docs/0.9.1/features/programs-n-accounts/#__codelineno-4-12) None, [](https://ackee.xyz/trident/docs/0.9.1/features/programs-n-accounts/#__codelineno-4-13) processor!(entry_callee), [](https://ackee.xyz/trident/docs/0.9.1/features/programs-n-accounts/#__codelineno-4-14) ); [](https://ackee.xyz/trident/docs/0.9.1/features/programs-n-accounts/#__codelineno-4-15) [](https://ackee.xyz/trident/docs/0.9.1/features/programs-n-accounts/#__codelineno-4-16) // Program 2 [](https://ackee.xyz/trident/docs/0.9.1/features/programs-n-accounts/#__codelineno-4-17) let program_caller = ProgramEntrypoint::new( [](https://ackee.xyz/trident/docs/0.9.1/features/programs-n-accounts/#__codelineno-4-18) pubkey!("FWtSodrkUnovFPnNRCxneP6VWh6JH6jtQZ4PHoP8Ejuz"), [](https://ackee.xyz/trident/docs/0.9.1/features/programs-n-accounts/#__codelineno-4-19) None, [](https://ackee.xyz/trident/docs/0.9.1/features/programs-n-accounts/#__codelineno-4-20) processor!(entry_caller), [](https://ackee.xyz/trident/docs/0.9.1/features/programs-n-accounts/#__codelineno-4-21) ); [](https://ackee.xyz/trident/docs/0.9.1/features/programs-n-accounts/#__codelineno-4-22) let config = Config::new(); [](https://ackee.xyz/trident/docs/0.9.1/features/programs-n-accounts/#__codelineno-4-23) [](https://ackee.xyz/trident/docs/0.9.1/features/programs-n-accounts/#__codelineno-4-24) let mut client = TridentSVM::new_client( [](https://ackee.xyz/trident/docs/0.9.1/features/programs-n-accounts/#__codelineno-4-25) &[program_callee, program_caller], [](https://ackee.xyz/trident/docs/0.9.1/features/programs-n-accounts/#__codelineno-4-26) &config [](https://ackee.xyz/trident/docs/0.9.1/features/programs-n-accounts/#__codelineno-4-27) ); [](https://ackee.xyz/trident/docs/0.9.1/features/programs-n-accounts/#__codelineno-4-28) [](https://ackee.xyz/trident/docs/0.9.1/features/programs-n-accounts/#__codelineno-4-29) fuzz_trident ! [](https://ackee.xyz/trident/docs/0.9.1/features/programs-n-accounts/#__codelineno-4-30) (fuzz_ix : FuzzInstruction , | fuzz_data : InstructionsSequence | [](https://ackee.xyz/trident/docs/0.9.1/features/programs-n-accounts/#__codelineno-4-31) { fuzz_iteration (fuzz_data , & config , & mut client) ; }); [](https://ackee.xyz/trident/docs/0.9.1/features/programs-n-accounts/#__codelineno-4-32) }` Tip Consider checking the [Examples](https://ackee.xyz/trident/docs/0.9.1/examples/examples/) section for more tips. Back to top --- # Error Handler - Trident [Skip to content](https://ackee.xyz/trident/docs/0.9.1/features/error-handlers/#error-handler) Error Handler[#](https://ackee.xyz/trident/docs/0.9.1/features/error-handlers/#error-handler "Permanent link") =============================================================================================================== Trident allows you to specify a custom error handler for each instruction. This can be particularly helpful in the following scenarios: * 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 By default, transaction errors are propagated, meaning that if the transaction fails, the fuzzing iteration is stopped, and a new fuzzing iteration is started. `[](https://ackee.xyz/trident/docs/0.9.1/features/error-handlers/#__codelineno-0-1) /// Default implementation [](https://ackee.xyz/trident/docs/0.9.1/features/error-handlers/#__codelineno-0-2) fn tx_error_handler( [](https://ackee.xyz/trident/docs/0.9.1/features/error-handlers/#__codelineno-0-3) &self, [](https://ackee.xyz/trident/docs/0.9.1/features/error-handlers/#__codelineno-0-4) e: TransactionError, [](https://ackee.xyz/trident/docs/0.9.1/features/error-handlers/#__codelineno-0-5) ix_data: Vec, [](https://ackee.xyz/trident/docs/0.9.1/features/error-handlers/#__codelineno-0-6) pre_ix_acc_infos: &[SnapshotAccount], [](https://ackee.xyz/trident/docs/0.9.1/features/error-handlers/#__codelineno-0-7) ) -> Result<(), TransactionError> { [](https://ackee.xyz/trident/docs/0.9.1/features/error-handlers/#__codelineno-0-8) Err(e) [](https://ackee.xyz/trident/docs/0.9.1/features/error-handlers/#__codelineno-0-9) }` To omit the error and continue with the next instruction in the iteration, you can use the following implementation: `[](https://ackee.xyz/trident/docs/0.9.1/features/error-handlers/#__codelineno-1-1) /// Custom implementation [](https://ackee.xyz/trident/docs/0.9.1/features/error-handlers/#__codelineno-1-2) fn tx_error_handler( [](https://ackee.xyz/trident/docs/0.9.1/features/error-handlers/#__codelineno-1-3) &self, [](https://ackee.xyz/trident/docs/0.9.1/features/error-handlers/#__codelineno-1-4) e: TransactionError, [](https://ackee.xyz/trident/docs/0.9.1/features/error-handlers/#__codelineno-1-5) ix_data: Vec, [](https://ackee.xyz/trident/docs/0.9.1/features/error-handlers/#__codelineno-1-6) pre_ix_acc_infos: &[SnapshotAccount], [](https://ackee.xyz/trident/docs/0.9.1/features/error-handlers/#__codelineno-1-7) ) -> Result<(), TransactionError> { [](https://ackee.xyz/trident/docs/0.9.1/features/error-handlers/#__codelineno-1-8) Ok(()) [](https://ackee.xyz/trident/docs/0.9.1/features/error-handlers/#__codelineno-1-9) }` Back to top --- # Account Storages - Trident [Skip to content](https://ackee.xyz/trident/docs/0.8.1/features/account-storages/#account-storages) Account Storages[#](https://ackee.xyz/trident/docs/0.8.1/features/account-storages/#account-storages "Permanent link") ======================================================================================================================= Trident allows developers to generate random accounts for fuzzing. However, the Accounts are not completely random, and neither are the Account addresses. Instead, Trident generates random **AccountIDs** which are indexes to **Account Storages**. Each unique Account contained within the Anchor generated IDL has its own AccountStorage. The FuzzAccounts containing the Accounts Storages is global to all Instructions to use. Note **Details:** Always generating only random accounts would **in most cases lead to a situation where the fuzzer would be stuck because the accounts would be almost every time rejected by your Anchor program**. Therefore it is necessary to specify, what accounts should be used and also limit the number of newly created accounts to reduce the space complexity. Important Currently, supported types of Account Storages: * Signer (KeypairStore) * Program Derived Address (PdaStore) * Token Account (TokenStore) * Mint Account (MintStore) * Program Account (ProgramStore) * Stake Account (StakeStore) * Vote Account (VoteStore) Then use the corresponding AccountsStorage. `[](https://ackee.xyz/trident/docs/0.8.1/features/account-storages/#__codelineno-0-1) pub struct FuzzAccounts { [](https://ackee.xyz/trident/docs/0.8.1/features/account-storages/#__codelineno-0-2) signer: AccountsStorage, [](https://ackee.xyz/trident/docs/0.8.1/features/account-storages/#__codelineno-0-3) some_pda: AccountsStorage, [](https://ackee.xyz/trident/docs/0.8.1/features/account-storages/#__codelineno-0-4) token_vault: AccountsStorage, [](https://ackee.xyz/trident/docs/0.8.1/features/account-storages/#__codelineno-0-5) mint: AccountsStorage, [](https://ackee.xyz/trident/docs/0.8.1/features/account-storages/#__codelineno-0-6) // ... [](https://ackee.xyz/trident/docs/0.8.1/features/account-storages/#__codelineno-0-7) }` Tip Keep in mind: * You do not need to specify every `AccountStorage`, some accounts do not necessarily need to be stored in their corresponding storage. * For example `System Program` does not need to be stored, rather can be used from the `solana_sdk`. * If you are about to Initialize `Mint` or `Token Account` in your Solana Program. * use `Keypair` or `PdaStore` (not `MintStore` or `TokenStore`). * If you are going to initialize `Associated Token Account` in your Solana Program. * use `PdaStore`. * You can rename fields of `FuzzAccounts` to whatever you want. The default names are generated based on the Program's `IDL`. Tip Consider checking the [Examples](https://ackee.xyz/trident/docs/0.8.1/examples/examples/) section for more tips. Back to top --- # Installation - Trident [Skip to content](https://ackee.xyz/trident/docs/0.9.1/installation/installation/#installation) Installation[#](https://ackee.xyz/trident/docs/0.9.1/installation/installation/#installation "Permanent link") =============================================================================================================== Prerequisites Before proceeding, ensure you have installed: * [Rust](https://www.rust-lang.org/tools/install) (stable version) * [Solana CLI](https://solana.com/docs/intro/installation) * [Anchor](https://www.anchor-lang.com/docs/installation) Check out [supported versions](https://ackee.xyz/trident/docs/0.9.1/installation/installation/#supported-versions) for version compatibility. Install system dependencies[#](https://ackee.xyz/trident/docs/0.9.1/installation/installation/#install-system-dependencies "Permanent link") --------------------------------------------------------------------------------------------------------------------------------------------- Update your package list: `[](https://ackee.xyz/trident/docs/0.9.1/installation/installation/#__codelineno-0-1) sudo apt update [](https://ackee.xyz/trident/docs/0.9.1/installation/installation/#__codelineno-0-2) sudo apt upgrade` Install the required packages: `[](https://ackee.xyz/trident/docs/0.9.1/installation/installation/#__codelineno-1-1) sudo apt install build-essential [](https://ackee.xyz/trident/docs/0.9.1/installation/installation/#__codelineno-1-2) sudo apt-get install binutils-dev [](https://ackee.xyz/trident/docs/0.9.1/installation/installation/#__codelineno-1-3) sudo apt-get install libunwind-dev` Install Trident[#](https://ackee.xyz/trident/docs/0.9.1/installation/installation/#install-trident "Permanent link") --------------------------------------------------------------------------------------------------------------------- `[](https://ackee.xyz/trident/docs/0.9.1/installation/installation/#__codelineno-2-1) cargo install trident-cli` You can also use the `version` flag to install a specific version: `[](https://ackee.xyz/trident/docs/0.9.1/installation/installation/#__codelineno-3-1) cargo install trident-cli --version x.y.z` Install Hongfuzz and AFL[#](https://ackee.xyz/trident/docs/0.9.1/installation/installation/#install-hongfuzz-and-afl "Permanent link") --------------------------------------------------------------------------------------------------------------------------------------- `[](https://ackee.xyz/trident/docs/0.9.1/installation/installation/#__codelineno-4-1) cargo install honggfuzz [](https://ackee.xyz/trident/docs/0.9.1/installation/installation/#__codelineno-4-2) cargo install cargo-afl` To install a specific version use the following commands: `[](https://ackee.xyz/trident/docs/0.9.1/installation/installation/#__codelineno-5-1) cargo install honggfuzz --version x.y.z [](https://ackee.xyz/trident/docs/0.9.1/installation/installation/#__codelineno-5-2) cargo install cargo-afl --version x.y.z` Supported versions[#](https://ackee.xyz/trident/docs/0.9.1/installation/installation/#supported-versions "Permanent link") --------------------------------------------------------------------------------------------------------------------------- | **_Trident CLI_** | **_Anchor_** | **_Solana_** | **_Rust_** | **_Honggfuzz_** | **_AFL_** | | --- | --- | --- | --- | --- | --- | | **_`develop`_** | `>=0.29.0` | `>=1.17.3` | `nightly` | `0.5.56` | `0.15.11` | | **_`0.9.0`_** | `>=0.29.0` | `>=1.17.3` | `nightly` | `0.5.56` | `0.15.11` | | **_`0.8.*`_** | `0.30.1` | `^1.17.4` | `nightly` | `0.5.56` | \- | | **_`0.7.0`_** | `>=0.29.*` | `^1.17.4` | `nightly` | `0.5.56` | \- | | **_`0.6.0`_** | `>=0.29.*` | `^1.17` | `nightly` | `0.5.55` | \- | | **_`0.5.0`_** | `~0.28.*` | `=1.16.6` | \- | \- | \- | | **_`0.4.0`_** | `~0.27.*` | `>=1.15` | \- | \- | \- | | **_`0.3.0`_** | `~0.25.*` | `>=1.10` | \- | \- | \- | | **_`0.2.0`_** | `~0.24.*` | `>=1.9` | \- | \- | \- | Back to top --- # Current Limitations - Trident [Skip to content](https://ackee.xyz/trident/docs/0.9.1/features/limitations/#current-limitations) Current Limitations[#](https://ackee.xyz/trident/docs/0.9.1/features/limitations/#current-limitations "Permanent link") ======================================================================================================================== This section summarizes some known limitations in the current development stage. Further development will be focused on resolving these limitations. * Remaining accounts in check methods are not supported. Back to top --- # Fuzz Instructions - Trident [Skip to content](https://ackee.xyz/trident/docs/0.9.1/features/fuzz-instructions/#fuzz-instructions) Fuzz Instructions[#](https://ackee.xyz/trident/docs/0.9.1/features/fuzz-instructions/#fuzz-instructions "Permanent link") ========================================================================================================================== Trident defines the `FuzzInstruction` enum, which contains all available **Instructions** within your program. Each enum variant corresponds to one instruction within your program. This enum is crucial for defining how different instructions behave during fuzz testing. The enum variants additionally contain their corresponding structures for **Accounts** and **Input** arguments. `[](https://ackee.xyz/trident/docs/0.9.1/features/fuzz-instructions/#__codelineno-0-1) #[derive(Arbitrary, DisplayIx, FuzzTestExecutor)] [](https://ackee.xyz/trident/docs/0.9.1/features/fuzz-instructions/#__codelineno-0-2) pub enum FuzzInstruction { [](https://ackee.xyz/trident/docs/0.9.1/features/fuzz-instructions/#__codelineno-0-3) Initialize(Initialize), [](https://ackee.xyz/trident/docs/0.9.1/features/fuzz-instructions/#__codelineno-0-4) Update(Update), [](https://ackee.xyz/trident/docs/0.9.1/features/fuzz-instructions/#__codelineno-0-5) } [](https://ackee.xyz/trident/docs/0.9.1/features/fuzz-instructions/#__codelineno-0-6) #[derive(Arbitrary, Debug)] [](https://ackee.xyz/trident/docs/0.9.1/features/fuzz-instructions/#__codelineno-0-7) pub struct Initialize { [](https://ackee.xyz/trident/docs/0.9.1/features/fuzz-instructions/#__codelineno-0-8) pub accounts: InitializeAccounts, [](https://ackee.xyz/trident/docs/0.9.1/features/fuzz-instructions/#__codelineno-0-9) pub data: InitializeData, [](https://ackee.xyz/trident/docs/0.9.1/features/fuzz-instructions/#__codelineno-0-10) } [](https://ackee.xyz/trident/docs/0.9.1/features/fuzz-instructions/#__codelineno-0-11) #[derive(Arbitrary, Debug)] [](https://ackee.xyz/trident/docs/0.9.1/features/fuzz-instructions/#__codelineno-0-12) pub struct Update { [](https://ackee.xyz/trident/docs/0.9.1/features/fuzz-instructions/#__codelineno-0-13) pub accounts: UpdateAccounts, [](https://ackee.xyz/trident/docs/0.9.1/features/fuzz-instructions/#__codelineno-0-14) pub data: UpdateData, [](https://ackee.xyz/trident/docs/0.9.1/features/fuzz-instructions/#__codelineno-0-15) } [](https://ackee.xyz/trident/docs/0.9.1/features/fuzz-instructions/#__codelineno-0-16) // ...` Instruction Behavior[#](https://ackee.xyz/trident/docs/0.9.1/features/fuzz-instructions/#instruction-behavior "Permanent link") -------------------------------------------------------------------------------------------------------------------------------- Each Instruction variant must define the `IxOps` trait, which contains the following methods: * [`get_discriminator()`](https://ackee.xyz/trident/docs/0.9.1/features/fuzz-instructions/#get_discriminator) (automatically implemented) * [`get_program_id()`](https://ackee.xyz/trident/docs/0.9.1/features/fuzz-instructions/#get_program_id) (automatically implemented) * [`get_data()`](https://ackee.xyz/trident/docs/0.9.1/features/fuzz-instructions/#get_data) (required) * [`get_accounts()`](https://ackee.xyz/trident/docs/0.9.1/features/fuzz-instructions/#get_accounts) (required) * [`check()`](https://ackee.xyz/trident/docs/0.9.1/features/fuzz-instructions/#check) (optional) * [`tx_error_handler()`](https://ackee.xyz/trident/docs/0.9.1/features/fuzz-instructions/#tx_error_handler) (optional) `get_discriminator()`[#](https://ackee.xyz/trident/docs/0.9.1/features/fuzz-instructions/#get_discriminator "Permanent link") ------------------------------------------------------------------------------------------------------------------------------ This method specifies the **discriminator** of the instruction. Tip * The IDL created by Anchor 0.29.0 and lower does not contain the discriminator. In that case, the **discriminator** is generated automatically. * If you are experiencing errors with the wrong **discriminator**, you can specify it manually by hashing `global:` with SHA256 and taking the first 8 bytes. `get_program_id()`[#](https://ackee.xyz/trident/docs/0.9.1/features/fuzz-instructions/#get_program_id "Permanent link") ------------------------------------------------------------------------------------------------------------------------ This method specifies the **program ID** to which the Instruction corresponds. `get_data()`[#](https://ackee.xyz/trident/docs/0.9.1/features/fuzz-instructions/#get_data "Permanent link") ------------------------------------------------------------------------------------------------------------ This method specifies what the Instruction Input Data should look like. You can use completely random data generated by the fuzzer, such as: `[](https://ackee.xyz/trident/docs/0.9.1/features/fuzz-instructions/#__codelineno-1-1) fn get_data( [](https://ackee.xyz/trident/docs/0.9.1/features/fuzz-instructions/#__codelineno-1-2) &self, [](https://ackee.xyz/trident/docs/0.9.1/features/fuzz-instructions/#__codelineno-1-3) client: &mut impl FuzzClient, [](https://ackee.xyz/trident/docs/0.9.1/features/fuzz-instructions/#__codelineno-1-4) fuzz_accounts: &mut FuzzAccounts, [](https://ackee.xyz/trident/docs/0.9.1/features/fuzz-instructions/#__codelineno-1-5) ) -> Result, FuzzingError> { [](https://ackee.xyz/trident/docs/0.9.1/features/fuzz-instructions/#__codelineno-1-6) let mut args: Vec = self.get_discriminator(); [](https://ackee.xyz/trident/docs/0.9.1/features/fuzz-instructions/#__codelineno-1-7) { [](https://ackee.xyz/trident/docs/0.9.1/features/fuzz-instructions/#__codelineno-1-8) args.extend(borsh::to_vec(&self.data.input).unwrap()); [](https://ackee.xyz/trident/docs/0.9.1/features/fuzz-instructions/#__codelineno-1-9) } [](https://ackee.xyz/trident/docs/0.9.1/features/fuzz-instructions/#__codelineno-1-10) Ok(args) [](https://ackee.xyz/trident/docs/0.9.1/features/fuzz-instructions/#__codelineno-1-11) }` You can also use always constant values: `[](https://ackee.xyz/trident/docs/0.9.1/features/fuzz-instructions/#__codelineno-2-1) fn get_data( [](https://ackee.xyz/trident/docs/0.9.1/features/fuzz-instructions/#__codelineno-2-2) &self, [](https://ackee.xyz/trident/docs/0.9.1/features/fuzz-instructions/#__codelineno-2-3) client: &mut impl FuzzClient, [](https://ackee.xyz/trident/docs/0.9.1/features/fuzz-instructions/#__codelineno-2-4) fuzz_accounts: &mut FuzzAccounts, [](https://ackee.xyz/trident/docs/0.9.1/features/fuzz-instructions/#__codelineno-2-5) ) -> Result, FuzzingError> { [](https://ackee.xyz/trident/docs/0.9.1/features/fuzz-instructions/#__codelineno-2-6) let mut args: Vec = self.get_discriminator(); [](https://ackee.xyz/trident/docs/0.9.1/features/fuzz-instructions/#__codelineno-2-7) { [](https://ackee.xyz/trident/docs/0.9.1/features/fuzz-instructions/#__codelineno-2-8) // The constant value 5 is used as an example [](https://ackee.xyz/trident/docs/0.9.1/features/fuzz-instructions/#__codelineno-2-9) args.extend(borsh::to_vec(5).unwrap()); [](https://ackee.xyz/trident/docs/0.9.1/features/fuzz-instructions/#__codelineno-2-10) } [](https://ackee.xyz/trident/docs/0.9.1/features/fuzz-instructions/#__codelineno-2-11) Ok(args) [](https://ackee.xyz/trident/docs/0.9.1/features/fuzz-instructions/#__codelineno-2-12) }` Additionally, you can limit the range of the data generated using the `Arbitrary` crate. Check [Arbitrary Data](https://ackee.xyz/trident/docs/0.9.1/features/customize-ix-data/) . `get_accounts()`[#](https://ackee.xyz/trident/docs/0.9.1/features/fuzz-instructions/#get_accounts "Permanent link") -------------------------------------------------------------------------------------------------------------------- This method specifies the **Accounts** that will be used for the corresponding Instruction. To use multiple combinations of accounts, Trident utilizes the **AccountStorage**, where accounts are stored across the fuzzing process. There are three main functions to use within the `get_accounts()`: * [`get_or_create_account()`](https://ackee.xyz/trident/docs/0.9.1/features/fuzz-instructions/#get_or_create_account) * [`get()`](https://ackee.xyz/trident/docs/0.9.1/features/fuzz-instructions/#get) * [`set_account_custom()`](https://ackee.xyz/trident/docs/0.9.1/features/fuzz-instructions/#set_account_custom) For additional methods, check [Account Storage Methods](https://ackee.xyz/trident/docs/0.9.1/features/account-storages/#account-storage-methods) . ### `get_or_create_account()`[#](https://ackee.xyz/trident/docs/0.9.1/features/fuzz-instructions/#get_or_create_account "Permanent link") Retrieves a record from AccountsStorage based on the entered `account_id`. If no record exists for the `account_id`, a new empty account is created. Tip * This function is particularly useful for instructions that initialize accounts. Example: `[](https://ackee.xyz/trident/docs/0.9.1/features/fuzz-instructions/#__codelineno-3-1) let hello_world_account = fuzz_accounts.hello_world_account.get_or_create_account( [](https://ackee.xyz/trident/docs/0.9.1/features/fuzz-instructions/#__codelineno-3-2) self.accounts.hello_world_account, [](https://ackee.xyz/trident/docs/0.9.1/features/fuzz-instructions/#__codelineno-3-3) client, [](https://ackee.xyz/trident/docs/0.9.1/features/fuzz-instructions/#__codelineno-3-4) &[b"hello_world_seed"], [](https://ackee.xyz/trident/docs/0.9.1/features/fuzz-instructions/#__codelineno-3-5) &hello_world::ID, [](https://ackee.xyz/trident/docs/0.9.1/features/fuzz-instructions/#__codelineno-3-6) );` ### `get()`[#](https://ackee.xyz/trident/docs/0.9.1/features/fuzz-instructions/#get "Permanent link") Retrieves a record from AccountsStorage based on the entered `account_id`. If no record exists for the `account_id`, a **random public key** is returned. Tip * This function is particularly useful for instructions other than those that perform initialization. Example: `[](https://ackee.xyz/trident/docs/0.9.1/features/fuzz-instructions/#__codelineno-4-1) let hello_world_account = fuzz_accounts [](https://ackee.xyz/trident/docs/0.9.1/features/fuzz-instructions/#__codelineno-4-2) .hello_world_account [](https://ackee.xyz/trident/docs/0.9.1/features/fuzz-instructions/#__codelineno-4-3) .get(self.accounts.hello_world_account);` ### `set_account_custom()`[#](https://ackee.xyz/trident/docs/0.9.1/features/fuzz-instructions/#set_account_custom "Permanent link") If the previous two functions are insufficient, you can use `set_account_custom()` to manually set an account with data you select. Tip Example: `[](https://ackee.xyz/trident/docs/0.9.1/features/fuzz-instructions/#__codelineno-5-1) let author = fuzz_accounts.author_hello_world.get_or_create_account( [](https://ackee.xyz/trident/docs/0.9.1/features/fuzz-instructions/#__codelineno-5-2) self.accounts.author, [](https://ackee.xyz/trident/docs/0.9.1/features/fuzz-instructions/#__codelineno-5-3) client, [](https://ackee.xyz/trident/docs/0.9.1/features/fuzz-instructions/#__codelineno-5-4) 500 * LAMPORTS_PER_SOL, [](https://ackee.xyz/trident/docs/0.9.1/features/fuzz-instructions/#__codelineno-5-5) ); [](https://ackee.xyz/trident/docs/0.9.1/features/fuzz-instructions/#__codelineno-5-6) client.set_account_custom( [](https://ackee.xyz/trident/docs/0.9.1/features/fuzz-instructions/#__codelineno-5-7) &author.pubkey(), [](https://ackee.xyz/trident/docs/0.9.1/features/fuzz-instructions/#__codelineno-5-8) &AccountSharedData::create( [](https://ackee.xyz/trident/docs/0.9.1/features/fuzz-instructions/#__codelineno-5-9) 10 * LAMPORTS_PER_SOL, [](https://ackee.xyz/trident/docs/0.9.1/features/fuzz-instructions/#__codelineno-5-10) vec![1, 2, 3, 4, 5, 6, 7, 8, 9], [](https://ackee.xyz/trident/docs/0.9.1/features/fuzz-instructions/#__codelineno-5-11) solana_sdk::system_program::ID, [](https://ackee.xyz/trident/docs/0.9.1/features/fuzz-instructions/#__codelineno-5-12) false, [](https://ackee.xyz/trident/docs/0.9.1/features/fuzz-instructions/#__codelineno-5-13) 0, [](https://ackee.xyz/trident/docs/0.9.1/features/fuzz-instructions/#__codelineno-5-14) ), [](https://ackee.xyz/trident/docs/0.9.1/features/fuzz-instructions/#__codelineno-5-15) );` `check()`[#](https://ackee.xyz/trident/docs/0.9.1/features/fuzz-instructions/#check "Permanent link") ------------------------------------------------------------------------------------------------------ This method provides an Invariant Check for the corresponding Instruction. Check [Invariant Checks](https://ackee.xyz/trident/docs/0.9.1/features/invariant-checks/) . `tx_error_handler()`[#](https://ackee.xyz/trident/docs/0.9.1/features/fuzz-instructions/#tx_error_handler "Permanent link") ---------------------------------------------------------------------------------------------------------------------------- This method provides a Tx Error Handler for the corresponding Instruction. Check [Error Handler](https://ackee.xyz/trident/docs/0.9.1/features/error-handlers/) . Example[#](https://ackee.xyz/trident/docs/0.9.1/features/fuzz-instructions/#example "Permanent link") ------------------------------------------------------------------------------------------------------ Tip Consider checking the [Examples](https://ackee.xyz/trident/docs/0.9.1/examples/examples/) section for more tips. Back to top --- # Customize Instruction Data - Trident [Skip to content](https://ackee.xyz/trident/docs/0.9.1/features/customize-ix-data/#customize-instruction-data) Customize Instruction Data[#](https://ackee.xyz/trident/docs/0.9.1/features/customize-ix-data/#customize-instruction-data "Permanent link") ============================================================================================================================================ Trident allows you to customize instruction data. Trident by default generates random data for instructions, however, you can customize the data to select specific values. For example, your Initialize Instruction expects two arguments: `start_at` and `end_at`. You know that in order for the Instruction to make sense, it is required that `start_at` < `end_at`. Moreover, there should be a significant difference between these two. This can be utilized with the **Arbitrary crate**. `[](https://ackee.xyz/trident/docs/0.9.1/features/customize-ix-data/#__codelineno-0-1) #[derive(Arbitrary, Debug)] [](https://ackee.xyz/trident/docs/0.9.1/features/customize-ix-data/#__codelineno-0-2) pub struct InitVestingData { [](https://ackee.xyz/trident/docs/0.9.1/features/customize-ix-data/#__codelineno-0-3) pub recipient: AccountId, [](https://ackee.xyz/trident/docs/0.9.1/features/customize-ix-data/#__codelineno-0-4) #[arbitrary( [](https://ackee.xyz/trident/docs/0.9.1/features/customize-ix-data/#__codelineno-0-5) with = |u: &mut arbitrary::Unstructured| u.int_in_range(1..=1_000_000) [](https://ackee.xyz/trident/docs/0.9.1/features/customize-ix-data/#__codelineno-0-6) )] [](https://ackee.xyz/trident/docs/0.9.1/features/customize-ix-data/#__codelineno-0-7) pub amount: u64, [](https://ackee.xyz/trident/docs/0.9.1/features/customize-ix-data/#__codelineno-0-8) // we want start_at smaller than end_at [](https://ackee.xyz/trident/docs/0.9.1/features/customize-ix-data/#__codelineno-0-9) // and for testing purposes we can run tests with times from the past [](https://ackee.xyz/trident/docs/0.9.1/features/customize-ix-data/#__codelineno-0-10) #[arbitrary( [](https://ackee.xyz/trident/docs/0.9.1/features/customize-ix-data/#__codelineno-0-11) with = |u: &mut arbitrary::Unstructured| u.int_in_range(0..=1_000_000) [](https://ackee.xyz/trident/docs/0.9.1/features/customize-ix-data/#__codelineno-0-12) )] [](https://ackee.xyz/trident/docs/0.9.1/features/customize-ix-data/#__codelineno-0-13) pub start_at: u64, [](https://ackee.xyz/trident/docs/0.9.1/features/customize-ix-data/#__codelineno-0-14) #[arbitrary( [](https://ackee.xyz/trident/docs/0.9.1/features/customize-ix-data/#__codelineno-0-15) with = |u: &mut arbitrary::Unstructured| u.int_in_range(1_001_001..=1_050_000) [](https://ackee.xyz/trident/docs/0.9.1/features/customize-ix-data/#__codelineno-0-16) )] [](https://ackee.xyz/trident/docs/0.9.1/features/customize-ix-data/#__codelineno-0-17) pub end_at: u64, [](https://ackee.xyz/trident/docs/0.9.1/features/customize-ix-data/#__codelineno-0-18) #[arbitrary( [](https://ackee.xyz/trident/docs/0.9.1/features/customize-ix-data/#__codelineno-0-19) with = |u: &mut arbitrary::Unstructured| u.int_in_range(1..=1000) [](https://ackee.xyz/trident/docs/0.9.1/features/customize-ix-data/#__codelineno-0-20) )] [](https://ackee.xyz/trident/docs/0.9.1/features/customize-ix-data/#__codelineno-0-21) pub interval: u64, [](https://ackee.xyz/trident/docs/0.9.1/features/customize-ix-data/#__codelineno-0-22) }` Implement Arbitrary[#](https://ackee.xyz/trident/docs/0.9.1/features/customize-ix-data/#implement-arbitrary "Permanent link") ------------------------------------------------------------------------------------------------------------------------------ There are macros available to use with Arbitrary, however, it is possible to Implement the arbitrary function by yourself. `[](https://ackee.xyz/trident/docs/0.9.1/features/customize-ix-data/#__codelineno-1-1) // ------------------------------------------------------------------- [](https://ackee.xyz/trident/docs/0.9.1/features/customize-ix-data/#__codelineno-1-2) // ------------------------------------------------------------------- [](https://ackee.xyz/trident/docs/0.9.1/features/customize-ix-data/#__codelineno-1-3) // Implement Arbitrary [](https://ackee.xyz/trident/docs/0.9.1/features/customize-ix-data/#__codelineno-1-4) impl<'a> Arbitrary<'a> for InitVestingData { [](https://ackee.xyz/trident/docs/0.9.1/features/customize-ix-data/#__codelineno-1-5) fn arbitrary( [](https://ackee.xyz/trident/docs/0.9.1/features/customize-ix-data/#__codelineno-1-6) u: &mut arbitrary::Unstructured<'a> [](https://ackee.xyz/trident/docs/0.9.1/features/customize-ix-data/#__codelineno-1-7) ) -> arbitrary::Result { [](https://ackee.xyz/trident/docs/0.9.1/features/customize-ix-data/#__codelineno-1-8) // obtain AccountId [](https://ackee.xyz/trident/docs/0.9.1/features/customize-ix-data/#__codelineno-1-9) let recipient = AccountId::arbitrary(u)?; [](https://ackee.xyz/trident/docs/0.9.1/features/customize-ix-data/#__codelineno-1-10) [](https://ackee.xyz/trident/docs/0.9.1/features/customize-ix-data/#__codelineno-1-11) // limit the generated amount to the 1_000_000 [](https://ackee.xyz/trident/docs/0.9.1/features/customize-ix-data/#__codelineno-1-12) let amount = u.int_in_range(1..=1_000_000)?; [](https://ackee.xyz/trident/docs/0.9.1/features/customize-ix-data/#__codelineno-1-13) [](https://ackee.xyz/trident/docs/0.9.1/features/customize-ix-data/#__codelineno-1-14) // now we want to obtain [](https://ackee.xyz/trident/docs/0.9.1/features/customize-ix-data/#__codelineno-1-15) // - start_at [](https://ackee.xyz/trident/docs/0.9.1/features/customize-ix-data/#__codelineno-1-16) // - end_at [](https://ackee.xyz/trident/docs/0.9.1/features/customize-ix-data/#__codelineno-1-17) // - interval [](https://ackee.xyz/trident/docs/0.9.1/features/customize-ix-data/#__codelineno-1-18) // however we want to limit the data such that: [](https://ackee.xyz/trident/docs/0.9.1/features/customize-ix-data/#__codelineno-1-19) // - start_at < end_at [](https://ackee.xyz/trident/docs/0.9.1/features/customize-ix-data/#__codelineno-1-20) // - end_at - start_at > interval [](https://ackee.xyz/trident/docs/0.9.1/features/customize-ix-data/#__codelineno-1-21) // - interval has lower limit of 500 and upper limit of 1000. [](https://ackee.xyz/trident/docs/0.9.1/features/customize-ix-data/#__codelineno-1-22) [](https://ackee.xyz/trident/docs/0.9.1/features/customize-ix-data/#__codelineno-1-23) let start_at: u64 = u.int_in_range(1_000_000..=5_000_000)?; [](https://ackee.xyz/trident/docs/0.9.1/features/customize-ix-data/#__codelineno-1-24) let end_at: u64 = u.int_in_range(1_000_000..=5_000_000)?; [](https://ackee.xyz/trident/docs/0.9.1/features/customize-ix-data/#__codelineno-1-25) let interval: u64 = u.int_in_range(500..=1000)?; [](https://ackee.xyz/trident/docs/0.9.1/features/customize-ix-data/#__codelineno-1-26) [](https://ackee.xyz/trident/docs/0.9.1/features/customize-ix-data/#__codelineno-1-27) // ensure that start_at < end_at [](https://ackee.xyz/trident/docs/0.9.1/features/customize-ix-data/#__codelineno-1-28) if start_at >= end_at { [](https://ackee.xyz/trident/docs/0.9.1/features/customize-ix-data/#__codelineno-1-29) return Err(arbitrary::Error::IncorrectFormat); [](https://ackee.xyz/trident/docs/0.9.1/features/customize-ix-data/#__codelineno-1-30) } [](https://ackee.xyz/trident/docs/0.9.1/features/customize-ix-data/#__codelineno-1-31) [](https://ackee.xyz/trident/docs/0.9.1/features/customize-ix-data/#__codelineno-1-32) // ensure that end_at - start_at > interval [](https://ackee.xyz/trident/docs/0.9.1/features/customize-ix-data/#__codelineno-1-33) match end_at.checked_sub(start_at) { [](https://ackee.xyz/trident/docs/0.9.1/features/customize-ix-data/#__codelineno-1-34) Some(diff) => { [](https://ackee.xyz/trident/docs/0.9.1/features/customize-ix-data/#__codelineno-1-35) if diff <= interval { [](https://ackee.xyz/trident/docs/0.9.1/features/customize-ix-data/#__codelineno-1-36) return Err(arbitrary::Error::IncorrectFormat); [](https://ackee.xyz/trident/docs/0.9.1/features/customize-ix-data/#__codelineno-1-37) } [](https://ackee.xyz/trident/docs/0.9.1/features/customize-ix-data/#__codelineno-1-38) } [](https://ackee.xyz/trident/docs/0.9.1/features/customize-ix-data/#__codelineno-1-39) None => return Err(arbitrary::Error::IncorrectFormat), [](https://ackee.xyz/trident/docs/0.9.1/features/customize-ix-data/#__codelineno-1-40) } [](https://ackee.xyz/trident/docs/0.9.1/features/customize-ix-data/#__codelineno-1-41) [](https://ackee.xyz/trident/docs/0.9.1/features/customize-ix-data/#__codelineno-1-42) Ok(InitVestingData { [](https://ackee.xyz/trident/docs/0.9.1/features/customize-ix-data/#__codelineno-1-43) recipient, [](https://ackee.xyz/trident/docs/0.9.1/features/customize-ix-data/#__codelineno-1-44) amount, [](https://ackee.xyz/trident/docs/0.9.1/features/customize-ix-data/#__codelineno-1-45) start_at, [](https://ackee.xyz/trident/docs/0.9.1/features/customize-ix-data/#__codelineno-1-46) end_at, [](https://ackee.xyz/trident/docs/0.9.1/features/customize-ix-data/#__codelineno-1-47) interval, [](https://ackee.xyz/trident/docs/0.9.1/features/customize-ix-data/#__codelineno-1-48) }) [](https://ackee.xyz/trident/docs/0.9.1/features/customize-ix-data/#__codelineno-1-49) } [](https://ackee.xyz/trident/docs/0.9.1/features/customize-ix-data/#__codelineno-1-50) // ------------------------------------------------------------------- [](https://ackee.xyz/trident/docs/0.9.1/features/customize-ix-data/#__codelineno-1-51) // ------------------------------------------------------------------- [](https://ackee.xyz/trident/docs/0.9.1/features/customize-ix-data/#__codelineno-1-52) }` Tip Consider checking the [Examples](https://ackee.xyz/trident/docs/0.9.1/examples/examples/) section for more tips. Back to top --- # Trident Manifest - Trident [Skip to content](https://ackee.xyz/trident/docs/0.9.1/features/trident-manifest/#trident-manifest) Trident Manifest[#](https://ackee.xyz/trident/docs/0.9.1/features/trident-manifest/#trident-manifest "Permanent link") ======================================================================================================================= You can pass supported parameters via the **Trident.toml** configuration file: \[fuzz\][#](https://ackee.xyz/trident/docs/0.9.1/features/trident-manifest/#fuzz "Permanent link") --------------------------------------------------------------------------------------------------- #### programs[#](https://ackee.xyz/trident/docs/0.9.1/features/trident-manifest/#programs "Permanent link") * Use dumped program from desired cluster, during fuzzing. `[](https://ackee.xyz/trident/docs/0.9.1/features/trident-manifest/#__codelineno-0-1) [[fuzz.programs]] [](https://ackee.xyz/trident/docs/0.9.1/features/trident-manifest/#__codelineno-0-2) address = "metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s" [](https://ackee.xyz/trident/docs/0.9.1/features/trident-manifest/#__codelineno-0-3) program = "metaplex-program/metaplex-token-metadata.so"` * * * #### accounts[#](https://ackee.xyz/trident/docs/0.9.1/features/trident-manifest/#accounts "Permanent link") * Use dumped accounts from desired cluster, during fuzzing. `[](https://ackee.xyz/trident/docs/0.9.1/features/trident-manifest/#__codelineno-1-1) [[fuzz.accounts]] [](https://ackee.xyz/trident/docs/0.9.1/features/trident-manifest/#__codelineno-1-2) address = "6YG3J7PaxyMnnbU67ifyrgF3BzNzc7cD8hPkqK6ATweE" [](https://ackee.xyz/trident/docs/0.9.1/features/trident-manifest/#__codelineno-1-3) filename = "tests/accounts/core_bridge_mainnet/guardian_set_5_mock.json"` * * * #### allow\_duplicate\_txs[#](https://ackee.xyz/trident/docs/0.9.1/features/trident-manifest/#allow_duplicate_txs "Permanent link") * Allow processing of duplicate transactions. Setting to true might speed up fuzzing but can cause false positive crashes (default: false). `[](https://ackee.xyz/trident/docs/0.9.1/features/trident-manifest/#__codelineno-2-1) [fuzz] [](https://ackee.xyz/trident/docs/0.9.1/features/trident-manifest/#__codelineno-2-2) # Allow processing of duplicate transactions. [](https://ackee.xyz/trident/docs/0.9.1/features/trident-manifest/#__codelineno-2-3) # Setting to true might speed up fuzzing but can cause [](https://ackee.xyz/trident/docs/0.9.1/features/trident-manifest/#__codelineno-2-4) # false positive crashes (default: false) [](https://ackee.xyz/trident/docs/0.9.1/features/trident-manifest/#__codelineno-2-5) allow_duplicate_txs = false` * * * #### fuzzing\_with\_stats[#](https://ackee.xyz/trident/docs/0.9.1/features/trident-manifest/#fuzzing_with_stats "Permanent link") * Trident will show statistics after the fuzzing session. This option forces use of honggfuzz parameter `keep_output` as true in order to be able to catch fuzzer stdout. (default: false) ``[](https://ackee.xyz/trident/docs/0.9.1/features/trident-manifest/#__codelineno-3-1) [fuzz] [](https://ackee.xyz/trident/docs/0.9.1/features/trident-manifest/#__codelineno-3-2) # Trident will show statistics after the fuzzing session. [](https://ackee.xyz/trident/docs/0.9.1/features/trident-manifest/#__codelineno-3-3) # This option forces use of honggfuzz parameter [](https://ackee.xyz/trident/docs/0.9.1/features/trident-manifest/#__codelineno-3-4) # `keep_output` as true in order to be able to catch fuzzer stdout. [](https://ackee.xyz/trident/docs/0.9.1/features/trident-manifest/#__codelineno-3-5) # (default: false) [](https://ackee.xyz/trident/docs/0.9.1/features/trident-manifest/#__codelineno-3-6) fuzzing_with_stats = true`` * * * \[honggfuzz\][#](https://ackee.xyz/trident/docs/0.9.1/features/trident-manifest/#honggfuzz "Permanent link") ------------------------------------------------------------------------------------------------------------- #### run\_time[#](https://ackee.xyz/trident/docs/0.9.1/features/trident-manifest/#run_time "Permanent link") * Number of seconds this fuzzing session will last (default: 0 \[no limit\]) `[](https://ackee.xyz/trident/docs/0.9.1/features/trident-manifest/#__codelineno-4-1) [honggfuzz] [](https://ackee.xyz/trident/docs/0.9.1/features/trident-manifest/#__codelineno-4-2) # Number of seconds this fuzzing session will last (default: 0 [no limit]) [](https://ackee.xyz/trident/docs/0.9.1/features/trident-manifest/#__codelineno-4-3) run_time = 0` * * * #### iterations[#](https://ackee.xyz/trident/docs/0.9.1/features/trident-manifest/#iterations "Permanent link") * Number of fuzzing iterations (default: 0 \[no limit\]) `[](https://ackee.xyz/trident/docs/0.9.1/features/trident-manifest/#__codelineno-5-1) [honggfuzz] [](https://ackee.xyz/trident/docs/0.9.1/features/trident-manifest/#__codelineno-5-2) # Number of fuzzing iterations (default: 0 [no limit]) [](https://ackee.xyz/trident/docs/0.9.1/features/trident-manifest/#__codelineno-5-3) iterations = 0` * * * #### threads[#](https://ackee.xyz/trident/docs/0.9.1/features/trident-manifest/#threads "Permanent link") * Number of concurrent fuzzing threads (default: 0 \[number of CPUs / 2\]) `[](https://ackee.xyz/trident/docs/0.9.1/features/trident-manifest/#__codelineno-6-1) [honggfuzz] [](https://ackee.xyz/trident/docs/0.9.1/features/trident-manifest/#__codelineno-6-2) # Number of concurrent fuzzing threads (default: 0 [number of CPUs / 2]) [](https://ackee.xyz/trident/docs/0.9.1/features/trident-manifest/#__codelineno-6-3) threads = 0` * * * #### keep\_output[#](https://ackee.xyz/trident/docs/0.9.1/features/trident-manifest/#keep_output "Permanent link") * Don't close children's stdin, stdout, stderr; can be noisy (default: false) `[](https://ackee.xyz/trident/docs/0.9.1/features/trident-manifest/#__codelineno-7-1) [honggfuzz] [](https://ackee.xyz/trident/docs/0.9.1/features/trident-manifest/#__codelineno-7-2) # Don't close children's stdin, stdout, stderr; can be noisy (default: false) [](https://ackee.xyz/trident/docs/0.9.1/features/trident-manifest/#__codelineno-7-3) keep_output = false` * * * #### verbose[#](https://ackee.xyz/trident/docs/0.9.1/features/trident-manifest/#verbose "Permanent link") * Disable ANSI console; use simple log output (default: false) `[](https://ackee.xyz/trident/docs/0.9.1/features/trident-manifest/#__codelineno-8-1) [honggfuzz] [](https://ackee.xyz/trident/docs/0.9.1/features/trident-manifest/#__codelineno-8-2) # Disable ANSI console; use simple log output (default: false) [](https://ackee.xyz/trident/docs/0.9.1/features/trident-manifest/#__codelineno-8-3) verbose = false` * * * #### exit\_upon\_crash[#](https://ackee.xyz/trident/docs/0.9.1/features/trident-manifest/#exit_upon_crash "Permanent link") * Exit upon seeing the first crash (default: false) `[](https://ackee.xyz/trident/docs/0.9.1/features/trident-manifest/#__codelineno-9-1) [honggfuzz] [](https://ackee.xyz/trident/docs/0.9.1/features/trident-manifest/#__codelineno-9-2) # Exit upon seeing the first crash (default: false) [](https://ackee.xyz/trident/docs/0.9.1/features/trident-manifest/#__codelineno-9-3) exit_upon_crash = false` * * * #### mutations\_per\_run[#](https://ackee.xyz/trident/docs/0.9.1/features/trident-manifest/#mutations_per_run "Permanent link") * Maximal number of mutations per one run (default: 6) `[](https://ackee.xyz/trident/docs/0.9.1/features/trident-manifest/#__codelineno-10-1) [honggfuzz] [](https://ackee.xyz/trident/docs/0.9.1/features/trident-manifest/#__codelineno-10-2) # Maximal number of mutations per one run (default: 6) [](https://ackee.xyz/trident/docs/0.9.1/features/trident-manifest/#__codelineno-10-3) mutations_per_run = 6` * * * #### cargo\_target\_dir[#](https://ackee.xyz/trident/docs/0.9.1/features/trident-manifest/#cargo_target_dir "Permanent link") * Target compilation directory, (default: "" \["trident-tests/fuzzing/honggfuzz/hfuzz\_target"\]). * To not clash with cargo build's default target directory. `[](https://ackee.xyz/trident/docs/0.9.1/features/trident-manifest/#__codelineno-11-1) [honggfuzz] [](https://ackee.xyz/trident/docs/0.9.1/features/trident-manifest/#__codelineno-11-2) # Target compilation directory, [](https://ackee.xyz/trident/docs/0.9.1/features/trident-manifest/#__codelineno-11-3) # (default: "" ["trident-tests/fuzz_tests/fuzzing/honggfuzz/hfuzz_target"]). [](https://ackee.xyz/trident/docs/0.9.1/features/trident-manifest/#__codelineno-11-4) # To not clash with cargo build's default target directory. [](https://ackee.xyz/trident/docs/0.9.1/features/trident-manifest/#__codelineno-11-5) cargo_target_dir = ""` * * * #### hfuzz\_workspace[#](https://ackee.xyz/trident/docs/0.9.1/features/trident-manifest/#hfuzz_workspace "Permanent link") * Honggfuzz working directory, (default: "" \["trident-tests/fuzzing/honggfuzz/hfuzz\_workspace"\]). `[](https://ackee.xyz/trident/docs/0.9.1/features/trident-manifest/#__codelineno-12-1) [honggfuzz] [](https://ackee.xyz/trident/docs/0.9.1/features/trident-manifest/#__codelineno-12-2) # Honggfuzz working directory, [](https://ackee.xyz/trident/docs/0.9.1/features/trident-manifest/#__codelineno-12-3) # (default: "" ["trident-tests/fuzz_tests/fuzzing/honggfuzz/hfuzz_workspace"]). [](https://ackee.xyz/trident/docs/0.9.1/features/trident-manifest/#__codelineno-12-4) hfuzz_workspace = ""` * * * #### crashdir[#](https://ackee.xyz/trident/docs/0.9.1/features/trident-manifest/#crashdir "Permanent link") * Directory where crashes are saved to (default: "" \[workspace directory\]) `[](https://ackee.xyz/trident/docs/0.9.1/features/trident-manifest/#__codelineno-13-1) [honggfuzz] [](https://ackee.xyz/trident/docs/0.9.1/features/trident-manifest/#__codelineno-13-2) # Directory where crashes are saved to (default: "" [workspace directory]) [](https://ackee.xyz/trident/docs/0.9.1/features/trident-manifest/#__codelineno-13-3) crashdir = ""` * * * #### extension[#](https://ackee.xyz/trident/docs/0.9.1/features/trident-manifest/#extension "Permanent link") * Input file extension (e.g. 'swf'), (default: "" \['fuzz'\]) `[](https://ackee.xyz/trident/docs/0.9.1/features/trident-manifest/#__codelineno-14-1) [honggfuzz] [](https://ackee.xyz/trident/docs/0.9.1/features/trident-manifest/#__codelineno-14-2) # Input file extension (e.g. 'swf'), (default: "" ['fuzz']) [](https://ackee.xyz/trident/docs/0.9.1/features/trident-manifest/#__codelineno-14-3) extension = ""` * * * #### timeout[#](https://ackee.xyz/trident/docs/0.9.1/features/trident-manifest/#timeout "Permanent link") * Timeout in seconds (default: 10) `[](https://ackee.xyz/trident/docs/0.9.1/features/trident-manifest/#__codelineno-15-1) [honggfuzz] [](https://ackee.xyz/trident/docs/0.9.1/features/trident-manifest/#__codelineno-15-2) # Timeout in seconds (default: 10) [](https://ackee.xyz/trident/docs/0.9.1/features/trident-manifest/#__codelineno-15-3) timeout = 0` * * * #### max\_file\_size[#](https://ackee.xyz/trident/docs/0.9.1/features/trident-manifest/#max_file_size "Permanent link") * Maximal size of files processed by the fuzzer in bytes (default: 1048576 = 1MB) `[](https://ackee.xyz/trident/docs/0.9.1/features/trident-manifest/#__codelineno-16-1) [honggfuzz] [](https://ackee.xyz/trident/docs/0.9.1/features/trident-manifest/#__codelineno-16-2) # Maximal size of files processed by the fuzzer in bytes [](https://ackee.xyz/trident/docs/0.9.1/features/trident-manifest/#__codelineno-16-3) # (default: 1048576 = 1MB) [](https://ackee.xyz/trident/docs/0.9.1/features/trident-manifest/#__codelineno-16-4) max_file_size = 1048576` * * * #### save\_all[#](https://ackee.xyz/trident/docs/0.9.1/features/trident-manifest/#save_all "Permanent link") * Save all test-cases (not only the unique ones) by appending the current time-stamp to the filenames (default: false) `[](https://ackee.xyz/trident/docs/0.9.1/features/trident-manifest/#__codelineno-17-1) [honggfuzz] [](https://ackee.xyz/trident/docs/0.9.1/features/trident-manifest/#__codelineno-17-2) # Save all test-cases [](https://ackee.xyz/trident/docs/0.9.1/features/trident-manifest/#__codelineno-17-3) # (not only the unique ones) by appending the current [](https://ackee.xyz/trident/docs/0.9.1/features/trident-manifest/#__codelineno-17-4) # time-stamp to the filename (default: false) [](https://ackee.xyz/trident/docs/0.9.1/features/trident-manifest/#__codelineno-17-5) save_all = false` \[afl\][#](https://ackee.xyz/trident/docs/0.9.1/features/trident-manifest/#afl "Permanent link") ------------------------------------------------------------------------------------------------- #### run\_time[#](https://ackee.xyz/trident/docs/0.9.1/features/trident-manifest/#run_time_1 "Permanent link") * Number of seconds this fuzzing session will last (default: 0 \[no limit\]) `[](https://ackee.xyz/trident/docs/0.9.1/features/trident-manifest/#__codelineno-18-1) [afl] [](https://ackee.xyz/trident/docs/0.9.1/features/trident-manifest/#__codelineno-18-2) # Number of seconds this fuzzing session will last (default: 0 [no limit]) [](https://ackee.xyz/trident/docs/0.9.1/features/trident-manifest/#__codelineno-18-3) run_time = 0` * * * #### iterations[#](https://ackee.xyz/trident/docs/0.9.1/features/trident-manifest/#iterations_1 "Permanent link") * Number of fuzzing iterations (default: 0 \[no limit\]) `[](https://ackee.xyz/trident/docs/0.9.1/features/trident-manifest/#__codelineno-19-1) [afl] [](https://ackee.xyz/trident/docs/0.9.1/features/trident-manifest/#__codelineno-19-2) # Number of fuzzing iterations (default: 0 [no limit]) [](https://ackee.xyz/trident/docs/0.9.1/features/trident-manifest/#__codelineno-19-3) iterations = 0` * * * #### cargo\_target\_dir[#](https://ackee.xyz/trident/docs/0.9.1/features/trident-manifest/#cargo_target_dir_1 "Permanent link") * Target compilation directory, (default: "" \["trident-tests/fuzz\_tests/fuzzing/afl/afl\_target"\]). * To not clash with cargo build's default target directory. `[](https://ackee.xyz/trident/docs/0.9.1/features/trident-manifest/#__codelineno-20-1) [afl] [](https://ackee.xyz/trident/docs/0.9.1/features/trident-manifest/#__codelineno-20-2) # Target compilation directory, [](https://ackee.xyz/trident/docs/0.9.1/features/trident-manifest/#__codelineno-20-3) # (default: "" ["trident-tests/fuzz_tests/fuzzing/afl/afl_target"]). [](https://ackee.xyz/trident/docs/0.9.1/features/trident-manifest/#__codelineno-20-4) # To not clash with cargo build's default target directory. [](https://ackee.xyz/trident/docs/0.9.1/features/trident-manifest/#__codelineno-20-5) cargo_target_dir = ""` * * * #### afl\_workspace\_in[#](https://ackee.xyz/trident/docs/0.9.1/features/trident-manifest/#afl_workspace_in "Permanent link") * AFL working input directory, * (default: "" \["trident-tests/fuzz\_tests/fuzzing/afl/afl\_workspace/in"\]). `[](https://ackee.xyz/trident/docs/0.9.1/features/trident-manifest/#__codelineno-21-1) [afl] [](https://ackee.xyz/trident/docs/0.9.1/features/trident-manifest/#__codelineno-21-2) # AFL working input directory, [](https://ackee.xyz/trident/docs/0.9.1/features/trident-manifest/#__codelineno-21-3) # (default: "" ["trident-tests/fuzz_tests/fuzzing/afl/afl_workspace/in"]). [](https://ackee.xyz/trident/docs/0.9.1/features/trident-manifest/#__codelineno-21-4) afl_workspace_in = ""` * * * #### afl\_workspace\_out[#](https://ackee.xyz/trident/docs/0.9.1/features/trident-manifest/#afl_workspace_out "Permanent link") * AFL working output directory, * (default: "" \["trident-tests/fuzz\_tests/fuzzing/afl/afl\_workspace/out"\]). `[](https://ackee.xyz/trident/docs/0.9.1/features/trident-manifest/#__codelineno-22-1) [afl] [](https://ackee.xyz/trident/docs/0.9.1/features/trident-manifest/#__codelineno-22-2) # AFL working output directory, [](https://ackee.xyz/trident/docs/0.9.1/features/trident-manifest/#__codelineno-22-3) # (default: "" ["trident-tests/fuzz_tests/fuzzing/afl/afl_workspace/out"]). [](https://ackee.xyz/trident/docs/0.9.1/features/trident-manifest/#__codelineno-22-4) afl_workspace_out = ""` * * * #### seeds[#](https://ackee.xyz/trident/docs/0.9.1/features/trident-manifest/#seeds "Permanent link") * Predefined inputs to the AFL * You can specify multiple input seeds. Important `bytes_count` has precedence before `seed`, in that case if both are specified. Seed is generated as random array of `bytes_count` bytes. `[](https://ackee.xyz/trident/docs/0.9.1/features/trident-manifest/#__codelineno-23-1) [[afl.seeds]] [](https://ackee.xyz/trident/docs/0.9.1/features/trident-manifest/#__codelineno-23-2) # Filename under which the test input is generated. [](https://ackee.xyz/trident/docs/0.9.1/features/trident-manifest/#__codelineno-23-3) # The location of file is afl_workspace_in directory. [](https://ackee.xyz/trident/docs/0.9.1/features/trident-manifest/#__codelineno-23-4) # (default: "" ["trident-seed"]). [](https://ackee.xyz/trident/docs/0.9.1/features/trident-manifest/#__codelineno-23-5) file_name = "" [](https://ackee.xyz/trident/docs/0.9.1/features/trident-manifest/#__codelineno-23-6) # String used as seed. [](https://ackee.xyz/trident/docs/0.9.1/features/trident-manifest/#__codelineno-23-7) # (default: "" ["trident"]). [](https://ackee.xyz/trident/docs/0.9.1/features/trident-manifest/#__codelineno-23-8) seed = "" [](https://ackee.xyz/trident/docs/0.9.1/features/trident-manifest/#__codelineno-23-9) # If the file already exists at specific location, [](https://ackee.xyz/trident/docs/0.9.1/features/trident-manifest/#__codelineno-23-10) # select if override. [](https://ackee.xyz/trident/docs/0.9.1/features/trident-manifest/#__codelineno-23-11) # (default: false). [](https://ackee.xyz/trident/docs/0.9.1/features/trident-manifest/#__codelineno-23-12) override_file = true [](https://ackee.xyz/trident/docs/0.9.1/features/trident-manifest/#__codelineno-23-13) # Number of randomly generated bytes. [](https://ackee.xyz/trident/docs/0.9.1/features/trident-manifest/#__codelineno-23-14) # (default: 0). [](https://ackee.xyz/trident/docs/0.9.1/features/trident-manifest/#__codelineno-23-15) bytes_count = 20` * * * Tip Consider checking the [Examples](https://ackee.xyz/trident/docs/0.9.1/examples/examples/) section for more tips. Back to top --- # Fuzz Test Lifecycle - Trident [Skip to content](https://ackee.xyz/trident/docs/0.8.1/features/lifecycle/#fuzz-test-lifecycle) Fuzz Test Lifecycle[#](https://ackee.xyz/trident/docs/0.8.1/features/lifecycle/#fuzz-test-lifecycle "Permanent link") ====================================================================================================================== In the sequence diagram below you can see a simplified fuzz test lifecycle. Some diagram states are labeled with emojis: * ⚡ Mandatory methods that must be implemented by the user. * 👤 Optional methods that can be implemented by the user. Lifecycle[#](https://ackee.xyz/trident/docs/0.8.1/features/lifecycle/#lifecycle "Permanent link") -------------------------------------------------------------------------------------------------- 1. The fuzzer is running until: 1. The maximal number of iterations is reached (if specified). 2. A crash was detected and the `exit_upon_crash` parameter was set. 3. User interrupted the test manually (for example by hitting `CTRL+C`). 2. In each iteration, the fuzzer generates a sequence of random instructions to execute. 1. User can optionally customize how the instructions are generated and can specify the instructions that should be executed at the beginning (`pre_ixs`), in the middle (`ixs`) and at the end (`post_ixs`) of each iteration. This can be useful for example if your program needs an initialization or you want to fuzz some specific program state. 3. For each instruction: 1. User defined mandatory method `get_accounts()` is called to collect necessary instruction accounts. 2. User defined mandatory method `get_data()` is called to collect instruction data. 3. A snapshot of all instruction accounts before the instruction execution is saved. 4. The instruction is executed. 5. A snapshot of all instruction accounts after the instruction execution is saved. 6. User defined optional method `check()` is called to check accounts data and evaluate invariants. fuzzer\_iterations = 0 fuzzer\_iterations = 0 fuzzer\_iterations <  max\_iterations fuzzer\_iterations <... done done create pre-instruction  accounts snapshots create pre-instruction... execute instruction execute instruction create post-instruction  accounts snapshots create post-instruction... check invariants 👤 check invariants 👤 fuzzer\_iterations++ fuzzer\_iterations++Generate instructions pre\_ixs 👤 pre\_ixs 👤 ixs 👤 ixs 👤 post\_ixs 👤 post\_ixs 👤 end end for ix in instructions for ix in instructions get instruction accounts ⚡ get instruction accounts ⚡ get instruction data ⚡ get instruction data ⚡ next ix next ixText is not SVG - cannot display Back to top --- # Fuzz Test Lifecycle - Trident [Skip to content](https://ackee.xyz/trident/docs/0.9.1/features/lifecycle/#fuzz-test-lifecycle) Fuzz Test Lifecycle[#](https://ackee.xyz/trident/docs/0.9.1/features/lifecycle/#fuzz-test-lifecycle "Permanent link") ====================================================================================================================== In the sequence diagram below you can see a simplified fuzz test lifecycle. Some diagram states are labeled with emojis: * ⚡ Mandatory methods that must be implemented by the user. * 👤 Optional methods that can be implemented by the user. Lifecycle[#](https://ackee.xyz/trident/docs/0.9.1/features/lifecycle/#lifecycle "Permanent link") -------------------------------------------------------------------------------------------------- 1. The fuzzer is running until: 1. The maximal number of iterations is reached (if specified). 2. A crash was detected and the `exit_upon_crash` parameter was set. 3. User interrupted the test manually (for example by hitting `CTRL+C`). 2. In each iteration, the fuzzer generates a sequence of random instructions to execute. 1. User can optionally customize how the instructions are generated and can specify the instructions that should be executed at the beginning (`pre_ixs`), in the middle (`ixs`) and at the end (`post_ixs`) of each iteration. This can be useful for example if your program needs an initialization or you want to fuzz some specific program state. 3. For each instruction: 1. User defined mandatory method `get_accounts()` is called to collect necessary instruction accounts. 2. User defined mandatory method `get_data()` is called to collect instruction data. 3. A snapshot of all instruction accounts before the instruction execution is saved. 4. The instruction is executed. 5. A snapshot of all instruction accounts after the instruction execution is saved. 6. User defined optional method `check()` is called to check accounts data and evaluate invariants. fuzzer\_iterations = 0 fuzzer\_iterations = 0 fuzzer\_iterations <  max\_iterations fuzzer\_iterations <... done done create pre-instruction  accounts snapshots create pre-instruction... execute instruction execute instruction create post-instruction  accounts snapshots create post-instruction... check invariants 👤 check invariants 👤 fuzzer\_iterations++ fuzzer\_iterations++Generate instructions pre\_ixs 👤 pre\_ixs 👤 ixs 👤 ixs 👤 post\_ixs 👤 post\_ixs 👤 end end for ix in instructions for ix in instructions get instruction accounts ⚡ get instruction accounts ⚡ get instruction data ⚡ get instruction data ⚡ next ix next ixText is not SVG - cannot display Back to top ---