Account->AccountSharedData (#15691)

This commit is contained in:
Jeff Washington (jwash)
2021-03-09 15:06:07 -06:00
committed by GitHub
parent 61c7ce857e
commit 8a3135d17b
71 changed files with 2032 additions and 1161 deletions

View File

@ -20,7 +20,7 @@ use {
genesis_utils::{create_genesis_config_with_leader, GenesisConfigInfo},
},
solana_sdk::{
account::Account,
account::AccountSharedData,
clock::Slot,
genesis_config::GenesisConfig,
keyed_account::KeyedAccount,
@ -111,7 +111,7 @@ pub fn builtin_process_instruction(
set_invoke_context(invoke_context);
// Copy all the accounts into a HashMap to ensure there are no duplicates
let mut accounts: HashMap<Pubkey, Account> = keyed_accounts
let mut accounts: HashMap<Pubkey, AccountSharedData> = keyed_accounts
.iter()
.map(|ka| (*ka.unsigned_key(), ka.account.borrow().clone()))
.collect();
@ -238,8 +238,8 @@ impl program_stubs::SyscallStubs for SyscallStubs {
stable_log::program_invoke(&logger, &program_id, invoke_context.invoke_depth());
fn ai_to_a(ai: &AccountInfo) -> Account {
Account {
fn ai_to_a(ai: &AccountInfo) -> AccountSharedData {
AccountSharedData {
lamports: ai.lamports(),
data: ai.try_borrow_data().unwrap().to_vec(),
owner: *ai.owner,
@ -409,7 +409,7 @@ fn setup_fee_calculator(bank: Bank) -> Bank {
}
pub struct ProgramTest {
accounts: Vec<(Pubkey, Account)>,
accounts: Vec<(Pubkey, AccountSharedData)>,
builtins: Vec<Builtin>,
bpf_compute_max_units: Option<u64>,
prefer_bpf: bool,
@ -468,7 +468,7 @@ impl ProgramTest {
}
/// Add an account to the test environment
pub fn add_account(&mut self, address: Pubkey, account: Account) {
pub fn add_account(&mut self, address: Pubkey, account: AccountSharedData) {
self.accounts.push((address, account));
}
@ -482,7 +482,7 @@ impl ProgramTest {
) {
self.add_account(
address,
Account {
AccountSharedData {
lamports,
data: read_file(find_file(filename).unwrap_or_else(|| {
panic!("Unable to locate {}", filename);
@ -505,7 +505,7 @@ impl ProgramTest {
) {
self.add_account(
address,
Account {
AccountSharedData {
lamports,
data: base64::decode(data_base64)
.unwrap_or_else(|err| panic!("Failed to base64 decode: {}", err)),
@ -568,7 +568,7 @@ impl ProgramTest {
self.add_account(
program_id,
Account {
AccountSharedData {
lamports: Rent::default().minimum_balance(data.len()).min(1),
data,
owner: loader,

View File

@ -1,4 +1,4 @@
use solana_sdk::{account::Account, pubkey::Pubkey, rent::Rent};
use solana_sdk::{account::AccountSharedData, pubkey::Pubkey, rent::Rent};
mod spl_token {
solana_sdk::declare_id!("TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA");
@ -29,13 +29,13 @@ static SPL_PROGRAMS: &[(Pubkey, &[u8])] = &[
),
];
pub fn spl_programs(rent: &Rent) -> Vec<(Pubkey, Account)> {
pub fn spl_programs(rent: &Rent) -> Vec<(Pubkey, AccountSharedData)> {
SPL_PROGRAMS
.iter()
.map(|(program_id, elf)| {
(
*program_id,
Account {
AccountSharedData {
lamports: rent.minimum_balance(elf.len()).min(1),
data: elf.to_vec(),
owner: solana_program::bpf_loader::id(),