pub struct LiteSVMBuilder { /* private fields */ }Expand description
Builder for creating a LiteSVM instance with programs pre-deployed
This provides a more ergonomic way to set up test environments compared to manually creating LiteSVM instances and deploying programs.
§Example
ⓘ
use litesvm_utils::LiteSVMBuilder;
use solana_program::pubkey::Pubkey;
// Simple single program setup
let program_id = Pubkey::new_unique();
let program_bytes = include_bytes!("../target/deploy/my_program.so");
let mut svm = LiteSVMBuilder::new()
.deploy_program(program_id, program_bytes)
.build();
// Or use the convenience method for single program
let mut svm = LiteSVMBuilder::build_with_program(program_id, program_bytes);Implementations§
Source§impl LiteSVMBuilder
impl LiteSVMBuilder
Sourcepub fn deploy_program(self, program_id: Pubkey, program_bytes: &[u8]) -> Self
pub fn deploy_program(self, program_id: Pubkey, program_bytes: &[u8]) -> Self
Sourcepub fn build_with_program(program_id: Pubkey, program_bytes: &[u8]) -> LiteSVM
pub fn build_with_program(program_id: Pubkey, program_bytes: &[u8]) -> LiteSVM
Convenience method to quickly set up a single program
This is equivalent to:
ⓘ
LiteSVMBuilder::new()
.deploy_program(program_id, program_bytes)
.build()§Arguments
program_id- The program ID to deploy atprogram_bytes- The compiled program bytes
§Returns
Returns a configured LiteSVM instance with the program deployed
§Example
ⓘ
let mut svm = LiteSVMBuilder::build_with_program(program_id, program_bytes);Sourcepub fn build_with_programs(programs: &[(Pubkey, &[u8])]) -> LiteSVM
pub fn build_with_programs(programs: &[(Pubkey, &[u8])]) -> LiteSVM
Convenience method to quickly set up multiple programs
§Arguments
programs- A slice of (program_id, program_bytes) tuples
§Returns
Returns a configured LiteSVM instance with all programs deployed
§Example
ⓘ
let programs = vec![
(program_id1, program_bytes1),
(program_id2, program_bytes2),
];
let mut svm = LiteSVMBuilder::build_with_programs(&programs);Trait Implementations§
Auto Trait Implementations§
impl Freeze for LiteSVMBuilder
impl RefUnwindSafe for LiteSVMBuilder
impl Send for LiteSVMBuilder
impl Sync for LiteSVMBuilder
impl Unpin for LiteSVMBuilder
impl UnwindSafe for LiteSVMBuilder
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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