Skip to content
This repository has been archived by the owner on Jan 22, 2025. It is now read-only.

Commit

Permalink
Update verify policy (#18459)
Browse files Browse the repository at this point in the history
  • Loading branch information
jackcmay authored Jul 7, 2021
1 parent d69f469 commit 44289e6
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion runtime/src/message_processor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ impl PreAccount {
}
if !is_writable // line coverage used to get branch coverage
|| pre.executable()
|| program_id != pre.owner()
|| program_id != post.owner()
{
return Err(InstructionError::ExecutableModified);
}
Expand Down Expand Up @@ -1787,6 +1787,21 @@ mod tests {
);
}

#[test]
fn test_verify_account_changes_owner_executable() {
let alice_program_id = solana_sdk::pubkey::new_rand();
let bob_program_id = solana_sdk::pubkey::new_rand();

assert_eq!(
Change::new(&alice_program_id, &alice_program_id)
.owner(&bob_program_id)
.executable(false, true)
.verify(),
Err(InstructionError::ExecutableModified),
"Program should not be able to change owner and executable at the same time"
);
}

#[test]
fn test_process_message_readonly_handling() {
#[derive(Serialize, Deserialize)]
Expand Down

0 comments on commit 44289e6

Please sign in to comment.