* Add pubkey_new_rand(), mark Pubkey::new_rand() deprecated (cherry picked from commit0e68ed6a8d
) * Add hash_new_rand(), mark Hash::new_rand() as deprecated (cherry picked from commit76f11c7dae
) * Run `codemod --extensions rs Pubkey::new_rand solana_sdk::pubkey::new_rand` (cherry picked from commit7bc073defe
) # Conflicts: # programs/bpf/benches/bpf_loader.rs # runtime/benches/accounts.rs # runtime/src/accounts.rs * Run `codemod --extensions rs Hash::new_rand solana_sdk:#️⃣:new_rand` (cherry picked from commit17c391121a
) * Remove unused pubkey::Pubkey imports (cherry picked from commit959880db60
) # Conflicts: # runtime/src/accounts_index.rs * Resolve conflicts Co-authored-by: Michael Vines <mvines@gmail.com>
This commit is contained in:
@@ -879,7 +879,7 @@ pub fn create_test_accounts(
|
||||
slot: Slot,
|
||||
) {
|
||||
for t in 0..num {
|
||||
let pubkey = Pubkey::new_rand();
|
||||
let pubkey = solana_sdk::pubkey::new_rand();
|
||||
let account = Account::new((t + 1) as u64, 0, &Account::default().owner);
|
||||
accounts.store_slow(slot, &pubkey, &account);
|
||||
pubkeys.push(pubkey);
|
||||
@@ -1102,7 +1102,7 @@ mod tests {
|
||||
let keypair = Keypair::new();
|
||||
let key0 = keypair.pubkey();
|
||||
|
||||
let account = Account::new(1, 1, &Pubkey::new_rand()); // <-- owner is not the system program
|
||||
let account = Account::new(1, 1, &solana_sdk::pubkey::new_rand()); // <-- owner is not the system program
|
||||
accounts.push((key0, account));
|
||||
|
||||
let instructions = vec![CompiledInstruction::new(1, &(), vec![0])];
|
||||
@@ -1496,13 +1496,13 @@ mod tests {
|
||||
let accounts = Accounts::new(Vec::new(), &ClusterType::Development);
|
||||
|
||||
// Load accounts owned by various programs into AccountsDB
|
||||
let pubkey0 = Pubkey::new_rand();
|
||||
let pubkey0 = solana_sdk::pubkey::new_rand();
|
||||
let account0 = Account::new(1, 0, &Pubkey::new(&[2; 32]));
|
||||
accounts.store_slow(0, &pubkey0, &account0);
|
||||
let pubkey1 = Pubkey::new_rand();
|
||||
let pubkey1 = solana_sdk::pubkey::new_rand();
|
||||
let account1 = Account::new(1, 0, &Pubkey::new(&[2; 32]));
|
||||
accounts.store_slow(0, &pubkey1, &account1);
|
||||
let pubkey2 = Pubkey::new_rand();
|
||||
let pubkey2 = solana_sdk::pubkey::new_rand();
|
||||
let account2 = Account::new(1, 0, &Pubkey::new(&[3; 32]));
|
||||
accounts.store_slow(0, &pubkey2, &account2);
|
||||
|
||||
@@ -1527,7 +1527,7 @@ mod tests {
|
||||
&storage,
|
||||
&ancestors,
|
||||
&accounts_index,
|
||||
&Pubkey::new_rand(),
|
||||
&solana_sdk::pubkey::new_rand(),
|
||||
&mut error_counters
|
||||
),
|
||||
Err(TransactionError::ProgramAccountNotFound)
|
||||
@@ -1734,7 +1734,7 @@ mod tests {
|
||||
fn test_collect_accounts_to_store() {
|
||||
let keypair0 = Keypair::new();
|
||||
let keypair1 = Keypair::new();
|
||||
let pubkey = Pubkey::new_rand();
|
||||
let pubkey = solana_sdk::pubkey::new_rand();
|
||||
|
||||
let rent_collector = RentCollector::default();
|
||||
|
||||
@@ -1853,7 +1853,7 @@ mod tests {
|
||||
let zero_account = Account::new(0, 0, &Account::default().owner);
|
||||
info!("storing..");
|
||||
for i in 0..2_000 {
|
||||
let pubkey = Pubkey::new_rand();
|
||||
let pubkey = solana_sdk::pubkey::new_rand();
|
||||
let account = Account::new((i + 1) as u64, 0, &Account::default().owner);
|
||||
accounts.store_slow(i, &pubkey, &account);
|
||||
accounts.store_slow(i, &old_pubkey, &zero_account);
|
||||
@@ -1900,7 +1900,7 @@ mod tests {
|
||||
let instructions = vec![CompiledInstruction::new(1, &(), vec![0, 1])];
|
||||
let tx = Transaction::new_with_compiled_instructions(
|
||||
&[&keypair],
|
||||
&[Pubkey::new_rand(), instructions_key],
|
||||
&[solana_sdk::pubkey::new_rand(), instructions_key],
|
||||
Hash::default(),
|
||||
vec![native_loader::id()],
|
||||
instructions,
|
||||
|
@@ -2669,7 +2669,7 @@ pub mod tests {
|
||||
create_account(&db, &mut pubkeys, 0, 2, DEFAULT_FILE_SIZE as usize / 3, 0);
|
||||
assert!(check_storage(&db, 0, 2));
|
||||
|
||||
let pubkey = Pubkey::new_rand();
|
||||
let pubkey = solana_sdk::pubkey::new_rand();
|
||||
let account = Account::new(1, DEFAULT_FILE_SIZE as usize / 3, &pubkey);
|
||||
db.store(1, &[(&pubkey, &account)]);
|
||||
db.store(1, &[(&pubkeys[0], &account)]);
|
||||
@@ -2787,7 +2787,7 @@ pub mod tests {
|
||||
fn test_remove_unrooted_slot_snapshot() {
|
||||
let unrooted_slot = 9;
|
||||
let db = AccountsDB::new(Vec::new(), &ClusterType::Development);
|
||||
let key = Pubkey::new_rand();
|
||||
let key = solana_sdk::pubkey::new_rand();
|
||||
let account0 = Account::new(1, 0, &key);
|
||||
db.store(unrooted_slot, &[(&key, &account0)]);
|
||||
|
||||
@@ -2795,7 +2795,7 @@ pub mod tests {
|
||||
db.remove_unrooted_slot(unrooted_slot);
|
||||
|
||||
// Add a new root
|
||||
let key2 = Pubkey::new_rand();
|
||||
let key2 = solana_sdk::pubkey::new_rand();
|
||||
let new_root = unrooted_slot + 1;
|
||||
db.store(new_root, &[(&key2, &account0)]);
|
||||
db.add_root(new_root);
|
||||
@@ -2821,14 +2821,14 @@ pub mod tests {
|
||||
) {
|
||||
let ancestors = vec![(slot, 0)].into_iter().collect();
|
||||
for t in 0..num {
|
||||
let pubkey = Pubkey::new_rand();
|
||||
let pubkey = solana_sdk::pubkey::new_rand();
|
||||
let account = Account::new((t + 1) as u64, space, &Account::default().owner);
|
||||
pubkeys.push(pubkey);
|
||||
assert!(accounts.load_slow(&ancestors, &pubkey).is_none());
|
||||
accounts.store(slot, &[(&pubkey, &account)]);
|
||||
}
|
||||
for t in 0..num_vote {
|
||||
let pubkey = Pubkey::new_rand();
|
||||
let pubkey = solana_sdk::pubkey::new_rand();
|
||||
let account = Account::new((num + t + 1) as u64, space, &solana_vote_program::id());
|
||||
pubkeys.push(pubkey);
|
||||
let ancestors = vec![(slot, 0)].into_iter().collect();
|
||||
@@ -2948,7 +2948,7 @@ pub mod tests {
|
||||
let accounts = AccountsDB::new_sized(paths, size);
|
||||
let mut keys = vec![];
|
||||
for i in 0..9 {
|
||||
let key = Pubkey::new_rand();
|
||||
let key = solana_sdk::pubkey::new_rand();
|
||||
let account = Account::new(i + 1, size as usize / 4, &key);
|
||||
accounts.store(0, &[(&key, &account)]);
|
||||
keys.push(key);
|
||||
@@ -2983,7 +2983,7 @@ pub mod tests {
|
||||
|
||||
let count = [0, 1];
|
||||
let status = [AccountStorageStatus::Available, AccountStorageStatus::Full];
|
||||
let pubkey1 = Pubkey::new_rand();
|
||||
let pubkey1 = solana_sdk::pubkey::new_rand();
|
||||
let account1 = Account::new(1, DEFAULT_FILE_SIZE as usize / 2, &pubkey1);
|
||||
accounts.store(0, &[(&pubkey1, &account1)]);
|
||||
{
|
||||
@@ -2993,7 +2993,7 @@ pub mod tests {
|
||||
assert_eq!(stores.0[&0][&0].status(), AccountStorageStatus::Available);
|
||||
}
|
||||
|
||||
let pubkey2 = Pubkey::new_rand();
|
||||
let pubkey2 = solana_sdk::pubkey::new_rand();
|
||||
let account2 = Account::new(1, DEFAULT_FILE_SIZE as usize / 2, &pubkey2);
|
||||
accounts.store(0, &[(&pubkey2, &account2)]);
|
||||
{
|
||||
@@ -3071,7 +3071,7 @@ pub mod tests {
|
||||
//A slot is purged when a non root bank is cleaned up. If a slot is behind root but it is
|
||||
//not root, it means we are retaining dead banks.
|
||||
let accounts = AccountsDB::new(Vec::new(), &ClusterType::Development);
|
||||
let pubkey = Pubkey::new_rand();
|
||||
let pubkey = solana_sdk::pubkey::new_rand();
|
||||
let account = Account::new(1, 0, &Account::default().owner);
|
||||
//store an account
|
||||
accounts.store(0, &[(&pubkey, &account)]);
|
||||
@@ -3148,8 +3148,8 @@ pub mod tests {
|
||||
solana_logger::setup();
|
||||
|
||||
let accounts = AccountsDB::new(Vec::new(), &ClusterType::Development);
|
||||
let pubkey1 = Pubkey::new_rand();
|
||||
let pubkey2 = Pubkey::new_rand();
|
||||
let pubkey1 = solana_sdk::pubkey::new_rand();
|
||||
let pubkey2 = solana_sdk::pubkey::new_rand();
|
||||
let account = Account::new(1, 1, &Account::default().owner);
|
||||
let zero_lamport_account = Account::new(0, 0, &Account::default().owner);
|
||||
|
||||
@@ -3208,7 +3208,7 @@ pub mod tests {
|
||||
solana_logger::setup();
|
||||
|
||||
let accounts = AccountsDB::new(Vec::new(), &ClusterType::Development);
|
||||
let pubkey = Pubkey::new_rand();
|
||||
let pubkey = solana_sdk::pubkey::new_rand();
|
||||
let account = Account::new(1, 0, &Account::default().owner);
|
||||
let zero_lamport_account = Account::new(0, 0, &Account::default().owner);
|
||||
|
||||
@@ -3252,7 +3252,7 @@ pub mod tests {
|
||||
solana_logger::setup();
|
||||
|
||||
let accounts = AccountsDB::new(Vec::new(), &ClusterType::Development);
|
||||
let pubkey = Pubkey::new_rand();
|
||||
let pubkey = solana_sdk::pubkey::new_rand();
|
||||
let account = Account::new(1, 0, &Account::default().owner);
|
||||
//store an account
|
||||
accounts.store(0, &[(&pubkey, &account)]);
|
||||
@@ -3278,8 +3278,8 @@ pub mod tests {
|
||||
solana_logger::setup();
|
||||
|
||||
let accounts = AccountsDB::new(Vec::new(), &ClusterType::Development);
|
||||
let pubkey1 = Pubkey::new_rand();
|
||||
let pubkey2 = Pubkey::new_rand();
|
||||
let pubkey1 = solana_sdk::pubkey::new_rand();
|
||||
let pubkey2 = solana_sdk::pubkey::new_rand();
|
||||
let normal_account = Account::new(1, 0, &Account::default().owner);
|
||||
let zero_account = Account::new(0, 0, &Account::default().owner);
|
||||
//store an account
|
||||
@@ -3308,8 +3308,8 @@ pub mod tests {
|
||||
solana_logger::setup();
|
||||
|
||||
let accounts = AccountsDB::new(Vec::new(), &ClusterType::Development);
|
||||
let pubkey1 = Pubkey::new_rand();
|
||||
let pubkey2 = Pubkey::new_rand();
|
||||
let pubkey1 = solana_sdk::pubkey::new_rand();
|
||||
let pubkey2 = solana_sdk::pubkey::new_rand();
|
||||
let normal_account = Account::new(1, 0, &Account::default().owner);
|
||||
let zero_account = Account::new(0, 0, &Account::default().owner);
|
||||
|
||||
@@ -3355,7 +3355,7 @@ pub mod tests {
|
||||
solana_logger::setup();
|
||||
|
||||
let accounts = AccountsDB::new(Vec::new(), &ClusterType::Development);
|
||||
let pubkey = Pubkey::new_rand();
|
||||
let pubkey = solana_sdk::pubkey::new_rand();
|
||||
let account = Account::new(1, 0, &Account::default().owner);
|
||||
let zero_account = Account::new(0, 0, &Account::default().owner);
|
||||
|
||||
@@ -3402,7 +3402,7 @@ pub mod tests {
|
||||
solana_logger::setup();
|
||||
|
||||
let accounts = AccountsDB::new(Vec::new(), &ClusterType::Development);
|
||||
let pubkey = Pubkey::new_rand();
|
||||
let pubkey = solana_sdk::pubkey::new_rand();
|
||||
let account = Account::new(1, 0, &Account::default().owner);
|
||||
//store an account
|
||||
accounts.store(0, &[(&pubkey, &account)]);
|
||||
@@ -3573,10 +3573,10 @@ pub mod tests {
|
||||
let owner = Account::default().owner;
|
||||
|
||||
let account = Account::new(some_lamport, no_data, &owner);
|
||||
let pubkey = Pubkey::new_rand();
|
||||
let pubkey = solana_sdk::pubkey::new_rand();
|
||||
|
||||
let account2 = Account::new(some_lamport, no_data, &owner);
|
||||
let pubkey2 = Pubkey::new_rand();
|
||||
let pubkey2 = solana_sdk::pubkey::new_rand();
|
||||
|
||||
let zero_lamport_account = Account::new(zero_lamport, no_data, &owner);
|
||||
|
||||
@@ -3654,7 +3654,7 @@ pub mod tests {
|
||||
let owner = Account::default().owner;
|
||||
|
||||
let account = Account::new(some_lamport, no_data, &owner);
|
||||
let pubkey = Pubkey::new_rand();
|
||||
let pubkey = solana_sdk::pubkey::new_rand();
|
||||
|
||||
let zero_lamport_account = Account::new(zero_lamport, no_data, &owner);
|
||||
|
||||
@@ -3717,14 +3717,14 @@ pub mod tests {
|
||||
let owner = Account::default().owner;
|
||||
|
||||
let account = Account::new(some_lamport, no_data, &owner);
|
||||
let pubkey = Pubkey::new_rand();
|
||||
let pubkey = solana_sdk::pubkey::new_rand();
|
||||
let zero_lamport_account = Account::new(zero_lamport, no_data, &owner);
|
||||
|
||||
let account2 = Account::new(some_lamport + 1, no_data, &owner);
|
||||
let pubkey2 = Pubkey::new_rand();
|
||||
let pubkey2 = solana_sdk::pubkey::new_rand();
|
||||
|
||||
let filler_account = Account::new(some_lamport, no_data, &owner);
|
||||
let filler_account_pubkey = Pubkey::new_rand();
|
||||
let filler_account_pubkey = solana_sdk::pubkey::new_rand();
|
||||
|
||||
let accounts = AccountsDB::new_single();
|
||||
|
||||
@@ -3780,9 +3780,9 @@ pub mod tests {
|
||||
let account3 = Account::new(some_lamport + 100_002, no_data, &owner);
|
||||
let zero_lamport_account = Account::new(zero_lamport, no_data, &owner);
|
||||
|
||||
let pubkey = Pubkey::new_rand();
|
||||
let purged_pubkey1 = Pubkey::new_rand();
|
||||
let purged_pubkey2 = Pubkey::new_rand();
|
||||
let pubkey = solana_sdk::pubkey::new_rand();
|
||||
let purged_pubkey1 = solana_sdk::pubkey::new_rand();
|
||||
let purged_pubkey2 = solana_sdk::pubkey::new_rand();
|
||||
|
||||
let dummy_account = Account::new(dummy_lamport, no_data, &owner);
|
||||
let dummy_pubkey = Pubkey::default();
|
||||
@@ -3862,7 +3862,7 @@ pub mod tests {
|
||||
std::thread::Builder::new()
|
||||
.name("account-writers".to_string())
|
||||
.spawn(move || {
|
||||
let pubkey = Pubkey::new_rand();
|
||||
let pubkey = solana_sdk::pubkey::new_rand();
|
||||
let mut account = Account::new(1, 0, &pubkey);
|
||||
let mut i = 0;
|
||||
loop {
|
||||
@@ -3893,12 +3893,12 @@ pub mod tests {
|
||||
solana_logger::setup();
|
||||
let db = AccountsDB::new(Vec::new(), &ClusterType::Development);
|
||||
let key = Pubkey::default();
|
||||
let key0 = Pubkey::new_rand();
|
||||
let key0 = solana_sdk::pubkey::new_rand();
|
||||
let account0 = Account::new(1, 0, &key);
|
||||
|
||||
db.store(0, &[(&key0, &account0)]);
|
||||
|
||||
let key1 = Pubkey::new_rand();
|
||||
let key1 = solana_sdk::pubkey::new_rand();
|
||||
let account1 = Account::new(2, 0, &key);
|
||||
db.store(1, &[(&key1, &account1)]);
|
||||
|
||||
@@ -3927,12 +3927,12 @@ pub mod tests {
|
||||
let db = AccountsDB::new_single();
|
||||
|
||||
let key = Pubkey::default();
|
||||
let key0 = Pubkey::new_rand();
|
||||
let key0 = solana_sdk::pubkey::new_rand();
|
||||
let account0 = Account::new(1, 0, &key);
|
||||
|
||||
db.store(0, &[(&key0, &account0)]);
|
||||
|
||||
let key1 = Pubkey::new_rand();
|
||||
let key1 = solana_sdk::pubkey::new_rand();
|
||||
let account1 = Account::new(2, 0, &key);
|
||||
db.store(1, &[(&key1, &account1)]);
|
||||
|
||||
@@ -4210,7 +4210,7 @@ pub mod tests {
|
||||
solana_logger::setup();
|
||||
let db = AccountsDB::new(Vec::new(), &ClusterType::Development);
|
||||
|
||||
let key = Pubkey::new_rand();
|
||||
let key = solana_sdk::pubkey::new_rand();
|
||||
let some_data_len = 0;
|
||||
let some_slot: Slot = 0;
|
||||
let account = Account::new(1, some_data_len, &key);
|
||||
@@ -4252,7 +4252,7 @@ pub mod tests {
|
||||
solana_logger::setup();
|
||||
let db = AccountsDB::new(Vec::new(), &ClusterType::Development);
|
||||
|
||||
let key = Pubkey::new_rand();
|
||||
let key = solana_sdk::pubkey::new_rand();
|
||||
let some_data_len = 0;
|
||||
let some_slot: Slot = 0;
|
||||
let account = Account::new(1, some_data_len, &key);
|
||||
@@ -4266,7 +4266,7 @@ pub mod tests {
|
||||
Ok(_)
|
||||
);
|
||||
|
||||
let native_account_pubkey = Pubkey::new_rand();
|
||||
let native_account_pubkey = solana_sdk::pubkey::new_rand();
|
||||
db.store(
|
||||
some_slot,
|
||||
&[(
|
||||
@@ -4451,7 +4451,7 @@ pub mod tests {
|
||||
#[should_panic(expected = "double remove of account in slot: 0/store: 0!!")]
|
||||
fn test_storage_remove_account_double_remove() {
|
||||
let accounts = AccountsDB::new(Vec::new(), &ClusterType::Development);
|
||||
let pubkey = Pubkey::new_rand();
|
||||
let pubkey = solana_sdk::pubkey::new_rand();
|
||||
let account = Account::new(1, 0, &Account::default().owner);
|
||||
accounts.store(0, &[(&pubkey, &account)]);
|
||||
let storage = accounts.storage.read().unwrap();
|
||||
@@ -4474,10 +4474,10 @@ pub mod tests {
|
||||
let dummy_account = Account::new(99_999_999, no_data, &owner);
|
||||
let zero_lamport_account = Account::new(zero_lamport, no_data, &owner);
|
||||
|
||||
let pubkey = Pubkey::new_rand();
|
||||
let dummy_pubkey = Pubkey::new_rand();
|
||||
let purged_pubkey1 = Pubkey::new_rand();
|
||||
let purged_pubkey2 = Pubkey::new_rand();
|
||||
let pubkey = solana_sdk::pubkey::new_rand();
|
||||
let dummy_pubkey = solana_sdk::pubkey::new_rand();
|
||||
let purged_pubkey1 = solana_sdk::pubkey::new_rand();
|
||||
let purged_pubkey2 = solana_sdk::pubkey::new_rand();
|
||||
|
||||
let mut current_slot = 0;
|
||||
let accounts = AccountsDB::new_single();
|
||||
@@ -4536,9 +4536,9 @@ pub mod tests {
|
||||
let dummy_account = Account::new(dummy_lamport, no_data, &owner);
|
||||
let zero_lamport_account = Account::new(zero_lamport, no_data, &owner);
|
||||
|
||||
let pubkey1 = Pubkey::new_rand();
|
||||
let pubkey2 = Pubkey::new_rand();
|
||||
let dummy_pubkey = Pubkey::new_rand();
|
||||
let pubkey1 = solana_sdk::pubkey::new_rand();
|
||||
let pubkey2 = solana_sdk::pubkey::new_rand();
|
||||
let dummy_pubkey = solana_sdk::pubkey::new_rand();
|
||||
|
||||
let mut current_slot = 0;
|
||||
let accounts = AccountsDB::new_single();
|
||||
@@ -4710,7 +4710,9 @@ pub mod tests {
|
||||
let accounts = AccountsDB::new_single();
|
||||
|
||||
let pubkey_count = 100;
|
||||
let pubkeys: Vec<_> = (0..pubkey_count).map(|_| Pubkey::new_rand()).collect();
|
||||
let pubkeys: Vec<_> = (0..pubkey_count)
|
||||
.map(|_| solana_sdk::pubkey::new_rand())
|
||||
.collect();
|
||||
|
||||
let some_lamport = 223;
|
||||
let no_data = 0;
|
||||
@@ -4774,7 +4776,9 @@ pub mod tests {
|
||||
let accounts = AccountsDB::new_single();
|
||||
|
||||
let pubkey_count = 100;
|
||||
let pubkeys: Vec<_> = (0..pubkey_count).map(|_| Pubkey::new_rand()).collect();
|
||||
let pubkeys: Vec<_> = (0..pubkey_count)
|
||||
.map(|_| solana_sdk::pubkey::new_rand())
|
||||
.collect();
|
||||
|
||||
let some_lamport = 223;
|
||||
let no_data = 0;
|
||||
@@ -4918,7 +4922,7 @@ pub mod tests {
|
||||
for current_slot in 0..1000 {
|
||||
while alive_accounts.len() <= 10 {
|
||||
alive_accounts.push((
|
||||
Pubkey::new_rand(),
|
||||
solana_sdk::pubkey::new_rand(),
|
||||
Account::new(thread_rng().gen_range(0, 50), 0, &owner),
|
||||
));
|
||||
}
|
||||
@@ -4953,7 +4957,11 @@ pub mod tests {
|
||||
);
|
||||
// any random program data accounts
|
||||
assert_eq!(
|
||||
AccountsDB::account_balance_for_capitalization(10, &Pubkey::new_rand(), false),
|
||||
AccountsDB::account_balance_for_capitalization(
|
||||
10,
|
||||
&solana_sdk::pubkey::new_rand(),
|
||||
false
|
||||
),
|
||||
10
|
||||
);
|
||||
}
|
||||
|
@@ -674,7 +674,7 @@ pub mod tests {
|
||||
let path = &file.path;
|
||||
let mut av = AppendVec::new(&path, true, 1024 * 1024);
|
||||
|
||||
let pubkey = Pubkey::new_rand();
|
||||
let pubkey = solana_sdk::pubkey::new_rand();
|
||||
let owner = Pubkey::default();
|
||||
let data_len = 3 as u64;
|
||||
let mut account = Account::new(0, data_len as usize, &owner);
|
||||
|
@@ -4165,7 +4165,7 @@ mod tests {
|
||||
#[test]
|
||||
#[allow(clippy::float_cmp)]
|
||||
fn test_bank_new() {
|
||||
let dummy_leader_pubkey = Pubkey::new_rand();
|
||||
let dummy_leader_pubkey = solana_sdk::pubkey::new_rand();
|
||||
let dummy_leader_lamports = BOOTSTRAP_VALIDATOR_LAMPORTS;
|
||||
let mint_lamports = 10_000;
|
||||
let GenesisConfigInfo {
|
||||
@@ -4275,7 +4275,12 @@ mod tests {
|
||||
fn test_bank_capitalization() {
|
||||
let bank = Arc::new(Bank::new(&GenesisConfig {
|
||||
accounts: (0..42)
|
||||
.map(|_| (Pubkey::new_rand(), Account::new(42, 0, &Pubkey::default())))
|
||||
.map(|_| {
|
||||
(
|
||||
solana_sdk::pubkey::new_rand(),
|
||||
Account::new(42, 0, &Pubkey::default()),
|
||||
)
|
||||
})
|
||||
.collect(),
|
||||
cluster_type: ClusterType::MainnetBeta,
|
||||
..GenesisConfig::default()
|
||||
@@ -4559,7 +4564,7 @@ mod tests {
|
||||
fn test_rent_distribution() {
|
||||
solana_logger::setup();
|
||||
|
||||
let bootstrap_validator_pubkey = Pubkey::new_rand();
|
||||
let bootstrap_validator_pubkey = solana_sdk::pubkey::new_rand();
|
||||
let bootstrap_validator_stake_lamports = 30;
|
||||
let mut genesis_config = create_genesis_config_with_leader(
|
||||
10,
|
||||
@@ -4582,7 +4587,7 @@ mod tests {
|
||||
|
||||
let rent = Rent::free();
|
||||
|
||||
let validator_1_pubkey = Pubkey::new_rand();
|
||||
let validator_1_pubkey = solana_sdk::pubkey::new_rand();
|
||||
let validator_1_stake_lamports = 20;
|
||||
let validator_1_staking_keypair = Keypair::new();
|
||||
let validator_1_voting_keypair = Keypair::new();
|
||||
@@ -4615,7 +4620,7 @@ mod tests {
|
||||
validator_1_vote_account,
|
||||
);
|
||||
|
||||
let validator_2_pubkey = Pubkey::new_rand();
|
||||
let validator_2_pubkey = solana_sdk::pubkey::new_rand();
|
||||
let validator_2_stake_lamports = 20;
|
||||
let validator_2_staking_keypair = Keypair::new();
|
||||
let validator_2_voting_keypair = Keypair::new();
|
||||
@@ -4648,7 +4653,7 @@ mod tests {
|
||||
validator_2_vote_account,
|
||||
);
|
||||
|
||||
let validator_3_pubkey = Pubkey::new_rand();
|
||||
let validator_3_pubkey = solana_sdk::pubkey::new_rand();
|
||||
let validator_3_stake_lamports = 30;
|
||||
let validator_3_staking_keypair = Keypair::new();
|
||||
let validator_3_voting_keypair = Keypair::new();
|
||||
@@ -4806,7 +4811,7 @@ mod tests {
|
||||
const RENT_TO_BE_DISTRIBUTED: u64 = 120_525;
|
||||
const VALIDATOR_STAKE: u64 = 374_999_998_287_840;
|
||||
|
||||
let validator_pubkey = Pubkey::new_rand();
|
||||
let validator_pubkey = solana_sdk::pubkey::new_rand();
|
||||
let mut genesis_config =
|
||||
create_genesis_config_with_leader(10, &validator_pubkey, VALIDATOR_STAKE)
|
||||
.genesis_config;
|
||||
@@ -4852,11 +4857,15 @@ mod tests {
|
||||
};
|
||||
|
||||
let root_bank = Arc::new(Bank::new(&genesis_config));
|
||||
let bank = create_child_bank_for_rent_test(&root_bank, &genesis_config, Pubkey::new_rand());
|
||||
let bank = create_child_bank_for_rent_test(
|
||||
&root_bank,
|
||||
&genesis_config,
|
||||
solana_sdk::pubkey::new_rand(),
|
||||
);
|
||||
|
||||
let account_pubkey = Pubkey::new_rand();
|
||||
let account_pubkey = solana_sdk::pubkey::new_rand();
|
||||
let account_balance = 1;
|
||||
let mut account = Account::new(account_balance, 0, &Pubkey::new_rand());
|
||||
let mut account = Account::new(account_balance, 0, &solana_sdk::pubkey::new_rand());
|
||||
account.executable = true;
|
||||
bank.store_account(&account_pubkey, &account);
|
||||
|
||||
@@ -5117,7 +5126,7 @@ mod tests {
|
||||
#[test]
|
||||
#[allow(clippy::cognitive_complexity)]
|
||||
fn test_rent_eager_across_epoch_without_gap_under_multi_epoch_cycle() {
|
||||
let leader_pubkey = Pubkey::new_rand();
|
||||
let leader_pubkey = solana_sdk::pubkey::new_rand();
|
||||
let leader_lamports = 3;
|
||||
let mut genesis_config =
|
||||
create_genesis_config_with_leader(5, &leader_pubkey, leader_lamports).genesis_config;
|
||||
@@ -5187,7 +5196,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_rent_eager_across_epoch_with_gap_under_multi_epoch_cycle() {
|
||||
let leader_pubkey = Pubkey::new_rand();
|
||||
let leader_pubkey = solana_sdk::pubkey::new_rand();
|
||||
let leader_lamports = 3;
|
||||
let mut genesis_config =
|
||||
create_genesis_config_with_leader(5, &leader_pubkey, leader_lamports).genesis_config;
|
||||
@@ -5245,7 +5254,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_rent_eager_with_warmup_epochs_under_multi_epoch_cycle() {
|
||||
let leader_pubkey = Pubkey::new_rand();
|
||||
let leader_pubkey = solana_sdk::pubkey::new_rand();
|
||||
let leader_lamports = 3;
|
||||
let mut genesis_config =
|
||||
create_genesis_config_with_leader(5, &leader_pubkey, leader_lamports).genesis_config;
|
||||
@@ -5302,7 +5311,7 @@ mod tests {
|
||||
#[test]
|
||||
fn test_rent_eager_under_fixed_cycle_for_developemnt() {
|
||||
solana_logger::setup();
|
||||
let leader_pubkey = Pubkey::new_rand();
|
||||
let leader_pubkey = solana_sdk::pubkey::new_rand();
|
||||
let leader_lamports = 3;
|
||||
let mut genesis_config =
|
||||
create_genesis_config_with_leader(5, &leader_pubkey, leader_lamports).genesis_config;
|
||||
@@ -5439,7 +5448,7 @@ mod tests {
|
||||
fn map_to_test_bad_range() -> AccountMap<Pubkey, i8> {
|
||||
let mut map: AccountMap<Pubkey, i8> = AccountMap::new();
|
||||
// when empty, AccountMap (= std::collections::BTreeMap) doesn't sanitize given range...
|
||||
map.insert(Pubkey::new_rand(), 1);
|
||||
map.insert(solana_sdk::pubkey::new_rand(), 1);
|
||||
map
|
||||
}
|
||||
|
||||
@@ -5645,9 +5654,9 @@ mod tests {
|
||||
let (mut genesis_config, _mint_keypair) = create_genesis_config(1);
|
||||
activate_all_features(&mut genesis_config);
|
||||
|
||||
let zero_lamport_pubkey = Pubkey::new_rand();
|
||||
let rent_due_pubkey = Pubkey::new_rand();
|
||||
let rent_exempt_pubkey = Pubkey::new_rand();
|
||||
let zero_lamport_pubkey = solana_sdk::pubkey::new_rand();
|
||||
let rent_due_pubkey = solana_sdk::pubkey::new_rand();
|
||||
let rent_exempt_pubkey = solana_sdk::pubkey::new_rand();
|
||||
|
||||
let mut bank = Arc::new(Bank::new(&genesis_config));
|
||||
let zero_lamports = 0;
|
||||
@@ -5727,7 +5736,7 @@ mod tests {
|
||||
|
||||
let (genesis_config, _mint_keypair) = create_genesis_config(1);
|
||||
|
||||
let zero_lamport_pubkey = Pubkey::new_rand();
|
||||
let zero_lamport_pubkey = solana_sdk::pubkey::new_rand();
|
||||
|
||||
let genesis_bank1 = Arc::new(Bank::new(&genesis_config));
|
||||
let genesis_bank2 = Arc::new(Bank::new(&genesis_config));
|
||||
@@ -5793,7 +5802,7 @@ mod tests {
|
||||
accounts: (0..42)
|
||||
.map(|_| {
|
||||
(
|
||||
Pubkey::new_rand(),
|
||||
solana_sdk::pubkey::new_rand(),
|
||||
Account::new(1_000_000_000, 0, &Pubkey::default()),
|
||||
)
|
||||
})
|
||||
@@ -5911,7 +5920,7 @@ mod tests {
|
||||
accounts: (0..42)
|
||||
.map(|_| {
|
||||
(
|
||||
Pubkey::new_rand(),
|
||||
solana_sdk::pubkey::new_rand(),
|
||||
Account::new(1_000_000_000, 0, &Pubkey::default()),
|
||||
)
|
||||
})
|
||||
@@ -5938,8 +5947,9 @@ mod tests {
|
||||
assert_eq!(bank.capitalization(), 42 * 1_000_000_000);
|
||||
assert!(bank.rewards.read().unwrap().is_empty());
|
||||
|
||||
let vote_id = Pubkey::new_rand();
|
||||
let mut vote_account = vote_state::create_account(&vote_id, &Pubkey::new_rand(), 50, 100);
|
||||
let vote_id = solana_sdk::pubkey::new_rand();
|
||||
let mut vote_account =
|
||||
vote_state::create_account(&vote_id, &solana_sdk::pubkey::new_rand(), 50, 100);
|
||||
let (stake_id1, stake_account1) = crate::stakes::tests::create_stake_account(123, &vote_id);
|
||||
let (stake_id2, stake_account2) = crate::stakes::tests::create_stake_account(456, &vote_id);
|
||||
|
||||
@@ -6014,7 +6024,7 @@ mod tests {
|
||||
let mut bank = parent;
|
||||
for _ in 0..10 {
|
||||
let blockhash = bank.last_blockhash();
|
||||
let pubkey = Pubkey::new_rand();
|
||||
let pubkey = solana_sdk::pubkey::new_rand();
|
||||
let tx = system_transaction::transfer(&mint_keypair, &pubkey, 0, blockhash);
|
||||
bank.process_transaction(&tx).unwrap();
|
||||
bank.squash();
|
||||
@@ -6032,7 +6042,7 @@ mod tests {
|
||||
bank0.process_transaction(&tx).unwrap();
|
||||
|
||||
let bank1 = Arc::new(new_from_parent(&bank0));
|
||||
let pubkey = Pubkey::new_rand();
|
||||
let pubkey = solana_sdk::pubkey::new_rand();
|
||||
let blockhash = bank.last_blockhash();
|
||||
let tx = system_transaction::transfer(&keypair, &pubkey, 10, blockhash);
|
||||
bank1.process_transaction(&tx).unwrap();
|
||||
@@ -6075,7 +6085,7 @@ mod tests {
|
||||
#[test]
|
||||
fn test_two_payments_to_one_party() {
|
||||
let (genesis_config, mint_keypair) = create_genesis_config(10_000);
|
||||
let pubkey = Pubkey::new_rand();
|
||||
let pubkey = solana_sdk::pubkey::new_rand();
|
||||
let bank = Bank::new(&genesis_config);
|
||||
assert_eq!(bank.last_blockhash(), genesis_config.hash());
|
||||
|
||||
@@ -6090,8 +6100,8 @@ mod tests {
|
||||
#[test]
|
||||
fn test_one_source_two_tx_one_batch() {
|
||||
let (genesis_config, mint_keypair) = create_genesis_config(1);
|
||||
let key1 = Pubkey::new_rand();
|
||||
let key2 = Pubkey::new_rand();
|
||||
let key1 = solana_sdk::pubkey::new_rand();
|
||||
let key2 = solana_sdk::pubkey::new_rand();
|
||||
let bank = Bank::new(&genesis_config);
|
||||
assert_eq!(bank.last_blockhash(), genesis_config.hash());
|
||||
|
||||
@@ -6114,8 +6124,8 @@ mod tests {
|
||||
#[test]
|
||||
fn test_one_tx_two_out_atomic_fail() {
|
||||
let (genesis_config, mint_keypair) = create_genesis_config(1);
|
||||
let key1 = Pubkey::new_rand();
|
||||
let key2 = Pubkey::new_rand();
|
||||
let key1 = solana_sdk::pubkey::new_rand();
|
||||
let key2 = solana_sdk::pubkey::new_rand();
|
||||
let bank = Bank::new(&genesis_config);
|
||||
let instructions =
|
||||
system_instruction::transfer_many(&mint_keypair.pubkey(), &[(key1, 1), (key2, 1)]);
|
||||
@@ -6133,8 +6143,8 @@ mod tests {
|
||||
#[test]
|
||||
fn test_one_tx_two_out_atomic_pass() {
|
||||
let (genesis_config, mint_keypair) = create_genesis_config(2);
|
||||
let key1 = Pubkey::new_rand();
|
||||
let key2 = Pubkey::new_rand();
|
||||
let key1 = solana_sdk::pubkey::new_rand();
|
||||
let key2 = solana_sdk::pubkey::new_rand();
|
||||
let bank = Bank::new(&genesis_config);
|
||||
let instructions =
|
||||
system_instruction::transfer_many(&mint_keypair.pubkey(), &[(key1, 1), (key2, 1)]);
|
||||
@@ -6193,7 +6203,7 @@ mod tests {
|
||||
fn test_insufficient_funds() {
|
||||
let (genesis_config, mint_keypair) = create_genesis_config(11_000);
|
||||
let bank = Bank::new(&genesis_config);
|
||||
let pubkey = Pubkey::new_rand();
|
||||
let pubkey = solana_sdk::pubkey::new_rand();
|
||||
bank.transfer(1_000, &mint_keypair, &pubkey).unwrap();
|
||||
assert_eq!(bank.transaction_count(), 1);
|
||||
assert_eq!(bank.get_balance(&pubkey), 1_000);
|
||||
@@ -6216,7 +6226,7 @@ mod tests {
|
||||
solana_logger::setup();
|
||||
let (genesis_config, mint_keypair) = create_genesis_config(10_000);
|
||||
let bank = Bank::new(&genesis_config);
|
||||
let pubkey = Pubkey::new_rand();
|
||||
let pubkey = solana_sdk::pubkey::new_rand();
|
||||
bank.transfer(500, &mint_keypair, &pubkey).unwrap();
|
||||
assert_eq!(bank.get_balance(&pubkey), 500);
|
||||
}
|
||||
@@ -6227,7 +6237,7 @@ mod tests {
|
||||
let (genesis_config, mint_keypair) = create_genesis_config(10_000);
|
||||
let bank = Arc::new(Bank::new(&genesis_config));
|
||||
|
||||
let normal_pubkey = Pubkey::new_rand();
|
||||
let normal_pubkey = solana_sdk::pubkey::new_rand();
|
||||
let sysvar_pubkey = sysvar::clock::id();
|
||||
assert_eq!(bank.get_balance(&normal_pubkey), 0);
|
||||
assert_eq!(bank.get_balance(&sysvar_pubkey), 1);
|
||||
@@ -6326,7 +6336,7 @@ mod tests {
|
||||
fn test_bank_tx_fee() {
|
||||
let arbitrary_transfer_amount = 42;
|
||||
let mint = arbitrary_transfer_amount * 100;
|
||||
let leader = Pubkey::new_rand();
|
||||
let leader = solana_sdk::pubkey::new_rand();
|
||||
let GenesisConfigInfo {
|
||||
mut genesis_config,
|
||||
mint_keypair,
|
||||
@@ -6424,7 +6434,7 @@ mod tests {
|
||||
fn test_bank_blockhash_fee_schedule() {
|
||||
//solana_logger::setup();
|
||||
|
||||
let leader = Pubkey::new_rand();
|
||||
let leader = solana_sdk::pubkey::new_rand();
|
||||
let GenesisConfigInfo {
|
||||
mut genesis_config,
|
||||
mint_keypair,
|
||||
@@ -6476,7 +6486,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_filter_program_errors_and_collect_fee() {
|
||||
let leader = Pubkey::new_rand();
|
||||
let leader = solana_sdk::pubkey::new_rand();
|
||||
let GenesisConfigInfo {
|
||||
mut genesis_config,
|
||||
mint_keypair,
|
||||
@@ -6548,12 +6558,12 @@ mod tests {
|
||||
genesis_config,
|
||||
mint_keypair,
|
||||
..
|
||||
} = create_genesis_config_with_leader(500, &Pubkey::new_rand(), 0);
|
||||
} = create_genesis_config_with_leader(500, &solana_sdk::pubkey::new_rand(), 0);
|
||||
let bank = Bank::new(&genesis_config);
|
||||
|
||||
let vote_pubkey0 = Pubkey::new_rand();
|
||||
let vote_pubkey1 = Pubkey::new_rand();
|
||||
let vote_pubkey2 = Pubkey::new_rand();
|
||||
let vote_pubkey0 = solana_sdk::pubkey::new_rand();
|
||||
let vote_pubkey1 = solana_sdk::pubkey::new_rand();
|
||||
let vote_pubkey2 = solana_sdk::pubkey::new_rand();
|
||||
let authorized_voter = Keypair::new();
|
||||
let payer0 = Keypair::new();
|
||||
let payer1 = Keypair::new();
|
||||
@@ -6607,7 +6617,7 @@ mod tests {
|
||||
);
|
||||
let tx1 = system_transaction::transfer(
|
||||
&authorized_voter,
|
||||
&Pubkey::new_rand(),
|
||||
&solana_sdk::pubkey::new_rand(),
|
||||
1,
|
||||
bank.last_blockhash(),
|
||||
);
|
||||
@@ -6666,7 +6676,7 @@ mod tests {
|
||||
let key0 = Keypair::new();
|
||||
let key1 = Keypair::new();
|
||||
let key2 = Keypair::new();
|
||||
let key3 = Pubkey::new_rand();
|
||||
let key3 = solana_sdk::pubkey::new_rand();
|
||||
|
||||
let message = Message {
|
||||
header: MessageHeader {
|
||||
@@ -6821,7 +6831,7 @@ mod tests {
|
||||
let initial_state = bank0.hash_internal_state();
|
||||
assert_eq!(bank1.hash_internal_state(), initial_state);
|
||||
|
||||
let pubkey = Pubkey::new_rand();
|
||||
let pubkey = solana_sdk::pubkey::new_rand();
|
||||
bank0.transfer(1_000, &mint_keypair, &pubkey).unwrap();
|
||||
assert_ne!(bank0.hash_internal_state(), initial_state);
|
||||
bank1.transfer(1_000, &mint_keypair, &pubkey).unwrap();
|
||||
@@ -6831,7 +6841,7 @@ mod tests {
|
||||
let bank2 = new_from_parent(&Arc::new(bank1));
|
||||
assert_ne!(bank0.hash_internal_state(), bank2.hash_internal_state());
|
||||
|
||||
let pubkey2 = Pubkey::new_rand();
|
||||
let pubkey2 = solana_sdk::pubkey::new_rand();
|
||||
info!("transfer 2 {}", pubkey2);
|
||||
bank2.transfer(10, &mint_keypair, &pubkey2).unwrap();
|
||||
bank2.update_accounts_hash();
|
||||
@@ -6844,14 +6854,14 @@ mod tests {
|
||||
let (genesis_config, mint_keypair) = create_genesis_config(2_000);
|
||||
let bank0 = Bank::new(&genesis_config);
|
||||
|
||||
let pubkey = Pubkey::new_rand();
|
||||
let pubkey = solana_sdk::pubkey::new_rand();
|
||||
info!("transfer 0 {} mint: {}", pubkey, mint_keypair.pubkey());
|
||||
bank0.transfer(1_000, &mint_keypair, &pubkey).unwrap();
|
||||
|
||||
let bank0_state = bank0.hash_internal_state();
|
||||
let bank0 = Arc::new(bank0);
|
||||
// Checkpointing should result in a new state while freezing the parent
|
||||
let bank2 = Bank::new_from_parent(&bank0, &Pubkey::new_rand(), 1);
|
||||
let bank2 = Bank::new_from_parent(&bank0, &solana_sdk::pubkey::new_rand(), 1);
|
||||
assert_ne!(bank0_state, bank2.hash_internal_state());
|
||||
// Checkpointing should modify the checkpoint's state when freezed
|
||||
assert_ne!(bank0_state, bank0.hash_internal_state());
|
||||
@@ -6860,13 +6870,13 @@ mod tests {
|
||||
let bank0_state = bank0.hash_internal_state();
|
||||
bank2.update_accounts_hash();
|
||||
assert!(bank2.verify_bank_hash());
|
||||
let bank3 = Bank::new_from_parent(&bank0, &Pubkey::new_rand(), 2);
|
||||
let bank3 = Bank::new_from_parent(&bank0, &solana_sdk::pubkey::new_rand(), 2);
|
||||
assert_eq!(bank0_state, bank0.hash_internal_state());
|
||||
assert!(bank2.verify_bank_hash());
|
||||
bank3.update_accounts_hash();
|
||||
assert!(bank3.verify_bank_hash());
|
||||
|
||||
let pubkey2 = Pubkey::new_rand();
|
||||
let pubkey2 = solana_sdk::pubkey::new_rand();
|
||||
info!("transfer 2 {}", pubkey2);
|
||||
bank2.transfer(10, &mint_keypair, &pubkey2).unwrap();
|
||||
bank2.update_accounts_hash();
|
||||
@@ -6884,7 +6894,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_verify_snapshot_bank() {
|
||||
let pubkey = Pubkey::new_rand();
|
||||
let pubkey = solana_sdk::pubkey::new_rand();
|
||||
let (genesis_config, mint_keypair) = create_genesis_config(2_000);
|
||||
let bank = Bank::new(&genesis_config);
|
||||
bank.transfer(1_000, &mint_keypair, &pubkey).unwrap();
|
||||
@@ -6908,7 +6918,7 @@ mod tests {
|
||||
assert_ne!(bank1.hash_internal_state(), initial_state);
|
||||
|
||||
info!("transfer bank1");
|
||||
let pubkey = Pubkey::new_rand();
|
||||
let pubkey = solana_sdk::pubkey::new_rand();
|
||||
bank1.transfer(1_000, &mint_keypair, &pubkey).unwrap();
|
||||
assert_ne!(bank1.hash_internal_state(), initial_state);
|
||||
|
||||
@@ -6935,8 +6945,8 @@ mod tests {
|
||||
let bank0 = Bank::new(&genesis_config);
|
||||
let bank1 = Bank::new(&genesis_config);
|
||||
assert_eq!(bank0.hash_internal_state(), bank1.hash_internal_state());
|
||||
let key0 = Pubkey::new_rand();
|
||||
let key1 = Pubkey::new_rand();
|
||||
let key0 = solana_sdk::pubkey::new_rand();
|
||||
let key1 = solana_sdk::pubkey::new_rand();
|
||||
bank0.transfer(10, &mint_keypair, &key0).unwrap();
|
||||
bank0.transfer(20, &mint_keypair, &key1).unwrap();
|
||||
|
||||
@@ -6951,7 +6961,7 @@ mod tests {
|
||||
solana_logger::setup();
|
||||
let (genesis_config, mint_keypair) = create_genesis_config(100);
|
||||
let bank = Bank::new(&genesis_config);
|
||||
let key0 = Pubkey::new_rand();
|
||||
let key0 = solana_sdk::pubkey::new_rand();
|
||||
bank.transfer(10, &mint_keypair, &key0).unwrap();
|
||||
let orig = bank.hash_internal_state();
|
||||
|
||||
@@ -7108,7 +7118,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_bank_get_account_modified_since_parent() {
|
||||
let pubkey = Pubkey::new_rand();
|
||||
let pubkey = solana_sdk::pubkey::new_rand();
|
||||
|
||||
let (genesis_config, mint_keypair) = create_genesis_config(500);
|
||||
let bank1 = Arc::new(Bank::new(&genesis_config));
|
||||
@@ -7143,7 +7153,7 @@ mod tests {
|
||||
fn test_bank_update_sysvar_account() {
|
||||
use sysvar::clock::Clock;
|
||||
|
||||
let dummy_clock_id = Pubkey::new_rand();
|
||||
let dummy_clock_id = solana_sdk::pubkey::new_rand();
|
||||
let (genesis_config, _mint_keypair) = create_genesis_config(500);
|
||||
|
||||
let expected_previous_slot = 3;
|
||||
@@ -7208,7 +7218,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_bank_epoch_vote_accounts() {
|
||||
let leader_pubkey = Pubkey::new_rand();
|
||||
let leader_pubkey = solana_sdk::pubkey::new_rand();
|
||||
let leader_lamports = 3;
|
||||
let mut genesis_config =
|
||||
create_genesis_config_with_leader(5, &leader_pubkey, leader_lamports).genesis_config;
|
||||
@@ -7389,9 +7399,13 @@ mod tests {
|
||||
let bank0 = Arc::new(Bank::new(&genesis_config));
|
||||
|
||||
// Bank 1
|
||||
let bank1 = Arc::new(Bank::new_from_parent(&bank0, &Pubkey::new_rand(), 1));
|
||||
let bank1 = Arc::new(Bank::new_from_parent(
|
||||
&bank0,
|
||||
&solana_sdk::pubkey::new_rand(),
|
||||
1,
|
||||
));
|
||||
// Bank 2
|
||||
let bank2 = Bank::new_from_parent(&bank0, &Pubkey::new_rand(), 2);
|
||||
let bank2 = Bank::new_from_parent(&bank0, &solana_sdk::pubkey::new_rand(), 2);
|
||||
|
||||
// transfer a token
|
||||
assert_eq!(
|
||||
@@ -7414,7 +7428,7 @@ mod tests {
|
||||
assert_eq!(bank2.transaction_count(), 0);
|
||||
assert_eq!(bank1.transaction_count(), 1);
|
||||
|
||||
let bank6 = Bank::new_from_parent(&bank1, &Pubkey::new_rand(), 3);
|
||||
let bank6 = Bank::new_from_parent(&bank1, &solana_sdk::pubkey::new_rand(), 3);
|
||||
assert_eq!(bank1.transaction_count(), 1);
|
||||
assert_eq!(bank6.transaction_count(), 1);
|
||||
|
||||
@@ -7446,7 +7460,7 @@ mod tests {
|
||||
genesis_config,
|
||||
mint_keypair,
|
||||
..
|
||||
} = create_genesis_config_with_leader(500, &Pubkey::new_rand(), 1);
|
||||
} = create_genesis_config_with_leader(500, &solana_sdk::pubkey::new_rand(), 1);
|
||||
let bank = Arc::new(Bank::new(&genesis_config));
|
||||
|
||||
let vote_accounts = bank.vote_accounts();
|
||||
@@ -7494,7 +7508,7 @@ mod tests {
|
||||
genesis_config,
|
||||
mint_keypair,
|
||||
..
|
||||
} = create_genesis_config_with_leader(500, &Pubkey::new_rand(), 1);
|
||||
} = create_genesis_config_with_leader(500, &solana_sdk::pubkey::new_rand(), 1);
|
||||
let bank = Arc::new(Bank::new(&genesis_config));
|
||||
|
||||
let stake_delegations = bank.stake_delegations();
|
||||
@@ -7578,7 +7592,7 @@ mod tests {
|
||||
// Should fail with InstructionError, but InstructionErrors are committable,
|
||||
// so is_delta should be true
|
||||
assert_eq!(
|
||||
bank.transfer(10_001, &mint_keypair, &Pubkey::new_rand()),
|
||||
bank.transfer(10_001, &mint_keypair, &solana_sdk::pubkey::new_rand()),
|
||||
Err(TransactionError::InstructionError(
|
||||
0,
|
||||
SystemError::ResultWithNegativeLamports.into(),
|
||||
@@ -7609,7 +7623,7 @@ mod tests {
|
||||
);
|
||||
|
||||
let bank0 = Arc::new(new_from_parent(&parent));
|
||||
let pubkey0 = Pubkey::new_rand();
|
||||
let pubkey0 = solana_sdk::pubkey::new_rand();
|
||||
let program_id = Pubkey::new(&[2; 32]);
|
||||
let account0 = Account::new(1, 0, &program_id);
|
||||
bank0.store_account(&pubkey0, &account0);
|
||||
@@ -7635,11 +7649,11 @@ mod tests {
|
||||
);
|
||||
|
||||
let bank2 = Arc::new(new_from_parent(&bank1));
|
||||
let pubkey1 = Pubkey::new_rand();
|
||||
let pubkey1 = solana_sdk::pubkey::new_rand();
|
||||
let account1 = Account::new(3, 0, &program_id);
|
||||
bank2.store_account(&pubkey1, &account1);
|
||||
// Accounts with 0 lamports should be filtered out by Accounts::load_by_program()
|
||||
let pubkey2 = Pubkey::new_rand();
|
||||
let pubkey2 = solana_sdk::pubkey::new_rand();
|
||||
let account2 = Account::new(0, 0, &program_id);
|
||||
bank2.store_account(&pubkey2, &account2);
|
||||
|
||||
@@ -7729,7 +7743,7 @@ mod tests {
|
||||
genesis_config,
|
||||
mint_keypair,
|
||||
..
|
||||
} = create_genesis_config_with_leader(500, &Pubkey::new_rand(), 0);
|
||||
} = create_genesis_config_with_leader(500, &solana_sdk::pubkey::new_rand(), 0);
|
||||
let mut bank = Bank::new(&genesis_config);
|
||||
|
||||
fn mock_vote_processor(
|
||||
@@ -7899,7 +7913,7 @@ mod tests {
|
||||
const LOTSA: usize = 4_096;
|
||||
|
||||
(0..LOTSA).for_each(|_| {
|
||||
let pubkey = Pubkey::new_rand();
|
||||
let pubkey = solana_sdk::pubkey::new_rand();
|
||||
genesis_config.add_account(
|
||||
pubkey,
|
||||
solana_stake_program::stake_state::create_lockup_stake_account(
|
||||
@@ -8304,7 +8318,11 @@ mod tests {
|
||||
let nonce_tx = Transaction::new_signed_with_payer(
|
||||
&[
|
||||
system_instruction::advance_nonce_account(&nonce_pubkey, &nonce_pubkey),
|
||||
system_instruction::transfer(&custodian_pubkey, &Pubkey::new_rand(), 100_000),
|
||||
system_instruction::transfer(
|
||||
&custodian_pubkey,
|
||||
&solana_sdk::pubkey::new_rand(),
|
||||
100_000,
|
||||
),
|
||||
],
|
||||
Some(&custodian_pubkey),
|
||||
&[&custodian_keypair, &nonce_keypair],
|
||||
@@ -8338,8 +8356,8 @@ mod tests {
|
||||
let bank0 = Arc::new(new_from_parent(&parent));
|
||||
|
||||
let keypair = Keypair::new();
|
||||
let pubkey0 = Pubkey::new_rand();
|
||||
let pubkey1 = Pubkey::new_rand();
|
||||
let pubkey0 = solana_sdk::pubkey::new_rand();
|
||||
let pubkey1 = solana_sdk::pubkey::new_rand();
|
||||
let program_id = Pubkey::new(&[2; 32]);
|
||||
let keypair_account = Account::new(8, 0, &program_id);
|
||||
let account0 = Account::new(11, 0, &program_id);
|
||||
@@ -8390,9 +8408,9 @@ mod tests {
|
||||
|
||||
let keypair0 = Keypair::new();
|
||||
let keypair1 = Keypair::new();
|
||||
let pubkey0 = Pubkey::new_rand();
|
||||
let pubkey1 = Pubkey::new_rand();
|
||||
let pubkey2 = Pubkey::new_rand();
|
||||
let pubkey0 = solana_sdk::pubkey::new_rand();
|
||||
let pubkey1 = solana_sdk::pubkey::new_rand();
|
||||
let pubkey2 = solana_sdk::pubkey::new_rand();
|
||||
let keypair0_account = Account::new(8, 0, &Pubkey::default());
|
||||
let keypair1_account = Account::new(9, 0, &Pubkey::default());
|
||||
let account0 = Account::new(11, 0, &&Pubkey::default());
|
||||
@@ -8465,8 +8483,8 @@ mod tests {
|
||||
let mock_program_id = Pubkey::new(&[2u8; 32]);
|
||||
bank.add_builtin_program("mock_program", mock_program_id, mock_process_instruction);
|
||||
|
||||
let from_pubkey = Pubkey::new_rand();
|
||||
let to_pubkey = Pubkey::new_rand();
|
||||
let from_pubkey = solana_sdk::pubkey::new_rand();
|
||||
let to_pubkey = solana_sdk::pubkey::new_rand();
|
||||
let dup_pubkey = from_pubkey;
|
||||
let from_account = Account::new(100, 1, &mock_program_id);
|
||||
let to_account = Account::new(0, 1, &mock_program_id);
|
||||
@@ -8508,8 +8526,8 @@ mod tests {
|
||||
let mock_program_id = Pubkey::new(&[2u8; 32]);
|
||||
bank.add_builtin_program("mock_program", mock_program_id, mock_process_instruction);
|
||||
|
||||
let from_pubkey = Pubkey::new_rand();
|
||||
let to_pubkey = Pubkey::new_rand();
|
||||
let from_pubkey = solana_sdk::pubkey::new_rand();
|
||||
let to_pubkey = solana_sdk::pubkey::new_rand();
|
||||
let dup_pubkey = from_pubkey;
|
||||
let from_account = Account::new(100, 1, &mock_program_id);
|
||||
let to_account = Account::new(0, 1, &mock_program_id);
|
||||
@@ -8540,8 +8558,8 @@ mod tests {
|
||||
let (genesis_config, mint_keypair) = create_genesis_config(500);
|
||||
let mut bank = Bank::new(&genesis_config);
|
||||
|
||||
let from_pubkey = Pubkey::new_rand();
|
||||
let to_pubkey = Pubkey::new_rand();
|
||||
let from_pubkey = solana_sdk::pubkey::new_rand();
|
||||
let to_pubkey = solana_sdk::pubkey::new_rand();
|
||||
|
||||
let account_metas = vec![
|
||||
AccountMeta::new(from_pubkey, false),
|
||||
@@ -8556,7 +8574,7 @@ mod tests {
|
||||
bank.last_blockhash(),
|
||||
);
|
||||
|
||||
tx.message.account_keys.push(Pubkey::new_rand());
|
||||
tx.message.account_keys.push(solana_sdk::pubkey::new_rand());
|
||||
|
||||
bank.add_builtin_program(
|
||||
"mock_vote",
|
||||
@@ -8604,8 +8622,8 @@ mod tests {
|
||||
let (genesis_config, mint_keypair) = create_genesis_config(500);
|
||||
let mut bank = Bank::new(&genesis_config);
|
||||
|
||||
let from_pubkey = Pubkey::new_rand();
|
||||
let to_pubkey = Pubkey::new_rand();
|
||||
let from_pubkey = solana_sdk::pubkey::new_rand();
|
||||
let to_pubkey = solana_sdk::pubkey::new_rand();
|
||||
|
||||
let account_metas = vec![
|
||||
AccountMeta::new(from_pubkey, false),
|
||||
@@ -8637,8 +8655,8 @@ mod tests {
|
||||
let (genesis_config, mint_keypair) = create_genesis_config(500);
|
||||
let mut bank = Bank::new(&genesis_config);
|
||||
|
||||
let from_pubkey = Pubkey::new_rand();
|
||||
let to_pubkey = Pubkey::new_rand();
|
||||
let from_pubkey = solana_sdk::pubkey::new_rand();
|
||||
let to_pubkey = solana_sdk::pubkey::new_rand();
|
||||
|
||||
let account_metas = vec![
|
||||
AccountMeta::new(from_pubkey, false),
|
||||
@@ -8692,8 +8710,8 @@ mod tests {
|
||||
let (genesis_config, mint_keypair) = create_genesis_config(500);
|
||||
let mut bank = Bank::new(&genesis_config);
|
||||
|
||||
let from_pubkey = Pubkey::new_rand();
|
||||
let to_pubkey = Pubkey::new_rand();
|
||||
let from_pubkey = solana_sdk::pubkey::new_rand();
|
||||
let to_pubkey = solana_sdk::pubkey::new_rand();
|
||||
|
||||
let account_metas = vec![
|
||||
AccountMeta::new(from_pubkey, false),
|
||||
@@ -8714,7 +8732,7 @@ mod tests {
|
||||
bank.last_blockhash(),
|
||||
);
|
||||
|
||||
tx.message.account_keys.push(Pubkey::new_rand());
|
||||
tx.message.account_keys.push(solana_sdk::pubkey::new_rand());
|
||||
assert_eq!(tx.message.account_keys.len(), 5);
|
||||
tx.message.instructions[0].accounts.remove(0);
|
||||
tx.message.instructions[0].accounts.push(4);
|
||||
@@ -8734,7 +8752,7 @@ mod tests {
|
||||
let program_keys: Vec<_> = (0..max_programs)
|
||||
.enumerate()
|
||||
.map(|i| {
|
||||
let key = Pubkey::new_rand();
|
||||
let key = solana_sdk::pubkey::new_rand();
|
||||
let name = format!("program{:?}", i);
|
||||
bank.add_builtin_program(&name, key, mock_ok_vote_processor);
|
||||
(key, name.as_bytes().to_vec())
|
||||
@@ -8744,7 +8762,7 @@ mod tests {
|
||||
let keys: Vec<_> = (0..max_keys)
|
||||
.enumerate()
|
||||
.map(|_| {
|
||||
let key = Pubkey::new_rand();
|
||||
let key = solana_sdk::pubkey::new_rand();
|
||||
let balance = if thread_rng().gen_ratio(9, 10) {
|
||||
let lamports = if thread_rng().gen_ratio(1, 5) {
|
||||
thread_rng().gen_range(0, 10)
|
||||
@@ -8942,11 +8960,11 @@ mod tests {
|
||||
let mut bank = Bank::new(&genesis_config);
|
||||
|
||||
// Add a new program
|
||||
let program1_pubkey = Pubkey::new_rand();
|
||||
let program1_pubkey = solana_sdk::pubkey::new_rand();
|
||||
bank.add_builtin_program("program", program1_pubkey, nested_processor);
|
||||
|
||||
// Add a new program owned by the first
|
||||
let program2_pubkey = Pubkey::new_rand();
|
||||
let program2_pubkey = solana_sdk::pubkey::new_rand();
|
||||
let mut program2_account = Account::new(42, 1, &program1_pubkey);
|
||||
program2_account.executable = true;
|
||||
bank.store_account(&program2_pubkey, &program2_account);
|
||||
@@ -8968,8 +8986,8 @@ mod tests {
|
||||
solana_logger::setup();
|
||||
|
||||
let (genesis_config, _mint_keypair) = create_genesis_config(1_000_000_000);
|
||||
let pubkey1 = Pubkey::new_rand();
|
||||
let pubkey2 = Pubkey::new_rand();
|
||||
let pubkey1 = solana_sdk::pubkey::new_rand();
|
||||
let pubkey2 = solana_sdk::pubkey::new_rand();
|
||||
|
||||
let mut bank = Arc::new(Bank::new(&genesis_config));
|
||||
bank.lazy_rent_collection.store(true, Relaxed);
|
||||
@@ -9018,7 +9036,7 @@ mod tests {
|
||||
mut genesis_config,
|
||||
mint_keypair,
|
||||
..
|
||||
} = create_genesis_config_with_leader(500, &Pubkey::new_rand(), 0);
|
||||
} = create_genesis_config_with_leader(500, &solana_sdk::pubkey::new_rand(), 0);
|
||||
genesis_config.fee_rate_governor = FeeRateGovernor::new(1, 0);
|
||||
let bank = Arc::new(Bank::new(&genesis_config));
|
||||
|
||||
@@ -9040,7 +9058,7 @@ mod tests {
|
||||
);
|
||||
assert_eq!(bank.get_balance(&mint_keypair.pubkey()), 500); // no transaction fee charged
|
||||
|
||||
let vote_pubkey = Pubkey::new_rand();
|
||||
let vote_pubkey = solana_sdk::pubkey::new_rand();
|
||||
let authorized_voter = Keypair::new();
|
||||
|
||||
// VoteInstruction::Vote is allowed. The transaction fails with a vote program instruction
|
||||
@@ -9117,7 +9135,7 @@ mod tests {
|
||||
}
|
||||
|
||||
let slot = 123;
|
||||
let program_id = Pubkey::new_rand();
|
||||
let program_id = solana_sdk::pubkey::new_rand();
|
||||
|
||||
let mut bank = Arc::new(Bank::new_from_parent(
|
||||
&Arc::new(Bank::new(&genesis_config)),
|
||||
@@ -9156,7 +9174,7 @@ mod tests {
|
||||
}
|
||||
|
||||
let slot = 123;
|
||||
let loader_id = Pubkey::new_rand();
|
||||
let loader_id = solana_sdk::pubkey::new_rand();
|
||||
|
||||
let mut bank = Arc::new(Bank::new_from_parent(
|
||||
&Arc::new(Bank::new(&genesis_config)),
|
||||
@@ -9186,7 +9204,7 @@ mod tests {
|
||||
let (genesis_config, _mint_keypair) = create_genesis_config(100_000);
|
||||
|
||||
let slot = 123;
|
||||
let program_id = Pubkey::new_rand();
|
||||
let program_id = solana_sdk::pubkey::new_rand();
|
||||
|
||||
let mut bank = Arc::new(Bank::new_from_parent(
|
||||
&Arc::new(Bank::new(&genesis_config)),
|
||||
@@ -9237,7 +9255,7 @@ mod tests {
|
||||
solana_logger::setup();
|
||||
|
||||
let mut genesis_config =
|
||||
create_genesis_config_with_leader(5, &Pubkey::new_rand(), 0).genesis_config;
|
||||
create_genesis_config_with_leader(5, &solana_sdk::pubkey::new_rand(), 0).genesis_config;
|
||||
|
||||
// ClusterType::Development - Native mint exists immediately
|
||||
assert_eq!(genesis_config.cluster_type, ClusterType::Development);
|
||||
@@ -9303,16 +9321,16 @@ mod tests {
|
||||
solana_logger::setup();
|
||||
|
||||
let mut genesis_config =
|
||||
create_genesis_config_with_leader(5, &Pubkey::new_rand(), 0).genesis_config;
|
||||
create_genesis_config_with_leader(5, &solana_sdk::pubkey::new_rand(), 0).genesis_config;
|
||||
|
||||
// Testnet - Storage rewards pool is purged at epoch 93
|
||||
// Also this is with bad capitalization
|
||||
genesis_config.cluster_type = ClusterType::Testnet;
|
||||
genesis_config.inflation = Inflation::default();
|
||||
let reward_pubkey = Pubkey::new_rand();
|
||||
let reward_pubkey = solana_sdk::pubkey::new_rand();
|
||||
genesis_config.rewards_pools.insert(
|
||||
reward_pubkey,
|
||||
Account::new(u64::MAX, 0, &Pubkey::new_rand()),
|
||||
Account::new(u64::MAX, 0, &solana_sdk::pubkey::new_rand()),
|
||||
);
|
||||
let bank0 = Bank::new(&genesis_config);
|
||||
// because capitalization has been reset with bogus capitalization calculation allowing overflows,
|
||||
@@ -9364,10 +9382,10 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_cached_executors() {
|
||||
let key1 = Pubkey::new_rand();
|
||||
let key2 = Pubkey::new_rand();
|
||||
let key3 = Pubkey::new_rand();
|
||||
let key4 = Pubkey::new_rand();
|
||||
let key1 = solana_sdk::pubkey::new_rand();
|
||||
let key2 = solana_sdk::pubkey::new_rand();
|
||||
let key3 = solana_sdk::pubkey::new_rand();
|
||||
let key4 = solana_sdk::pubkey::new_rand();
|
||||
let executor: Arc<dyn Executor> = Arc::new(TestExecutor {});
|
||||
let mut cache = CachedExecutors::new(3);
|
||||
|
||||
@@ -9404,10 +9422,10 @@ mod tests {
|
||||
let (genesis_config, _) = create_genesis_config(1);
|
||||
let bank = Bank::new(&genesis_config);
|
||||
|
||||
let key1 = Pubkey::new_rand();
|
||||
let key2 = Pubkey::new_rand();
|
||||
let key3 = Pubkey::new_rand();
|
||||
let key4 = Pubkey::new_rand();
|
||||
let key1 = solana_sdk::pubkey::new_rand();
|
||||
let key2 = solana_sdk::pubkey::new_rand();
|
||||
let key3 = solana_sdk::pubkey::new_rand();
|
||||
let key4 = solana_sdk::pubkey::new_rand();
|
||||
let executor: Arc<dyn Executor> = Arc::new(TestExecutor {});
|
||||
|
||||
let message = Message {
|
||||
@@ -9454,7 +9472,7 @@ mod tests {
|
||||
assert!(executors.borrow().executors.contains_key(&key4));
|
||||
|
||||
// Check inheritance
|
||||
let bank = Bank::new_from_parent(&Arc::new(bank), &Pubkey::new_rand(), 1);
|
||||
let bank = Bank::new_from_parent(&Arc::new(bank), &solana_sdk::pubkey::new_rand(), 1);
|
||||
let executors = bank.get_executors(&message, loaders);
|
||||
assert_eq!(executors.borrow().executors.len(), 4);
|
||||
assert!(executors.borrow().executors.contains_key(&key1));
|
||||
@@ -9481,8 +9499,8 @@ mod tests {
|
||||
let (genesis_config, _) = create_genesis_config(1);
|
||||
let root = Arc::new(Bank::new(&genesis_config));
|
||||
|
||||
let key1 = Pubkey::new_rand();
|
||||
let key2 = Pubkey::new_rand();
|
||||
let key1 = solana_sdk::pubkey::new_rand();
|
||||
let key2 = solana_sdk::pubkey::new_rand();
|
||||
let executor: Arc<dyn Executor> = Arc::new(TestExecutor {});
|
||||
|
||||
let loaders = &[vec![(key1, Account::default()), (key2, Account::default())]];
|
||||
@@ -9665,7 +9683,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_timestamp_correction_feature() {
|
||||
let leader_pubkey = Pubkey::new_rand();
|
||||
let leader_pubkey = solana_sdk::pubkey::new_rand();
|
||||
let GenesisConfigInfo {
|
||||
mut genesis_config,
|
||||
voting_keypair,
|
||||
@@ -9718,7 +9736,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_update_clock_timestamp() {
|
||||
let leader_pubkey = Pubkey::new_rand();
|
||||
let leader_pubkey = solana_sdk::pubkey::new_rand();
|
||||
let GenesisConfigInfo {
|
||||
genesis_config,
|
||||
voting_keypair,
|
||||
@@ -9790,7 +9808,7 @@ mod tests {
|
||||
1,
|
||||
));
|
||||
|
||||
let zero_lamport_pubkey = Pubkey::new_rand();
|
||||
let zero_lamport_pubkey = solana_sdk::pubkey::new_rand();
|
||||
|
||||
bank1.add_account_and_update_capitalization(
|
||||
&zero_lamport_pubkey,
|
||||
@@ -9800,7 +9818,7 @@ mod tests {
|
||||
// (guaranteed because of large file size). We need this to ensure slot is
|
||||
// not cleaned up after clean is called, so that the bank hash still exists
|
||||
// when we call rehash() later in this test.
|
||||
let large_account_pubkey = Pubkey::new_rand();
|
||||
let large_account_pubkey = solana_sdk::pubkey::new_rand();
|
||||
bank1.add_account_and_update_capitalization(
|
||||
&large_account_pubkey,
|
||||
&Account::new(
|
||||
|
@@ -313,7 +313,7 @@ mod tests {
|
||||
let bank_client = BankClient::new(bank);
|
||||
|
||||
// Create 2-2 Multisig Transfer instruction.
|
||||
let bob_pubkey = Pubkey::new_rand();
|
||||
let bob_pubkey = solana_sdk::pubkey::new_rand();
|
||||
let mut transfer_instruction = system_instruction::transfer(&john_pubkey, &bob_pubkey, 42);
|
||||
transfer_instruction
|
||||
.accounts
|
||||
|
@@ -264,7 +264,7 @@ mod test {
|
||||
#[test]
|
||||
fn test_atomic_bloom() {
|
||||
let mut rng = rand::thread_rng();
|
||||
let hash_values: Vec<_> = std::iter::repeat_with(|| Hash::new_rand(&mut rng))
|
||||
let hash_values: Vec<_> = std::iter::repeat_with(|| solana_sdk::hash::new_rand(&mut rng))
|
||||
.take(1200)
|
||||
.collect();
|
||||
let bloom: AtomicBloom<_> = Bloom::<Hash>::random(1287, 0.1, 7424).into();
|
||||
@@ -279,7 +279,7 @@ mod test {
|
||||
for hash_value in hash_values {
|
||||
assert!(bloom.contains(&hash_value));
|
||||
}
|
||||
let false_positive = std::iter::repeat_with(|| Hash::new_rand(&mut rng))
|
||||
let false_positive = std::iter::repeat_with(|| solana_sdk::hash::new_rand(&mut rng))
|
||||
.take(10_000)
|
||||
.filter(|hash_value| bloom.contains(hash_value))
|
||||
.count();
|
||||
@@ -291,7 +291,7 @@ mod test {
|
||||
let mut rng = rand::thread_rng();
|
||||
let keys: Vec<_> = std::iter::repeat_with(|| rng.gen()).take(5).collect();
|
||||
let mut bloom = Bloom::<Hash>::new(9731, keys.clone());
|
||||
let hash_values: Vec<_> = std::iter::repeat_with(|| Hash::new_rand(&mut rng))
|
||||
let hash_values: Vec<_> = std::iter::repeat_with(|| solana_sdk::hash::new_rand(&mut rng))
|
||||
.take(1000)
|
||||
.collect();
|
||||
for hash_value in &hash_values {
|
||||
@@ -318,9 +318,10 @@ mod test {
|
||||
assert!(bloom.contains(hash_value));
|
||||
}
|
||||
// Round trip, inserting new hash values.
|
||||
let more_hash_values: Vec<_> = std::iter::repeat_with(|| Hash::new_rand(&mut rng))
|
||||
.take(1000)
|
||||
.collect();
|
||||
let more_hash_values: Vec<_> =
|
||||
std::iter::repeat_with(|| solana_sdk::hash::new_rand(&mut rng))
|
||||
.take(1000)
|
||||
.collect();
|
||||
let bloom: AtomicBloom<_> = bloom.into();
|
||||
assert_eq!(bloom.num_bits, 9731);
|
||||
assert_eq!(bloom.bits.len(), (9731 + 63) / 64);
|
||||
@@ -339,7 +340,7 @@ mod test {
|
||||
for hash_value in &more_hash_values {
|
||||
assert!(bloom.contains(hash_value));
|
||||
}
|
||||
let false_positive = std::iter::repeat_with(|| Hash::new_rand(&mut rng))
|
||||
let false_positive = std::iter::repeat_with(|| solana_sdk::hash::new_rand(&mut rng))
|
||||
.take(10_000)
|
||||
.filter(|hash_value| bloom.contains(hash_value))
|
||||
.count();
|
||||
|
@@ -129,13 +129,13 @@ pub(crate) mod tests {
|
||||
// Create some vote accounts for each pubkey
|
||||
let vote_accounts_map: HashMap<Pubkey, Vec<VoteAccountInfo>> = (0..10)
|
||||
.map(|_| {
|
||||
let node_id = Pubkey::new_rand();
|
||||
let node_id = solana_sdk::pubkey::new_rand();
|
||||
(
|
||||
node_id,
|
||||
iter::repeat_with(|| {
|
||||
let authorized_voter = Pubkey::new_rand();
|
||||
let authorized_voter = solana_sdk::pubkey::new_rand();
|
||||
VoteAccountInfo {
|
||||
vote_account: Pubkey::new_rand(),
|
||||
vote_account: solana_sdk::pubkey::new_rand(),
|
||||
account: create_account_with_authorized(
|
||||
&node_id,
|
||||
&authorized_voter,
|
||||
|
@@ -46,7 +46,7 @@ pub struct GenesisConfigInfo {
|
||||
}
|
||||
|
||||
pub fn create_genesis_config(mint_lamports: u64) -> GenesisConfigInfo {
|
||||
create_genesis_config_with_leader(mint_lamports, &Pubkey::new_rand(), 0)
|
||||
create_genesis_config_with_leader(mint_lamports, &solana_sdk::pubkey::new_rand(), 0)
|
||||
}
|
||||
|
||||
pub fn create_genesis_config_with_vote_accounts(
|
||||
@@ -117,7 +117,7 @@ pub fn create_genesis_config_with_leader(
|
||||
mint_lamports,
|
||||
bootstrap_validator_pubkey,
|
||||
&Keypair::new(),
|
||||
&Pubkey::new_rand(),
|
||||
&solana_sdk::pubkey::new_rand(),
|
||||
bootstrap_validator_stake_lamports,
|
||||
BOOTSTRAP_VALIDATOR_LAMPORTS,
|
||||
ClusterType::Development,
|
||||
|
@@ -762,8 +762,8 @@ mod tests {
|
||||
let mut pre_accounts = vec![];
|
||||
let mut accounts = vec![];
|
||||
for i in 0..MAX_DEPTH {
|
||||
program_ids.push(Pubkey::new_rand());
|
||||
keys.push(Pubkey::new_rand());
|
||||
program_ids.push(solana_sdk::pubkey::new_rand());
|
||||
keys.push(solana_sdk::pubkey::new_rand());
|
||||
accounts.push(Rc::new(RefCell::new(Account::new(
|
||||
i as u64,
|
||||
1,
|
||||
@@ -867,7 +867,10 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_verify_account_references() {
|
||||
let accounts = vec![(Pubkey::new_rand(), RefCell::new(Account::default()))];
|
||||
let accounts = vec![(
|
||||
solana_sdk::pubkey::new_rand(),
|
||||
RefCell::new(Account::default()),
|
||||
)];
|
||||
|
||||
assert!(MessageProcessor::verify_account_references(&accounts).is_ok());
|
||||
|
||||
@@ -890,7 +893,7 @@ mod tests {
|
||||
program_id: *program_id,
|
||||
rent: Rent::default(),
|
||||
pre: PreAccount::new(
|
||||
&Pubkey::new_rand(),
|
||||
&solana_sdk::pubkey::new_rand(),
|
||||
&Account {
|
||||
owner: *owner,
|
||||
lamports: std::u64::MAX,
|
||||
@@ -943,8 +946,8 @@ mod tests {
|
||||
#[test]
|
||||
fn test_verify_account_changes_owner() {
|
||||
let system_program_id = system_program::id();
|
||||
let alice_program_id = Pubkey::new_rand();
|
||||
let mallory_program_id = Pubkey::new_rand();
|
||||
let alice_program_id = solana_sdk::pubkey::new_rand();
|
||||
let mallory_program_id = solana_sdk::pubkey::new_rand();
|
||||
|
||||
assert_eq!(
|
||||
Change::new(&system_program_id, &system_program_id)
|
||||
@@ -995,8 +998,8 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_verify_account_changes_executable() {
|
||||
let owner = Pubkey::new_rand();
|
||||
let mallory_program_id = Pubkey::new_rand();
|
||||
let owner = solana_sdk::pubkey::new_rand();
|
||||
let mallory_program_id = solana_sdk::pubkey::new_rand();
|
||||
let system_program_id = system_program::id();
|
||||
|
||||
assert_eq!(
|
||||
@@ -1102,7 +1105,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_verify_account_changes_data_len() {
|
||||
let alice_program_id = Pubkey::new_rand();
|
||||
let alice_program_id = solana_sdk::pubkey::new_rand();
|
||||
|
||||
assert_eq!(
|
||||
Change::new(&system_program::id(), &system_program::id())
|
||||
@@ -1122,8 +1125,8 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_verify_account_changes_data() {
|
||||
let alice_program_id = Pubkey::new_rand();
|
||||
let mallory_program_id = Pubkey::new_rand();
|
||||
let alice_program_id = solana_sdk::pubkey::new_rand();
|
||||
let mallory_program_id = solana_sdk::pubkey::new_rand();
|
||||
|
||||
assert_eq!(
|
||||
Change::new(&alice_program_id, &alice_program_id)
|
||||
@@ -1151,7 +1154,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_verify_account_changes_rent_epoch() {
|
||||
let alice_program_id = Pubkey::new_rand();
|
||||
let alice_program_id = solana_sdk::pubkey::new_rand();
|
||||
|
||||
assert_eq!(
|
||||
Change::new(&alice_program_id, &system_program::id()).verify(),
|
||||
@@ -1169,8 +1172,8 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_verify_account_changes_deduct_lamports_and_reassign_account() {
|
||||
let alice_program_id = Pubkey::new_rand();
|
||||
let bob_program_id = Pubkey::new_rand();
|
||||
let alice_program_id = solana_sdk::pubkey::new_rand();
|
||||
let bob_program_id = solana_sdk::pubkey::new_rand();
|
||||
|
||||
// positive test of this capability
|
||||
assert_eq!(
|
||||
@@ -1186,7 +1189,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_verify_account_changes_lamports() {
|
||||
let alice_program_id = Pubkey::new_rand();
|
||||
let alice_program_id = solana_sdk::pubkey::new_rand();
|
||||
|
||||
assert_eq!(
|
||||
Change::new(&alice_program_id, &system_program::id())
|
||||
@@ -1224,7 +1227,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_verify_account_changes_data_size_changed() {
|
||||
let alice_program_id = Pubkey::new_rand();
|
||||
let alice_program_id = solana_sdk::pubkey::new_rand();
|
||||
|
||||
assert_eq!(
|
||||
Change::new(&alice_program_id, &system_program::id())
|
||||
@@ -1299,8 +1302,8 @@ mod tests {
|
||||
|
||||
let executors = Rc::new(RefCell::new(Executors::default()));
|
||||
|
||||
let from_pubkey = Pubkey::new_rand();
|
||||
let to_pubkey = Pubkey::new_rand();
|
||||
let from_pubkey = solana_sdk::pubkey::new_rand();
|
||||
let to_pubkey = solana_sdk::pubkey::new_rand();
|
||||
let account_metas = vec![
|
||||
AccountMeta::new(from_pubkey, true),
|
||||
AccountMeta::new_readonly(to_pubkey, false),
|
||||
@@ -1456,8 +1459,8 @@ mod tests {
|
||||
|
||||
let executors = Rc::new(RefCell::new(Executors::default()));
|
||||
|
||||
let from_pubkey = Pubkey::new_rand();
|
||||
let to_pubkey = Pubkey::new_rand();
|
||||
let from_pubkey = solana_sdk::pubkey::new_rand();
|
||||
let to_pubkey = solana_sdk::pubkey::new_rand();
|
||||
let dup_pubkey = from_pubkey;
|
||||
let account_metas = vec![
|
||||
AccountMeta::new(from_pubkey, true),
|
||||
@@ -1579,8 +1582,8 @@ mod tests {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
let caller_program_id = Pubkey::new_rand();
|
||||
let callee_program_id = Pubkey::new_rand();
|
||||
let caller_program_id = solana_sdk::pubkey::new_rand();
|
||||
let callee_program_id = solana_sdk::pubkey::new_rand();
|
||||
let mut message_processor = MessageProcessor::default();
|
||||
message_processor.add_program(callee_program_id, mock_process_instruction);
|
||||
|
||||
@@ -1588,12 +1591,12 @@ mod tests {
|
||||
program_account.executable = true;
|
||||
let executable_accounts = vec![(callee_program_id, RefCell::new(program_account))];
|
||||
|
||||
let owned_key = Pubkey::new_rand();
|
||||
let owned_key = solana_sdk::pubkey::new_rand();
|
||||
let owned_account = Account::new(42, 1, &callee_program_id);
|
||||
let owned_preaccount = PreAccount::new(&owned_key, &owned_account, false, true);
|
||||
|
||||
let not_owned_key = Pubkey::new_rand();
|
||||
let not_owned_account = Account::new(84, 1, &Pubkey::new_rand());
|
||||
let not_owned_key = solana_sdk::pubkey::new_rand();
|
||||
let not_owned_account = Account::new(84, 1, &solana_sdk::pubkey::new_rand());
|
||||
let not_owned_preaccount = PreAccount::new(¬_owned_key, ¬_owned_account, false, true);
|
||||
|
||||
#[allow(unused_mut)]
|
||||
@@ -1682,7 +1685,7 @@ mod tests {
|
||||
) -> Result<(), InstructionError> {
|
||||
Ok(())
|
||||
}
|
||||
let program_id = Pubkey::new_rand();
|
||||
let program_id = solana_sdk::pubkey::new_rand();
|
||||
message_processor.add_program(program_id, mock_process_instruction);
|
||||
message_processor.add_loader(program_id, mock_ix_processor);
|
||||
|
||||
|
@@ -138,7 +138,7 @@ mod tests {
|
||||
|
||||
// collect rent on a newly-created account
|
||||
let collected = rent_collector.collect_from_created_account(
|
||||
&Pubkey::new_rand(),
|
||||
&solana_sdk::pubkey::new_rand(),
|
||||
&mut created_account,
|
||||
true,
|
||||
);
|
||||
@@ -148,7 +148,7 @@ mod tests {
|
||||
|
||||
// collect rent on a already-existing account
|
||||
let collected = rent_collector.collect_from_existing_account(
|
||||
&Pubkey::new_rand(),
|
||||
&solana_sdk::pubkey::new_rand(),
|
||||
&mut existing_account,
|
||||
true,
|
||||
);
|
||||
@@ -168,7 +168,7 @@ mod tests {
|
||||
let huge_lamports = 123_456_789_012;
|
||||
let tiny_lamports = 789_012;
|
||||
let mut collected;
|
||||
let pubkey = Pubkey::new_rand();
|
||||
let pubkey = solana_sdk::pubkey::new_rand();
|
||||
|
||||
account.lamports = huge_lamports;
|
||||
assert_eq!(account.rent_epoch, 0);
|
||||
|
@@ -190,8 +190,9 @@ pub mod tests {
|
||||
|
||||
// set up some dummies for a staked node (( vote ) ( stake ))
|
||||
pub fn create_staked_node_accounts(stake: u64) -> ((Pubkey, Account), (Pubkey, Account)) {
|
||||
let vote_pubkey = Pubkey::new_rand();
|
||||
let vote_account = vote_state::create_account(&vote_pubkey, &Pubkey::new_rand(), 0, 1);
|
||||
let vote_pubkey = solana_sdk::pubkey::new_rand();
|
||||
let vote_account =
|
||||
vote_state::create_account(&vote_pubkey, &solana_sdk::pubkey::new_rand(), 0, 1);
|
||||
(
|
||||
(vote_pubkey, vote_account),
|
||||
create_stake_account(stake, &vote_pubkey),
|
||||
@@ -200,13 +201,13 @@ pub mod tests {
|
||||
|
||||
// add stake to a vote_pubkey ( stake )
|
||||
pub fn create_stake_account(stake: u64, vote_pubkey: &Pubkey) -> (Pubkey, Account) {
|
||||
let stake_pubkey = Pubkey::new_rand();
|
||||
let stake_pubkey = solana_sdk::pubkey::new_rand();
|
||||
(
|
||||
stake_pubkey,
|
||||
stake_state::create_account(
|
||||
&stake_pubkey,
|
||||
&vote_pubkey,
|
||||
&vote_state::create_account(&vote_pubkey, &Pubkey::new_rand(), 0, 1),
|
||||
&vote_state::create_account(&vote_pubkey, &solana_sdk::pubkey::new_rand(), 0, 1),
|
||||
&Rent::free(),
|
||||
stake,
|
||||
),
|
||||
@@ -217,8 +218,9 @@ pub mod tests {
|
||||
stake: u64,
|
||||
epoch: Epoch,
|
||||
) -> ((Pubkey, Account), (Pubkey, Account)) {
|
||||
let vote_pubkey = Pubkey::new_rand();
|
||||
let vote_account = vote_state::create_account(&vote_pubkey, &Pubkey::new_rand(), 0, 1);
|
||||
let vote_pubkey = solana_sdk::pubkey::new_rand();
|
||||
let vote_account =
|
||||
vote_state::create_account(&vote_pubkey, &solana_sdk::pubkey::new_rand(), 0, 1);
|
||||
(
|
||||
(vote_pubkey, vote_account),
|
||||
create_warming_stake_account(stake, epoch, &vote_pubkey),
|
||||
@@ -231,13 +233,13 @@ pub mod tests {
|
||||
epoch: Epoch,
|
||||
vote_pubkey: &Pubkey,
|
||||
) -> (Pubkey, Account) {
|
||||
let stake_pubkey = Pubkey::new_rand();
|
||||
let stake_pubkey = solana_sdk::pubkey::new_rand();
|
||||
(
|
||||
stake_pubkey,
|
||||
stake_state::create_account_with_activation_epoch(
|
||||
&stake_pubkey,
|
||||
&vote_pubkey,
|
||||
&vote_state::create_account(&vote_pubkey, &Pubkey::new_rand(), 0, 1),
|
||||
&vote_state::create_account(&vote_pubkey, &solana_sdk::pubkey::new_rand(), 0, 1),
|
||||
&Rent::free(),
|
||||
stake,
|
||||
epoch,
|
||||
|
@@ -399,8 +399,8 @@ mod tests {
|
||||
#[test]
|
||||
fn test_create_account() {
|
||||
let new_owner = Pubkey::new(&[9; 32]);
|
||||
let from = Pubkey::new_rand();
|
||||
let to = Pubkey::new_rand();
|
||||
let from = solana_sdk::pubkey::new_rand();
|
||||
let to = solana_sdk::pubkey::new_rand();
|
||||
let from_account = Account::new_ref(100, 0, &system_program::id());
|
||||
let to_account = Account::new_ref(0, 0, &Pubkey::default());
|
||||
|
||||
@@ -429,7 +429,7 @@ mod tests {
|
||||
#[test]
|
||||
fn test_create_account_with_seed() {
|
||||
let new_owner = Pubkey::new(&[9; 32]);
|
||||
let from = Pubkey::new_rand();
|
||||
let from = solana_sdk::pubkey::new_rand();
|
||||
let seed = "shiny pepper";
|
||||
let to = Pubkey::create_with_seed(&from, seed, &new_owner).unwrap();
|
||||
|
||||
@@ -462,10 +462,10 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_address_create_with_seed_mismatch() {
|
||||
let from = Pubkey::new_rand();
|
||||
let from = solana_sdk::pubkey::new_rand();
|
||||
let seed = "dull boy";
|
||||
let to = Pubkey::new_rand();
|
||||
let owner = Pubkey::new_rand();
|
||||
let to = solana_sdk::pubkey::new_rand();
|
||||
let owner = solana_sdk::pubkey::new_rand();
|
||||
|
||||
assert_eq!(
|
||||
Address::create(&to, Some((&from, seed, &owner))),
|
||||
@@ -476,7 +476,7 @@ mod tests {
|
||||
#[test]
|
||||
fn test_create_account_with_seed_missing_sig() {
|
||||
let new_owner = Pubkey::new(&[9; 32]);
|
||||
let from = Pubkey::new_rand();
|
||||
let from = solana_sdk::pubkey::new_rand();
|
||||
let seed = "dull boy";
|
||||
let to = Pubkey::create_with_seed(&from, seed, &new_owner).unwrap();
|
||||
|
||||
@@ -504,10 +504,10 @@ mod tests {
|
||||
fn test_create_with_zero_lamports() {
|
||||
// create account with zero lamports tranferred
|
||||
let new_owner = Pubkey::new(&[9; 32]);
|
||||
let from = Pubkey::new_rand();
|
||||
let from_account = Account::new_ref(100, 1, &Pubkey::new_rand()); // not from system account
|
||||
let from = solana_sdk::pubkey::new_rand();
|
||||
let from_account = Account::new_ref(100, 1, &solana_sdk::pubkey::new_rand()); // not from system account
|
||||
|
||||
let to = Pubkey::new_rand();
|
||||
let to = solana_sdk::pubkey::new_rand();
|
||||
let to_account = Account::new_ref(0, 0, &Pubkey::default());
|
||||
|
||||
assert_eq!(
|
||||
@@ -537,10 +537,10 @@ mod tests {
|
||||
fn test_create_negative_lamports() {
|
||||
// Attempt to create account with more lamports than remaining in from_account
|
||||
let new_owner = Pubkey::new(&[9; 32]);
|
||||
let from = Pubkey::new_rand();
|
||||
let from = solana_sdk::pubkey::new_rand();
|
||||
let from_account = Account::new_ref(100, 0, &system_program::id());
|
||||
|
||||
let to = Pubkey::new_rand();
|
||||
let to = solana_sdk::pubkey::new_rand();
|
||||
let to_account = Account::new_ref(0, 0, &Pubkey::default());
|
||||
|
||||
let result = create_account(
|
||||
@@ -558,9 +558,9 @@ mod tests {
|
||||
#[test]
|
||||
fn test_request_more_than_allowed_data_length() {
|
||||
let from_account = Account::new_ref(100, 0, &system_program::id());
|
||||
let from = Pubkey::new_rand();
|
||||
let from = solana_sdk::pubkey::new_rand();
|
||||
let to_account = Account::new_ref(0, 0, &system_program::id());
|
||||
let to = Pubkey::new_rand();
|
||||
let to = solana_sdk::pubkey::new_rand();
|
||||
|
||||
let signers = &[from, to].iter().cloned().collect::<HashSet<_>>();
|
||||
let address = &to.into();
|
||||
@@ -603,11 +603,11 @@ mod tests {
|
||||
fn test_create_already_in_use() {
|
||||
// Attempt to create system account in account already owned by another program
|
||||
let new_owner = Pubkey::new(&[9; 32]);
|
||||
let from = Pubkey::new_rand();
|
||||
let from = solana_sdk::pubkey::new_rand();
|
||||
let from_account = Account::new_ref(100, 0, &system_program::id());
|
||||
|
||||
let original_program_owner = Pubkey::new(&[5; 32]);
|
||||
let owned_key = Pubkey::new_rand();
|
||||
let owned_key = solana_sdk::pubkey::new_rand();
|
||||
let owned_account = Account::new_ref(0, 0, &original_program_owner);
|
||||
let unchanged_account = owned_account.clone();
|
||||
|
||||
@@ -667,10 +667,10 @@ mod tests {
|
||||
fn test_create_unsigned() {
|
||||
// Attempt to create an account without signing the transfer
|
||||
let new_owner = Pubkey::new(&[9; 32]);
|
||||
let from = Pubkey::new_rand();
|
||||
let from = solana_sdk::pubkey::new_rand();
|
||||
let from_account = Account::new_ref(100, 0, &system_program::id());
|
||||
|
||||
let owned_key = Pubkey::new_rand();
|
||||
let owned_key = solana_sdk::pubkey::new_rand();
|
||||
let owned_account = Account::new_ref(0, 0, &Pubkey::default());
|
||||
|
||||
let owned_address = owned_key.into();
|
||||
@@ -717,10 +717,10 @@ mod tests {
|
||||
#[test]
|
||||
fn test_create_sysvar_invalid_id() {
|
||||
// Attempt to create system account in account already owned by another program
|
||||
let from = Pubkey::new_rand();
|
||||
let from = solana_sdk::pubkey::new_rand();
|
||||
let from_account = Account::new_ref(100, 0, &system_program::id());
|
||||
|
||||
let to = Pubkey::new_rand();
|
||||
let to = solana_sdk::pubkey::new_rand();
|
||||
let to_account = Account::new_ref(0, 0, &system_program::id());
|
||||
|
||||
let signers = [from, to].iter().cloned().collect::<HashSet<_>>();
|
||||
@@ -744,10 +744,10 @@ mod tests {
|
||||
fn test_create_data_populated() {
|
||||
// Attempt to create system account in account with populated data
|
||||
let new_owner = Pubkey::new(&[9; 32]);
|
||||
let from = Pubkey::new_rand();
|
||||
let from = solana_sdk::pubkey::new_rand();
|
||||
let from_account = Account::new_ref(100, 0, &system_program::id());
|
||||
|
||||
let populated_key = Pubkey::new_rand();
|
||||
let populated_key = solana_sdk::pubkey::new_rand();
|
||||
let populated_account = Account {
|
||||
data: vec![0, 1, 2, 3],
|
||||
..Account::default()
|
||||
@@ -774,7 +774,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_create_from_account_is_nonce_fail() {
|
||||
let nonce = Pubkey::new_rand();
|
||||
let nonce = solana_sdk::pubkey::new_rand();
|
||||
let nonce_account = Account::new_ref_data(
|
||||
42,
|
||||
&nonce::state::Versions::new_current(nonce::State::Initialized(
|
||||
@@ -784,7 +784,7 @@ mod tests {
|
||||
)
|
||||
.unwrap();
|
||||
let from = KeyedAccount::new(&nonce, true, &nonce_account);
|
||||
let new = Pubkey::new_rand();
|
||||
let new = solana_sdk::pubkey::new_rand();
|
||||
|
||||
let new_account = Account::new_ref(0, 0, &system_program::id());
|
||||
|
||||
@@ -799,7 +799,7 @@ mod tests {
|
||||
&new_address,
|
||||
42,
|
||||
0,
|
||||
&Pubkey::new_rand(),
|
||||
&solana_sdk::pubkey::new_rand(),
|
||||
&signers
|
||||
),
|
||||
Err(InstructionError::InvalidArgument),
|
||||
@@ -810,7 +810,7 @@ mod tests {
|
||||
fn test_assign() {
|
||||
let new_owner = Pubkey::new(&[9; 32]);
|
||||
|
||||
let pubkey = Pubkey::new_rand();
|
||||
let pubkey = solana_sdk::pubkey::new_rand();
|
||||
let mut account = Account::new(100, 0, &system_program::id());
|
||||
|
||||
assert_eq!(
|
||||
@@ -843,7 +843,7 @@ mod tests {
|
||||
fn test_assign_to_sysvar() {
|
||||
let new_owner = sysvar::id();
|
||||
|
||||
let from = Pubkey::new_rand();
|
||||
let from = solana_sdk::pubkey::new_rand();
|
||||
let mut from_account = Account::new(100, 0, &system_program::id());
|
||||
|
||||
assert_eq!(
|
||||
@@ -861,13 +861,13 @@ mod tests {
|
||||
fn test_process_bogus_instruction() {
|
||||
// Attempt to assign with no accounts
|
||||
let instruction = SystemInstruction::Assign {
|
||||
owner: Pubkey::new_rand(),
|
||||
owner: solana_sdk::pubkey::new_rand(),
|
||||
};
|
||||
let data = serialize(&instruction).unwrap();
|
||||
let result = process_instruction(&system_program::id(), &[], &data);
|
||||
assert_eq!(result, Err(InstructionError::NotEnoughAccountKeys));
|
||||
|
||||
let from = Pubkey::new_rand();
|
||||
let from = solana_sdk::pubkey::new_rand();
|
||||
let from_account = Account::new_ref(100, 0, &system_program::id());
|
||||
// Attempt to transfer with no destination
|
||||
let instruction = SystemInstruction::Transfer { lamports: 0 };
|
||||
@@ -882,7 +882,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_transfer_lamports() {
|
||||
let from = Pubkey::new_rand();
|
||||
let from = solana_sdk::pubkey::new_rand();
|
||||
let from_account = Account::new_ref(100, 0, &Pubkey::new(&[2; 32])); // account owner should not matter
|
||||
let to = Pubkey::new(&[3; 32]);
|
||||
let to_account = Account::new_ref(1, 0, &to); // account owner should not matter
|
||||
@@ -910,7 +910,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_transfer_with_seed() {
|
||||
let base = Pubkey::new_rand();
|
||||
let base = solana_sdk::pubkey::new_rand();
|
||||
let base_account = Account::new_ref(100, 0, &Pubkey::new(&[2; 32])); // account owner should not matter
|
||||
let from_base_keyed_account = KeyedAccount::new(&base, true, &base_account);
|
||||
let from_seed = "42";
|
||||
@@ -966,7 +966,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_transfer_lamports_from_nonce_account_fail() {
|
||||
let from = Pubkey::new_rand();
|
||||
let from = solana_sdk::pubkey::new_rand();
|
||||
let from_account = Account::new_ref_data(
|
||||
100,
|
||||
&nonce::state::Versions::new_current(nonce::State::Initialized(nonce::state::Data {
|
||||
@@ -1002,7 +1002,7 @@ mod tests {
|
||||
let alice_keypair = Keypair::new();
|
||||
let alice_pubkey = alice_keypair.pubkey();
|
||||
let seed = "seed";
|
||||
let owner = Pubkey::new_rand();
|
||||
let owner = solana_sdk::pubkey::new_rand();
|
||||
let alice_with_seed = Pubkey::create_with_seed(&alice_pubkey, seed, &owner).unwrap();
|
||||
|
||||
bank_client
|
||||
@@ -1043,8 +1043,8 @@ mod tests {
|
||||
let alice_pubkey = alice_keypair.pubkey();
|
||||
let bob_pubkey = bob_keypair.pubkey();
|
||||
|
||||
let program = Pubkey::new_rand();
|
||||
let collector = Pubkey::new_rand();
|
||||
let program = solana_sdk::pubkey::new_rand();
|
||||
let collector = solana_sdk::pubkey::new_rand();
|
||||
|
||||
let mint_lamports = 10000;
|
||||
let len1 = 123;
|
||||
@@ -1070,7 +1070,7 @@ mod tests {
|
||||
let bank = Arc::new(Bank::new_from_parent(&bank, &collector, bank.slot() + 1));
|
||||
let bank_client = BankClient::new_shared(&bank);
|
||||
bank_client
|
||||
.transfer_and_confirm(50, &alice_keypair, &Pubkey::new_rand())
|
||||
.transfer_and_confirm(50, &alice_keypair, &solana_sdk::pubkey::new_rand())
|
||||
.unwrap();
|
||||
|
||||
// super fun time; callback chooses to .clean_accounts(None) or not
|
||||
@@ -1112,7 +1112,7 @@ mod tests {
|
||||
let alice_keypair = Keypair::new();
|
||||
let alice_pubkey = alice_keypair.pubkey();
|
||||
let seed = "seed";
|
||||
let owner = Pubkey::new_rand();
|
||||
let owner = solana_sdk::pubkey::new_rand();
|
||||
let alice_with_seed = Pubkey::create_with_seed(&alice_pubkey, seed, &owner).unwrap();
|
||||
|
||||
bank_client
|
||||
@@ -1576,7 +1576,7 @@ mod tests {
|
||||
&nonce::state::Versions::new_current(nonce::State::Initialized(
|
||||
nonce::state::Data::default(),
|
||||
)),
|
||||
&Pubkey::new_rand(),
|
||||
&solana_sdk::pubkey::new_rand(),
|
||||
)
|
||||
.unwrap();
|
||||
assert_eq!(get_system_account_kind(&nonce_account), None);
|
||||
|
@@ -62,7 +62,7 @@ impl<'a, 'b> Drop for TransactionBatch<'a, 'b> {
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::genesis_utils::{create_genesis_config_with_leader, GenesisConfigInfo};
|
||||
use solana_sdk::{pubkey::Pubkey, signature::Keypair, system_transaction};
|
||||
use solana_sdk::{signature::Keypair, system_transaction};
|
||||
|
||||
#[test]
|
||||
fn test_transaction_batch() {
|
||||
@@ -104,7 +104,7 @@ mod tests {
|
||||
}
|
||||
|
||||
fn setup() -> (Bank, Vec<Transaction>) {
|
||||
let dummy_leader_pubkey = Pubkey::new_rand();
|
||||
let dummy_leader_pubkey = solana_sdk::pubkey::new_rand();
|
||||
let GenesisConfigInfo {
|
||||
genesis_config,
|
||||
mint_keypair,
|
||||
@@ -112,9 +112,9 @@ mod tests {
|
||||
} = create_genesis_config_with_leader(500, &dummy_leader_pubkey, 100);
|
||||
let bank = Bank::new(&genesis_config);
|
||||
|
||||
let pubkey = Pubkey::new_rand();
|
||||
let pubkey = solana_sdk::pubkey::new_rand();
|
||||
let keypair2 = Keypair::new();
|
||||
let pubkey2 = Pubkey::new_rand();
|
||||
let pubkey2 = solana_sdk::pubkey::new_rand();
|
||||
|
||||
let txs = vec![
|
||||
system_transaction::transfer(&mint_keypair, &pubkey, 1, genesis_config.hash()),
|
||||
|
Reference in New Issue
Block a user