Struct solana_program_test::InvokeContext
source · [−]pub struct InvokeContext<'a> {
pub sysvar_cache: Cow<'a, SysvarCache>,
pub instruction_trace: Vec<InstructionRecorder, Global>,
pub feature_set: Arc<FeatureSet>,
pub timings: ExecuteDetailsTimings,
pub blockhash: Hash,
pub lamports_per_signature: u64,
pub return_data: (Pubkey, Vec<u8, Global>),
/* private fields */
}
Fields
sysvar_cache: Cow<'a, SysvarCache>
instruction_trace: Vec<InstructionRecorder, Global>
feature_set: Arc<FeatureSet>
timings: ExecuteDetailsTimings
blockhash: Hash
lamports_per_signature: u64
return_data: (Pubkey, Vec<u8, Global>)
Implementations
sourceimpl<'a> InvokeContext<'a>
impl<'a> InvokeContext<'a>
pub fn new(
rent: Rent,
accounts: &'a [(Pubkey, Rc<RefCell<AccountSharedData>>)],
builtin_programs: &'a [BuiltinProgram],
sysvar_cache: Cow<'a, SysvarCache>,
log_collector: Option<Rc<RefCell<LogCollector>>>,
compute_budget: ComputeBudget,
executors: Rc<RefCell<HashMap<Pubkey, TransactionExecutor, RandomState>>>,
feature_set: Arc<FeatureSet>,
blockhash: Hash,
lamports_per_signature: u64,
initial_accounts_data_len: u64
) -> InvokeContext<'a>
pub fn new_mock(
accounts: &'a [(Pubkey, Rc<RefCell<AccountSharedData>>)],
builtin_programs: &'a [BuiltinProgram]
) -> InvokeContext<'a>
sourcepub fn push(
&mut self,
message: &SanitizedMessage,
instruction: &CompiledInstruction,
program_indices: &[usize],
account_indices: &[usize]
) -> Result<(), InstructionError>
pub fn push(
&mut self,
message: &SanitizedMessage,
instruction: &CompiledInstruction,
program_indices: &[usize],
account_indices: &[usize]
) -> Result<(), InstructionError>
Push a stack frame onto the invocation stack
sourcepub fn get_stack_height(&self) -> usize
pub fn get_stack_height(&self) -> usize
Current height of the stack
sourcepub fn native_invoke(
&mut self,
instruction: Instruction,
signers: &[Pubkey]
) -> Result<(), InstructionError>
pub fn native_invoke(
&mut self,
instruction: Instruction,
signers: &[Pubkey]
) -> Result<(), InstructionError>
Entrypoint for a cross-program invocation from a builtin program
sourcepub fn create_message(
&mut self,
instruction: &Instruction,
signers: &[Pubkey]
) -> Result<(Message, Vec<bool, Global>, Vec<usize, Global>), InstructionError>
pub fn create_message(
&mut self,
instruction: &Instruction,
signers: &[Pubkey]
) -> Result<(Message, Vec<bool, Global>, Vec<usize, Global>), InstructionError>
Helper to prepare for process_instruction()
sourcepub fn process_instruction(
&mut self,
message: &SanitizedMessage,
instruction: &CompiledInstruction,
program_indices: &[usize],
account_indices: &[usize],
caller_write_privileges: &[bool],
timings: &mut ExecuteTimings
) -> ProcessInstructionResult
pub fn process_instruction(
&mut self,
message: &SanitizedMessage,
instruction: &CompiledInstruction,
program_indices: &[usize],
account_indices: &[usize],
caller_write_privileges: &[bool],
timings: &mut ExecuteTimings
) -> ProcessInstructionResult
Processes a cross-program instruction and returns how many compute units were used
sourcepub fn get_caller(&self) -> Result<&Pubkey, InstructionError>
pub fn get_caller(&self) -> Result<&Pubkey, InstructionError>
Get the program ID of the currently executing program
sourcepub fn get_loader(&self) -> Result<Pubkey, InstructionError>
pub fn get_loader(&self) -> Result<Pubkey, InstructionError>
Get the owner of the currently executing program
sourcepub fn remove_first_keyed_account(&mut self) -> Result<(), InstructionError>
👎 Deprecated since 1.9.0: To be removed together with remove_native_loader
pub fn remove_first_keyed_account(&mut self) -> Result<(), InstructionError>
To be removed together with remove_native_loader
Removes the first keyed account
sourcepub fn get_keyed_accounts(
&self
) -> Result<&[KeyedAccount<'_>], InstructionError>
pub fn get_keyed_accounts(
&self
) -> Result<&[KeyedAccount<'_>], InstructionError>
Get the list of keyed accounts
sourcepub fn get_instruction_keyed_accounts(
&self
) -> Result<&[KeyedAccount<'_>], InstructionError>
pub fn get_instruction_keyed_accounts(
&self
) -> Result<&[KeyedAccount<'_>], InstructionError>
Get the list of keyed accounts without the chain of program accounts
Note: This only contains the KeyedAccount
s passed by the caller.
sourcepub fn get_log_collector(&self) -> Option<Rc<RefCell<LogCollector>>>
pub fn get_log_collector(&self) -> Option<Rc<RefCell<LogCollector>>>
Get this invocation’s LogCollector
sourcepub fn get_compute_meter(&self) -> Rc<RefCell<ComputeMeter>>
pub fn get_compute_meter(&self) -> Rc<RefCell<ComputeMeter>>
Get this invocation’s ComputeMeter
sourcepub fn get_accounts_data_meter(&self) -> &AccountsDataMeter
pub fn get_accounts_data_meter(&self) -> &AccountsDataMeter
Get this invocation’s AccountsDataMeter
sourcepub fn add_executor(
&self,
pubkey: &Pubkey,
executor: Arc<dyn Executor + 'static>
)
pub fn add_executor(
&self,
pubkey: &Pubkey,
executor: Arc<dyn Executor + 'static>
)
Cache an executor that wasn’t found in the cache
sourcepub fn update_executor(
&self,
pubkey: &Pubkey,
executor: Arc<dyn Executor + 'static>
)
pub fn update_executor(
&self,
pubkey: &Pubkey,
executor: Arc<dyn Executor + 'static>
)
Cache an executor that has changed
sourcepub fn get_executor(
&self,
pubkey: &Pubkey
) -> Option<Arc<dyn Executor + 'static>>
pub fn get_executor(
&self,
pubkey: &Pubkey
) -> Option<Arc<dyn Executor + 'static>>
Get the completed loader work that can be re-used across execution
sourcepub fn get_account(
&self,
pubkey: &Pubkey
) -> Option<(usize, Rc<RefCell<AccountSharedData>>)>
pub fn get_account(
&self,
pubkey: &Pubkey
) -> Option<(usize, Rc<RefCell<AccountSharedData>>)>
Find an account_index and account by its key
sourcepub fn get_compute_budget(&self) -> &ComputeBudget
pub fn get_compute_budget(&self) -> &ComputeBudget
Get this invocation’s compute budget
sourcepub fn get_sysvar_cache(&self) -> &SysvarCache
pub fn get_sysvar_cache(&self) -> &SysvarCache
Get cached sysvars
sourcepub fn record_top_level_instruction(&mut self, instruction: Instruction)
pub fn record_top_level_instruction(&mut self, instruction: Instruction)
Record top-level instruction in the instruction trace
sourcepub fn record_instruction(
&mut self,
stack_height: usize,
instruction: Instruction
)
pub fn record_instruction(
&mut self,
stack_height: usize,
instruction: Instruction
)
Record instruction in the instruction trace
sourcepub fn get_instruction_trace(&self) -> &[InstructionRecorder]
pub fn get_instruction_trace(&self) -> &[InstructionRecorder]
Get the instruction trace
Auto Trait Implementations
impl<'a> !RefUnwindSafe for InvokeContext<'a>
impl<'a> !Send for InvokeContext<'a>
impl<'a> !Sync for InvokeContext<'a>
impl<'a> Unpin for InvokeContext<'a>
impl<'a> !UnwindSafe for InvokeContext<'a>
Blanket Implementations
impl<T> AbiExample for T
impl<T> AbiExample for T
default fn example() -> T
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<T> FutureExt for T
impl<T> FutureExt for T
fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
impl<T> Pointable for T
impl<T> Pointable for T
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
fn vzip(self) -> V
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
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
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more