@ -568,6 +568,7 @@ fn test_program_bpf_invoke() {
|
||||
const TEST_ALLOC_ACCESS_VIOLATION: u8 = 8;
|
||||
const TEST_INSTRUCTION_DATA_TOO_LARGE: u8 = 9;
|
||||
const TEST_INSTRUCTION_META_TOO_LARGE: u8 = 10;
|
||||
const TEST_RETURN_ERROR: u8 = 11;
|
||||
|
||||
#[allow(dead_code)]
|
||||
#[derive(Debug)]
|
||||
@ -683,7 +684,6 @@ fn test_program_bpf_invoke() {
|
||||
invoked_program_id.clone(),
|
||||
invoked_program_id.clone(),
|
||||
invoked_program_id.clone(),
|
||||
invoked_program_id.clone(),
|
||||
],
|
||||
Languages::Rust => vec![
|
||||
solana_sdk::system_program::id(),
|
||||
@ -700,9 +700,9 @@ fn test_program_bpf_invoke() {
|
||||
invoked_program_id.clone(),
|
||||
invoked_program_id.clone(),
|
||||
invoked_program_id.clone(),
|
||||
invoked_program_id.clone(),
|
||||
],
|
||||
};
|
||||
assert_eq!(invoked_programs.len(), expected_invoked_programs.len());
|
||||
assert_eq!(invoked_programs, expected_invoked_programs);
|
||||
|
||||
let no_invoked_programs: Vec<Pubkey> = inner_instructions[1]
|
||||
@ -960,6 +960,33 @@ fn test_program_bpf_invoke() {
|
||||
TransactionError::InstructionError(0, InstructionError::ComputationalBudgetExceeded)
|
||||
);
|
||||
|
||||
let instruction = Instruction::new(
|
||||
invoke_program_id,
|
||||
&[TEST_RETURN_ERROR, bump_seed1, bump_seed2, bump_seed3],
|
||||
account_metas.clone(),
|
||||
);
|
||||
let message = Message::new(&[instruction], Some(&mint_pubkey));
|
||||
let tx = Transaction::new(
|
||||
&[
|
||||
&mint_keypair,
|
||||
&argument_keypair,
|
||||
&invoked_argument_keypair,
|
||||
&from_keypair,
|
||||
],
|
||||
message.clone(),
|
||||
bank.last_blockhash(),
|
||||
);
|
||||
let (result, inner_instructions) = process_transaction_and_record_inner(&bank, tx);
|
||||
let invoked_programs: Vec<Pubkey> = inner_instructions[0]
|
||||
.iter()
|
||||
.map(|ix| message.account_keys[ix.program_id_index as usize].clone())
|
||||
.collect();
|
||||
assert_eq!(invoked_programs, vec![invoked_program_id.clone()]);
|
||||
assert_eq!(
|
||||
result.unwrap_err(),
|
||||
TransactionError::InstructionError(0, InstructionError::Custom(42))
|
||||
);
|
||||
|
||||
// Check final state
|
||||
|
||||
assert_eq!(43, bank.get_balance(&derived_key1));
|
||||
|
Reference in New Issue
Block a user