Trident#
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.
Core Transaction Processing Methods#
process_transaction#
Processes a transaction with the given instructions and returns the result with logs.
pub fn process_transaction(
&mut self,
instructions: &[Instruction],
log_as: Option<&str>,
) -> TransactionResult
Parameters:
instructions- Array of instructions to execute in the transactionlog_as- Optional name for the transaction (used in metrics and logging). IfNone, the transaction will not be logged.
Returns: TransactionResult containing success/failure status and transaction logs.
Description: Executes a transaction containing one or more instructions and returns the results. Use this to test your program's instructions with various inputs. Provide a transaction name to enable metrics collection and logging for that transaction. See TransactionResult for available methods to inspect the transaction outcome.
deploy_program#
Deploys a program to the fuzzing environment.
Parameters:
program- The program binary and metadata to deploy
Description: Makes a program available for testing by deploying it to the fuzzing environment.
deploy_entrypoint (syscall-v2 feature)#
Deploys an entrypoint program to the fuzzing environment.
Parameters:
program- The entrypoint program to deploy
Description: Makes an entrypoint program available for testing when using the syscall-v2 feature.
Not Yet Implemented#
get_last_blockhash#
Status: TODO - Not yet implemented for TridentSVM.
Method Categories#
Specialized Method Groups#
- Account Management - Account data retrieval, manipulation, and lamport management
- Time & Clock - Time manipulation and clock-related operations for testing time-dependent logic
- Random Generation - Generate random data for comprehensive fuzz testing
- Metrics & Regression - Collect metrics and track account states for regression testing
Native Program Methods#
- System Program Methods - Account creation, allocation, assignment, and SOL transfers
Feature-Gated Methods#
- SPL Token Methods - Available with
tokenfeature - Token 2022 Methods - Available with
tokenfeature - Vote Program Methods - Available with
votefeature - Stake Program Methods - Available with
stakefeature
Getting Started#
For most fuzz tests, you'll primarily use:
process_transaction- Execute your program instructions- Random generation methods - Create varied test inputs
- Account management methods - Set up and inspect account states
Example Usage#
use trident_fuzz::*;
#[flow]
fn basic_fuzz_example(&mut self) {
// Generate random test data
let amount = self.random_from_range(1..1000u64);
let recipient = self.random_pubkey();
// Create and execute transaction with logging
let transfer_ix = self.transfer(&self.payer().pubkey(), &recipient, amount);
let result = self.process_transaction(&[transfer_ix], Some("Transfer Test"));
// Verify results
assert!(result.is_success());
// Or execute without logging (pass None)
let result = self.process_transaction(&[transfer_ix], None);
}