Don't update if already an executable

This commit is contained in:
Jack May
2021-06-25 01:00:43 -07:00
committed by Trent Nelson
parent b44af11511
commit 2fbedd834f
4 changed files with 70 additions and 4 deletions

View File

@ -758,6 +758,7 @@ fn test_program_bpf_invoke_sanity() {
const TEST_PRIVILEGE_DEESCALATION_ESCALATION_WRITABLE: u8 = 13;
const TEST_WRITABLE_DEESCALATION_WRITABLE: u8 = 14;
const TEST_NESTED_INVOKE_TOO_DEEP: u8 = 15;
const TEST_EXECUTABLE_LAMPORTS: u8 = 16;
#[allow(dead_code)]
#[derive(Debug)]
@ -832,6 +833,7 @@ fn test_program_bpf_invoke_sanity() {
AccountMeta::new_readonly(derived_key3, false),
AccountMeta::new_readonly(solana_sdk::system_program::id(), false),
AccountMeta::new(from_keypair.pubkey(), true),
AccountMeta::new_readonly(invoke_program_id, false),
];
// success cases
@ -854,7 +856,7 @@ fn test_program_bpf_invoke_sanity() {
bank.last_blockhash(),
);
let (result, inner_instructions) = process_transaction_and_record_inner(&bank, tx);
assert!(result.is_ok());
assert_eq!(result, Ok(()));
let invoked_programs: Vec<Pubkey> = inner_instructions[0]
.iter()
@ -937,7 +939,7 @@ fn test_program_bpf_invoke_sanity() {
.iter()
.map(|ix| message.account_keys[ix.program_id_index as usize].clone())
.collect();
assert_eq!(result.unwrap_err(), expected_error);
assert_eq!(result, Err(expected_error));
assert_eq!(invoked_programs, expected_invoked_programs);
};
@ -1025,6 +1027,12 @@ fn test_program_bpf_invoke_sanity() {
],
);
do_invoke_failure_test_local(
TEST_EXECUTABLE_LAMPORTS,
TransactionError::InstructionError(0, InstructionError::ExecutableLamportChange),
&[invoke_program_id.clone()],
);
// Check resulting state
assert_eq!(43, bank.get_balance(&derived_key1));