Fixes the empty transaction bug in ThisInvokeContext::push() and adds a test for it to the bank.
This commit is contained in:
Alexander Meißner
2021-11-19 20:43:42 +01:00
committed by GitHub
parent 0bda0c3e0c
commit 8a50b6302f
4 changed files with 35 additions and 25 deletions

View File

@ -15391,4 +15391,18 @@ pub(crate) mod tests {
.unwrap();
assert_eq!(Bank::calculate_fee(&message, 1), 11);
}
#[test]
fn test_an_empty_transaction_without_program() {
let (genesis_config, mint_keypair) = create_genesis_config(1);
let bank = Bank::new_for_tests(&genesis_config);
let destination = solana_sdk::pubkey::new_rand();
let mut ix = system_instruction::transfer(&mint_keypair.pubkey(), &destination, 0);
ix.program_id = native_loader::id(); // Empty executable account chain
let message = Message::new(&[ix], Some(&mint_keypair.pubkey()));
let tx = Transaction::new(&[&mint_keypair], message, genesis_config.hash());
bank.process_transaction(&tx).unwrap();
}
}

View File

@ -17,8 +17,6 @@ fn process_instruction_with_program_logging(
instruction_data: &[u8],
invoke_context: &mut dyn InvokeContext,
) -> Result<(), InstructionError> {
debug_assert_eq!(first_instruction_account, 1);
let logger = invoke_context.get_logger();
let program_id = invoke_context.get_caller()?;
stable_log::program_invoke(&logger, program_id, invoke_context.invoke_depth());