Invoke with empty account slice (#13931)
This commit is contained in:
@ -490,6 +490,7 @@ fn test_program_bpf_invoke() {
|
||||
const TEST_PRIVILEGE_ESCALATION_SIGNER: u8 = 2;
|
||||
const TEST_PRIVILEGE_ESCALATION_WRITABLE: u8 = 3;
|
||||
const TEST_PPROGRAM_NOT_EXECUTABLE: u8 = 4;
|
||||
const TEST_EMPTY_ACCOUNTS_SLICE: u8 = 5;
|
||||
|
||||
#[allow(dead_code)]
|
||||
#[derive(Debug)]
|
||||
@ -732,6 +733,38 @@ fn test_program_bpf_invoke() {
|
||||
TransactionError::InstructionError(0, InstructionError::AccountNotExecutable)
|
||||
);
|
||||
|
||||
let instruction = Instruction::new(
|
||||
invoke_program_id,
|
||||
&[
|
||||
TEST_EMPTY_ACCOUNTS_SLICE,
|
||||
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![]);
|
||||
assert_eq!(
|
||||
result.unwrap_err(),
|
||||
TransactionError::InstructionError(0, InstructionError::MissingAccount)
|
||||
);
|
||||
|
||||
// Check final state
|
||||
|
||||
assert_eq!(43, bank.get_balance(&derived_key1));
|
||||
|
Reference in New Issue
Block a user