account.owner = X -> account.set_owner(X) (#16754)
This commit is contained in:
parent
63436cc2bf
commit
fb0b76c1f3
|
@ -2455,7 +2455,7 @@ mod tests {
|
|||
min_program_balance,
|
||||
min_programdata_balance,
|
||||
);
|
||||
program_account.borrow_mut().owner = Pubkey::new_unique();
|
||||
program_account.borrow_mut().set_owner(Pubkey::new_unique());
|
||||
let keyed_accounts = vec![
|
||||
KeyedAccount::new(&programdata_address, false, &programdata_account),
|
||||
KeyedAccount::new(&program_address, false, &program_account),
|
||||
|
|
|
@ -626,7 +626,7 @@ mod tests {
|
|||
use super::*;
|
||||
use bincode::serialize;
|
||||
use solana_sdk::{
|
||||
account::{self, Account, AccountSharedData},
|
||||
account::{self, Account, AccountSharedData, WritableAccount},
|
||||
keyed_account::KeyedAccount,
|
||||
process_instruction::MockInvokeContext,
|
||||
rent::Rent,
|
||||
|
@ -1026,7 +1026,9 @@ mod tests {
|
|||
let stake_account = create_default_stake_account();
|
||||
let vote_address = Pubkey::default();
|
||||
let mut bad_vote_account = create_default_account();
|
||||
bad_vote_account.get_mut().owner = solana_vote_program::id();
|
||||
bad_vote_account
|
||||
.get_mut()
|
||||
.set_owner(solana_vote_program::id());
|
||||
let clock_address = sysvar::clock::id();
|
||||
let clock_account = RefCell::new(account::create_account_shared_data_for_test(
|
||||
&sysvar::clock::Clock::default(),
|
||||
|
|
|
@ -1708,8 +1708,11 @@ mod tests {
|
|||
use super::*;
|
||||
use crate::id;
|
||||
use solana_sdk::{
|
||||
account::AccountSharedData, native_token, process_instruction::MockInvokeContext,
|
||||
pubkey::Pubkey, system_program,
|
||||
account::{AccountSharedData, WritableAccount},
|
||||
native_token,
|
||||
process_instruction::MockInvokeContext,
|
||||
pubkey::Pubkey,
|
||||
system_program,
|
||||
};
|
||||
use solana_vote_program::vote_state;
|
||||
use std::{cell::RefCell, iter::FromIterator};
|
||||
|
@ -2010,7 +2013,9 @@ mod tests {
|
|||
|
||||
// signed but faked vote account
|
||||
let faked_vote_account = vote_account.clone();
|
||||
faked_vote_account.borrow_mut().owner = solana_sdk::pubkey::new_rand();
|
||||
faked_vote_account
|
||||
.borrow_mut()
|
||||
.set_owner(solana_sdk::pubkey::new_rand());
|
||||
let faked_vote_keyed_account = KeyedAccount::new(&vote_pubkey, false, &faked_vote_account);
|
||||
assert_eq!(
|
||||
stake_keyed_account.delegate(
|
||||
|
|
|
@ -6687,10 +6687,10 @@ pub mod tests {
|
|||
account_data_with_mint[..PUBKEY_BYTES].clone_from_slice(&(mint_key.to_bytes()));
|
||||
|
||||
let mut normal_account = AccountSharedData::new(1, 0, AccountSharedData::default().owner());
|
||||
normal_account.owner = inline_spl_token_v2_0::id();
|
||||
normal_account.set_owner(inline_spl_token_v2_0::id());
|
||||
normal_account.set_data(account_data_with_mint.clone());
|
||||
let mut zero_account = AccountSharedData::new(0, 0, AccountSharedData::default().owner());
|
||||
zero_account.owner = inline_spl_token_v2_0::id();
|
||||
zero_account.set_owner(inline_spl_token_v2_0::id());
|
||||
zero_account.set_data(account_data_with_mint);
|
||||
|
||||
//store an account
|
||||
|
|
|
@ -12121,7 +12121,7 @@ pub(crate) mod tests {
|
|||
// freely modified with malicious data
|
||||
let bogus_vote_program = Pubkey::new_unique();
|
||||
vote_account.lamports = original_lamports;
|
||||
vote_account.owner = bogus_vote_program;
|
||||
vote_account.set_owner(bogus_vote_program);
|
||||
bank.store_account(
|
||||
&validator_vote_keypairs0.vote_keypair.pubkey(),
|
||||
&vote_account,
|
||||
|
@ -12135,7 +12135,7 @@ pub(crate) mod tests {
|
|||
let mut stake_account = bank
|
||||
.get_account(&validator_vote_keypairs1.stake_keypair.pubkey())
|
||||
.unwrap_or_default();
|
||||
stake_account.owner = bogus_stake_program;
|
||||
stake_account.set_owner(bogus_stake_program);
|
||||
bank.store_account(
|
||||
&validator_vote_keypairs1.stake_keypair.pubkey(),
|
||||
&stake_account,
|
||||
|
|
|
@ -916,7 +916,9 @@ impl MessageProcessor {
|
|||
return Err(InstructionError::InvalidRealloc);
|
||||
}
|
||||
dst_keyed_account.try_account_ref_mut()?.lamports = src_keyed_account.lamports;
|
||||
dst_keyed_account.try_account_ref_mut()?.owner = src_keyed_account.owner;
|
||||
dst_keyed_account
|
||||
.try_account_ref_mut()?
|
||||
.set_owner(src_keyed_account.owner);
|
||||
dst_keyed_account
|
||||
.try_account_ref_mut()?
|
||||
.set_data(src_keyed_account.data().to_vec());
|
||||
|
@ -1463,7 +1465,7 @@ mod tests {
|
|||
self
|
||||
}
|
||||
pub fn owner(mut self, post: &Pubkey) -> Self {
|
||||
self.post.owner = *post;
|
||||
self.post.set_owner(*post);
|
||||
self
|
||||
}
|
||||
pub fn data(mut self, pre: Vec<u8>, post: Vec<u8>) -> Self {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use log::*;
|
||||
use solana_sdk::{
|
||||
account::{AccountSharedData, ReadableAccount},
|
||||
account::{AccountSharedData, ReadableAccount, WritableAccount},
|
||||
account_utils::StateMut,
|
||||
ic_msg,
|
||||
instruction::InstructionError,
|
||||
|
@ -126,7 +126,7 @@ fn assign(
|
|||
return Err(SystemError::InvalidProgramId.into());
|
||||
}
|
||||
|
||||
account.owner = *owner;
|
||||
account.set_owner(*owner);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue