pub struct ProgramTest { /* private fields */ }agave-unstable-api crate feature must be specified to acknowledge use of an interface that may break without warning.Implementations§
Source§impl ProgramTest
impl ProgramTest
Sourcepub fn new(
program_name: &'static str,
program_id: Pubkey,
builtin_function: Option<BuiltinFunctionWithContext>,
) -> Self
👎Deprecated since 3.1.0: This crate has been marked for formal inclusion in the Agave Unstable API. From v4.0.0 onward, the agave-unstable-api crate feature must be specified to acknowledge use of an interface that may break without warning.
pub fn new( program_name: &'static str, program_id: Pubkey, builtin_function: Option<BuiltinFunctionWithContext>, ) -> Self
agave-unstable-api crate feature must be specified to acknowledge use of an interface that may break without warning.Create a ProgramTest.
This is a wrapper around default and add_program. See their documentation for more
details.
Sourcepub fn prefer_bpf(&mut self, prefer_bpf: bool)
👎Deprecated since 3.1.0: This crate has been marked for formal inclusion in the Agave Unstable API. From v4.0.0 onward, the agave-unstable-api crate feature must be specified to acknowledge use of an interface that may break without warning.
pub fn prefer_bpf(&mut self, prefer_bpf: bool)
agave-unstable-api crate feature must be specified to acknowledge use of an interface that may break without warning.Override default SBF program selection
Sourcepub fn set_compute_max_units(&mut self, compute_max_units: u64)
👎Deprecated since 3.1.0: This crate has been marked for formal inclusion in the Agave Unstable API. From v4.0.0 onward, the agave-unstable-api crate feature must be specified to acknowledge use of an interface that may break without warning.
pub fn set_compute_max_units(&mut self, compute_max_units: u64)
agave-unstable-api crate feature must be specified to acknowledge use of an interface that may break without warning.Override the default maximum compute units
Sourcepub fn set_transaction_account_lock_limit(
&mut self,
transaction_account_lock_limit: usize,
)
👎Deprecated since 3.1.0: This crate has been marked for formal inclusion in the Agave Unstable API. From v4.0.0 onward, the agave-unstable-api crate feature must be specified to acknowledge use of an interface that may break without warning.
pub fn set_transaction_account_lock_limit( &mut self, transaction_account_lock_limit: usize, )
agave-unstable-api crate feature must be specified to acknowledge use of an interface that may break without warning.Override the default transaction account lock limit
Sourcepub fn add_genesis_account(&mut self, address: Pubkey, account: Account)
👎Deprecated since 3.1.0: This crate has been marked for formal inclusion in the Agave Unstable API. From v4.0.0 onward, the agave-unstable-api crate feature must be specified to acknowledge use of an interface that may break without warning.
pub fn add_genesis_account(&mut self, address: Pubkey, account: Account)
agave-unstable-api crate feature must be specified to acknowledge use of an interface that may break without warning.Add an account to the test environment’s genesis config.
Sourcepub fn add_account(&mut self, address: Pubkey, account: Account)
👎Deprecated since 3.1.0: This crate has been marked for formal inclusion in the Agave Unstable API. From v4.0.0 onward, the agave-unstable-api crate feature must be specified to acknowledge use of an interface that may break without warning.
pub fn add_account(&mut self, address: Pubkey, account: Account)
agave-unstable-api crate feature must be specified to acknowledge use of an interface that may break without warning.Add an account to the test environment
Sourcepub fn add_account_with_file_data(
&mut self,
address: Pubkey,
lamports: u64,
owner: Pubkey,
filename: &str,
)
👎Deprecated since 3.1.0: This crate has been marked for formal inclusion in the Agave Unstable API. From v4.0.0 onward, the agave-unstable-api crate feature must be specified to acknowledge use of an interface that may break without warning.
pub fn add_account_with_file_data( &mut self, address: Pubkey, lamports: u64, owner: Pubkey, filename: &str, )
agave-unstable-api crate feature must be specified to acknowledge use of an interface that may break without warning.Add an account to the test environment with the account data in the provided filename
Sourcepub fn add_account_with_base64_data(
&mut self,
address: Pubkey,
lamports: u64,
owner: Pubkey,
data_base64: &str,
)
👎Deprecated since 3.1.0: This crate has been marked for formal inclusion in the Agave Unstable API. From v4.0.0 onward, the agave-unstable-api crate feature must be specified to acknowledge use of an interface that may break without warning.
pub fn add_account_with_base64_data( &mut self, address: Pubkey, lamports: u64, owner: Pubkey, data_base64: &str, )
agave-unstable-api crate feature must be specified to acknowledge use of an interface that may break without warning.Add an account to the test environment with the account data in the provided as a base 64 string
pub fn add_sysvar_account<S: SysvarSerialize>( &mut self, address: Pubkey, sysvar: &S, )
agave-unstable-api crate feature must be specified to acknowledge use of an interface that may break without warning.Sourcepub fn add_upgradeable_program_to_genesis(
&mut self,
program_name: &'static str,
program_id: &Pubkey,
)
👎Deprecated since 3.1.0: This crate has been marked for formal inclusion in the Agave Unstable API. From v4.0.0 onward, the agave-unstable-api crate feature must be specified to acknowledge use of an interface that may break without warning.
pub fn add_upgradeable_program_to_genesis( &mut self, program_name: &'static str, program_id: &Pubkey, )
agave-unstable-api crate feature must be specified to acknowledge use of an interface that may break without warning.Add a BPF Upgradeable program to the test environment’s genesis config.
When testing BPF programs using the program ID of a runtime builtin program - such as Core BPF programs - the program accounts must be added to the genesis config in order to make them available to the new Bank as it’s being initialized.
The presence of these program accounts will cause Bank to skip adding the builtin version of the program, allowing the provided BPF program to be used at the designated program ID instead.
See https://github.com/anza-xyz/agave/blob/c038908600b8a1b0080229dea015d7fc9939c418/runtime/src/bank.rs#L5109-L5126.
Sourcepub fn add_program(
&mut self,
program_name: &'static str,
program_id: Pubkey,
builtin_function: Option<BuiltinFunctionWithContext>,
)
👎Deprecated since 3.1.0: This crate has been marked for formal inclusion in the Agave Unstable API. From v4.0.0 onward, the agave-unstable-api crate feature must be specified to acknowledge use of an interface that may break without warning.
pub fn add_program( &mut self, program_name: &'static str, program_id: Pubkey, builtin_function: Option<BuiltinFunctionWithContext>, )
agave-unstable-api crate feature must be specified to acknowledge use of an interface that may break without warning.Add a SBF program to the test environment.
program_name will also be used to locate the SBF shared object in the current or fixtures
directory.
If builtin_function is provided, the natively built-program may be used instead of the
SBF shared object depending on the BPF_OUT_DIR environment variable.
Sourcepub fn add_builtin_program(
&mut self,
program_name: &'static str,
program_id: Pubkey,
builtin_function: BuiltinFunctionWithContext,
)
👎Deprecated since 3.1.0: This crate has been marked for formal inclusion in the Agave Unstable API. From v4.0.0 onward, the agave-unstable-api crate feature must be specified to acknowledge use of an interface that may break without warning.
pub fn add_builtin_program( &mut self, program_name: &'static str, program_id: Pubkey, builtin_function: BuiltinFunctionWithContext, )
agave-unstable-api crate feature must be specified to acknowledge use of an interface that may break without warning.Add a builtin program to the test environment.
Note that builtin programs are responsible for their own stable_log output.
Sourcepub fn deactivate_feature(&mut self, feature_id: Pubkey)
👎Deprecated since 3.1.0: This crate has been marked for formal inclusion in the Agave Unstable API. From v4.0.0 onward, the agave-unstable-api crate feature must be specified to acknowledge use of an interface that may break without warning.
pub fn deactivate_feature(&mut self, feature_id: Pubkey)
agave-unstable-api crate feature must be specified to acknowledge use of an interface that may break without warning.Deactivate a runtime feature.
Note that all features are activated by default.
pub async fn start(self) -> (BanksClient, Keypair, Hash)
agave-unstable-api crate feature must be specified to acknowledge use of an interface that may break without warning.Sourcepub async fn start_with_context(self) -> ProgramTestContext
👎Deprecated since 3.1.0: This crate has been marked for formal inclusion in the Agave Unstable API. From v4.0.0 onward, the agave-unstable-api crate feature must be specified to acknowledge use of an interface that may break without warning.
pub async fn start_with_context(self) -> ProgramTestContext
agave-unstable-api crate feature must be specified to acknowledge use of an interface that may break without warning.Start the test client
Returns a BanksClient interface into the test environment as well as a payer Keypair
with SOL for sending transactions
Trait Implementations§
Source§impl Default for ProgramTest
impl Default for ProgramTest
Source§fn default() -> Self
fn default() -> Self
Initialize a new ProgramTest
If the BPF_OUT_DIR environment variable is defined, BPF programs will be preferred over
over a native instruction processor. The ProgramTest::prefer_bpf() method may be
used to override this preference at runtime. cargo test-bpf will set BPF_OUT_DIR
automatically.
SBF program shared objects and account data files are searched for in
- the value of the
BPF_OUT_DIRenvironment variable - the
tests/fixturessub-directory - the current working directory
Auto Trait Implementations§
impl Freeze for ProgramTest
impl RefUnwindSafe for ProgramTest
impl Send for ProgramTest
impl Sync for ProgramTest
impl Unpin for ProgramTest
impl !UnwindSafe for ProgramTest
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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
Source§impl<T> FmtForward for T
impl<T> FmtForward for T
Source§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self to use its Binary implementation when Debug-formatted.Source§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self to use its Display implementation when
Debug-formatted.Source§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self to use its LowerExp implementation when
Debug-formatted.Source§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self to use its LowerHex implementation when
Debug-formatted.Source§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self to use its Octal implementation when Debug-formatted.Source§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self to use its Pointer implementation when
Debug-formatted.Source§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self to use its UpperExp implementation when
Debug-formatted.Source§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self to use its UpperHex implementation when
Debug-formatted.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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>
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>
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 moreSource§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
Source§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
Source§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
Source§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
Source§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self, then passes self.as_ref() into the pipe function.Source§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self, then passes self.as_mut() into the pipe
function.Source§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self, then passes self.deref() into the pipe function.Source§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<T> Tap for T
impl<T> Tap for T
Source§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B> of a value. Read moreSource§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B> of a value. Read moreSource§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R> view of a value. Read moreSource§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R> view of a value. Read moreSource§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap() only in debug builds, and is erased in release builds.Source§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut() only in debug builds, and is erased in release
builds.Source§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref() only in debug builds, and is erased in release
builds.Source§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut() only in debug builds, and is erased in release
builds.Source§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref() only in debug builds, and is erased in release
builds.