AddressStorage

Struct AddressStorage 

Source
pub struct AddressStorage { /* private fields */ }
Expand description

A storage container for managing and tracking public key addresses

AddressStorage provides a convenient way to store and retrieve addresses during fuzz testing. It can generate random addresses or derive PDAs, and allows you to randomly select from stored addresses.

Implementations§

Source§

impl AddressStorage

Source

pub fn insert( &mut self, trident: &mut Trident, seeds: Option<PdaSeeds<'_>>, ) -> Pubkey

Inserts a new address into storage

Generates a new address (either a PDA or random keypair) and stores it. If PDA seeds are provided, attempts to derive a PDA. If derivation fails or no seeds are provided, generates a random keypair address.

§Arguments
  • trident - The Trident instance for random number generation
  • seeds - Optional PDA seeds for deriving a program-derived address
§Returns

The newly created and stored address

Source

pub fn insert_with_address(&mut self, address: Pubkey)

Inserts an existing address into storage

Stores a pre-existing address without generating a new one. Useful when you need to track addresses created elsewhere.

§Arguments
  • address - The address to store
Source

pub fn get(&self, trident: &mut Trident) -> Option<Pubkey>

Retrieves a random address from storage

Randomly selects one of the stored addresses using Trident’s RNG. This is useful for fuzzing operations that need to work with previously created accounts.

§Arguments
  • trident - The Trident instance for random number generation
§Returns
  • Some(Pubkey) - A randomly selected address from storage
  • None - If the storage is empty
Source

pub fn get_except( &self, trident: &mut Trident, except_addresses: &[Pubkey], ) -> Option<Pubkey>

Retrieves a random address from storage, excluding specified addresses

Randomly selects one of the stored addresses using Trident’s RNG, ensuring the selected address is not in the exclusion list. This is useful for fuzzing operations that need distinct accounts (e.g., sender and receiver must be different).

§Arguments
  • trident - The Trident instance for random number generation
  • except_addresses - Slice of addresses to exclude from selection
§Returns
  • Some(Pubkey) - A randomly selected address that is not in the exclusion list
  • None - If storage is empty or all addresses are in the exclusion list
§Examples
let sender = storage.get(&mut trident)?;
// Get a different address for receiver
let receiver = storage.get_except(&mut trident, &[sender])?;
Source

pub fn is_empty(&self) -> bool

Checks if the storage is empty

§Returns

true if no addresses are stored, false otherwise

Source

pub fn len(&self) -> usize

Returns the number of stored addresses

§Returns

The count of addresses currently in storage

Trait Implementations§

Source§

impl Default for AddressStorage

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more