Native/builtin programs now receive an InvokeContext
This commit is contained in:
@@ -10,6 +10,7 @@ use solana_sdk::{
|
||||
decode_error::DecodeError,
|
||||
instruction::{AccountMeta, Instruction, InstructionError},
|
||||
keyed_account::{from_keyed_account, get_signers, next_keyed_account, KeyedAccount},
|
||||
process_instruction::InvokeContext,
|
||||
program_utils::limited_deserialize,
|
||||
pubkey::Pubkey,
|
||||
system_instruction,
|
||||
@@ -446,6 +447,7 @@ pub fn process_instruction(
|
||||
_program_id: &Pubkey,
|
||||
keyed_accounts: &[KeyedAccount],
|
||||
data: &[u8],
|
||||
_invoke_context: &mut dyn InvokeContext,
|
||||
) -> Result<(), InstructionError> {
|
||||
trace!("process_instruction: {:?}", data);
|
||||
trace!("keyed_accounts: {:?}", keyed_accounts);
|
||||
@@ -525,6 +527,7 @@ mod tests {
|
||||
use bincode::serialize;
|
||||
use solana_sdk::{
|
||||
account::{self, Account},
|
||||
process_instruction::MockInvokeContext,
|
||||
rent::Rent,
|
||||
sysvar::stake_history::StakeHistory,
|
||||
};
|
||||
@@ -562,7 +565,12 @@ mod tests {
|
||||
.zip(accounts.iter())
|
||||
.map(|(meta, account)| KeyedAccount::new(&meta.pubkey, meta.is_signer, account))
|
||||
.collect();
|
||||
super::process_instruction(&Pubkey::default(), &keyed_accounts, &instruction.data)
|
||||
super::process_instruction(
|
||||
&Pubkey::default(),
|
||||
&keyed_accounts,
|
||||
&instruction.data,
|
||||
&mut MockInvokeContext::default(),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -661,6 +669,7 @@ mod tests {
|
||||
Lockup::default()
|
||||
))
|
||||
.unwrap(),
|
||||
&mut MockInvokeContext::default()
|
||||
),
|
||||
Err(InstructionError::NotEnoughAccountKeys),
|
||||
);
|
||||
@@ -679,6 +688,7 @@ mod tests {
|
||||
Lockup::default()
|
||||
))
|
||||
.unwrap(),
|
||||
&mut MockInvokeContext::default()
|
||||
),
|
||||
Err(InstructionError::NotEnoughAccountKeys),
|
||||
);
|
||||
@@ -696,6 +706,7 @@ mod tests {
|
||||
Lockup::default()
|
||||
))
|
||||
.unwrap(),
|
||||
&mut MockInvokeContext::default()
|
||||
),
|
||||
Err(InstructionError::InvalidArgument),
|
||||
);
|
||||
@@ -717,6 +728,7 @@ mod tests {
|
||||
Lockup::default()
|
||||
))
|
||||
.unwrap(),
|
||||
&mut MockInvokeContext::default()
|
||||
),
|
||||
Err(InstructionError::InvalidAccountData),
|
||||
);
|
||||
@@ -731,6 +743,7 @@ mod tests {
|
||||
&create_default_account()
|
||||
),],
|
||||
&serialize(&StakeInstruction::DelegateStake).unwrap(),
|
||||
&mut MockInvokeContext::default()
|
||||
),
|
||||
Err(InstructionError::NotEnoughAccountKeys),
|
||||
);
|
||||
@@ -745,6 +758,7 @@ mod tests {
|
||||
&create_default_account()
|
||||
)],
|
||||
&serialize(&StakeInstruction::DelegateStake).unwrap(),
|
||||
&mut MockInvokeContext::default()
|
||||
),
|
||||
Err(InstructionError::NotEnoughAccountKeys),
|
||||
);
|
||||
@@ -776,6 +790,7 @@ mod tests {
|
||||
),
|
||||
],
|
||||
&serialize(&StakeInstruction::DelegateStake).unwrap(),
|
||||
&mut MockInvokeContext::default()
|
||||
),
|
||||
Err(InstructionError::InvalidAccountData),
|
||||
);
|
||||
@@ -802,6 +817,7 @@ mod tests {
|
||||
),
|
||||
],
|
||||
&serialize(&StakeInstruction::Withdraw(42)).unwrap(),
|
||||
&mut MockInvokeContext::default()
|
||||
),
|
||||
Err(InstructionError::InvalidArgument),
|
||||
);
|
||||
@@ -816,6 +832,7 @@ mod tests {
|
||||
&create_default_account()
|
||||
)],
|
||||
&serialize(&StakeInstruction::Withdraw(42)).unwrap(),
|
||||
&mut MockInvokeContext::default()
|
||||
),
|
||||
Err(InstructionError::NotEnoughAccountKeys),
|
||||
);
|
||||
@@ -836,6 +853,7 @@ mod tests {
|
||||
),
|
||||
],
|
||||
&serialize(&StakeInstruction::Deactivate).unwrap(),
|
||||
&mut MockInvokeContext::default()
|
||||
),
|
||||
Err(InstructionError::InvalidArgument),
|
||||
);
|
||||
@@ -846,6 +864,7 @@ mod tests {
|
||||
&Pubkey::default(),
|
||||
&[],
|
||||
&serialize(&StakeInstruction::Deactivate).unwrap(),
|
||||
&mut MockInvokeContext::default()
|
||||
),
|
||||
Err(InstructionError::NotEnoughAccountKeys),
|
||||
);
|
||||
|
Reference in New Issue
Block a user