AccountSharedData construction (#15790)
This commit is contained in:
parent
3419a5446e
commit
952c3bcbb7
|
@ -224,10 +224,10 @@ mod test {
|
||||||
fn test_base64_zstd() {
|
fn test_base64_zstd() {
|
||||||
let encoded_account = UiAccount::encode(
|
let encoded_account = UiAccount::encode(
|
||||||
&Pubkey::default(),
|
&Pubkey::default(),
|
||||||
AccountSharedData {
|
AccountSharedData::from(Account {
|
||||||
data: vec![0; 1024],
|
data: vec![0; 1024],
|
||||||
..AccountSharedData::default()
|
..Account::default()
|
||||||
},
|
}),
|
||||||
UiAccountEncoding::Base64Zstd,
|
UiAccountEncoding::Base64Zstd,
|
||||||
None,
|
None,
|
||||||
None,
|
None,
|
||||||
|
|
|
@ -1253,7 +1253,7 @@ pub mod test {
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
use solana_sdk::{
|
use solana_sdk::{
|
||||||
account::{AccountSharedData, WritableAccount},
|
account::{Account, AccountSharedData, WritableAccount},
|
||||||
clock::Slot,
|
clock::Slot,
|
||||||
hash::Hash,
|
hash::Hash,
|
||||||
pubkey::Pubkey,
|
pubkey::Pubkey,
|
||||||
|
@ -2255,10 +2255,10 @@ pub mod test {
|
||||||
#[test]
|
#[test]
|
||||||
fn test_stake_is_updated_for_entire_branch() {
|
fn test_stake_is_updated_for_entire_branch() {
|
||||||
let mut voted_stakes = HashMap::new();
|
let mut voted_stakes = HashMap::new();
|
||||||
let account = AccountSharedData {
|
let account = AccountSharedData::from(Account {
|
||||||
lamports: 1,
|
lamports: 1,
|
||||||
..AccountSharedData::default()
|
..Account::default()
|
||||||
};
|
});
|
||||||
let set: HashSet<u64> = vec![0u64, 1u64].into_iter().collect();
|
let set: HashSet<u64> = vec![0u64, 1u64].into_iter().collect();
|
||||||
let ancestors: HashMap<u64, HashSet<u64>> = [(2u64, set)].iter().cloned().collect();
|
let ancestors: HashMap<u64, HashSet<u64>> = [(2u64, set)].iter().cloned().collect();
|
||||||
Tower::update_ancestor_voted_stakes(&mut voted_stakes, 2, account.lamports, &ancestors);
|
Tower::update_ancestor_voted_stakes(&mut voted_stakes, 2, account.lamports, &ancestors);
|
||||||
|
|
|
@ -3100,6 +3100,7 @@ pub mod tests {
|
||||||
accounts_background_service::AbsRequestSender, commitment::BlockCommitment,
|
accounts_background_service::AbsRequestSender, commitment::BlockCommitment,
|
||||||
};
|
};
|
||||||
use solana_sdk::{
|
use solana_sdk::{
|
||||||
|
account::Account,
|
||||||
clock::MAX_RECENT_BLOCKHASHES,
|
clock::MAX_RECENT_BLOCKHASHES,
|
||||||
fee_calculator::DEFAULT_BURN_PERCENT,
|
fee_calculator::DEFAULT_BURN_PERCENT,
|
||||||
hash::{hash, Hash},
|
hash::{hash, Hash},
|
||||||
|
@ -5614,12 +5615,12 @@ pub mod tests {
|
||||||
close_authority: COption::Some(owner),
|
close_authority: COption::Some(owner),
|
||||||
};
|
};
|
||||||
TokenAccount::pack(token_account, &mut account_data).unwrap();
|
TokenAccount::pack(token_account, &mut account_data).unwrap();
|
||||||
let token_account = AccountSharedData {
|
let token_account = AccountSharedData::from(Account {
|
||||||
lamports: 111,
|
lamports: 111,
|
||||||
data: account_data.to_vec(),
|
data: account_data.to_vec(),
|
||||||
owner: spl_token_id_v2_0(),
|
owner: spl_token_id_v2_0(),
|
||||||
..AccountSharedData::default()
|
..Account::default()
|
||||||
};
|
});
|
||||||
let token_account_pubkey = solana_sdk::pubkey::new_rand();
|
let token_account_pubkey = solana_sdk::pubkey::new_rand();
|
||||||
bank.store_account(&token_account_pubkey, &token_account);
|
bank.store_account(&token_account_pubkey, &token_account);
|
||||||
|
|
||||||
|
@ -5633,12 +5634,12 @@ pub mod tests {
|
||||||
freeze_authority: COption::Some(owner),
|
freeze_authority: COption::Some(owner),
|
||||||
};
|
};
|
||||||
Mint::pack(mint_state, &mut mint_data).unwrap();
|
Mint::pack(mint_state, &mut mint_data).unwrap();
|
||||||
let mint_account = AccountSharedData {
|
let mint_account = AccountSharedData::from(Account {
|
||||||
lamports: 111,
|
lamports: 111,
|
||||||
data: mint_data.to_vec(),
|
data: mint_data.to_vec(),
|
||||||
owner: spl_token_id_v2_0(),
|
owner: spl_token_id_v2_0(),
|
||||||
..AccountSharedData::default()
|
..Account::default()
|
||||||
};
|
});
|
||||||
bank.store_account(&Pubkey::from_str(&mint.to_string()).unwrap(), &mint_account);
|
bank.store_account(&Pubkey::from_str(&mint.to_string()).unwrap(), &mint_account);
|
||||||
|
|
||||||
let req = format!(
|
let req = format!(
|
||||||
|
@ -5710,12 +5711,12 @@ pub mod tests {
|
||||||
close_authority: COption::Some(owner),
|
close_authority: COption::Some(owner),
|
||||||
};
|
};
|
||||||
TokenAccount::pack(token_account, &mut account_data).unwrap();
|
TokenAccount::pack(token_account, &mut account_data).unwrap();
|
||||||
let token_account = AccountSharedData {
|
let token_account = AccountSharedData::from(Account {
|
||||||
lamports: 111,
|
lamports: 111,
|
||||||
data: account_data.to_vec(),
|
data: account_data.to_vec(),
|
||||||
owner: spl_token_id_v2_0(),
|
owner: spl_token_id_v2_0(),
|
||||||
..AccountSharedData::default()
|
..Account::default()
|
||||||
};
|
});
|
||||||
let token_with_different_mint_pubkey = solana_sdk::pubkey::new_rand();
|
let token_with_different_mint_pubkey = solana_sdk::pubkey::new_rand();
|
||||||
bank.store_account(&token_with_different_mint_pubkey, &token_account);
|
bank.store_account(&token_with_different_mint_pubkey, &token_account);
|
||||||
|
|
||||||
|
@ -5929,12 +5930,12 @@ pub mod tests {
|
||||||
freeze_authority: COption::Some(owner),
|
freeze_authority: COption::Some(owner),
|
||||||
};
|
};
|
||||||
Mint::pack(mint_state, &mut mint_data).unwrap();
|
Mint::pack(mint_state, &mut mint_data).unwrap();
|
||||||
let mint_account = AccountSharedData {
|
let mint_account = AccountSharedData::from(Account {
|
||||||
lamports: 111,
|
lamports: 111,
|
||||||
data: mint_data.to_vec(),
|
data: mint_data.to_vec(),
|
||||||
owner: spl_token_id_v2_0(),
|
owner: spl_token_id_v2_0(),
|
||||||
..AccountSharedData::default()
|
..Account::default()
|
||||||
};
|
});
|
||||||
bank.store_account(
|
bank.store_account(
|
||||||
&Pubkey::from_str(&new_mint.to_string()).unwrap(),
|
&Pubkey::from_str(&new_mint.to_string()).unwrap(),
|
||||||
&mint_account,
|
&mint_account,
|
||||||
|
@ -5951,12 +5952,12 @@ pub mod tests {
|
||||||
close_authority: COption::Some(owner),
|
close_authority: COption::Some(owner),
|
||||||
};
|
};
|
||||||
TokenAccount::pack(token_account, &mut account_data).unwrap();
|
TokenAccount::pack(token_account, &mut account_data).unwrap();
|
||||||
let token_account = AccountSharedData {
|
let token_account = AccountSharedData::from(Account {
|
||||||
lamports: 111,
|
lamports: 111,
|
||||||
data: account_data.to_vec(),
|
data: account_data.to_vec(),
|
||||||
owner: spl_token_id_v2_0(),
|
owner: spl_token_id_v2_0(),
|
||||||
..AccountSharedData::default()
|
..Account::default()
|
||||||
};
|
});
|
||||||
let token_with_smaller_balance = solana_sdk::pubkey::new_rand();
|
let token_with_smaller_balance = solana_sdk::pubkey::new_rand();
|
||||||
bank.store_account(&token_with_smaller_balance, &token_account);
|
bank.store_account(&token_with_smaller_balance, &token_account);
|
||||||
|
|
||||||
|
@ -6015,12 +6016,12 @@ pub mod tests {
|
||||||
close_authority: COption::Some(owner),
|
close_authority: COption::Some(owner),
|
||||||
};
|
};
|
||||||
TokenAccount::pack(token_account, &mut account_data).unwrap();
|
TokenAccount::pack(token_account, &mut account_data).unwrap();
|
||||||
let token_account = AccountSharedData {
|
let token_account = AccountSharedData::from(Account {
|
||||||
lamports: 111,
|
lamports: 111,
|
||||||
data: account_data.to_vec(),
|
data: account_data.to_vec(),
|
||||||
owner: spl_token_id_v2_0(),
|
owner: spl_token_id_v2_0(),
|
||||||
..AccountSharedData::default()
|
..Account::default()
|
||||||
};
|
});
|
||||||
let token_account_pubkey = solana_sdk::pubkey::new_rand();
|
let token_account_pubkey = solana_sdk::pubkey::new_rand();
|
||||||
bank.store_account(&token_account_pubkey, &token_account);
|
bank.store_account(&token_account_pubkey, &token_account);
|
||||||
|
|
||||||
|
@ -6034,12 +6035,12 @@ pub mod tests {
|
||||||
freeze_authority: COption::Some(owner),
|
freeze_authority: COption::Some(owner),
|
||||||
};
|
};
|
||||||
Mint::pack(mint_state, &mut mint_data).unwrap();
|
Mint::pack(mint_state, &mut mint_data).unwrap();
|
||||||
let mint_account = AccountSharedData {
|
let mint_account = AccountSharedData::from(Account {
|
||||||
lamports: 111,
|
lamports: 111,
|
||||||
data: mint_data.to_vec(),
|
data: mint_data.to_vec(),
|
||||||
owner: spl_token_id_v2_0(),
|
owner: spl_token_id_v2_0(),
|
||||||
..AccountSharedData::default()
|
..Account::default()
|
||||||
};
|
});
|
||||||
bank.store_account(&Pubkey::from_str(&mint.to_string()).unwrap(), &mint_account);
|
bank.store_account(&Pubkey::from_str(&mint.to_string()).unwrap(), &mint_account);
|
||||||
|
|
||||||
let req = format!(
|
let req = format!(
|
||||||
|
|
|
@ -13,7 +13,7 @@ use {
|
||||||
hardened_unpack::MAX_GENESIS_ARCHIVE_UNPACKED_SIZE,
|
hardened_unpack::MAX_GENESIS_ARCHIVE_UNPACKED_SIZE,
|
||||||
},
|
},
|
||||||
solana_sdk::{
|
solana_sdk::{
|
||||||
account::AccountSharedData,
|
account::{Account, AccountSharedData},
|
||||||
clock::{Slot, DEFAULT_MS_PER_SLOT},
|
clock::{Slot, DEFAULT_MS_PER_SLOT},
|
||||||
commitment_config::CommitmentConfig,
|
commitment_config::CommitmentConfig,
|
||||||
fee_calculator::{FeeCalculator, FeeRateGovernor},
|
fee_calculator::{FeeCalculator, FeeRateGovernor},
|
||||||
|
@ -133,7 +133,7 @@ impl TestValidatorGenesis {
|
||||||
) -> &mut Self {
|
) -> &mut Self {
|
||||||
self.add_account(
|
self.add_account(
|
||||||
address,
|
address,
|
||||||
AccountSharedData {
|
AccountSharedData::from(Account {
|
||||||
lamports,
|
lamports,
|
||||||
data: solana_program_test::read_file(
|
data: solana_program_test::read_file(
|
||||||
solana_program_test::find_file(filename).unwrap_or_else(|| {
|
solana_program_test::find_file(filename).unwrap_or_else(|| {
|
||||||
|
@ -143,7 +143,7 @@ impl TestValidatorGenesis {
|
||||||
owner,
|
owner,
|
||||||
executable: false,
|
executable: false,
|
||||||
rent_epoch: 0,
|
rent_epoch: 0,
|
||||||
},
|
}),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -158,14 +158,14 @@ impl TestValidatorGenesis {
|
||||||
) -> &mut Self {
|
) -> &mut Self {
|
||||||
self.add_account(
|
self.add_account(
|
||||||
address,
|
address,
|
||||||
AccountSharedData {
|
AccountSharedData::from(Account {
|
||||||
lamports,
|
lamports,
|
||||||
data: base64::decode(data_base64)
|
data: base64::decode(data_base64)
|
||||||
.unwrap_or_else(|err| panic!("Failed to base64 decode: {}", err)),
|
.unwrap_or_else(|err| panic!("Failed to base64 decode: {}", err)),
|
||||||
owner,
|
owner,
|
||||||
executable: false,
|
executable: false,
|
||||||
rent_epoch: 0,
|
rent_epoch: 0,
|
||||||
},
|
}),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -285,13 +285,13 @@ impl TestValidator {
|
||||||
let data = solana_program_test::read_file(&program.program_path);
|
let data = solana_program_test::read_file(&program.program_path);
|
||||||
accounts.insert(
|
accounts.insert(
|
||||||
program.program_id,
|
program.program_id,
|
||||||
AccountSharedData {
|
AccountSharedData::from(Account {
|
||||||
lamports: Rent::default().minimum_balance(data.len()).min(1),
|
lamports: Rent::default().minimum_balance(data.len()).min(1),
|
||||||
data,
|
data,
|
||||||
owner: program.loader,
|
owner: program.loader,
|
||||||
executable: true,
|
executable: true,
|
||||||
rent_epoch: 0,
|
rent_epoch: 0,
|
||||||
},
|
}),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,7 @@ use solana_ledger::{
|
||||||
};
|
};
|
||||||
use solana_runtime::hardened_unpack::MAX_GENESIS_ARCHIVE_UNPACKED_SIZE;
|
use solana_runtime::hardened_unpack::MAX_GENESIS_ARCHIVE_UNPACKED_SIZE;
|
||||||
use solana_sdk::{
|
use solana_sdk::{
|
||||||
account::AccountSharedData,
|
account::{Account, AccountSharedData},
|
||||||
clock,
|
clock,
|
||||||
epoch_schedule::EpochSchedule,
|
epoch_schedule::EpochSchedule,
|
||||||
fee_calculator::FeeRateGovernor,
|
fee_calculator::FeeRateGovernor,
|
||||||
|
@ -620,13 +620,13 @@ fn main() -> Result<(), Box<dyn error::Error>> {
|
||||||
});
|
});
|
||||||
genesis_config.add_account(
|
genesis_config.add_account(
|
||||||
address,
|
address,
|
||||||
AccountSharedData {
|
AccountSharedData::from(Account {
|
||||||
lamports: genesis_config.rent.minimum_balance(program_data.len()),
|
lamports: genesis_config.rent.minimum_balance(program_data.len()),
|
||||||
data: program_data,
|
data: program_data,
|
||||||
executable: true,
|
executable: true,
|
||||||
owner: loader,
|
owner: loader,
|
||||||
rent_epoch: 0,
|
rent_epoch: 0,
|
||||||
},
|
}),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
_ => unreachable!(),
|
_ => unreachable!(),
|
||||||
|
|
|
@ -20,7 +20,7 @@ use {
|
||||||
genesis_utils::{create_genesis_config_with_leader, GenesisConfigInfo},
|
genesis_utils::{create_genesis_config_with_leader, GenesisConfigInfo},
|
||||||
},
|
},
|
||||||
solana_sdk::{
|
solana_sdk::{
|
||||||
account::{AccountSharedData, ReadableAccount},
|
account::{Account, AccountSharedData, ReadableAccount},
|
||||||
clock::Slot,
|
clock::Slot,
|
||||||
genesis_config::GenesisConfig,
|
genesis_config::GenesisConfig,
|
||||||
keyed_account::KeyedAccount,
|
keyed_account::KeyedAccount,
|
||||||
|
@ -239,13 +239,13 @@ impl program_stubs::SyscallStubs for SyscallStubs {
|
||||||
stable_log::program_invoke(&logger, &program_id, invoke_context.invoke_depth());
|
stable_log::program_invoke(&logger, &program_id, invoke_context.invoke_depth());
|
||||||
|
|
||||||
fn ai_to_a(ai: &AccountInfo) -> AccountSharedData {
|
fn ai_to_a(ai: &AccountInfo) -> AccountSharedData {
|
||||||
AccountSharedData {
|
AccountSharedData::from(Account {
|
||||||
lamports: ai.lamports(),
|
lamports: ai.lamports(),
|
||||||
data: ai.try_borrow_data().unwrap().to_vec(),
|
data: ai.try_borrow_data().unwrap().to_vec(),
|
||||||
owner: *ai.owner,
|
owner: *ai.owner,
|
||||||
executable: ai.executable,
|
executable: ai.executable,
|
||||||
rent_epoch: ai.rent_epoch,
|
rent_epoch: ai.rent_epoch,
|
||||||
}
|
})
|
||||||
}
|
}
|
||||||
let executables = vec![(
|
let executables = vec![(
|
||||||
program_id,
|
program_id,
|
||||||
|
@ -486,7 +486,7 @@ impl ProgramTest {
|
||||||
) {
|
) {
|
||||||
self.add_account(
|
self.add_account(
|
||||||
address,
|
address,
|
||||||
AccountSharedData {
|
AccountSharedData::from(Account {
|
||||||
lamports,
|
lamports,
|
||||||
data: read_file(find_file(filename).unwrap_or_else(|| {
|
data: read_file(find_file(filename).unwrap_or_else(|| {
|
||||||
panic!("Unable to locate {}", filename);
|
panic!("Unable to locate {}", filename);
|
||||||
|
@ -494,7 +494,7 @@ impl ProgramTest {
|
||||||
owner,
|
owner,
|
||||||
executable: false,
|
executable: false,
|
||||||
rent_epoch: 0,
|
rent_epoch: 0,
|
||||||
},
|
}),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -509,14 +509,14 @@ impl ProgramTest {
|
||||||
) {
|
) {
|
||||||
self.add_account(
|
self.add_account(
|
||||||
address,
|
address,
|
||||||
AccountSharedData {
|
AccountSharedData::from(Account {
|
||||||
lamports,
|
lamports,
|
||||||
data: base64::decode(data_base64)
|
data: base64::decode(data_base64)
|
||||||
.unwrap_or_else(|err| panic!("Failed to base64 decode: {}", err)),
|
.unwrap_or_else(|err| panic!("Failed to base64 decode: {}", err)),
|
||||||
owner,
|
owner,
|
||||||
executable: false,
|
executable: false,
|
||||||
rent_epoch: 0,
|
rent_epoch: 0,
|
||||||
},
|
}),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -572,13 +572,13 @@ impl ProgramTest {
|
||||||
|
|
||||||
self.add_account(
|
self.add_account(
|
||||||
program_id,
|
program_id,
|
||||||
AccountSharedData {
|
AccountSharedData::from(Account {
|
||||||
lamports: Rent::default().minimum_balance(data.len()).min(1),
|
lamports: Rent::default().minimum_balance(data.len()).min(1),
|
||||||
data,
|
data,
|
||||||
owner: loader,
|
owner: loader,
|
||||||
executable: true,
|
executable: true,
|
||||||
rent_epoch: 0,
|
rent_epoch: 0,
|
||||||
},
|
}),
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
info!("\"{}\" program loaded as native code", program_name);
|
info!("\"{}\" program loaded as native code", program_name);
|
||||||
|
|
|
@ -1,4 +1,8 @@
|
||||||
use solana_sdk::{account::AccountSharedData, pubkey::Pubkey, rent::Rent};
|
use solana_sdk::{
|
||||||
|
account::{Account, AccountSharedData},
|
||||||
|
pubkey::Pubkey,
|
||||||
|
rent::Rent,
|
||||||
|
};
|
||||||
|
|
||||||
mod spl_token {
|
mod spl_token {
|
||||||
solana_sdk::declare_id!("TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA");
|
solana_sdk::declare_id!("TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA");
|
||||||
|
@ -35,13 +39,13 @@ pub fn spl_programs(rent: &Rent) -> Vec<(Pubkey, AccountSharedData)> {
|
||||||
.map(|(program_id, elf)| {
|
.map(|(program_id, elf)| {
|
||||||
(
|
(
|
||||||
*program_id,
|
*program_id,
|
||||||
AccountSharedData {
|
AccountSharedData::from(Account {
|
||||||
lamports: rent.minimum_balance(elf.len()).min(1),
|
lamports: rent.minimum_balance(elf.len()).min(1),
|
||||||
data: elf.to_vec(),
|
data: elf.to_vec(),
|
||||||
owner: solana_program::bpf_loader::id(),
|
owner: solana_program::bpf_loader::id(),
|
||||||
executable: true,
|
executable: true,
|
||||||
rent_epoch: 0,
|
rent_epoch: 0,
|
||||||
},
|
}),
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
.collect()
|
.collect()
|
||||||
|
|
|
@ -251,7 +251,10 @@ pub fn deserialize_parameters_aligned(
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
use solana_sdk::{
|
use solana_sdk::{
|
||||||
account::AccountSharedData, account_info::AccountInfo, bpf_loader, entrypoint::deserialize,
|
account::{Account, AccountSharedData},
|
||||||
|
account_info::AccountInfo,
|
||||||
|
bpf_loader,
|
||||||
|
entrypoint::deserialize,
|
||||||
};
|
};
|
||||||
use std::{
|
use std::{
|
||||||
cell::RefCell,
|
cell::RefCell,
|
||||||
|
@ -271,35 +274,35 @@ mod tests {
|
||||||
solana_sdk::pubkey::new_rand(),
|
solana_sdk::pubkey::new_rand(),
|
||||||
];
|
];
|
||||||
let accounts = [
|
let accounts = [
|
||||||
RefCell::new(AccountSharedData {
|
RefCell::new(AccountSharedData::from(Account {
|
||||||
lamports: 1,
|
lamports: 1,
|
||||||
data: vec![1u8, 2, 3, 4, 5],
|
data: vec![1u8, 2, 3, 4, 5],
|
||||||
owner: bpf_loader::id(),
|
owner: bpf_loader::id(),
|
||||||
executable: false,
|
executable: false,
|
||||||
rent_epoch: 100,
|
rent_epoch: 100,
|
||||||
}),
|
})),
|
||||||
// dup of first
|
// dup of first
|
||||||
RefCell::new(AccountSharedData {
|
RefCell::new(AccountSharedData::from(Account {
|
||||||
lamports: 1,
|
lamports: 1,
|
||||||
data: vec![1u8, 2, 3, 4, 5],
|
data: vec![1u8, 2, 3, 4, 5],
|
||||||
owner: bpf_loader::id(),
|
owner: bpf_loader::id(),
|
||||||
executable: false,
|
executable: false,
|
||||||
rent_epoch: 100,
|
rent_epoch: 100,
|
||||||
}),
|
})),
|
||||||
RefCell::new(AccountSharedData {
|
RefCell::new(AccountSharedData::from(Account {
|
||||||
lamports: 2,
|
lamports: 2,
|
||||||
data: vec![11u8, 12, 13, 14, 15, 16, 17, 18, 19],
|
data: vec![11u8, 12, 13, 14, 15, 16, 17, 18, 19],
|
||||||
owner: bpf_loader::id(),
|
owner: bpf_loader::id(),
|
||||||
executable: true,
|
executable: true,
|
||||||
rent_epoch: 200,
|
rent_epoch: 200,
|
||||||
}),
|
})),
|
||||||
RefCell::new(AccountSharedData {
|
RefCell::new(AccountSharedData::from(Account {
|
||||||
lamports: 3,
|
lamports: 3,
|
||||||
data: vec![],
|
data: vec![],
|
||||||
owner: bpf_loader::id(),
|
owner: bpf_loader::id(),
|
||||||
executable: false,
|
executable: false,
|
||||||
rent_epoch: 3100,
|
rent_epoch: 3100,
|
||||||
}),
|
})),
|
||||||
];
|
];
|
||||||
|
|
||||||
let keyed_accounts: Vec<_> = keys
|
let keyed_accounts: Vec<_> = keys
|
||||||
|
|
|
@ -10,7 +10,7 @@ use solana_rbpf::{
|
||||||
};
|
};
|
||||||
use solana_runtime::message_processor::MessageProcessor;
|
use solana_runtime::message_processor::MessageProcessor;
|
||||||
use solana_sdk::{
|
use solana_sdk::{
|
||||||
account::{AccountSharedData, ReadableAccount},
|
account::{Account, AccountSharedData, ReadableAccount},
|
||||||
account_info::AccountInfo,
|
account_info::AccountInfo,
|
||||||
account_utils::StateMut,
|
account_utils::StateMut,
|
||||||
bpf_loader, bpf_loader_deprecated,
|
bpf_loader, bpf_loader_deprecated,
|
||||||
|
@ -1009,13 +1009,13 @@ impl<'a> SyscallInvokeSigned<'a> for SyscallInvokeSignedRust<'a> {
|
||||||
};
|
};
|
||||||
|
|
||||||
Ok((
|
Ok((
|
||||||
Rc::new(RefCell::new(AccountSharedData {
|
Rc::new(RefCell::new(AccountSharedData::from(Account {
|
||||||
lamports: *lamports,
|
lamports: *lamports,
|
||||||
data: data.to_vec(),
|
data: data.to_vec(),
|
||||||
executable: account_info.executable,
|
executable: account_info.executable,
|
||||||
owner: *owner,
|
owner: *owner,
|
||||||
rent_epoch: account_info.rent_epoch,
|
rent_epoch: account_info.rent_epoch,
|
||||||
})),
|
}))),
|
||||||
Some(AccountReferences {
|
Some(AccountReferences {
|
||||||
lamports,
|
lamports,
|
||||||
owner,
|
owner,
|
||||||
|
@ -1294,13 +1294,13 @@ impl<'a> SyscallInvokeSigned<'a> for SyscallInvokeSignedC<'a> {
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
Ok((
|
Ok((
|
||||||
Rc::new(RefCell::new(AccountSharedData {
|
Rc::new(RefCell::new(AccountSharedData::from(Account {
|
||||||
lamports: *lamports,
|
lamports: *lamports,
|
||||||
data: data.to_vec(),
|
data: data.to_vec(),
|
||||||
executable: account_info.executable,
|
executable: account_info.executable,
|
||||||
owner: *owner,
|
owner: *owner,
|
||||||
rent_epoch: account_info.rent_epoch,
|
rent_epoch: account_info.rent_epoch,
|
||||||
})),
|
}))),
|
||||||
Some(AccountReferences {
|
Some(AccountReferences {
|
||||||
lamports,
|
lamports,
|
||||||
owner,
|
owner,
|
||||||
|
|
|
@ -247,7 +247,7 @@ mod tests {
|
||||||
use crate::id;
|
use crate::id;
|
||||||
use solana_runtime::bank::Bank;
|
use solana_runtime::bank::Bank;
|
||||||
use solana_runtime::bank_client::BankClient;
|
use solana_runtime::bank_client::BankClient;
|
||||||
use solana_sdk::account::AccountSharedData;
|
use solana_sdk::account::{Account, AccountSharedData};
|
||||||
use solana_sdk::client::SyncClient;
|
use solana_sdk::client::SyncClient;
|
||||||
use solana_sdk::genesis_config::create_genesis_config;
|
use solana_sdk::genesis_config::create_genesis_config;
|
||||||
use solana_sdk::hash::hash;
|
use solana_sdk::hash::hash;
|
||||||
|
@ -540,11 +540,11 @@ mod tests {
|
||||||
fn test_pay_when_account_data() {
|
fn test_pay_when_account_data() {
|
||||||
let (bank, alice_keypair) = create_bank(42);
|
let (bank, alice_keypair) = create_bank(42);
|
||||||
let game_pubkey = solana_sdk::pubkey::new_rand();
|
let game_pubkey = solana_sdk::pubkey::new_rand();
|
||||||
let game_account = AccountSharedData {
|
let game_account = AccountSharedData::from(Account {
|
||||||
lamports: 1,
|
lamports: 1,
|
||||||
data: vec![1, 2, 3],
|
data: vec![1, 2, 3],
|
||||||
..AccountSharedData::default()
|
..Account::default()
|
||||||
};
|
});
|
||||||
bank.store_account(&game_pubkey, &game_account);
|
bank.store_account(&game_pubkey, &game_account);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
bank.get_account(&game_pubkey).unwrap().data(),
|
bank.get_account(&game_pubkey).unwrap().data(),
|
||||||
|
|
|
@ -134,7 +134,7 @@ mod tests {
|
||||||
use bincode::serialized_size;
|
use bincode::serialized_size;
|
||||||
use serde_derive::{Deserialize, Serialize};
|
use serde_derive::{Deserialize, Serialize};
|
||||||
use solana_sdk::{
|
use solana_sdk::{
|
||||||
account::AccountSharedData,
|
account::{Account, AccountSharedData},
|
||||||
keyed_account::create_keyed_is_signer_accounts,
|
keyed_account::create_keyed_is_signer_accounts,
|
||||||
process_instruction::MockInvokeContext,
|
process_instruction::MockInvokeContext,
|
||||||
signature::{Keypair, Signer},
|
signature::{Keypair, Signer},
|
||||||
|
@ -183,11 +183,11 @@ mod tests {
|
||||||
} => space,
|
} => space,
|
||||||
_ => panic!("Not a CreateAccount system instruction"),
|
_ => panic!("Not a CreateAccount system instruction"),
|
||||||
};
|
};
|
||||||
let config_account = RefCell::new(AccountSharedData {
|
let config_account = RefCell::new(AccountSharedData::from(Account {
|
||||||
data: vec![0; space as usize],
|
data: vec![0; space as usize],
|
||||||
owner: id(),
|
owner: id(),
|
||||||
..AccountSharedData::default()
|
..Account::default()
|
||||||
});
|
}));
|
||||||
let accounts = vec![(&config_pubkey, true, &config_account)];
|
let accounts = vec![(&config_pubkey, true, &config_account)];
|
||||||
let keyed_accounts = create_keyed_is_signer_accounts(&accounts);
|
let keyed_accounts = create_keyed_is_signer_accounts(&accounts);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
|
@ -338,10 +338,10 @@ mod tests {
|
||||||
let my_config = MyConfig::new(42);
|
let my_config = MyConfig::new(42);
|
||||||
|
|
||||||
let instruction = config_instruction::store(&config_pubkey, false, keys, &my_config);
|
let instruction = config_instruction::store(&config_pubkey, false, keys, &my_config);
|
||||||
let signer0_account = RefCell::new(AccountSharedData {
|
let signer0_account = RefCell::new(AccountSharedData::from(Account {
|
||||||
owner: id(),
|
owner: id(),
|
||||||
..AccountSharedData::default()
|
..Account::default()
|
||||||
});
|
}));
|
||||||
let accounts = vec![(&signer0_pubkey, true, &signer0_account)];
|
let accounts = vec![(&signer0_pubkey, true, &signer0_account)];
|
||||||
let keyed_accounts = create_keyed_is_signer_accounts(&accounts);
|
let keyed_accounts = create_keyed_is_signer_accounts(&accounts);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
|
|
|
@ -5,7 +5,11 @@ pub mod date_instruction;
|
||||||
|
|
||||||
use bincode::{deserialize, serialize, serialized_size};
|
use bincode::{deserialize, serialize, serialized_size};
|
||||||
use serde_derive::{Deserialize, Serialize};
|
use serde_derive::{Deserialize, Serialize};
|
||||||
use solana_sdk::{account::AccountSharedData, pubkey::Pubkey, short_vec};
|
use solana_sdk::{
|
||||||
|
account::{Account, AccountSharedData},
|
||||||
|
pubkey::Pubkey,
|
||||||
|
short_vec,
|
||||||
|
};
|
||||||
|
|
||||||
solana_sdk::declare_id!("Config1111111111111111111111111111111111111");
|
solana_sdk::declare_id!("Config1111111111111111111111111111111111111");
|
||||||
|
|
||||||
|
@ -43,10 +47,10 @@ pub fn create_config_account<T: ConfigState>(
|
||||||
) -> AccountSharedData {
|
) -> AccountSharedData {
|
||||||
let mut data = serialize(&ConfigKeys { keys }).unwrap();
|
let mut data = serialize(&ConfigKeys { keys }).unwrap();
|
||||||
data.extend_from_slice(&serialize(config_data).unwrap());
|
data.extend_from_slice(&serialize(config_data).unwrap());
|
||||||
AccountSharedData {
|
AccountSharedData::from(Account {
|
||||||
lamports,
|
lamports,
|
||||||
data,
|
data,
|
||||||
owner: id(),
|
owner: id(),
|
||||||
..AccountSharedData::default()
|
..Account::default()
|
||||||
}
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -622,7 +622,7 @@ mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
use bincode::serialize;
|
use bincode::serialize;
|
||||||
use solana_sdk::{
|
use solana_sdk::{
|
||||||
account::{self, AccountSharedData},
|
account::{self, Account, AccountSharedData},
|
||||||
process_instruction::MockInvokeContext,
|
process_instruction::MockInvokeContext,
|
||||||
rent::Rent,
|
rent::Rent,
|
||||||
sysvar::stake_history::StakeHistory,
|
sysvar::stake_history::StakeHistory,
|
||||||
|
@ -635,10 +635,10 @@ mod tests {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn create_default_stake_account() -> RefCell<AccountSharedData> {
|
fn create_default_stake_account() -> RefCell<AccountSharedData> {
|
||||||
RefCell::new(AccountSharedData {
|
RefCell::new(AccountSharedData::from(Account {
|
||||||
owner: id(),
|
owner: id(),
|
||||||
..AccountSharedData::default()
|
..Account::default()
|
||||||
})
|
}))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn invalid_stake_state_pubkey() -> Pubkey {
|
fn invalid_stake_state_pubkey() -> Pubkey {
|
||||||
|
@ -673,25 +673,25 @@ mod tests {
|
||||||
} else if sysvar::rent::check_id(&meta.pubkey) {
|
} else if sysvar::rent::check_id(&meta.pubkey) {
|
||||||
account::create_account_shared_data(&Rent::default(), 1)
|
account::create_account_shared_data(&Rent::default(), 1)
|
||||||
} else if meta.pubkey == invalid_stake_state_pubkey() {
|
} else if meta.pubkey == invalid_stake_state_pubkey() {
|
||||||
AccountSharedData {
|
AccountSharedData::from(Account {
|
||||||
owner: id(),
|
owner: id(),
|
||||||
..AccountSharedData::default()
|
..Account::default()
|
||||||
}
|
})
|
||||||
} else if meta.pubkey == invalid_vote_state_pubkey() {
|
} else if meta.pubkey == invalid_vote_state_pubkey() {
|
||||||
AccountSharedData {
|
AccountSharedData::from(Account {
|
||||||
owner: solana_vote_program::id(),
|
owner: solana_vote_program::id(),
|
||||||
..AccountSharedData::default()
|
..Account::default()
|
||||||
}
|
})
|
||||||
} else if meta.pubkey == spoofed_stake_state_pubkey() {
|
} else if meta.pubkey == spoofed_stake_state_pubkey() {
|
||||||
AccountSharedData {
|
AccountSharedData::from(Account {
|
||||||
owner: spoofed_stake_program_id(),
|
owner: spoofed_stake_program_id(),
|
||||||
..AccountSharedData::default()
|
..Account::default()
|
||||||
}
|
})
|
||||||
} else {
|
} else {
|
||||||
AccountSharedData {
|
AccountSharedData::from(Account {
|
||||||
owner: id(),
|
owner: id(),
|
||||||
..AccountSharedData::default()
|
..Account::default()
|
||||||
}
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
.collect();
|
.collect();
|
||||||
|
|
|
@ -342,7 +342,7 @@ pub fn process_instruction(
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
use solana_sdk::{
|
use solana_sdk::{
|
||||||
account::{self, AccountSharedData},
|
account::{self, Account, AccountSharedData},
|
||||||
process_instruction::MockInvokeContext,
|
process_instruction::MockInvokeContext,
|
||||||
rent::Rent,
|
rent::Rent,
|
||||||
};
|
};
|
||||||
|
@ -376,15 +376,15 @@ mod tests {
|
||||||
} else if sysvar::rent::check_id(&meta.pubkey) {
|
} else if sysvar::rent::check_id(&meta.pubkey) {
|
||||||
account::create_account_shared_data(&Rent::free(), 1)
|
account::create_account_shared_data(&Rent::free(), 1)
|
||||||
} else if meta.pubkey == invalid_vote_state_pubkey() {
|
} else if meta.pubkey == invalid_vote_state_pubkey() {
|
||||||
AccountSharedData {
|
AccountSharedData::from(Account {
|
||||||
owner: invalid_vote_state_pubkey(),
|
owner: invalid_vote_state_pubkey(),
|
||||||
..AccountSharedData::default()
|
..Account::default()
|
||||||
}
|
})
|
||||||
} else {
|
} else {
|
||||||
AccountSharedData {
|
AccountSharedData::from(Account {
|
||||||
owner: id(),
|
owner: id(),
|
||||||
..AccountSharedData::default()
|
..Account::default()
|
||||||
}
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
.collect();
|
.collect();
|
||||||
|
|
|
@ -16,7 +16,7 @@ use dashmap::{
|
||||||
use log::*;
|
use log::*;
|
||||||
use rand::{thread_rng, Rng};
|
use rand::{thread_rng, Rng};
|
||||||
use solana_sdk::{
|
use solana_sdk::{
|
||||||
account::AccountSharedData,
|
account::{Account, AccountSharedData},
|
||||||
account_utils::StateMut,
|
account_utils::StateMut,
|
||||||
bpf_loader_upgradeable::{self, UpgradeableLoaderState},
|
bpf_loader_upgradeable::{self, UpgradeableLoaderState},
|
||||||
clock::Slot,
|
clock::Slot,
|
||||||
|
@ -167,10 +167,10 @@ impl Accounts {
|
||||||
let mut data = message.serialize_instructions();
|
let mut data = message.serialize_instructions();
|
||||||
// add room for current instruction index.
|
// add room for current instruction index.
|
||||||
data.resize(data.len() + 2, 0);
|
data.resize(data.len() + 2, 0);
|
||||||
AccountSharedData {
|
AccountSharedData::from(Account {
|
||||||
data,
|
data,
|
||||||
..AccountSharedData::default()
|
..Account::default()
|
||||||
}
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
fn load_transaction(
|
fn load_transaction(
|
||||||
|
@ -1036,7 +1036,7 @@ mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
use crate::rent_collector::RentCollector;
|
use crate::rent_collector::RentCollector;
|
||||||
use solana_sdk::{
|
use solana_sdk::{
|
||||||
account::AccountSharedData,
|
account::{AccountSharedData, WritableAccount},
|
||||||
epoch_schedule::EpochSchedule,
|
epoch_schedule::EpochSchedule,
|
||||||
fee_calculator::FeeCalculator,
|
fee_calculator::FeeCalculator,
|
||||||
genesis_config::ClusterType,
|
genesis_config::ClusterType,
|
||||||
|
@ -2016,10 +2016,8 @@ mod tests {
|
||||||
nonce::state::Data::default(),
|
nonce::state::Data::default(),
|
||||||
));
|
));
|
||||||
let account = AccountSharedData::new_data(42, &data, &system_program::id()).unwrap();
|
let account = AccountSharedData::new_data(42, &data, &system_program::id()).unwrap();
|
||||||
let pre_account = AccountSharedData {
|
let mut pre_account = account.clone();
|
||||||
lamports: 43,
|
pre_account.set_lamports(43);
|
||||||
..account.clone()
|
|
||||||
};
|
|
||||||
(
|
(
|
||||||
Pubkey::default(),
|
Pubkey::default(),
|
||||||
pre_account,
|
pre_account,
|
||||||
|
|
|
@ -5048,7 +5048,7 @@ pub mod tests {
|
||||||
use assert_matches::assert_matches;
|
use assert_matches::assert_matches;
|
||||||
use rand::{thread_rng, Rng};
|
use rand::{thread_rng, Rng};
|
||||||
use solana_sdk::{
|
use solana_sdk::{
|
||||||
account::{AccountSharedData, ReadableAccount, WritableAccount},
|
account::{Account, AccountSharedData, ReadableAccount, WritableAccount},
|
||||||
hash::HASH_BYTES,
|
hash::HASH_BYTES,
|
||||||
pubkey::PUBKEY_BYTES,
|
pubkey::PUBKEY_BYTES,
|
||||||
};
|
};
|
||||||
|
@ -5406,10 +5406,10 @@ pub mod tests {
|
||||||
let idx = thread_rng().gen_range(0, 99);
|
let idx = thread_rng().gen_range(0, 99);
|
||||||
let ancestors = vec![(0, 0)].into_iter().collect();
|
let ancestors = vec![(0, 0)].into_iter().collect();
|
||||||
let account = db.load_slow(&ancestors, &pubkeys[idx]).unwrap();
|
let account = db.load_slow(&ancestors, &pubkeys[idx]).unwrap();
|
||||||
let default_account = AccountSharedData {
|
let default_account = AccountSharedData::from(Account {
|
||||||
lamports: (idx + 1) as u64,
|
lamports: (idx + 1) as u64,
|
||||||
..AccountSharedData::default()
|
..Account::default()
|
||||||
};
|
});
|
||||||
assert_eq!((default_account, 0), account);
|
assert_eq!((default_account, 0), account);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5422,10 +5422,10 @@ pub mod tests {
|
||||||
let account0 = db.load_slow(&ancestors, &pubkeys[idx]).unwrap();
|
let account0 = db.load_slow(&ancestors, &pubkeys[idx]).unwrap();
|
||||||
let ancestors = vec![(1, 1)].into_iter().collect();
|
let ancestors = vec![(1, 1)].into_iter().collect();
|
||||||
let account1 = db.load_slow(&ancestors, &pubkeys[idx]).unwrap();
|
let account1 = db.load_slow(&ancestors, &pubkeys[idx]).unwrap();
|
||||||
let default_account = AccountSharedData {
|
let default_account = AccountSharedData::from(Account {
|
||||||
lamports: (idx + 1) as u64,
|
lamports: (idx + 1) as u64,
|
||||||
..AccountSharedData::default()
|
..Account::default()
|
||||||
};
|
});
|
||||||
assert_eq!(&default_account, &account0.0);
|
assert_eq!(&default_account, &account0.0);
|
||||||
assert_eq!(&default_account, &account1.0);
|
assert_eq!(&default_account, &account1.0);
|
||||||
}
|
}
|
||||||
|
@ -5620,10 +5620,10 @@ pub mod tests {
|
||||||
let ancestors = vec![(slot, 0)].into_iter().collect();
|
let ancestors = vec![(slot, 0)].into_iter().collect();
|
||||||
assert!(accounts.load_slow(&ancestors, &pubkeys[idx]).is_none());
|
assert!(accounts.load_slow(&ancestors, &pubkeys[idx]).is_none());
|
||||||
} else {
|
} else {
|
||||||
let default_account = AccountSharedData {
|
let default_account = AccountSharedData::from(Account {
|
||||||
lamports: account.lamports,
|
lamports: account.lamports,
|
||||||
..AccountSharedData::default()
|
..Account::default()
|
||||||
};
|
});
|
||||||
assert_eq!(default_account, account);
|
assert_eq!(default_account, account);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5712,10 +5712,10 @@ pub mod tests {
|
||||||
create_account(&db, &mut pubkeys, 0, 1, 0, 0);
|
create_account(&db, &mut pubkeys, 0, 1, 0, 0);
|
||||||
let ancestors = vec![(0, 0)].into_iter().collect();
|
let ancestors = vec![(0, 0)].into_iter().collect();
|
||||||
let account = db.load_slow(&ancestors, &pubkeys[0]).unwrap();
|
let account = db.load_slow(&ancestors, &pubkeys[0]).unwrap();
|
||||||
let default_account = AccountSharedData {
|
let default_account = AccountSharedData::from(Account {
|
||||||
lamports: 1,
|
lamports: 1,
|
||||||
..AccountSharedData::default()
|
..Account::default()
|
||||||
};
|
});
|
||||||
assert_eq!((default_account, 0), account);
|
assert_eq!((default_account, 0), account);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@ use log::*;
|
||||||
use memmap2::MmapMut;
|
use memmap2::MmapMut;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use solana_sdk::{
|
use solana_sdk::{
|
||||||
account::{AccountSharedData, ReadableAccount},
|
account::{Account, AccountSharedData, ReadableAccount},
|
||||||
clock::{Epoch, Slot},
|
clock::{Epoch, Slot},
|
||||||
hash::Hash,
|
hash::Hash,
|
||||||
pubkey::Pubkey,
|
pubkey::Pubkey,
|
||||||
|
@ -84,13 +84,13 @@ pub struct StoredAccountMeta<'a> {
|
||||||
impl<'a> StoredAccountMeta<'a> {
|
impl<'a> StoredAccountMeta<'a> {
|
||||||
/// Return a new Account by copying all the data referenced by the `StoredAccountMeta`.
|
/// Return a new Account by copying all the data referenced by the `StoredAccountMeta`.
|
||||||
pub fn clone_account(&self) -> AccountSharedData {
|
pub fn clone_account(&self) -> AccountSharedData {
|
||||||
AccountSharedData {
|
AccountSharedData::from(Account {
|
||||||
lamports: self.account_meta.lamports,
|
lamports: self.account_meta.lamports,
|
||||||
owner: self.account_meta.owner,
|
owner: self.account_meta.owner,
|
||||||
executable: self.account_meta.executable,
|
executable: self.account_meta.executable,
|
||||||
rent_epoch: self.account_meta.rent_epoch,
|
rent_epoch: self.account_meta.rent_epoch,
|
||||||
data: self.data.to_vec(),
|
data: self.data.to_vec(),
|
||||||
}
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
fn sanitize(&self) -> bool {
|
fn sanitize(&self) -> bool {
|
||||||
|
|
|
@ -32,7 +32,7 @@ use solana_measure::measure::Measure;
|
||||||
use solana_metrics::{datapoint_debug, inc_new_counter_debug, inc_new_counter_info};
|
use solana_metrics::{datapoint_debug, inc_new_counter_debug, inc_new_counter_info};
|
||||||
use solana_sdk::{
|
use solana_sdk::{
|
||||||
account::{
|
account::{
|
||||||
create_account_shared_data as create_account, from_account, AccountSharedData,
|
create_account_shared_data as create_account, from_account, Account, AccountSharedData,
|
||||||
ReadableAccount,
|
ReadableAccount,
|
||||||
},
|
},
|
||||||
clock::{
|
clock::{
|
||||||
|
@ -4829,13 +4829,13 @@ impl Bank {
|
||||||
};
|
};
|
||||||
|
|
||||||
if reconfigure_token2_native_mint {
|
if reconfigure_token2_native_mint {
|
||||||
let mut native_mint_account = solana_sdk::account::AccountSharedData {
|
let mut native_mint_account = solana_sdk::account::AccountSharedData::from(Account {
|
||||||
owner: inline_spl_token_v2_0::id(),
|
owner: inline_spl_token_v2_0::id(),
|
||||||
data: inline_spl_token_v2_0::native_mint::ACCOUNT_DATA.to_vec(),
|
data: inline_spl_token_v2_0::native_mint::ACCOUNT_DATA.to_vec(),
|
||||||
lamports: sol_to_lamports(1.),
|
lamports: sol_to_lamports(1.),
|
||||||
executable: false,
|
executable: false,
|
||||||
rent_epoch: self.epoch() + 1,
|
rent_epoch: self.epoch() + 1,
|
||||||
};
|
});
|
||||||
|
|
||||||
// As a workaround for
|
// As a workaround for
|
||||||
// https://github.com/solana-labs/solana-program-library/issues/374, ensure that the
|
// https://github.com/solana-labs/solana-program-library/issues/374, ensure that the
|
||||||
|
@ -11094,20 +11094,18 @@ pub(crate) mod tests {
|
||||||
// Setup original token account
|
// Setup original token account
|
||||||
bank.store_account_and_update_capitalization(
|
bank.store_account_and_update_capitalization(
|
||||||
&inline_spl_token_v2_0::id(),
|
&inline_spl_token_v2_0::id(),
|
||||||
&AccountSharedData {
|
&AccountSharedData::from(Account {
|
||||||
lamports: 100,
|
lamports: 100,
|
||||||
..AccountSharedData::default()
|
..Account::default()
|
||||||
},
|
}),
|
||||||
);
|
);
|
||||||
assert_eq!(bank.get_balance(&inline_spl_token_v2_0::id()), 100);
|
assert_eq!(bank.get_balance(&inline_spl_token_v2_0::id()), 100);
|
||||||
|
|
||||||
// Setup new token account
|
// Setup new token account
|
||||||
let new_token_account = AccountSharedData {
|
let new_token_account = AccountSharedData::from(Account {
|
||||||
lamports: 123,
|
lamports: 123,
|
||||||
data: vec![1, 2, 3],
|
..Account::default()
|
||||||
executable: true,
|
});
|
||||||
..AccountSharedData::default()
|
|
||||||
};
|
|
||||||
bank.store_account_and_update_capitalization(
|
bank.store_account_and_update_capitalization(
|
||||||
&inline_spl_token_v2_0::new_token_program::id(),
|
&inline_spl_token_v2_0::new_token_program::id(),
|
||||||
&new_token_account,
|
&new_token_account,
|
||||||
|
|
|
@ -1121,6 +1121,7 @@ impl MessageProcessor {
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
use solana_sdk::{
|
use solana_sdk::{
|
||||||
|
account::Account,
|
||||||
instruction::{AccountMeta, Instruction, InstructionError},
|
instruction::{AccountMeta, Instruction, InstructionError},
|
||||||
message::Message,
|
message::Message,
|
||||||
native_loader::create_loadable_account,
|
native_loader::create_loadable_account,
|
||||||
|
@ -1288,18 +1289,18 @@ mod tests {
|
||||||
is_writable: true,
|
is_writable: true,
|
||||||
pre: PreAccount::new(
|
pre: PreAccount::new(
|
||||||
&solana_sdk::pubkey::new_rand(),
|
&solana_sdk::pubkey::new_rand(),
|
||||||
&AccountSharedData {
|
&AccountSharedData::from(Account {
|
||||||
owner: *owner,
|
owner: *owner,
|
||||||
lamports: std::u64::MAX,
|
lamports: std::u64::MAX,
|
||||||
data: vec![],
|
data: vec![],
|
||||||
..AccountSharedData::default()
|
..Account::default()
|
||||||
},
|
}),
|
||||||
),
|
),
|
||||||
post: AccountSharedData {
|
post: AccountSharedData::from(Account {
|
||||||
owner: *owner,
|
owner: *owner,
|
||||||
lamports: std::u64::MAX,
|
lamports: std::u64::MAX,
|
||||||
..AccountSharedData::default()
|
..Account::default()
|
||||||
},
|
}),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pub fn read_only(mut self) -> Self {
|
pub fn read_only(mut self) -> Self {
|
||||||
|
|
|
@ -123,6 +123,7 @@ impl RentCollector {
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
use solana_sdk::account::Account;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_collect_from_account_created_and_existing() {
|
fn test_collect_from_account_created_and_existing() {
|
||||||
|
@ -131,11 +132,11 @@ mod tests {
|
||||||
let new_epoch = 3;
|
let new_epoch = 3;
|
||||||
|
|
||||||
let (mut created_account, mut existing_account) = {
|
let (mut created_account, mut existing_account) = {
|
||||||
let account = AccountSharedData {
|
let account = AccountSharedData::from(Account {
|
||||||
lamports: old_lamports,
|
lamports: old_lamports,
|
||||||
rent_epoch: old_epoch,
|
rent_epoch: old_epoch,
|
||||||
..AccountSharedData::default()
|
..Account::default()
|
||||||
};
|
});
|
||||||
|
|
||||||
(account.clone(), account)
|
(account.clone(), account)
|
||||||
};
|
};
|
||||||
|
|
|
@ -446,7 +446,7 @@ mod tests {
|
||||||
use crate::{bank::Bank, bank_client::BankClient};
|
use crate::{bank::Bank, bank_client::BankClient};
|
||||||
use bincode::serialize;
|
use bincode::serialize;
|
||||||
use solana_sdk::{
|
use solana_sdk::{
|
||||||
account::{self, AccountSharedData},
|
account::{self, Account, AccountSharedData},
|
||||||
client::SyncClient,
|
client::SyncClient,
|
||||||
fee_calculator::FeeCalculator,
|
fee_calculator::FeeCalculator,
|
||||||
genesis_config::create_genesis_config,
|
genesis_config::create_genesis_config,
|
||||||
|
@ -912,10 +912,10 @@ mod tests {
|
||||||
let from_account = AccountSharedData::new_ref(100, 0, &system_program::id());
|
let from_account = AccountSharedData::new_ref(100, 0, &system_program::id());
|
||||||
|
|
||||||
let populated_key = solana_sdk::pubkey::new_rand();
|
let populated_key = solana_sdk::pubkey::new_rand();
|
||||||
let populated_account = AccountSharedData {
|
let populated_account = AccountSharedData::from(Account {
|
||||||
data: vec![0, 1, 2, 3],
|
data: vec![0, 1, 2, 3],
|
||||||
..AccountSharedData::default()
|
..Account::default()
|
||||||
}
|
})
|
||||||
.into();
|
.into();
|
||||||
|
|
||||||
let signers = [from, populated_key]
|
let signers = [from, populated_key]
|
||||||
|
|
Loading…
Reference in New Issue