no check if no change (#7824)

This commit is contained in:
Rob Walker 2020-01-15 15:13:11 -08:00 committed by GitHub
parent da165d6943
commit 4c08184379
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 13 additions and 0 deletions

View File

@ -134,6 +134,11 @@ fn assign_account_to_program(
keyed_account: &mut KeyedAccount,
program_id: &Pubkey,
) -> Result<(), InstructionError> {
// no work to do, just return
if keyed_account.account.owner == *program_id {
return Ok(());
}
if keyed_account.signer_key().is_none() {
debug!("Assign: account must sign");
return Err(InstructionError::MissingRequiredSignature);
@ -713,6 +718,14 @@ mod tests {
),
Err(InstructionError::MissingRequiredSignature)
);
// no change, no signature needed
assert_eq!(
assign_account_to_program(
&mut KeyedAccount::new(&from, false, &mut from_account),
&system_program::id(),
),
Ok(())
);
assert_eq!(
process_instruction(