Struct solana_program_test::InvokeContext

source ·
pub struct InvokeContext<'a> {
    pub transaction_context: &'a mut TransactionContext,
    pub programs_loaded_for_tx_batch: &'a LoadedProgramsForTxBatch,
    pub programs_modified_by_tx: &'a mut LoadedProgramsForTxBatch,
    pub feature_set: Arc<FeatureSet>,
    pub timings: ExecuteDetailsTimings,
    pub blockhash: Hash,
    pub lamports_per_signature: u64,
    pub syscall_context: Vec<Option<SyscallContext>>,
    /* private fields */
}

Fields§

§transaction_context: &'a mut TransactionContext§programs_loaded_for_tx_batch: &'a LoadedProgramsForTxBatch§programs_modified_by_tx: &'a mut LoadedProgramsForTxBatch§feature_set: Arc<FeatureSet>§timings: ExecuteDetailsTimings§blockhash: Hash§lamports_per_signature: u64§syscall_context: Vec<Option<SyscallContext>>

Implementations§

source§

impl<'a> InvokeContext<'a>

source

pub fn new( transaction_context: &'a mut TransactionContext, sysvar_cache: &'a SysvarCache, log_collector: Option<Rc<RefCell<LogCollector>>>, compute_budget: ComputeBudget, programs_loaded_for_tx_batch: &'a LoadedProgramsForTxBatch, programs_modified_by_tx: &'a mut LoadedProgramsForTxBatch, feature_set: Arc<FeatureSet>, blockhash: Hash, lamports_per_signature: u64 ) -> InvokeContext<'a>

source

pub fn find_program_in_cache( &self, pubkey: &Pubkey ) -> Option<Arc<LoadedProgram>>

source

pub fn get_environments_for_slot( &self, effective_slot: u64 ) -> Result<&ProgramRuntimeEnvironments, InstructionError>

source

pub fn push(&mut self) -> Result<(), InstructionError>

Push a stack frame onto the invocation stack

source

pub fn pop(&mut self) -> Result<(), InstructionError>

Pop a stack frame from the invocation stack

source

pub fn get_stack_height(&self) -> usize

Current height of the invocation stack, top level instructions are height solana_sdk::instruction::TRANSACTION_LEVEL_STACK_HEIGHT

source

pub fn native_invoke( &mut self, instruction: StableInstruction, signers: &[Pubkey] ) -> Result<(), InstructionError>

Entrypoint for a cross-program invocation from a builtin program

source

pub fn prepare_instruction( &mut self, instruction: &StableInstruction, signers: &[Pubkey] ) -> Result<(Vec<InstructionAccount>, Vec<u16>), InstructionError>

Helper to prepare for process_instruction()

source

pub fn process_instruction( &mut self, instruction_data: &[u8], instruction_accounts: &[InstructionAccount], program_indices: &[u16], compute_units_consumed: &mut u64, timings: &mut ExecuteTimings ) -> Result<(), InstructionError>

Processes an instruction and returns how many compute units were used

source

pub fn get_log_collector(&self) -> Option<Rc<RefCell<LogCollector>>>

Get this invocation’s LogCollector

source

pub fn consume_checked(&self, amount: u64) -> Result<(), Box<dyn Error>>

Consume compute units

source

pub fn mock_set_remaining(&self, remaining: u64)

Set compute units

Only use for tests and benchmarks

source

pub fn get_compute_budget(&self) -> &ComputeBudget

Get this invocation’s compute budget

source

pub fn get_sysvar_cache(&self) -> &SysvarCache

Get cached sysvars

source

pub fn get_check_aligned(&self) -> bool

source

pub fn set_syscall_context( &mut self, syscall_context: SyscallContext ) -> Result<(), InstructionError>

source

pub fn get_syscall_context(&self) -> Result<&SyscallContext, InstructionError>

source

pub fn get_syscall_context_mut( &mut self ) -> Result<&mut SyscallContext, InstructionError>

source

pub fn get_traces(&self) -> &Vec<Vec<[u64; 12]>>

Return a references to traces

Trait Implementations§

source§

impl<'a> ContextObject for InvokeContext<'a>

source§

fn trace(&mut self, state: [u64; 12])

Called for every instruction executed when tracing is enabled
source§

fn consume(&mut self, amount: u64)

Consume instructions from meter
source§

fn get_remaining(&self) -> u64

Get the number of remaining instructions allowed

Auto Trait Implementations§

§

impl<'a> !Freeze for InvokeContext<'a>

§

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§

source§

impl<T> AbiExample for T

source§

default fn example() -> T

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<'a, T, E> AsTaggedExplicit<'a, E> for T
where T: 'a,

source§

fn explicit(self, class: Class, tag: u32) -> TaggedParser<'a, Explicit, Self, E>

source§

impl<'a, T, E> AsTaggedImplicit<'a, E> for T
where T: 'a,

source§

fn implicit( self, class: Class, constructed: bool, tag: u32 ) -> TaggedParser<'a, Implicit, Self, E>

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> FutureExt for T

source§

fn with_context(self, otel_cx: Context) -> WithContext<Self>

Attaches the provided Context to this type, returning a WithContext wrapper. Read more
source§

fn with_current_context(self) -> WithContext<Self>

Attaches the current Context to this type, returning a WithContext wrapper. Read more
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> Pointable for T

source§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

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

§

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>,

§

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