From 7bc073defeed6526618ebca272577080a91473e3 Mon Sep 17 00:00:00 2001 From: Michael Vines Date: Mon, 19 Oct 2020 12:12:08 -0700 Subject: [PATCH] Run `codemod --extensions rs Pubkey::new_rand solana_sdk::pubkey::new_rand` --- account-decoder/src/parse_account_data.rs | 4 +- account-decoder/src/parse_config.rs | 2 +- account-decoder/src/parse_stake.rs | 6 +- account-decoder/src/parse_sysvar.rs | 2 +- banking-bench/src/main.rs | 8 +- banks-client/src/lib.rs | 4 +- clap-utils/src/input_parsers.rs | 10 +- cli/src/checks.rs | 8 +- cli/src/cli.rs | 26 +- cli/src/nonce.rs | 4 +- cli/src/stake.rs | 18 +- cli/src/validator_info.rs | 2 +- cli/src/vote.rs | 2 +- cli/tests/nonce.rs | 2 +- cli/tests/vote.rs | 2 +- client/src/rpc_client.rs | 4 +- client/src/rpc_request.rs | 2 +- core/benches/banking_stage.rs | 10 +- core/benches/cluster_info.rs | 4 +- core/benches/crds_shards.rs | 2 +- core/benches/retransmit_stage.rs | 2 +- core/src/banking_stage.rs | 32 +-- .../broadcast_fake_shreds_run.rs | 2 +- core/src/broadcast_stage/broadcast_utils.rs | 2 +- core/src/cluster_info.rs | 40 +-- core/src/cluster_info_vote_listener.rs | 6 +- core/src/cluster_slots.rs | 12 +- core/src/commitment_service.rs | 24 +- core/src/consensus.rs | 2 +- core/src/contact_info.rs | 2 +- core/src/crds.rs | 6 +- core/src/crds_gossip_pull.rs | 52 ++-- core/src/crds_gossip_push.rs | 60 ++--- core/src/crds_shards.rs | 2 +- core/src/crds_value.rs | 2 +- core/src/gossip_service.rs | 8 +- core/src/non_circulating_supply.rs | 4 +- core/src/progress_map.rs | 14 +- core/src/replay_stage.rs | 6 +- core/src/retransmit_stage.rs | 4 +- core/src/rpc.rs | 112 ++++----- core/src/rpc_pubsub.rs | 6 +- core/src/rpc_service.rs | 2 +- core/src/rpc_subscriptions.rs | 2 +- core/src/serve_repair.rs | 20 +- core/src/test_validator.rs | 2 +- core/src/verified_vote_packets.rs | 4 +- core/src/vote_stake_tracker.rs | 2 +- core/src/window_service.rs | 2 +- core/tests/client.rs | 2 +- core/tests/cluster_info.rs | 4 +- core/tests/crds_gossip.rs | 12 +- core/tests/rpc.rs | 6 +- dos/src/main.rs | 4 +- faucet/src/faucet.rs | 4 +- faucet/src/faucet_mock.rs | 2 +- faucet/tests/local-faucet.rs | 2 +- genesis/src/main.rs | 30 +-- ledger/benches/protobuf.rs | 2 +- ledger/src/blockstore.rs | 24 +- ledger/src/blockstore_processor.rs | 16 +- ledger/src/genesis_utils.rs | 2 +- ledger/src/leader_schedule.rs | 16 +- ledger/src/leader_schedule_cache.rs | 10 +- ledger/src/leader_schedule_utils.rs | 14 +- ledger/src/staking_utils.rs | 4 +- local-cluster/tests/local_cluster.rs | 4 +- programs/bpf/benches/bpf_loader.rs | 6 +- programs/bpf/tests/programs.rs | 8 +- programs/bpf_loader/src/lib.rs | 30 +-- programs/bpf_loader/src/serialization.rs | 6 +- programs/bpf_loader/src/syscalls.rs | 10 +- programs/budget/src/budget_expr.rs | 22 +- programs/budget/src/budget_instruction.rs | 18 +- programs/budget/src/budget_processor.rs | 18 +- programs/config/src/config_processor.rs | 32 +-- programs/failure/tests/failure.rs | 2 +- programs/ownable/src/ownable_processor.rs | 10 +- programs/stake/src/stake_instruction.rs | 2 +- programs/stake/src/stake_state.rs | 154 ++++++------ programs/vest/src/vest_processor.rs | 42 ++-- programs/vote/src/vote_state/mod.rs | 68 ++--- remote-wallet/src/remote_wallet.rs | 8 +- runtime/benches/accounts.rs | 8 +- runtime/benches/accounts_index.rs | 2 +- runtime/benches/message_processor.rs | 8 +- runtime/src/accounts.rs | 18 +- runtime/src/accounts_db.rs | 96 +++---- runtime/src/append_vec.rs | 2 +- runtime/src/bank.rs | 238 +++++++++--------- runtime/src/bank_client.rs | 2 +- runtime/src/epoch_stakes.rs | 6 +- runtime/src/genesis_utils.rs | 4 +- runtime/src/message_processor.rs | 52 ++-- runtime/src/rent_collector.rs | 6 +- runtime/src/stakes.rs | 16 +- runtime/src/system_instruction_processor.rs | 76 +++--- runtime/src/transaction_batch.rs | 6 +- runtime/tests/bank.rs | 2 +- runtime/tests/noop.rs | 2 +- runtime/tests/stake.rs | 18 +- sdk/benches/serialize_instructions.rs | 4 +- sdk/src/genesis_config.rs | 4 +- sdk/src/message.rs | 62 ++--- sdk/src/nonce/account.rs | 2 +- sdk/src/pubkey.rs | 28 +-- sdk/src/stake_weighted_timestamp.rs | 8 +- sdk/src/system_instruction.rs | 10 +- sdk/src/transaction.rs | 18 +- stake-accounts/src/stake_accounts.rs | 12 +- storage-bigtable/src/bigtable.rs | 2 +- tokens/src/commands.rs | 28 +-- tokens/src/db.rs | 2 +- transaction-status/src/parse_accounts.rs | 8 +- transaction-status/src/parse_bpf_loader.rs | 6 +- transaction-status/src/parse_stake.rs | 12 +- transaction-status/src/parse_system.rs | 4 +- transaction-status/src/parse_token.rs | 4 +- 118 files changed, 963 insertions(+), 963 deletions(-) diff --git a/account-decoder/src/parse_account_data.rs b/account-decoder/src/parse_account_data.rs index a9f4aedf9..641b4f6db 100644 --- a/account-decoder/src/parse_account_data.rs +++ b/account-decoder/src/parse_account_data.rs @@ -111,8 +111,8 @@ mod test { #[test] fn test_parse_account_data() { - let account_pubkey = Pubkey::new_rand(); - let other_program = Pubkey::new_rand(); + let account_pubkey = solana_sdk::pubkey::new_rand(); + let other_program = solana_sdk::pubkey::new_rand(); let data = vec![0; 4]; assert!(parse_account_data(&account_pubkey, &other_program, &data, None).is_err()); diff --git a/account-decoder/src/parse_config.rs b/account-decoder/src/parse_config.rs index f17702ef8..a0d5623b3 100644 --- a/account-decoder/src/parse_config.rs +++ b/account-decoder/src/parse_config.rs @@ -117,7 +117,7 @@ mod test { })) .unwrap(), }; - let info_pubkey = Pubkey::new_rand(); + let info_pubkey = solana_sdk::pubkey::new_rand(); let validator_info_config_account = create_config_account( vec![(validator_info::id(), false), (info_pubkey, true)], &validator_info, diff --git a/account-decoder/src/parse_stake.rs b/account-decoder/src/parse_stake.rs index 86d01e106..557a6e54c 100644 --- a/account-decoder/src/parse_stake.rs +++ b/account-decoder/src/parse_stake.rs @@ -145,8 +145,8 @@ mod test { StakeAccountType::Uninitialized ); - let pubkey = Pubkey::new_rand(); - let custodian = Pubkey::new_rand(); + let pubkey = solana_sdk::pubkey::new_rand(); + let custodian = solana_sdk::pubkey::new_rand(); let authorized = Authorized::auto(&pubkey); let lockup = Lockup { unix_timestamp: 0, @@ -180,7 +180,7 @@ mod test { }) ); - let voter_pubkey = Pubkey::new_rand(); + let voter_pubkey = solana_sdk::pubkey::new_rand(); let stake = Stake { delegation: Delegation { voter_pubkey, diff --git a/account-decoder/src/parse_sysvar.rs b/account-decoder/src/parse_sysvar.rs index 9f9436830..755c3e457 100644 --- a/account-decoder/src/parse_sysvar.rs +++ b/account-decoder/src/parse_sysvar.rs @@ -319,7 +319,7 @@ mod test { }]), ); - let bad_pubkey = Pubkey::new_rand(); + let bad_pubkey = solana_sdk::pubkey::new_rand(); assert!(parse_sysvar(&stake_history_sysvar.data, &bad_pubkey).is_err()); let bad_data = vec![0; 4]; diff --git a/banking-bench/src/main.rs b/banking-bench/src/main.rs index 9da85ae9e..4e54b8f37 100644 --- a/banking-bench/src/main.rs +++ b/banking-bench/src/main.rs @@ -69,7 +69,7 @@ fn make_accounts_txs( hash: Hash, same_payer: bool, ) -> Vec { - let to_pubkey = Pubkey::new_rand(); + let to_pubkey = solana_sdk::pubkey::new_rand(); let payer_key = Keypair::new(); let dummy = system_transaction::transfer(&payer_key, &to_pubkey, 1, hash); (0..total_num_transactions) @@ -78,9 +78,9 @@ fn make_accounts_txs( let mut new = dummy.clone(); let sig: Vec = (0..64).map(|_| thread_rng().gen()).collect(); if !same_payer { - new.message.account_keys[0] = Pubkey::new_rand(); + new.message.account_keys[0] = solana_sdk::pubkey::new_rand(); } - new.message.account_keys[1] = Pubkey::new_rand(); + new.message.account_keys[1] = solana_sdk::pubkey::new_rand(); new.signatures = vec![Signature::new(&sig[0..64])]; new }) @@ -241,7 +241,7 @@ fn main() { let base_tx_count = bank.transaction_count(); let mut txs_processed = 0; let mut root = 1; - let collector = Pubkey::new_rand(); + let collector = solana_sdk::pubkey::new_rand(); let config = Config { packets_per_batch: packets_per_chunk, chunk_len, diff --git a/banks-client/src/lib.rs b/banks-client/src/lib.rs index 0000beddf..238c38c69 100644 --- a/banks-client/src/lib.rs +++ b/banks-client/src/lib.rs @@ -235,7 +235,7 @@ mod tests { &genesis.genesis_config, )))); - let bob_pubkey = Pubkey::new_rand(); + let bob_pubkey = solana_sdk::pubkey::new_rand(); let mint_pubkey = genesis.mint_keypair.pubkey(); let instruction = system_instruction::transfer(&mint_pubkey, &bob_pubkey, 1); let message = Message::new(&[instruction], Some(&mint_pubkey)); @@ -265,7 +265,7 @@ mod tests { )))); let mint_pubkey = &genesis.mint_keypair.pubkey(); - let bob_pubkey = Pubkey::new_rand(); + let bob_pubkey = solana_sdk::pubkey::new_rand(); let instruction = system_instruction::transfer(&mint_pubkey, &bob_pubkey, 1); let message = Message::new(&[instruction], Some(&mint_pubkey)); diff --git a/clap-utils/src/input_parsers.rs b/clap-utils/src/input_parsers.rs index 920b0db2c..3ff409260 100644 --- a/clap-utils/src/input_parsers.rs +++ b/clap-utils/src/input_parsers.rs @@ -228,8 +228,8 @@ mod tests { assert_eq!(values_of(&matches, "multiple"), Some(vec![50, 39])); assert_eq!(values_of::(&matches, "single"), None); - 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 matches = app().clone().get_matches_from(vec![ "test", "--multiple", @@ -251,7 +251,7 @@ mod tests { assert_eq!(value_of(&matches, "single"), Some(50)); assert_eq!(value_of::(&matches, "multiple"), None); - let pubkey = Pubkey::new_rand(); + let pubkey = solana_sdk::pubkey::new_rand(); let matches = app() .clone() .get_matches_from(vec!["test", "--single", &pubkey.to_string()]); @@ -331,8 +331,8 @@ mod tests { #[test] fn test_pubkeys_sigs_of() { - 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 sig1 = Keypair::new().sign_message(&[0u8]); let sig2 = Keypair::new().sign_message(&[1u8]); let signer1 = format!("{}={}", key1, sig1); diff --git a/cli/src/checks.rs b/cli/src/checks.rs index 7a2d01ae0..77abc74fe 100644 --- a/cli/src/checks.rs +++ b/cli/src/checks.rs @@ -161,7 +161,7 @@ mod tests { context: RpcResponseContext { slot: 1 }, value: json!(account_balance), }); - let pubkey = Pubkey::new_rand(); + let pubkey = solana_sdk::pubkey::new_rand(); let fee_calculator = FeeCalculator::new(1); let pubkey0 = Pubkey::new(&[0; 32]); @@ -221,7 +221,7 @@ mod tests { context: RpcResponseContext { slot: 1 }, value: json!(account_balance), }); - let pubkey = Pubkey::new_rand(); + let pubkey = solana_sdk::pubkey::new_rand(); let mut mocks = HashMap::new(); mocks.insert(RpcRequest::GetBalance, account_balance_response); @@ -267,9 +267,9 @@ mod tests { #[test] fn test_check_unique_pubkeys() { - let pubkey0 = Pubkey::new_rand(); + let pubkey0 = solana_sdk::pubkey::new_rand(); let pubkey_clone = pubkey0; - let pubkey1 = Pubkey::new_rand(); + let pubkey1 = solana_sdk::pubkey::new_rand(); check_unique_pubkeys((&pubkey0, "foo".to_string()), (&pubkey1, "bar".to_string())) .expect("unexpected result"); diff --git a/cli/src/cli.rs b/cli/src/cli.rs index 0c73690bc..7a3e57177 100644 --- a/cli/src/cli.rs +++ b/cli/src/cli.rs @@ -2409,7 +2409,7 @@ mod tests { .unwrap(); assert_eq!(signer_info.signers.len(), 1); assert_eq!(signer_info.index_of(None), Some(0)); - assert_eq!(signer_info.index_of(Some(Pubkey::new_rand())), None); + assert_eq!(signer_info.index_of(Some(solana_sdk::pubkey::new_rand())), None); let keypair0 = keypair_from_seed(&[1u8; 32]).unwrap(); let keypair0_pubkey = keypair0.pubkey(); @@ -2465,7 +2465,7 @@ mod tests { fn test_cli_parse_command() { let test_commands = app("test", "desc", "version"); - let pubkey = Pubkey::new_rand(); + let pubkey = solana_sdk::pubkey::new_rand(); let pubkey_string = format!("{}", pubkey); let default_keypair = Keypair::new(); @@ -2561,7 +2561,7 @@ mod tests { assert!(parse_command(&test_bad_signature, &default_signer, &mut None).is_err()); // Test CreateAddressWithSeed - let from_pubkey = Some(Pubkey::new_rand()); + let from_pubkey = Some(solana_sdk::pubkey::new_rand()); let from_str = from_pubkey.unwrap().to_string(); for (name, program_id) in &[ ("STAKE", solana_stake_program::id()), @@ -2718,7 +2718,7 @@ mod tests { let result = process_command(&config); assert!(result.is_ok()); - let new_authorized_pubkey = Pubkey::new_rand(); + let new_authorized_pubkey = solana_sdk::pubkey::new_rand(); config.signers = vec![&bob_keypair]; config.command = CliCommand::VoteAuthorize { vote_account_pubkey: bob_pubkey, @@ -2740,7 +2740,7 @@ mod tests { let bob_keypair = Keypair::new(); let bob_pubkey = bob_keypair.pubkey(); - let custodian = Pubkey::new_rand(); + let custodian = solana_sdk::pubkey::new_rand(); config.command = CliCommand::CreateStakeAccount { stake_account: 1, seed: None, @@ -2763,8 +2763,8 @@ mod tests { let result = process_command(&config); assert!(result.is_ok()); - let stake_account_pubkey = Pubkey::new_rand(); - let to_pubkey = Pubkey::new_rand(); + let stake_account_pubkey = solana_sdk::pubkey::new_rand(); + let to_pubkey = solana_sdk::pubkey::new_rand(); config.command = CliCommand::WithdrawStake { stake_account_pubkey, destination_account_pubkey: to_pubkey, @@ -2781,7 +2781,7 @@ mod tests { let result = process_command(&config); assert!(result.is_ok()); - let stake_account_pubkey = Pubkey::new_rand(); + let stake_account_pubkey = solana_sdk::pubkey::new_rand(); config.command = CliCommand::DeactivateStake { stake_account_pubkey, stake_authority: 0, @@ -2794,7 +2794,7 @@ mod tests { let result = process_command(&config); assert!(result.is_ok()); - let stake_account_pubkey = Pubkey::new_rand(); + let stake_account_pubkey = solana_sdk::pubkey::new_rand(); let split_stake_account = Keypair::new(); config.command = CliCommand::SplitStake { stake_account_pubkey, @@ -2812,8 +2812,8 @@ mod tests { let result = process_command(&config); assert!(result.is_ok()); - let stake_account_pubkey = Pubkey::new_rand(); - let source_stake_account_pubkey = Pubkey::new_rand(); + let stake_account_pubkey = solana_sdk::pubkey::new_rand(); + let source_stake_account_pubkey = solana_sdk::pubkey::new_rand(); let merge_stake_account = Keypair::new(); config.command = CliCommand::MergeStake { stake_account_pubkey, @@ -2836,7 +2836,7 @@ mod tests { assert_eq!(process_command(&config).unwrap(), "1234"); // CreateAddressWithSeed - let from_pubkey = Pubkey::new_rand(); + let from_pubkey = solana_sdk::pubkey::new_rand(); config.signers = vec![]; config.command = CliCommand::CreateAddressWithSeed { from_pubkey: Some(from_pubkey), @@ -2849,7 +2849,7 @@ mod tests { assert_eq!(address.unwrap(), expected_address.to_string()); // Need airdrop cases - let to = Pubkey::new_rand(); + let to = solana_sdk::pubkey::new_rand(); config.signers = vec![&keypair]; config.command = CliCommand::Airdrop { faucet_host: None, diff --git a/cli/src/nonce.rs b/cli/src/nonce.rs index 7e04d99df..5d9e964a5 100644 --- a/cli/src/nonce.rs +++ b/cli/src/nonce.rs @@ -833,7 +833,7 @@ mod tests { #[test] fn test_check_nonce_account() { let blockhash = Hash::default(); - let nonce_pubkey = Pubkey::new_rand(); + let nonce_pubkey = solana_sdk::pubkey::new_rand(); let data = Versions::new_current(State::Initialized(nonce::state::Data { authority: nonce_pubkey, blockhash, @@ -869,7 +869,7 @@ mod tests { } let data = Versions::new_current(State::Initialized(nonce::state::Data { - authority: Pubkey::new_rand(), + authority: solana_sdk::pubkey::new_rand(), blockhash, fee_calculator: FeeCalculator::default(), })); diff --git a/cli/src/stake.rs b/cli/src/stake.rs index 8d56e44c0..17c6c116a 100644 --- a/cli/src/stake.rs +++ b/cli/src/stake.rs @@ -2426,9 +2426,9 @@ mod tests { ); // Test CreateStakeAccount SubCommand - let custodian = Pubkey::new_rand(); + let custodian = solana_sdk::pubkey::new_rand(); let custodian_string = format!("{}", custodian); - let authorized = Pubkey::new_rand(); + let authorized = solana_sdk::pubkey::new_rand(); let authorized_string = format!("{}", authorized); let test_create_stake_account = test_commands.clone().get_matches_from(vec![ "test", @@ -2566,7 +2566,7 @@ mod tests { ); // Test DelegateStake Subcommand - let vote_account_pubkey = Pubkey::new_rand(); + let vote_account_pubkey = solana_sdk::pubkey::new_rand(); let vote_account_string = vote_account_pubkey.to_string(); let test_delegate_stake = test_commands.clone().get_matches_from(vec![ "test", @@ -2593,7 +2593,7 @@ mod tests { ); // Test DelegateStake Subcommand w/ authority - let vote_account_pubkey = Pubkey::new_rand(); + let vote_account_pubkey = solana_sdk::pubkey::new_rand(); let vote_account_string = vote_account_pubkey.to_string(); let test_delegate_stake = test_commands.clone().get_matches_from(vec![ "test", @@ -2712,7 +2712,7 @@ mod tests { ); // Test Delegate Subcommand w/ absent fee payer - let key1 = Pubkey::new_rand(); + let key1 = solana_sdk::pubkey::new_rand(); let sig1 = Keypair::new().sign_message(&[0u8]); let signer1 = format!("{}={}", key1, sig1); let test_delegate_stake = test_commands.clone().get_matches_from(vec![ @@ -2752,7 +2752,7 @@ mod tests { ); // Test Delegate Subcommand w/ absent fee payer and absent nonce authority - let key2 = Pubkey::new_rand(); + let key2 = solana_sdk::pubkey::new_rand(); let sig2 = Keypair::new().sign_message(&[0u8]); let signer2 = format!("{}={}", key2, sig2); let test_delegate_stake = test_commands.clone().get_matches_from(vec![ @@ -3080,7 +3080,7 @@ mod tests { ); // Test Deactivate Subcommand w/ absent fee payer - let key1 = Pubkey::new_rand(); + let key1 = solana_sdk::pubkey::new_rand(); let sig1 = Keypair::new().sign_message(&[0u8]); let signer1 = format!("{}={}", key1, sig1); let test_deactivate_stake = test_commands.clone().get_matches_from(vec![ @@ -3117,7 +3117,7 @@ mod tests { ); // Test Deactivate Subcommand w/ absent fee payer and nonce authority - let key2 = Pubkey::new_rand(); + let key2 = solana_sdk::pubkey::new_rand(); let sig2 = Keypair::new().sign_message(&[0u8]); let signer2 = format!("{}={}", key2, sig2); let test_deactivate_stake = test_commands.clone().get_matches_from(vec![ @@ -3296,7 +3296,7 @@ mod tests { let stake_account_keypair = Keypair::new(); write_keypair(&stake_account_keypair, tmp_file.as_file_mut()).unwrap(); - let source_stake_account_pubkey = Pubkey::new_rand(); + let source_stake_account_pubkey = solana_sdk::pubkey::new_rand(); let test_merge_stake_account = test_commands.clone().get_matches_from(vec![ "test", "merge-stake", diff --git a/cli/src/validator_info.rs b/cli/src/validator_info.rs index eb9a64ab5..daae04490 100644 --- a/cli/src/validator_info.rs +++ b/cli/src/validator_info.rs @@ -486,7 +486,7 @@ mod tests { #[test] fn test_parse_validator_info() { - let pubkey = Pubkey::new_rand(); + let pubkey = solana_sdk::pubkey::new_rand(); let keys = vec![(validator_info::id(), false), (pubkey, true)]; let config = ConfigKeys { keys }; diff --git a/cli/src/vote.rs b/cli/src/vote.rs index 29ce0a73a..e831cb520 100644 --- a/cli/src/vote.rs +++ b/cli/src/vote.rs @@ -915,7 +915,7 @@ mod tests { ); // test init with an authed voter - let authed = Pubkey::new_rand(); + let authed = solana_sdk::pubkey::new_rand(); let (keypair_file, mut tmp_file) = make_tmp_file(); let keypair = Keypair::new(); write_keypair(&keypair, tmp_file.as_file_mut()).unwrap(); diff --git a/cli/tests/nonce.rs b/cli/tests/nonce.rs index 06df183de..27451f86a 100644 --- a/cli/tests/nonce.rs +++ b/cli/tests/nonce.rs @@ -172,7 +172,7 @@ fn full_battery_tests( assert_ne!(first_nonce, third_nonce); // Withdraw from nonce account - let payee_pubkey = Pubkey::new_rand(); + let payee_pubkey = solana_sdk::pubkey::new_rand(); config_payer.signers = authorized_signers; config_payer.command = CliCommand::WithdrawFromNonceAccount { nonce_account, diff --git a/cli/tests/vote.rs b/cli/tests/vote.rs index 8510ee163..0d23a78f2 100644 --- a/cli/tests/vote.rs +++ b/cli/tests/vote.rs @@ -110,7 +110,7 @@ fn test_vote_authorize_and_withdraw() { assert_eq!(authorized_withdrawer, withdraw_authority.pubkey()); // Withdraw from vote account - let destination_account = Pubkey::new_rand(); // Send withdrawal to new account to make balance check easy + let destination_account = solana_sdk::pubkey::new_rand(); // Send withdrawal to new account to make balance check easy config.signers = vec![&default_signer, &withdraw_authority]; config.command = CliCommand::WithdrawFromVoteAccount { vote_account_pubkey, diff --git a/client/src/rpc_client.rs b/client/src/rpc_client.rs index e7d0b2d53..79a8cd413 100644 --- a/client/src/rpc_client.rs +++ b/client/src/rpc_client.rs @@ -1456,7 +1456,7 @@ mod tests { let rpc_client = RpcClient::new_mock("succeeds".to_string()); let key = Keypair::new(); - let to = Pubkey::new_rand(); + let to = solana_sdk::pubkey::new_rand(); let blockhash = Hash::default(); let tx = system_transaction::transfer(&key, &to, 50, blockhash); @@ -1509,7 +1509,7 @@ mod tests { let rpc_client = RpcClient::new_mock("succeeds".to_string()); let key = Keypair::new(); - let to = Pubkey::new_rand(); + let to = solana_sdk::pubkey::new_rand(); let blockhash = Hash::default(); let tx = system_transaction::transfer(&key, &to, 50, blockhash); let result = rpc_client.send_and_confirm_transaction(&tx); diff --git a/client/src/rpc_request.rs b/client/src/rpc_request.rs index d973c9fac..ec57f8680 100644 --- a/client/src/rpc_request.rs +++ b/client/src/rpc_request.rs @@ -228,7 +228,7 @@ mod tests { // Test request with CommitmentConfig and params let test_request = RpcRequest::GetTokenAccountsByOwner; - let mint = Pubkey::new_rand(); + let mint = solana_sdk::pubkey::new_rand(); let token_account_filter = RpcTokenAccountsFilter::Mint(mint.to_string()); let request = test_request .build_request_json(1, json!([addr, token_account_filter, commitment_config])); diff --git a/core/benches/banking_stage.rs b/core/benches/banking_stage.rs index 3cd5465c6..4a81c8619 100644 --- a/core/benches/banking_stage.rs +++ b/core/benches/banking_stage.rs @@ -56,7 +56,7 @@ fn bench_consume_buffered(bencher: &mut Bencher) { let GenesisConfigInfo { genesis_config, .. } = create_genesis_config(100_000); let bank = Arc::new(Bank::new(&genesis_config)); let ledger_path = get_tmp_ledger_path!(); - let my_pubkey = Pubkey::new_rand(); + let my_pubkey = solana_sdk::pubkey::new_rand(); { let blockstore = Arc::new( Blockstore::open(&ledger_path).expect("Expected to be able to open database ledger"), @@ -94,15 +94,15 @@ fn bench_consume_buffered(bencher: &mut Bencher) { } fn make_accounts_txs(txes: usize, mint_keypair: &Keypair, hash: Hash) -> Vec { - let to_pubkey = Pubkey::new_rand(); + let to_pubkey = solana_sdk::pubkey::new_rand(); let dummy = system_transaction::transfer(mint_keypair, &to_pubkey, 1, hash); (0..txes) .into_par_iter() .map(|_| { let mut new = dummy.clone(); let sig: Vec = (0..64).map(|_| thread_rng().gen()).collect(); - new.message.account_keys[0] = Pubkey::new_rand(); - new.message.account_keys[1] = Pubkey::new_rand(); + new.message.account_keys[0] = solana_sdk::pubkey::new_rand(); + new.message.account_keys[1] = solana_sdk::pubkey::new_rand(); new.signatures = vec![Signature::new(&sig[0..64])]; new }) @@ -117,7 +117,7 @@ fn make_programs_txs(txes: usize, hash: Hash) -> Vec { let mut instructions = vec![]; let from_key = Keypair::new(); for _ in 1..progs { - let to_key = Pubkey::new_rand(); + let to_key = solana_sdk::pubkey::new_rand(); instructions.push(system_instruction::transfer(&from_key.pubkey(), &to_key, 1)); } let message = Message::new(&instructions, Some(&from_key.pubkey())); diff --git a/core/benches/cluster_info.rs b/core/benches/cluster_info.rs index 697db76e8..42a32d2cd 100644 --- a/core/benches/cluster_info.rs +++ b/core/benches/cluster_info.rs @@ -20,7 +20,7 @@ use test::Bencher; #[bench] fn broadcast_shreds_bench(bencher: &mut Bencher) { solana_logger::setup(); - let leader_pubkey = Pubkey::new_rand(); + let leader_pubkey = solana_sdk::pubkey::new_rand(); let leader_info = Node::new_localhost_with_pubkey(&leader_pubkey); let cluster_info = ClusterInfo::new_with_invalid_keypair(leader_info.info); let socket = UdpSocket::bind("0.0.0.0:0").unwrap(); @@ -30,7 +30,7 @@ fn broadcast_shreds_bench(bencher: &mut Bencher) { let mut stakes = HashMap::new(); const NUM_PEERS: usize = 200; for _ in 0..NUM_PEERS { - let id = Pubkey::new_rand(); + let id = solana_sdk::pubkey::new_rand(); let contact_info = ContactInfo::new_localhost(&id, timestamp()); cluster_info.insert_info(contact_info); stakes.insert(id, thread_rng().gen_range(1, NUM_PEERS) as u64); diff --git a/core/benches/crds_shards.rs b/core/benches/crds_shards.rs index c419d5dce..171d1970d 100644 --- a/core/benches/crds_shards.rs +++ b/core/benches/crds_shards.rs @@ -14,7 +14,7 @@ use test::Bencher; const CRDS_SHARDS_BITS: u32 = 8; fn new_test_crds_value() -> VersionedCrdsValue { - let data = CrdsData::ContactInfo(ContactInfo::new_localhost(&Pubkey::new_rand(), timestamp())); + let data = CrdsData::ContactInfo(ContactInfo::new_localhost(&solana_sdk::pubkey::new_rand(), timestamp())); VersionedCrdsValue::new(timestamp(), CrdsValue::new_unsigned(data)) } diff --git a/core/benches/retransmit_stage.rs b/core/benches/retransmit_stage.rs index 65bdc0d7e..5f6474863 100644 --- a/core/benches/retransmit_stage.rs +++ b/core/benches/retransmit_stage.rs @@ -34,7 +34,7 @@ fn bench_retransmitter(bencher: &mut Bencher) { const NUM_PEERS: usize = 4; let mut peer_sockets = Vec::new(); for _ in 0..NUM_PEERS { - let id = Pubkey::new_rand(); + let id = solana_sdk::pubkey::new_rand(); let socket = UdpSocket::bind("0.0.0.0:0").unwrap(); let mut contact_info = ContactInfo::new_localhost(&id, timestamp()); contact_info.tvu = socket.local_addr().unwrap(); diff --git a/core/src/banking_stage.rs b/core/src/banking_stage.rs index 8fdf5f9f8..b584c63db 100644 --- a/core/src/banking_stage.rs +++ b/core/src/banking_stage.rs @@ -1246,16 +1246,16 @@ mod tests { bank.process_transaction(&fund_tx).unwrap(); // good tx - let to = Pubkey::new_rand(); + let to = solana_sdk::pubkey::new_rand(); let tx = system_transaction::transfer(&mint_keypair, &to, 1, start_hash); // good tx, but no verify - let to2 = Pubkey::new_rand(); + let to2 = solana_sdk::pubkey::new_rand(); let tx_no_ver = system_transaction::transfer(&keypair, &to2, 2, start_hash); // bad tx, AccountNotFound let keypair = Keypair::new(); - let to3 = Pubkey::new_rand(); + let to3 = solana_sdk::pubkey::new_rand(); let tx_anf = system_transaction::transfer(&keypair, &to3, 1, start_hash); // send 'em over @@ -1448,9 +1448,9 @@ mod tests { let poh_recorder = Arc::new(Mutex::new(poh_recorder)); poh_recorder.lock().unwrap().set_working_bank(working_bank); - 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 transactions = vec![ system_transaction::transfer(&mint_keypair, &pubkey, 1, genesis_config.hash()), @@ -1528,7 +1528,7 @@ mod tests { mint_keypair, .. } = create_genesis_config(10_000); - let pubkey = Pubkey::new_rand(); + let pubkey = solana_sdk::pubkey::new_rand(); let transactions = vec![ None, @@ -1609,7 +1609,7 @@ mod tests { mint_keypair, .. } = create_genesis_config(10_000); - let pubkey = Pubkey::new_rand(); + let pubkey = solana_sdk::pubkey::new_rand(); let transactions = vec![ system_transaction::transfer(&mint_keypair, &pubkey, 1, genesis_config.hash()), @@ -1680,8 +1680,8 @@ mod tests { #[test] fn test_should_process_or_forward_packets() { - let my_pubkey = Pubkey::new_rand(); - let my_pubkey1 = Pubkey::new_rand(); + let my_pubkey = solana_sdk::pubkey::new_rand(); + let my_pubkey1 = solana_sdk::pubkey::new_rand(); assert_eq!( BankingStage::consume_or_forward_packets(&my_pubkey, None, true, false,), @@ -1727,7 +1727,7 @@ mod tests { .. } = create_genesis_config(10_000); let bank = Arc::new(Bank::new(&genesis_config)); - let pubkey = Pubkey::new_rand(); + let pubkey = solana_sdk::pubkey::new_rand(); let transactions = vec![system_transaction::transfer( &mint_keypair, @@ -1824,8 +1824,8 @@ mod tests { .. } = create_genesis_config(10_000); let bank = Arc::new(Bank::new(&genesis_config)); - let pubkey = Pubkey::new_rand(); - let pubkey1 = Pubkey::new_rand(); + let pubkey = solana_sdk::pubkey::new_rand(); + let pubkey1 = solana_sdk::pubkey::new_rand(); let transactions = vec![ system_transaction::transfer(&mint_keypair, &pubkey, 1, genesis_config.hash()), @@ -1920,7 +1920,7 @@ mod tests { } = create_genesis_config(10_000); let bank = Arc::new(Bank::new(&genesis_config)); - let pubkey = Pubkey::new_rand(); + let pubkey = solana_sdk::pubkey::new_rand(); let transactions = vec![ @@ -1938,7 +1938,7 @@ mod tests { bank.slot(), Some((4, 4)), bank.ticks_per_slot(), - &Pubkey::new_rand(), + &solana_sdk::pubkey::new_rand(), &Arc::new(blockstore), &Arc::new(LeaderScheduleCache::new_from_bank(&bank)), &Arc::new(PohConfig::default()), @@ -1978,8 +1978,8 @@ mod tests { .. } = create_genesis_config(10_000); let bank = Arc::new(Bank::new(&genesis_config)); - let pubkey = Pubkey::new_rand(); - let pubkey1 = Pubkey::new_rand(); + let pubkey = solana_sdk::pubkey::new_rand(); + let pubkey1 = solana_sdk::pubkey::new_rand(); let keypair1 = Keypair::new(); let success_tx = diff --git a/core/src/broadcast_stage/broadcast_fake_shreds_run.rs b/core/src/broadcast_stage/broadcast_fake_shreds_run.rs index 46f001fe5..664975ed5 100644 --- a/core/src/broadcast_stage/broadcast_fake_shreds_run.rs +++ b/core/src/broadcast_stage/broadcast_fake_shreds_run.rs @@ -146,7 +146,7 @@ mod tests { #[test] fn test_tvu_peers_ordering() { let cluster = ClusterInfo::new_with_invalid_keypair(ContactInfo::new_localhost( - &Pubkey::new_rand(), + &solana_sdk::pubkey::new_rand(), 0, )); cluster.insert_info(ContactInfo::new_with_socketaddr(&SocketAddr::new( diff --git a/core/src/broadcast_stage/broadcast_utils.rs b/core/src/broadcast_stage/broadcast_utils.rs index 35dd4c112..df5140401 100644 --- a/core/src/broadcast_stage/broadcast_utils.rs +++ b/core/src/broadcast_stage/broadcast_utils.rs @@ -92,7 +92,7 @@ mod tests { let bank0 = Arc::new(Bank::new(&genesis_config)); let tx = system_transaction::transfer( &mint_keypair, - &Pubkey::new_rand(), + &solana_sdk::pubkey::new_rand(), 1, genesis_config.hash(), ); diff --git a/core/src/cluster_info.rs b/core/src/cluster_info.rs index 72c83f882..ac4dab091 100644 --- a/core/src/cluster_info.rs +++ b/core/src/cluster_info.rs @@ -2570,7 +2570,7 @@ pub struct Node { impl Node { pub fn new_localhost() -> Self { - let pubkey = Pubkey::new_rand(); + let pubkey = solana_sdk::pubkey::new_rand(); Self::new_localhost_with_pubkey(&pubkey) } pub fn new_localhost_with_pubkey(pubkey: &Pubkey) -> Self { @@ -2734,10 +2734,10 @@ mod tests { #[test] fn test_gossip_node() { //check that a gossip nodes always show up as spies - let (node, _, _) = ClusterInfo::spy_node(&Pubkey::new_rand(), 0); + let (node, _, _) = ClusterInfo::spy_node(&solana_sdk::pubkey::new_rand(), 0); assert!(ClusterInfo::is_spy_node(&node)); let (node, _, _) = - ClusterInfo::gossip_node(&Pubkey::new_rand(), &"1.1.1.1:1111".parse().unwrap(), 0); + ClusterInfo::gossip_node(&solana_sdk::pubkey::new_rand(), &"1.1.1.1:1111".parse().unwrap(), 0); assert!(ClusterInfo::is_spy_node(&node)); } @@ -2747,7 +2747,7 @@ mod tests { let node = Node::new_localhost(); let cluster_info = Arc::new(ClusterInfo::new_with_invalid_keypair(node.info)); - let entrypoint_pubkey = Pubkey::new_rand(); + let entrypoint_pubkey = solana_sdk::pubkey::new_rand(); let data = test_crds_values(entrypoint_pubkey); let timeouts = HashMap::new(); assert_eq!( @@ -2760,7 +2760,7 @@ mod tests { ) ); - let entrypoint_pubkey2 = Pubkey::new_rand(); + let entrypoint_pubkey2 = solana_sdk::pubkey::new_rand(); assert_eq!( (1, 0, 0), ClusterInfo::handle_pull_response(&cluster_info, &entrypoint_pubkey2, data, &timeouts) @@ -2775,7 +2775,7 @@ mod tests { #[test] fn test_filter_shred_version() { - let from = Pubkey::new_rand(); + let from = solana_sdk::pubkey::new_rand(); let my_shred_version = 1; let other_shred_version = 1; @@ -2810,7 +2810,7 @@ mod tests { assert_eq!(values.len(), 1); let snapshot_hash_data = CrdsValue::new_unsigned(CrdsData::SnapshotHashes(SnapshotHash { - from: Pubkey::new_rand(), + from: solana_sdk::pubkey::new_rand(), hashes: vec![], wallclock: 0, })); @@ -2831,7 +2831,7 @@ mod tests { let thread_pool = ThreadPoolBuilder::new().build().unwrap(); //check that gossip doesn't try to push to invalid addresses let node = Node::new_localhost(); - let (spy, _, _) = ClusterInfo::spy_node(&Pubkey::new_rand(), 0); + let (spy, _, _) = ClusterInfo::spy_node(&solana_sdk::pubkey::new_rand(), 0); let cluster_info = Arc::new(ClusterInfo::new_with_invalid_keypair(node.info)); cluster_info.insert_info(spy); cluster_info @@ -2851,16 +2851,16 @@ mod tests { #[test] fn test_cluster_info_new() { - let d = ContactInfo::new_localhost(&Pubkey::new_rand(), timestamp()); + let d = ContactInfo::new_localhost(&solana_sdk::pubkey::new_rand(), timestamp()); let cluster_info = ClusterInfo::new_with_invalid_keypair(d.clone()); assert_eq!(d.id, cluster_info.id()); } #[test] fn insert_info_test() { - let d = ContactInfo::new_localhost(&Pubkey::new_rand(), timestamp()); + let d = ContactInfo::new_localhost(&solana_sdk::pubkey::new_rand(), timestamp()); let cluster_info = ClusterInfo::new_with_invalid_keypair(d); - let d = ContactInfo::new_localhost(&Pubkey::new_rand(), timestamp()); + let d = ContactInfo::new_localhost(&solana_sdk::pubkey::new_rand(), timestamp()); let label = CrdsValueLabel::ContactInfo(d.id); cluster_info.insert_info(d); assert!(cluster_info @@ -2874,7 +2874,7 @@ mod tests { #[test] #[should_panic] fn test_update_contact_info() { - let d = ContactInfo::new_localhost(&Pubkey::new_rand(), timestamp()); + let d = ContactInfo::new_localhost(&solana_sdk::pubkey::new_rand(), timestamp()); let cluster_info = ClusterInfo::new_with_invalid_keypair(d); let entry_label = CrdsValueLabel::ContactInfo(cluster_info.id()); assert!(cluster_info @@ -2903,7 +2903,7 @@ mod tests { // Inserting Contactinfo with different pubkey should panic, // and update should fail - cluster_info.update_contact_info(|ci| ci.id = Pubkey::new_rand()) + cluster_info.update_contact_info(|ci| ci.id = solana_sdk::pubkey::new_rand()) } fn assert_in_range(x: u16, range: (u16, u16)) { @@ -2938,7 +2938,7 @@ mod tests { fn new_with_external_ip_test_random() { let ip = Ipv4Addr::from(0); let node = Node::new_with_external_ip( - &Pubkey::new_rand(), + &solana_sdk::pubkey::new_rand(), &socketaddr!(ip, 0), VALIDATOR_PORT_RANGE, IpAddr::V4(ip), @@ -2956,7 +2956,7 @@ mod tests { let ip = IpAddr::V4(Ipv4Addr::from(0)); let port = bind_in_range(ip, port_range).expect("Failed to bind").0; let node = - Node::new_with_external_ip(&Pubkey::new_rand(), &socketaddr!(0, port), port_range, ip); + Node::new_with_external_ip(&solana_sdk::pubkey::new_rand(), &socketaddr!(0, port), port_range, ip); check_node_sockets(&node, ip, port_range); @@ -3221,7 +3221,7 @@ mod tests { ContactInfo::new_localhost(&node_keypair.pubkey(), timestamp()), node_keypair, ); - let entrypoint_pubkey = Pubkey::new_rand(); + let entrypoint_pubkey = solana_sdk::pubkey::new_rand(); let entrypoint = ContactInfo::new_localhost(&entrypoint_pubkey, timestamp()); cluster_info.set_entrypoint(entrypoint.clone()); let pulls = cluster_info.new_pull_requests(&thread_pool, None, &HashMap::new()); @@ -3380,14 +3380,14 @@ mod tests { ContactInfo::new_localhost(&node_keypair.pubkey(), timestamp()), node_keypair, ); - let entrypoint_pubkey = Pubkey::new_rand(); + let entrypoint_pubkey = solana_sdk::pubkey::new_rand(); let mut entrypoint = ContactInfo::new_localhost(&entrypoint_pubkey, timestamp()); entrypoint.gossip = socketaddr!("127.0.0.2:1234"); cluster_info.set_entrypoint(entrypoint.clone()); let mut stakes = HashMap::new(); - let other_node_pubkey = Pubkey::new_rand(); + let other_node_pubkey = solana_sdk::pubkey::new_rand(); let other_node = ContactInfo::new_localhost(&other_node_pubkey, timestamp()); assert_ne!(other_node.gossip, entrypoint.gossip); cluster_info.insert_info(other_node.clone()); @@ -3430,7 +3430,7 @@ mod tests { for i in 0..10 { // make these invalid for the upcoming repair request let peer_lowest = if i >= 5 { 10 } else { 0 }; - let other_node_pubkey = Pubkey::new_rand(); + let other_node_pubkey = solana_sdk::pubkey::new_rand(); let other_node = ContactInfo::new_localhost(&other_node_pubkey, timestamp()); cluster_info.insert_info(other_node.clone()); let value = CrdsValue::new_unsigned(CrdsData::LowestSlot( @@ -3581,7 +3581,7 @@ mod tests { // Simulate getting entrypoint ContactInfo from gossip let mut gossiped_entrypoint_info = - ContactInfo::new_localhost(&Pubkey::new_rand(), timestamp()); + ContactInfo::new_localhost(&solana_sdk::pubkey::new_rand(), timestamp()); gossiped_entrypoint_info.gossip = entrypoint_gossip_addr; gossiped_entrypoint_info.shred_version = 1; cluster_info.insert_info(gossiped_entrypoint_info.clone()); diff --git a/core/src/cluster_info_vote_listener.rs b/core/src/cluster_info_vote_listener.rs index 88c45c9ec..b41bc3b84 100644 --- a/core/src/cluster_info_vote_listener.rs +++ b/core/src/cluster_info_vote_listener.rs @@ -898,7 +898,7 @@ mod tests { let (vote_tracker, bank, _, _) = setup(); // Check outdated slots are purged with new root - let new_voter = Arc::new(Pubkey::new_rand()); + let new_voter = Arc::new(solana_sdk::pubkey::new_rand()); // Make separate copy so the original doesn't count toward // the ref count, which would prevent cleanup let new_voter_ = Arc::new(*new_voter); @@ -1681,7 +1681,7 @@ mod tests { fn run_test_verify_votes_1_pass(hash: Option) { let vote_tx = test_vote_tx(hash); let votes = vec![vote_tx]; - let labels = vec![CrdsValueLabel::Vote(0, Pubkey::new_rand())]; + let labels = vec![CrdsValueLabel::Vote(0, solana_sdk::pubkey::new_rand())]; let (vote_txs, packets) = ClusterInfoVoteListener::verify_votes(votes, labels); assert_eq!(vote_txs.len(), 1); verify_packets_len(&packets, 1); @@ -1698,7 +1698,7 @@ mod tests { let mut bad_vote = vote_tx.clone(); bad_vote.signatures[0] = Signature::default(); let votes = vec![vote_tx.clone(), bad_vote, vote_tx]; - let label = CrdsValueLabel::Vote(0, Pubkey::new_rand()); + let label = CrdsValueLabel::Vote(0, solana_sdk::pubkey::new_rand()); let labels: Vec<_> = (0..votes.len()).map(|_| label.clone()).collect(); let (vote_txs, packets) = ClusterInfoVoteListener::verify_votes(votes, labels); assert_eq!(vote_txs.len(), 2); diff --git a/core/src/cluster_slots.rs b/core/src/cluster_slots.rs index 8e3abbe1a..aefdb0139 100644 --- a/core/src/cluster_slots.rs +++ b/core/src/cluster_slots.rs @@ -237,8 +237,8 @@ mod tests { let mut c1 = ContactInfo::default(); let mut c2 = ContactInfo::default(); let mut map = HashMap::new(); - let k1 = Pubkey::new_rand(); - let k2 = Pubkey::new_rand(); + let k1 = solana_sdk::pubkey::new_rand(); + let k2 = solana_sdk::pubkey::new_rand(); map.insert(Arc::new(k1), std::u64::MAX / 2); map.insert(Arc::new(k2), 0); cs.cluster_slots @@ -259,8 +259,8 @@ mod tests { let mut c1 = ContactInfo::default(); let mut c2 = ContactInfo::default(); let mut map = HashMap::new(); - let k1 = Pubkey::new_rand(); - let k2 = Pubkey::new_rand(); + let k1 = solana_sdk::pubkey::new_rand(); + let k2 = solana_sdk::pubkey::new_rand(); map.insert(Arc::new(k2), 0); cs.cluster_slots .write() @@ -290,7 +290,7 @@ mod tests { let cs = ClusterSlots::default(); let mut contact_infos = vec![ContactInfo::default(); 2]; for ci in contact_infos.iter_mut() { - ci.id = Pubkey::new_rand(); + ci.id = solana_sdk::pubkey::new_rand(); } let slot = 9; @@ -359,7 +359,7 @@ mod tests { let mut epoch_slot = EpochSlots::default(); epoch_slot.fill(&[1], 0); cs.update_internal(0, (vec![epoch_slot], None)); - let self_id = Pubkey::new_rand(); + let self_id = solana_sdk::pubkey::new_rand(); assert_eq!( cs.generate_repairs_for_missing_slots(&self_id, 0), vec![RepairType::HighestShred(1, 0)] diff --git a/core/src/commitment_service.rs b/core/src/commitment_service.rs index c3a7a6a14..24e1437d5 100644 --- a/core/src/commitment_service.rs +++ b/core/src/commitment_service.rs @@ -375,19 +375,19 @@ mod tests { let rooted_stake_amount = 40; - let sk1 = Pubkey::new_rand(); - let pk1 = Pubkey::new_rand(); - let mut vote_account1 = vote_state::create_account(&pk1, &Pubkey::new_rand(), 0, 100); + let sk1 = solana_sdk::pubkey::new_rand(); + let pk1 = solana_sdk::pubkey::new_rand(); + let mut vote_account1 = vote_state::create_account(&pk1, &solana_sdk::pubkey::new_rand(), 0, 100); let stake_account1 = stake_state::create_account(&sk1, &pk1, &vote_account1, &genesis_config.rent, 100); - let sk2 = Pubkey::new_rand(); - let pk2 = Pubkey::new_rand(); - let mut vote_account2 = vote_state::create_account(&pk2, &Pubkey::new_rand(), 0, 50); + let sk2 = solana_sdk::pubkey::new_rand(); + let pk2 = solana_sdk::pubkey::new_rand(); + let mut vote_account2 = vote_state::create_account(&pk2, &solana_sdk::pubkey::new_rand(), 0, 50); let stake_account2 = stake_state::create_account(&sk2, &pk2, &vote_account2, &genesis_config.rent, 50); - let sk3 = Pubkey::new_rand(); - let pk3 = Pubkey::new_rand(); - let mut vote_account3 = vote_state::create_account(&pk3, &Pubkey::new_rand(), 0, 1); + let sk3 = solana_sdk::pubkey::new_rand(); + let pk3 = solana_sdk::pubkey::new_rand(); + let mut vote_account3 = vote_state::create_account(&pk3, &solana_sdk::pubkey::new_rand(), 0, 1); let stake_account3 = stake_state::create_account( &sk3, &pk3, @@ -395,9 +395,9 @@ mod tests { &genesis_config.rent, rooted_stake_amount, ); - let sk4 = Pubkey::new_rand(); - let pk4 = Pubkey::new_rand(); - let mut vote_account4 = vote_state::create_account(&pk4, &Pubkey::new_rand(), 0, 1); + let sk4 = solana_sdk::pubkey::new_rand(); + let pk4 = solana_sdk::pubkey::new_rand(); + let mut vote_account4 = vote_state::create_account(&pk4, &solana_sdk::pubkey::new_rand(), 0, 1); let stake_account4 = stake_state::create_account( &sk4, &pk4, diff --git a/core/src/consensus.rs b/core/src/consensus.rs index 7869cc250..ebd91cd81 100644 --- a/core/src/consensus.rs +++ b/core/src/consensus.rs @@ -1536,7 +1536,7 @@ pub mod test { &mut account.data, ) .expect("serialize state"); - stakes.push((Pubkey::new_rand(), (*lamports, account))); + stakes.push((solana_sdk::pubkey::new_rand(), (*lamports, account))); } stakes } diff --git a/core/src/contact_info.rs b/core/src/contact_info.rs index fce883008..b12f42ca5 100644 --- a/core/src/contact_info.rs +++ b/core/src/contact_info.rs @@ -130,7 +130,7 @@ impl ContactInfo { let addr = socketaddr!("224.0.1.255:1000"); assert!(addr.ip().is_multicast()); Self { - id: Pubkey::new_rand(), + id: solana_sdk::pubkey::new_rand(), gossip: addr, tvu: addr, tvu_forwards: addr, diff --git a/core/src/crds.rs b/core/src/crds.rs index cf48568d9..cfab54459 100644 --- a/core/src/crds.rs +++ b/core/src/crds.rs @@ -361,7 +361,7 @@ mod test { } let mut crds = Crds::default(); - let pubkeys: Vec<_> = std::iter::repeat_with(Pubkey::new_rand).take(256).collect(); + let pubkeys: Vec<_> = std::iter::repeat_with(solana_sdk::pubkey::new_rand).take(256).collect(); let mut rng = thread_rng(); let mut num_inserts = 0; for _ in 0..4096 { @@ -484,14 +484,14 @@ mod test { let v1 = VersionedCrdsValue::new( 1, CrdsValue::new_unsigned(CrdsData::ContactInfo(ContactInfo::new_localhost( - &Pubkey::new_rand(), + &solana_sdk::pubkey::new_rand(), 0, ))), ); let v2 = VersionedCrdsValue::new( 1, CrdsValue::new_unsigned(CrdsData::ContactInfo(ContactInfo::new_localhost( - &Pubkey::new_rand(), + &solana_sdk::pubkey::new_rand(), 0, ))), ); diff --git a/core/src/crds_gossip_pull.rs b/core/src/crds_gossip_pull.rs index f65090b16..f3acad5fb 100644 --- a/core/src/crds_gossip_pull.rs +++ b/core/src/crds_gossip_pull.rs @@ -649,13 +649,13 @@ mod test { let mut stakes = HashMap::new(); let node = CrdsGossipPull::default(); let me = CrdsValue::new_unsigned(CrdsData::ContactInfo(ContactInfo::new_localhost( - &Pubkey::new_rand(), + &solana_sdk::pubkey::new_rand(), 0, ))); crds.insert(me.clone(), 0).unwrap(); for i in 1..=30 { let entry = CrdsValue::new_unsigned(CrdsData::ContactInfo(ContactInfo::new_localhost( - &Pubkey::new_rand(), + &solana_sdk::pubkey::new_rand(), 0, ))); let id = entry.label().pubkey(); @@ -682,25 +682,25 @@ mod test { let gossip = socketaddr!("127.0.0.1:1234"); let me = CrdsValue::new_unsigned(CrdsData::ContactInfo(ContactInfo { - id: Pubkey::new_rand(), + id: solana_sdk::pubkey::new_rand(), shred_version: 123, gossip, ..ContactInfo::default() })); let spy = CrdsValue::new_unsigned(CrdsData::ContactInfo(ContactInfo { - id: Pubkey::new_rand(), + id: solana_sdk::pubkey::new_rand(), shred_version: 0, gossip, ..ContactInfo::default() })); let node_123 = CrdsValue::new_unsigned(CrdsData::ContactInfo(ContactInfo { - id: Pubkey::new_rand(), + id: solana_sdk::pubkey::new_rand(), shred_version: 123, gossip, ..ContactInfo::default() })); let node_456 = CrdsValue::new_unsigned(CrdsData::ContactInfo(ContactInfo { - id: Pubkey::new_rand(), + id: solana_sdk::pubkey::new_rand(), shred_version: 456, gossip, ..ContactInfo::default() @@ -741,12 +741,12 @@ mod test { let gossip = socketaddr!("127.0.0.1:1234"); let me = CrdsValue::new_unsigned(CrdsData::ContactInfo(ContactInfo { - id: Pubkey::new_rand(), + id: solana_sdk::pubkey::new_rand(), gossip, ..ContactInfo::default() })); let node_123 = CrdsValue::new_unsigned(CrdsData::ContactInfo(ContactInfo { - id: Pubkey::new_rand(), + id: solana_sdk::pubkey::new_rand(), gossip, ..ContactInfo::default() })); @@ -767,7 +767,7 @@ mod test { assert!(options.is_empty()); // Unknown pubkey in gossip_validators -- will pull from nobody - gossip_validators.insert(Pubkey::new_rand()); + gossip_validators.insert(solana_sdk::pubkey::new_rand()); let options = node.pull_options( &crds, &me.label().pubkey(), @@ -898,7 +898,7 @@ mod test { let thread_pool = ThreadPoolBuilder::new().build().unwrap(); let mut crds = Crds::default(); let entry = CrdsValue::new_unsigned(CrdsData::ContactInfo(ContactInfo::new_localhost( - &Pubkey::new_rand(), + &solana_sdk::pubkey::new_rand(), 0, ))); let id = entry.label().pubkey(); @@ -933,7 +933,7 @@ mod test { ); let new = CrdsValue::new_unsigned(CrdsData::ContactInfo(ContactInfo::new_localhost( - &Pubkey::new_rand(), + &solana_sdk::pubkey::new_rand(), 0, ))); crds.insert(new.clone(), 0).unwrap(); @@ -957,19 +957,19 @@ mod test { let thread_pool = ThreadPoolBuilder::new().build().unwrap(); let mut crds = Crds::default(); let entry = CrdsValue::new_unsigned(CrdsData::ContactInfo(ContactInfo::new_localhost( - &Pubkey::new_rand(), + &solana_sdk::pubkey::new_rand(), 0, ))); let node_pubkey = entry.label().pubkey(); let mut node = CrdsGossipPull::default(); crds.insert(entry.clone(), 0).unwrap(); let old = CrdsValue::new_unsigned(CrdsData::ContactInfo(ContactInfo::new_localhost( - &Pubkey::new_rand(), + &solana_sdk::pubkey::new_rand(), 0, ))); crds.insert(old.clone(), 0).unwrap(); let new = CrdsValue::new_unsigned(CrdsData::ContactInfo(ContactInfo::new_localhost( - &Pubkey::new_rand(), + &solana_sdk::pubkey::new_rand(), 0, ))); crds.insert(new.clone(), 0).unwrap(); @@ -1000,14 +1000,14 @@ mod test { let thread_pool = ThreadPoolBuilder::new().build().unwrap(); let mut node_crds = Crds::default(); let entry = CrdsValue::new_unsigned(CrdsData::ContactInfo(ContactInfo::new_localhost( - &Pubkey::new_rand(), + &solana_sdk::pubkey::new_rand(), 0, ))); let node_pubkey = entry.label().pubkey(); let node = CrdsGossipPull::default(); node_crds.insert(entry, 0).unwrap(); let new = CrdsValue::new_unsigned(CrdsData::ContactInfo(ContactInfo::new_localhost( - &Pubkey::new_rand(), + &solana_sdk::pubkey::new_rand(), 0, ))); node_crds.insert(new, 0).unwrap(); @@ -1031,7 +1031,7 @@ mod test { assert_eq!(rsp[0].len(), 0); let new = CrdsValue::new_unsigned(CrdsData::ContactInfo(ContactInfo::new_localhost( - &Pubkey::new_rand(), + &solana_sdk::pubkey::new_rand(), CRDS_GOSSIP_PULL_MSG_TIMEOUT_MS, ))); dest_crds @@ -1047,7 +1047,7 @@ mod test { filters.push(filters[0].clone()); //should return new value since caller is new filters[1].0 = CrdsValue::new_unsigned(CrdsData::ContactInfo(ContactInfo::new_localhost( - &Pubkey::new_rand(), + &solana_sdk::pubkey::new_rand(), CRDS_GOSSIP_PULL_MSG_TIMEOUT_MS + 1, ))); @@ -1063,14 +1063,14 @@ mod test { let thread_pool = ThreadPoolBuilder::new().build().unwrap(); let mut node_crds = Crds::default(); let entry = CrdsValue::new_unsigned(CrdsData::ContactInfo(ContactInfo::new_localhost( - &Pubkey::new_rand(), + &solana_sdk::pubkey::new_rand(), 0, ))); let node_pubkey = entry.label().pubkey(); let node = CrdsGossipPull::default(); node_crds.insert(entry, 0).unwrap(); let new = CrdsValue::new_unsigned(CrdsData::ContactInfo(ContactInfo::new_localhost( - &Pubkey::new_rand(), + &solana_sdk::pubkey::new_rand(), 0, ))); node_crds.insert(new, 0).unwrap(); @@ -1113,7 +1113,7 @@ mod test { let thread_pool = ThreadPoolBuilder::new().build().unwrap(); let mut node_crds = Crds::default(); let entry = CrdsValue::new_unsigned(CrdsData::ContactInfo(ContactInfo::new_localhost( - &Pubkey::new_rand(), + &solana_sdk::pubkey::new_rand(), 1, ))); let node_pubkey = entry.label().pubkey(); @@ -1121,14 +1121,14 @@ mod test { node_crds.insert(entry, 0).unwrap(); let new = CrdsValue::new_unsigned(CrdsData::ContactInfo(ContactInfo::new_localhost( - &Pubkey::new_rand(), + &solana_sdk::pubkey::new_rand(), 1, ))); node_crds.insert(new, 0).unwrap(); let mut dest = CrdsGossipPull::default(); let mut dest_crds = Crds::default(); - let new_id = Pubkey::new_rand(); + let new_id = solana_sdk::pubkey::new_rand(); let new = CrdsValue::new_unsigned(CrdsData::ContactInfo(ContactInfo::new_localhost( &new_id, 1, ))); @@ -1210,7 +1210,7 @@ mod test { let thread_pool = ThreadPoolBuilder::new().build().unwrap(); let mut node_crds = Crds::default(); let entry = CrdsValue::new_unsigned(CrdsData::ContactInfo(ContactInfo::new_localhost( - &Pubkey::new_rand(), + &solana_sdk::pubkey::new_rand(), 0, ))); let node_label = entry.label(); @@ -1218,7 +1218,7 @@ mod test { let mut node = CrdsGossipPull::default(); node_crds.insert(entry, 0).unwrap(); let old = CrdsValue::new_unsigned(CrdsData::ContactInfo(ContactInfo::new_localhost( - &Pubkey::new_rand(), + &solana_sdk::pubkey::new_rand(), 0, ))); node_crds.insert(old.clone(), 0).unwrap(); @@ -1330,7 +1330,7 @@ mod test { let mut node_crds = Crds::default(); let mut node = CrdsGossipPull::default(); - let peer_pubkey = Pubkey::new_rand(); + let peer_pubkey = solana_sdk::pubkey::new_rand(); let peer_entry = CrdsValue::new_unsigned(CrdsData::ContactInfo( ContactInfo::new_localhost(&peer_pubkey, 0), )); diff --git a/core/src/crds_gossip_push.rs b/core/src/crds_gossip_push.rs index 07a9dc791..264986d7b 100644 --- a/core/src/crds_gossip_push.rs +++ b/core/src/crds_gossip_push.rs @@ -438,15 +438,15 @@ mod test { let mut push = CrdsGossipPush::default(); let mut stakes = HashMap::new(); - let self_id = Pubkey::new_rand(); - let origin = Pubkey::new_rand(); + let self_id = solana_sdk::pubkey::new_rand(); + let origin = solana_sdk::pubkey::new_rand(); stakes.insert(self_id, 100); stakes.insert(origin, 100); let value = CrdsValue::new_unsigned(CrdsData::ContactInfo(ContactInfo::new_localhost( &origin, 0, ))); - let low_staked_peers = (0..10).map(|_| Pubkey::new_rand()); + let low_staked_peers = (0..10).map(|_| solana_sdk::pubkey::new_rand()); let mut low_staked_set = HashSet::new(); low_staked_peers.for_each(|p| { let _ = push.process_push_message(&mut crds, &p, value.clone(), 0); @@ -460,7 +460,7 @@ mod test { "should not prune if min threshold has not been reached" ); - let high_staked_peer = Pubkey::new_rand(); + let high_staked_peer = solana_sdk::pubkey::new_rand(); let high_stake = CrdsGossipPush::prune_stake_threshold(100, 100) + 10; stakes.insert(high_staked_peer, high_stake); let _ = push.process_push_message(&mut crds, &high_staked_peer, value, 0); @@ -483,7 +483,7 @@ mod test { let mut crds = Crds::default(); let mut push = CrdsGossipPush::default(); let value = CrdsValue::new_unsigned(CrdsData::ContactInfo(ContactInfo::new_localhost( - &Pubkey::new_rand(), + &solana_sdk::pubkey::new_rand(), 0, ))); let label = value.label(); @@ -504,7 +504,7 @@ mod test { fn test_process_push_old_version() { let mut crds = Crds::default(); let mut push = CrdsGossipPush::default(); - let mut ci = ContactInfo::new_localhost(&Pubkey::new_rand(), 0); + let mut ci = ContactInfo::new_localhost(&solana_sdk::pubkey::new_rand(), 0); ci.wallclock = 1; let value = CrdsValue::new_unsigned(CrdsData::ContactInfo(ci.clone())); @@ -527,7 +527,7 @@ mod test { let mut crds = Crds::default(); let mut push = CrdsGossipPush::default(); let timeout = push.msg_timeout; - let mut ci = ContactInfo::new_localhost(&Pubkey::new_rand(), 0); + let mut ci = ContactInfo::new_localhost(&solana_sdk::pubkey::new_rand(), 0); // push a version to far in the future ci.wallclock = timeout + 1; @@ -549,7 +549,7 @@ mod test { fn test_process_push_update() { let mut crds = Crds::default(); let mut push = CrdsGossipPush::default(); - let mut ci = ContactInfo::new_localhost(&Pubkey::new_rand(), 0); + let mut ci = ContactInfo::new_localhost(&solana_sdk::pubkey::new_rand(), 0); ci.wallclock = 0; let value_old = CrdsValue::new_unsigned(CrdsData::ContactInfo(ci.clone())); @@ -584,7 +584,7 @@ mod test { let mut crds = Crds::default(); let mut push = CrdsGossipPush::default(); let value1 = CrdsValue::new_unsigned(CrdsData::ContactInfo(ContactInfo::new_localhost( - &Pubkey::new_rand(), + &solana_sdk::pubkey::new_rand(), 0, ))); @@ -593,7 +593,7 @@ mod test { assert!(push.active_set.get(&value1.label().pubkey()).is_some()); let value2 = CrdsValue::new_unsigned(CrdsData::ContactInfo(ContactInfo::new_localhost( - &Pubkey::new_rand(), + &solana_sdk::pubkey::new_rand(), 0, ))); assert!(push.active_set.get(&value2.label().pubkey()).is_none()); @@ -608,7 +608,7 @@ mod test { for _ in 0..push.num_active { let value2 = CrdsValue::new_unsigned(CrdsData::ContactInfo( - ContactInfo::new_localhost(&Pubkey::new_rand(), 0), + ContactInfo::new_localhost(&solana_sdk::pubkey::new_rand(), 0), )); assert_eq!(crds.insert(value2.clone(), now), Ok(None)); } @@ -624,7 +624,7 @@ mod test { let mut stakes = HashMap::new(); for i in 1..=100 { let peer = CrdsValue::new_unsigned(CrdsData::ContactInfo(ContactInfo::new_localhost( - &Pubkey::new_rand(), + &solana_sdk::pubkey::new_rand(), time, ))); let id = peer.label().pubkey(); @@ -652,25 +652,25 @@ mod test { let gossip = socketaddr!("127.0.0.1:1234"); let me = CrdsValue::new_unsigned(CrdsData::ContactInfo(ContactInfo { - id: Pubkey::new_rand(), + id: solana_sdk::pubkey::new_rand(), shred_version: 123, gossip, ..ContactInfo::default() })); let spy = CrdsValue::new_unsigned(CrdsData::ContactInfo(ContactInfo { - id: Pubkey::new_rand(), + id: solana_sdk::pubkey::new_rand(), shred_version: 0, gossip, ..ContactInfo::default() })); let node_123 = CrdsValue::new_unsigned(CrdsData::ContactInfo(ContactInfo { - id: Pubkey::new_rand(), + id: solana_sdk::pubkey::new_rand(), shred_version: 123, gossip, ..ContactInfo::default() })); let node_456 = CrdsValue::new_unsigned(CrdsData::ContactInfo(ContactInfo { - id: Pubkey::new_rand(), + id: solana_sdk::pubkey::new_rand(), shred_version: 456, gossip, ..ContactInfo::default() @@ -709,12 +709,12 @@ mod test { let gossip = socketaddr!("127.0.0.1:1234"); let me = CrdsValue::new_unsigned(CrdsData::ContactInfo(ContactInfo { - id: Pubkey::new_rand(), + id: solana_sdk::pubkey::new_rand(), gossip, ..ContactInfo::default() })); let node_123 = CrdsValue::new_unsigned(CrdsData::ContactInfo(ContactInfo { - id: Pubkey::new_rand(), + id: solana_sdk::pubkey::new_rand(), gossip, ..ContactInfo::default() })); @@ -735,7 +735,7 @@ mod test { assert!(options.is_empty()); // Unknown pubkey in gossip_validators -- will push to nobody - gossip_validators.insert(Pubkey::new_rand()); + gossip_validators.insert(solana_sdk::pubkey::new_rand()); let options = node.push_options( &crds, &me.label().pubkey(), @@ -765,14 +765,14 @@ mod test { let mut crds = Crds::default(); let mut push = CrdsGossipPush::default(); let peer = CrdsValue::new_unsigned(CrdsData::ContactInfo(ContactInfo::new_localhost( - &Pubkey::new_rand(), + &solana_sdk::pubkey::new_rand(), 0, ))); assert_eq!(crds.insert(peer.clone(), now), Ok(None)); push.refresh_push_active_set(&crds, &HashMap::new(), None, &Pubkey::default(), 0, 1, 1); let new_msg = CrdsValue::new_unsigned(CrdsData::ContactInfo(ContactInfo::new_localhost( - &Pubkey::new_rand(), + &solana_sdk::pubkey::new_rand(), 0, ))); let mut expected = HashMap::new(); @@ -790,17 +790,17 @@ mod test { let mut crds = Crds::default(); let mut push = CrdsGossipPush::default(); let peer_1 = CrdsValue::new_unsigned(CrdsData::ContactInfo(ContactInfo::new_localhost( - &Pubkey::new_rand(), + &solana_sdk::pubkey::new_rand(), 0, ))); assert_eq!(crds.insert(peer_1.clone(), now), Ok(None)); let peer_2 = CrdsValue::new_unsigned(CrdsData::ContactInfo(ContactInfo::new_localhost( - &Pubkey::new_rand(), + &solana_sdk::pubkey::new_rand(), 0, ))); assert_eq!(crds.insert(peer_2.clone(), now), Ok(None)); let peer_3 = CrdsValue::new_unsigned(CrdsData::ContactInfo(ContactInfo::new_localhost( - &Pubkey::new_rand(), + &solana_sdk::pubkey::new_rand(), now, ))); assert_eq!( @@ -823,17 +823,17 @@ mod test { #[test] fn test_process_prune() { let mut crds = Crds::default(); - let self_id = Pubkey::new_rand(); + let self_id = solana_sdk::pubkey::new_rand(); let mut push = CrdsGossipPush::default(); let peer = CrdsValue::new_unsigned(CrdsData::ContactInfo(ContactInfo::new_localhost( - &Pubkey::new_rand(), + &solana_sdk::pubkey::new_rand(), 0, ))); assert_eq!(crds.insert(peer.clone(), 0), Ok(None)); push.refresh_push_active_set(&crds, &HashMap::new(), None, &Pubkey::default(), 0, 1, 1); let new_msg = CrdsValue::new_unsigned(CrdsData::ContactInfo(ContactInfo::new_localhost( - &Pubkey::new_rand(), + &solana_sdk::pubkey::new_rand(), 0, ))); let expected = HashMap::new(); @@ -853,13 +853,13 @@ mod test { let mut crds = Crds::default(); let mut push = CrdsGossipPush::default(); let peer = CrdsValue::new_unsigned(CrdsData::ContactInfo(ContactInfo::new_localhost( - &Pubkey::new_rand(), + &solana_sdk::pubkey::new_rand(), 0, ))); assert_eq!(crds.insert(peer, 0), Ok(None)); push.refresh_push_active_set(&crds, &HashMap::new(), None, &Pubkey::default(), 0, 1, 1); - let mut ci = ContactInfo::new_localhost(&Pubkey::new_rand(), 0); + let mut ci = ContactInfo::new_localhost(&solana_sdk::pubkey::new_rand(), 0); ci.wallclock = 1; let new_msg = CrdsValue::new_unsigned(CrdsData::ContactInfo(ci)); let expected = HashMap::new(); @@ -875,7 +875,7 @@ mod test { fn test_purge_old_received_cache() { let mut crds = Crds::default(); let mut push = CrdsGossipPush::default(); - let mut ci = ContactInfo::new_localhost(&Pubkey::new_rand(), 0); + let mut ci = ContactInfo::new_localhost(&solana_sdk::pubkey::new_rand(), 0); ci.wallclock = 0; let value = CrdsValue::new_unsigned(CrdsData::ContactInfo(ci)); let label = value.label(); diff --git a/core/src/crds_shards.rs b/core/src/crds_shards.rs index 917eb656d..60676304c 100644 --- a/core/src/crds_shards.rs +++ b/core/src/crds_shards.rs @@ -142,7 +142,7 @@ mod test { fn new_test_crds_value() -> VersionedCrdsValue { let data = - CrdsData::ContactInfo(ContactInfo::new_localhost(&Pubkey::new_rand(), timestamp())); + CrdsData::ContactInfo(ContactInfo::new_localhost(&solana_sdk::pubkey::new_rand(), timestamp())); VersionedCrdsValue::new(timestamp(), CrdsValue::new_unsigned(data)) } diff --git a/core/src/crds_value.rs b/core/src/crds_value.rs index f4c84d0e2..bc800a3c2 100644 --- a/core/src/crds_value.rs +++ b/core/src/crds_value.rs @@ -318,7 +318,7 @@ impl CrdsValue { R: rand::Rng, { let now = rng.gen(); - let contact_info = ContactInfo::new_localhost(&Pubkey::new_rand(), now); + let contact_info = ContactInfo::new_localhost(&solana_sdk::pubkey::new_rand(), now); Self::new_signed(CrdsData::ContactInfo(contact_info), &Keypair::new()) } diff --git a/core/src/gossip_service.rs b/core/src/gossip_service.rs index 9892b62b8..d5bf6b2ad 100644 --- a/core/src/gossip_service.rs +++ b/core/src/gossip_service.rs @@ -306,8 +306,8 @@ mod tests { #[test] fn test_gossip_services_spy() { let keypair = Keypair::new(); - let peer0 = Pubkey::new_rand(); - let peer1 = Pubkey::new_rand(); + let peer0 = solana_sdk::pubkey::new_rand(); + let peer1 = solana_sdk::pubkey::new_rand(); let contact_info = ContactInfo::new_localhost(&keypair.pubkey(), 0); let peer0_info = ContactInfo::new_localhost(&peer0, 0); let peer1_info = ContactInfo::new_localhost(&peer1, 0); @@ -335,7 +335,7 @@ mod tests { spy_ref.clone(), None, Some(0), - Some(Pubkey::new_rand()), + Some(solana_sdk::pubkey::new_rand()), None, ); assert_eq!(met_criteria, false); @@ -349,7 +349,7 @@ mod tests { spy_ref.clone(), Some(1), Some(0), - Some(Pubkey::new_rand()), + Some(solana_sdk::pubkey::new_rand()), None, ); assert_eq!(met_criteria, false); diff --git a/core/src/non_circulating_supply.rs b/core/src/non_circulating_supply.rs index 5cd5222c0..de514996a 100644 --- a/core/src/non_circulating_supply.rs +++ b/core/src/non_circulating_supply.rs @@ -135,7 +135,7 @@ mod tests { let num_genesis_accounts = 10; for _ in 0..num_genesis_accounts { accounts.insert( - Pubkey::new_rand(), + solana_sdk::pubkey::new_rand(), Account::new(balance, 0, &Pubkey::default()), ); } @@ -147,7 +147,7 @@ mod tests { let num_stake_accounts = 3; for _ in 0..num_stake_accounts { - let pubkey = Pubkey::new_rand(); + let pubkey = solana_sdk::pubkey::new_rand(); let meta = Meta { authorized: Authorized::auto(&pubkey), lockup: Lockup { diff --git a/core/src/progress_map.rs b/core/src/progress_map.rs index 47eba07e3..edd144a81 100644 --- a/core/src/progress_map.rs +++ b/core/src/progress_map.rs @@ -401,7 +401,7 @@ mod test { fn test_add_vote_pubkey() { let mut stats = PropagatedStats::default(); let mut all_pubkeys = PubkeyReferences::default(); - let mut vote_pubkey = Pubkey::new_rand(); + let mut vote_pubkey = solana_sdk::pubkey::new_rand(); all_pubkeys.get_or_insert(&vote_pubkey); // Add a vote pubkey, the number of references in all_pubkeys @@ -420,7 +420,7 @@ mod test { assert_eq!(stats.propagated_validators_stake, 1); // Adding another pubkey should succeed - vote_pubkey = Pubkey::new_rand(); + vote_pubkey = solana_sdk::pubkey::new_rand(); stats.add_vote_pubkey(&vote_pubkey, &mut all_pubkeys, 2); assert!(stats.propagated_validators.contains(&vote_pubkey)); assert_eq!(stats.propagated_validators_stake, 3); @@ -434,7 +434,7 @@ mod test { fn test_add_node_pubkey_internal() { let num_vote_accounts = 10; let staked_vote_accounts = 5; - let vote_account_pubkeys: Vec<_> = std::iter::repeat_with(Pubkey::new_rand) + let vote_account_pubkeys: Vec<_> = std::iter::repeat_with(solana_sdk::pubkey::new_rand) .take(num_vote_accounts) .collect(); let epoch_vote_accounts: HashMap<_, _> = vote_account_pubkeys @@ -445,7 +445,7 @@ mod test { let mut stats = PropagatedStats::default(); let mut all_pubkeys = PubkeyReferences::default(); - let mut node_pubkey = Pubkey::new_rand(); + let mut node_pubkey = solana_sdk::pubkey::new_rand(); all_pubkeys.get_or_insert(&node_pubkey); // Add a vote pubkey, the number of references in all_pubkeys @@ -481,7 +481,7 @@ mod test { // Adding another pubkey with same vote accounts should succeed, but stake // shouldn't increase - node_pubkey = Pubkey::new_rand(); + node_pubkey = solana_sdk::pubkey::new_rand(); stats.add_node_pubkey_internal( &node_pubkey, &mut all_pubkeys, @@ -500,8 +500,8 @@ mod test { // Adding another pubkey with different vote accounts should succeed // and increase stake - node_pubkey = Pubkey::new_rand(); - let vote_account_pubkeys: Vec<_> = std::iter::repeat_with(Pubkey::new_rand) + node_pubkey = solana_sdk::pubkey::new_rand(); + let vote_account_pubkeys: Vec<_> = std::iter::repeat_with(solana_sdk::pubkey::new_rand) .take(num_vote_accounts) .collect(); let epoch_vote_accounts: HashMap<_, _> = vote_account_pubkeys diff --git a/core/src/replay_stage.rs b/core/src/replay_stage.rs index b53e73475..5526ce07a 100644 --- a/core/src/replay_stage.rs +++ b/core/src/replay_stage.rs @@ -2554,7 +2554,7 @@ pub(crate) mod tests { bank.store_account(&pubkey, &leader_vote_account); } - let leader_pubkey = Pubkey::new_rand(); + let leader_pubkey = solana_sdk::pubkey::new_rand(); let leader_lamports = 3; let genesis_config_info = create_genesis_config_with_leader(50, &leader_pubkey, leader_lamports); @@ -2596,7 +2596,7 @@ pub(crate) mod tests { .is_none()); let bank1 = Bank::new_from_parent(&arc_bank0, &Pubkey::default(), arc_bank0.slot() + 1); - let _res = bank1.transfer(10, &genesis_config_info.mint_keypair, &Pubkey::new_rand()); + let _res = bank1.transfer(10, &genesis_config_info.mint_keypair, &solana_sdk::pubkey::new_rand()); for _ in 0..genesis_config.ticks_per_slot { bank1.register_tick(&Hash::default()); } @@ -2612,7 +2612,7 @@ pub(crate) mod tests { ); let bank2 = Bank::new_from_parent(&arc_bank1, &Pubkey::default(), arc_bank1.slot() + 1); - let _res = bank2.transfer(10, &genesis_config_info.mint_keypair, &Pubkey::new_rand()); + let _res = bank2.transfer(10, &genesis_config_info.mint_keypair, &solana_sdk::pubkey::new_rand()); for _ in 0..genesis_config.ticks_per_slot { bank2.register_tick(&Hash::default()); } diff --git a/core/src/retransmit_stage.rs b/core/src/retransmit_stage.rs index 3ef9575c1..c15116305 100644 --- a/core/src/retransmit_stage.rs +++ b/core/src/retransmit_stage.rs @@ -521,7 +521,7 @@ mod tests { let leader_schedule_cache = Arc::new(cached_leader_schedule); let bank_forks = Arc::new(RwLock::new(bank_forks)); - let mut me = ContactInfo::new_localhost(&Pubkey::new_rand(), 0); + let mut me = ContactInfo::new_localhost(&solana_sdk::pubkey::new_rand(), 0); let ip_addr = IpAddr::V4(Ipv4Addr::new(0, 0, 0, 0)); let port = find_available_port_in_range(ip_addr, (8000, 10000)).unwrap(); let me_retransmit = UdpSocket::bind(format!("127.0.0.1:{}", port)).unwrap(); @@ -533,7 +533,7 @@ mod tests { .local_addr() .unwrap(); - let other = ContactInfo::new_localhost(&Pubkey::new_rand(), 0); + let other = ContactInfo::new_localhost(&solana_sdk::pubkey::new_rand(), 0); let cluster_info = ClusterInfo::new_with_invalid_keypair(other); cluster_info.insert_info(me); diff --git a/core/src/rpc.rs b/core/src/rpc.rs index 830cf734a..9bd9d88f6 100644 --- a/core/src/rpc.rs +++ b/core/src/rpc.rs @@ -2904,7 +2904,7 @@ pub mod tests { #[test] fn test_rpc_request_processor_new() { - let bob_pubkey = Pubkey::new_rand(); + let bob_pubkey = solana_sdk::pubkey::new_rand(); let genesis = create_genesis_config(100); let bank = Arc::new(Bank::new(&genesis.genesis_config)); bank.transfer(20, &genesis.mint_keypair, &bob_pubkey) @@ -2964,7 +2964,7 @@ pub mod tests { #[test] fn test_rpc_get_cluster_nodes() { - let bob_pubkey = Pubkey::new_rand(); + let bob_pubkey = solana_sdk::pubkey::new_rand(); let RpcHandler { io, meta, @@ -2991,7 +2991,7 @@ pub mod tests { #[test] fn test_rpc_get_recent_performance_samples() { - let bob_pubkey = Pubkey::new_rand(); + let bob_pubkey = solana_sdk::pubkey::new_rand(); let RpcHandler { io, meta, .. } = start_rpc_handler_with_tx(&bob_pubkey); let req = r#"{"jsonrpc":"2.0","id":1,"method":"getRecentPerformanceSamples"}"#; @@ -3020,7 +3020,7 @@ pub mod tests { #[test] fn test_rpc_get_recent_performance_samples_invalid_limit() { - let bob_pubkey = Pubkey::new_rand(); + let bob_pubkey = solana_sdk::pubkey::new_rand(); let RpcHandler { io, meta, .. } = start_rpc_handler_with_tx(&bob_pubkey); let req = @@ -3046,7 +3046,7 @@ pub mod tests { #[test] fn test_rpc_get_slot_leader() { - let bob_pubkey = Pubkey::new_rand(); + let bob_pubkey = solana_sdk::pubkey::new_rand(); let RpcHandler { io, meta, @@ -3066,7 +3066,7 @@ pub mod tests { #[test] fn test_rpc_get_tx_count() { - let bob_pubkey = Pubkey::new_rand(); + let bob_pubkey = solana_sdk::pubkey::new_rand(); let genesis = create_genesis_config(10); let bank = Arc::new(Bank::new(&genesis.genesis_config)); // Add 4 transactions @@ -3096,7 +3096,7 @@ pub mod tests { #[test] fn test_rpc_minimum_ledger_slot() { - let bob_pubkey = Pubkey::new_rand(); + let bob_pubkey = solana_sdk::pubkey::new_rand(); let RpcHandler { io, meta, .. } = start_rpc_handler_with_tx(&bob_pubkey); let req = r#"{"jsonrpc":"2.0","id":1,"method":"minimumLedgerSlot"}"#; @@ -3111,7 +3111,7 @@ pub mod tests { #[test] fn test_rpc_get_total_supply() { - let bob_pubkey = Pubkey::new_rand(); + let bob_pubkey = solana_sdk::pubkey::new_rand(); let RpcHandler { io, meta, .. } = start_rpc_handler_with_tx(&bob_pubkey); let req = r#"{"jsonrpc":"2.0","id":1,"method":"getTotalSupply"}"#; @@ -3136,7 +3136,7 @@ pub mod tests { #[test] fn test_get_supply() { - let bob_pubkey = Pubkey::new_rand(); + let bob_pubkey = solana_sdk::pubkey::new_rand(); let RpcHandler { io, meta, .. } = start_rpc_handler_with_tx(&bob_pubkey); let req = r#"{"jsonrpc":"2.0","id":1,"method":"getSupply"}"#; let res = io.handle_request_sync(&req, meta); @@ -3161,7 +3161,7 @@ pub mod tests { #[test] fn test_get_largest_accounts() { - let bob_pubkey = Pubkey::new_rand(); + let bob_pubkey = solana_sdk::pubkey::new_rand(); let RpcHandler { io, meta, alice, .. } = start_rpc_handler_with_tx(&bob_pubkey); @@ -3220,7 +3220,7 @@ pub mod tests { #[test] fn test_rpc_get_minimum_balance_for_rent_exemption() { - let bob_pubkey = Pubkey::new_rand(); + let bob_pubkey = solana_sdk::pubkey::new_rand(); let data_len = 50; let RpcHandler { io, meta, bank, .. } = start_rpc_handler_with_tx(&bob_pubkey); @@ -3252,7 +3252,7 @@ pub mod tests { #[test] fn test_rpc_get_inflation() { - let bob_pubkey = Pubkey::new_rand(); + let bob_pubkey = solana_sdk::pubkey::new_rand(); let RpcHandler { io, meta, bank, .. } = start_rpc_handler_with_tx(&bob_pubkey); let req = r#"{"jsonrpc":"2.0","id":1,"method":"getInflationGovernor"}"#; @@ -3299,7 +3299,7 @@ pub mod tests { #[test] fn test_rpc_get_epoch_schedule() { - let bob_pubkey = Pubkey::new_rand(); + let bob_pubkey = solana_sdk::pubkey::new_rand(); let RpcHandler { io, meta, bank, .. } = start_rpc_handler_with_tx(&bob_pubkey); let req = r#"{"jsonrpc":"2.0","id":1,"method":"getEpochSchedule"}"#; @@ -3321,7 +3321,7 @@ pub mod tests { #[test] fn test_rpc_get_leader_schedule() { - let bob_pubkey = Pubkey::new_rand(); + let bob_pubkey = solana_sdk::pubkey::new_rand(); let RpcHandler { io, meta, bank, .. } = start_rpc_handler_with_tx(&bob_pubkey); for req in [ @@ -3377,7 +3377,7 @@ pub mod tests { #[test] fn test_rpc_get_account_info() { - let bob_pubkey = Pubkey::new_rand(); + let bob_pubkey = solana_sdk::pubkey::new_rand(); let RpcHandler { io, meta, bank, .. } = start_rpc_handler_with_tx(&bob_pubkey); let req = format!( @@ -3405,7 +3405,7 @@ pub mod tests { .expect("actual response deserialization"); assert_eq!(expected, result); - let address = Pubkey::new_rand(); + let address = solana_sdk::pubkey::new_rand(); let data = vec![1, 2, 3, 4, 5]; let mut account = Account::new(42, 5, &Pubkey::default()); account.data = data.clone(); @@ -3459,7 +3459,7 @@ pub mod tests { #[test] fn test_rpc_get_multiple_accounts() { - let bob_pubkey = Pubkey::new_rand(); + let bob_pubkey = solana_sdk::pubkey::new_rand(); let RpcHandler { io, meta, bank, .. } = start_rpc_handler_with_tx(&bob_pubkey); let address = Pubkey::new(&[9; 32]); @@ -3586,7 +3586,7 @@ pub mod tests { .. } = start_rpc_handler_with_tx(&bob.pubkey()); - let new_program_id = Pubkey::new_rand(); + let new_program_id = solana_sdk::pubkey::new_rand(); let tx = system_transaction::assign(&bob, blockhash, &new_program_id); bank.process_transaction(&tx).unwrap(); let req = format!( @@ -3633,7 +3633,7 @@ pub mod tests { bank.process_transaction(&tx).unwrap(); let nonce_keypair1 = Keypair::new(); - let authority = Pubkey::new_rand(); + let authority = solana_sdk::pubkey::new_rand(); let instruction = system_instruction::create_nonce_account( &alice.pubkey(), &nonce_keypair1.pubkey(), @@ -3776,7 +3776,7 @@ pub mod tests { #[test] fn test_rpc_simulate_transaction() { - let bob_pubkey = Pubkey::new_rand(); + let bob_pubkey = solana_sdk::pubkey::new_rand(); let RpcHandler { io, meta, @@ -3877,7 +3877,7 @@ pub mod tests { #[test] #[should_panic] fn test_rpc_simulate_transaction_panic_on_unfrozen_bank() { - let bob_pubkey = Pubkey::new_rand(); + let bob_pubkey = solana_sdk::pubkey::new_rand(); let RpcHandler { io, meta, @@ -3903,7 +3903,7 @@ pub mod tests { #[test] fn test_rpc_confirm_tx() { - let bob_pubkey = Pubkey::new_rand(); + let bob_pubkey = solana_sdk::pubkey::new_rand(); let RpcHandler { io, meta, @@ -3935,7 +3935,7 @@ pub mod tests { #[test] fn test_rpc_get_signature_status() { - let bob_pubkey = Pubkey::new_rand(); + let bob_pubkey = solana_sdk::pubkey::new_rand(); let RpcHandler { io, meta, @@ -4005,7 +4005,7 @@ pub mod tests { #[test] fn test_rpc_get_signature_statuses() { - let bob_pubkey = Pubkey::new_rand(); + let bob_pubkey = solana_sdk::pubkey::new_rand(); let RpcHandler { io, meta, @@ -4061,7 +4061,7 @@ pub mod tests { #[test] fn test_rpc_get_recent_blockhash() { - let bob_pubkey = Pubkey::new_rand(); + let bob_pubkey = solana_sdk::pubkey::new_rand(); let RpcHandler { io, meta, @@ -4092,7 +4092,7 @@ pub mod tests { #[test] fn test_rpc_get_fees() { - let bob_pubkey = Pubkey::new_rand(); + let bob_pubkey = solana_sdk::pubkey::new_rand(); let RpcHandler { io, meta, @@ -4124,7 +4124,7 @@ pub mod tests { #[test] fn test_rpc_get_fee_calculator_for_blockhash() { - let bob_pubkey = Pubkey::new_rand(); + let bob_pubkey = solana_sdk::pubkey::new_rand(); let RpcHandler { io, meta, bank, .. } = start_rpc_handler_with_tx(&bob_pubkey); let (blockhash, fee_calculator) = bank.last_blockhash_with_fee_calculator(); @@ -4172,7 +4172,7 @@ pub mod tests { #[test] fn test_rpc_get_fee_rate_governor() { - let bob_pubkey = Pubkey::new_rand(); + let bob_pubkey = solana_sdk::pubkey::new_rand(); let RpcHandler { io, meta, .. } = start_rpc_handler_with_tx(&bob_pubkey); let req = r#"{"jsonrpc":"2.0","id":1,"method":"getFeeRateGovernor"}"#; @@ -4201,7 +4201,7 @@ pub mod tests { #[test] fn test_rpc_fail_request_airdrop() { - let bob_pubkey = Pubkey::new_rand(); + let bob_pubkey = solana_sdk::pubkey::new_rand(); let RpcHandler { io, meta, .. } = start_rpc_handler_with_tx(&bob_pubkey); // Expect internal error because no faucet is available @@ -4272,7 +4272,7 @@ pub mod tests { SendTransactionService::new(tpu_address, &bank_forks, None, receiver); let mut bad_transaction = - system_transaction::transfer(&mint_keypair, &Pubkey::new_rand(), 42, Hash::default()); + system_transaction::transfer(&mint_keypair, &solana_sdk::pubkey::new_rand(), 42, Hash::default()); // sendTransaction will fail because the blockhash is invalid let req = format!( @@ -4303,7 +4303,7 @@ pub mod tests { ) ); let mut bad_transaction = - system_transaction::transfer(&mint_keypair, &Pubkey::new_rand(), 42, recent_blockhash); + system_transaction::transfer(&mint_keypair, &solana_sdk::pubkey::new_rand(), 42, recent_blockhash); // sendTransaction will fail due to poor node health health.stub_set_health_status(Some(RpcHealthStatus::Behind)); @@ -4386,7 +4386,7 @@ pub mod tests { #[test] fn test_rpc_verify_pubkey() { - let pubkey = Pubkey::new_rand(); + let pubkey = solana_sdk::pubkey::new_rand(); assert_eq!(verify_pubkey(pubkey.to_string()).unwrap(), pubkey); let bad_pubkey = "a1b2c3d4"; assert_eq!( @@ -4397,7 +4397,7 @@ pub mod tests { #[test] fn test_rpc_verify_signature() { - let tx = system_transaction::transfer(&Keypair::new(), &Pubkey::new_rand(), 20, hash(&[0])); + let tx = system_transaction::transfer(&Keypair::new(), &solana_sdk::pubkey::new_rand(), 20, hash(&[0])); assert_eq!( verify_signature(&tx.signatures[0].to_string()).unwrap(), tx.signatures[0] @@ -4489,7 +4489,7 @@ pub mod tests { #[test] fn test_rpc_get_identity() { - let bob_pubkey = Pubkey::new_rand(); + let bob_pubkey = solana_sdk::pubkey::new_rand(); let RpcHandler { io, meta, .. } = start_rpc_handler_with_tx(&bob_pubkey); let req = r#"{"jsonrpc":"2.0","id":1,"method":"getIdentity"}"#; @@ -4510,7 +4510,7 @@ pub mod tests { #[test] fn test_rpc_get_version() { - let bob_pubkey = Pubkey::new_rand(); + let bob_pubkey = solana_sdk::pubkey::new_rand(); let RpcHandler { io, meta, .. } = start_rpc_handler_with_tx(&bob_pubkey); let req = r#"{"jsonrpc":"2.0","id":1,"method":"getVersion"}"#; @@ -4597,7 +4597,7 @@ pub mod tests { #[test] fn test_rpc_get_block_commitment() { - let bob_pubkey = Pubkey::new_rand(); + let bob_pubkey = solana_sdk::pubkey::new_rand(); let RpcHandler { io, meta, @@ -4651,7 +4651,7 @@ pub mod tests { #[test] fn test_get_confirmed_block() { - let bob_pubkey = Pubkey::new_rand(); + let bob_pubkey = solana_sdk::pubkey::new_rand(); let RpcHandler { io, meta, @@ -4749,7 +4749,7 @@ pub mod tests { #[test] fn test_get_confirmed_blocks() { - let bob_pubkey = Pubkey::new_rand(); + let bob_pubkey = solana_sdk::pubkey::new_rand(); let roots = vec![0, 1, 3, 4, 8]; let RpcHandler { io, @@ -4826,7 +4826,7 @@ pub mod tests { #[test] fn test_get_confirmed_blocks_with_limit() { - let bob_pubkey = Pubkey::new_rand(); + let bob_pubkey = solana_sdk::pubkey::new_rand(); let roots = vec![0, 1, 3, 4, 8]; let RpcHandler { io, @@ -4889,7 +4889,7 @@ pub mod tests { #[test] fn test_get_block_time() { - let bob_pubkey = Pubkey::new_rand(); + let bob_pubkey = solana_sdk::pubkey::new_rand(); let base_timestamp = 1_576_183_541; let RpcHandler { io, @@ -4976,7 +4976,7 @@ pub mod tests { leader_vote_keypair, block_commitment_cache, .. - } = start_rpc_handler_with_tx(&Pubkey::new_rand()); + } = start_rpc_handler_with_tx(&solana_sdk::pubkey::new_rand()); assert_eq!(bank.vote_accounts().len(), 1); @@ -5192,7 +5192,7 @@ pub mod tests { #[test] fn test_token_rpcs() { - let RpcHandler { io, meta, bank, .. } = start_rpc_handler_with_tx(&Pubkey::new_rand()); + let RpcHandler { io, meta, bank, .. } = start_rpc_handler_with_tx(&solana_sdk::pubkey::new_rand()); let mut account_data = vec![0; TokenAccount::get_packed_len()]; let mint = SplTokenPubkey::new(&[2; 32]); @@ -5215,7 +5215,7 @@ pub mod tests { owner: spl_token_id_v2_0(), ..Account::default() }; - let token_account_pubkey = Pubkey::new_rand(); + let token_account_pubkey = solana_sdk::pubkey::new_rand(); bank.store_account(&token_account_pubkey, &token_account); // Add the mint @@ -5253,7 +5253,7 @@ pub mod tests { // Test non-existent token account let req = format!( r#"{{"jsonrpc":"2.0","id":1,"method":"getTokenAccountBalance","params":["{}"]}}"#, - Pubkey::new_rand(), + solana_sdk::pubkey::new_rand(), ); let res = io.handle_request_sync(&req, meta.clone()); let result: Value = serde_json::from_str(&res.expect("actual response")) @@ -5278,7 +5278,7 @@ pub mod tests { // Test non-existent mint address let req = format!( r#"{{"jsonrpc":"2.0","id":1,"method":"getTokenSupply","params":["{}"]}}"#, - Pubkey::new_rand(), + solana_sdk::pubkey::new_rand(), ); let res = io.handle_request_sync(&req, meta.clone()); let result: Value = serde_json::from_str(&res.expect("actual response")) @@ -5286,7 +5286,7 @@ pub mod tests { assert!(result.get("error").is_some()); // Add another token account with the same owner, delegate, and mint - let other_token_account_pubkey = Pubkey::new_rand(); + let other_token_account_pubkey = solana_sdk::pubkey::new_rand(); bank.store_account(&other_token_account_pubkey, &token_account); // Add another token account with the same owner and delegate but different mint @@ -5309,7 +5309,7 @@ pub mod tests { owner: spl_token_id_v2_0(), ..Account::default() }; - let token_with_different_mint_pubkey = Pubkey::new_rand(); + let token_with_different_mint_pubkey = solana_sdk::pubkey::new_rand(); bank.store_account(&token_with_different_mint_pubkey, &token_account); // Test getTokenAccountsByOwner with Token program id returns all accounts, regardless of Mint address @@ -5390,7 +5390,7 @@ pub mod tests { "params":["{}", {{"programId": "{}"}}] }}"#, owner, - Pubkey::new_rand(), + solana_sdk::pubkey::new_rand(), ); let res = io.handle_request_sync(&req, meta.clone()); let result: Value = serde_json::from_str(&res.expect("actual response")) @@ -5404,7 +5404,7 @@ pub mod tests { "params":["{}", {{"mint": "{}"}}] }}"#, owner, - Pubkey::new_rand(), + solana_sdk::pubkey::new_rand(), ); let res = io.handle_request_sync(&req, meta.clone()); let result: Value = serde_json::from_str(&res.expect("actual response")) @@ -5419,7 +5419,7 @@ pub mod tests { "method":"getTokenAccountsByOwner", "params":["{}", {{"programId": "{}"}}] }}"#, - Pubkey::new_rand(), + solana_sdk::pubkey::new_rand(), spl_token_id_v2_0(), ); let res = io.handle_request_sync(&req, meta.clone()); @@ -5473,7 +5473,7 @@ pub mod tests { "params":["{}", {{"programId": "{}"}}] }}"#, delegate, - Pubkey::new_rand(), + solana_sdk::pubkey::new_rand(), ); let res = io.handle_request_sync(&req, meta.clone()); let result: Value = serde_json::from_str(&res.expect("actual response")) @@ -5487,7 +5487,7 @@ pub mod tests { "params":["{}", {{"mint": "{}"}}] }}"#, delegate, - Pubkey::new_rand(), + solana_sdk::pubkey::new_rand(), ); let res = io.handle_request_sync(&req, meta.clone()); let result: Value = serde_json::from_str(&res.expect("actual response")) @@ -5502,7 +5502,7 @@ pub mod tests { "method":"getTokenAccountsByDelegate", "params":["{}", {{"programId": "{}"}}] }}"#, - Pubkey::new_rand(), + solana_sdk::pubkey::new_rand(), spl_token_id_v2_0(), ); let res = io.handle_request_sync(&req, meta.clone()); @@ -5550,7 +5550,7 @@ pub mod tests { owner: spl_token_id_v2_0(), ..Account::default() }; - let token_with_smaller_balance = Pubkey::new_rand(); + let token_with_smaller_balance = solana_sdk::pubkey::new_rand(); bank.store_account(&token_with_smaller_balance, &token_account); // Test largest token accounts @@ -5588,7 +5588,7 @@ pub mod tests { #[test] fn test_token_parsing() { - let RpcHandler { io, meta, bank, .. } = start_rpc_handler_with_tx(&Pubkey::new_rand()); + let RpcHandler { io, meta, bank, .. } = start_rpc_handler_with_tx(&solana_sdk::pubkey::new_rand()); let mut account_data = vec![0; TokenAccount::get_packed_len()]; let mint = SplTokenPubkey::new(&[2; 32]); @@ -5611,7 +5611,7 @@ pub mod tests { owner: spl_token_id_v2_0(), ..Account::default() }; - let token_account_pubkey = Pubkey::new_rand(); + let token_account_pubkey = solana_sdk::pubkey::new_rand(); bank.store_account(&token_account_pubkey, &token_account); // Add the mint diff --git a/core/src/rpc_pubsub.rs b/core/src/rpc_pubsub.rs index 235b7fe58..7cbcc2be6 100644 --- a/core/src/rpc_pubsub.rs +++ b/core/src/rpc_pubsub.rs @@ -505,7 +505,7 @@ mod tests { mint_keypair: alice, .. } = create_genesis_config(10_000); - let bob_pubkey = Pubkey::new_rand(); + let bob_pubkey = solana_sdk::pubkey::new_rand(); let bank = Bank::new(&genesis_config); let blockhash = bank.last_blockhash(); let bank_forks = Arc::new(RwLock::new(BankForks::new(bank))); @@ -551,7 +551,7 @@ mod tests { .. } = create_genesis_config(10_000); - let new_stake_authority = Pubkey::new_rand(); + let new_stake_authority = solana_sdk::pubkey::new_rand(); let stake_authority = Keypair::new(); let from = Keypair::new(); let stake_account = Keypair::new(); @@ -748,7 +748,7 @@ mod tests { #[test] #[serial] fn test_account_unsubscribe() { - let bob_pubkey = Pubkey::new_rand(); + let bob_pubkey = solana_sdk::pubkey::new_rand(); let session = create_session(); let GenesisConfigInfo { genesis_config, .. } = create_genesis_config(10_000); let bank_forks = Arc::new(RwLock::new(BankForks::new(Bank::new(&genesis_config)))); diff --git a/core/src/rpc_service.rs b/core/src/rpc_service.rs index f3b7e0384..3229585d5 100644 --- a/core/src/rpc_service.rs +++ b/core/src/rpc_service.rs @@ -550,7 +550,7 @@ mod tests { let cluster_info = Arc::new(ClusterInfo::default()); let health_check_slot_distance = 123; let override_health_check = Arc::new(AtomicBool::new(false)); - let trusted_validators = vec![Pubkey::new_rand(), Pubkey::new_rand(), Pubkey::new_rand()]; + let trusted_validators = vec![solana_sdk::pubkey::new_rand(), solana_sdk::pubkey::new_rand(), solana_sdk::pubkey::new_rand()]; let health = Arc::new(RpcHealth::new( cluster_info.clone(), diff --git a/core/src/rpc_subscriptions.rs b/core/src/rpc_subscriptions.rs index d8896d51f..b497f8261 100644 --- a/core/src/rpc_subscriptions.rs +++ b/core/src/rpc_subscriptions.rs @@ -1250,7 +1250,7 @@ pub(crate) mod tests { .unwrap(); let next_bank = - Bank::new_from_parent(&bank_forks.banks[&0].clone(), &Pubkey::new_rand(), 1); + Bank::new_from_parent(&bank_forks.banks[&0].clone(), &solana_sdk::pubkey::new_rand(), 1); bank_forks.insert(next_bank); bank_forks diff --git a/core/src/serve_repair.rs b/core/src/serve_repair.rs index 2f2a210f0..9543118ab 100644 --- a/core/src/serve_repair.rs +++ b/core/src/serve_repair.rs @@ -396,7 +396,7 @@ impl ServeRepair { cache.insert(slot, (repair_peers, weights)); } let (repair_peers, weights) = cache.get(&slot).unwrap(); - let n = weighted_best(&weights, Pubkey::new_rand().to_bytes()); + let n = weighted_best(&weights, solana_sdk::pubkey::new_rand().to_bytes()); let addr = repair_peers[n].serve_repair; // send the request to the peer's serve_repair port let repair_peer_id = repair_peers[n].id; let out = self.map_repair_request( @@ -419,7 +419,7 @@ impl ServeRepair { return Err(ClusterInfoError::NoPeers.into()); } let weights = cluster_slots.compute_weights_exclude_noncomplete(slot, &repair_peers); - let n = weighted_best(&weights, Pubkey::new_rand().to_bytes()); + let n = weighted_best(&weights, solana_sdk::pubkey::new_rand().to_bytes()); Ok((repair_peers[n].id, repair_peers[n].serve_repair)) } @@ -678,7 +678,7 @@ mod tests { { let blockstore = Arc::new(Blockstore::open(&ledger_path).unwrap()); let me = ContactInfo { - id: Pubkey::new_rand(), + id: solana_sdk::pubkey::new_rand(), gossip: socketaddr!("127.0.0.1:1234"), tvu: socketaddr!("127.0.0.1:1235"), tvu_forwards: socketaddr!("127.0.0.1:1236"), @@ -748,7 +748,7 @@ mod tests { #[test] fn window_index_request() { let cluster_slots = ClusterSlots::default(); - let me = ContactInfo::new_localhost(&Pubkey::new_rand(), timestamp()); + let me = ContactInfo::new_localhost(&solana_sdk::pubkey::new_rand(), timestamp()); let cluster_info = Arc::new(ClusterInfo::new_with_invalid_keypair(me)); let serve_repair = ServeRepair::new(cluster_info.clone()); let rv = serve_repair.repair_request( @@ -762,7 +762,7 @@ mod tests { let serve_repair_addr = socketaddr!([127, 0, 0, 1], 1243); let nxt = ContactInfo { - id: Pubkey::new_rand(), + id: solana_sdk::pubkey::new_rand(), gossip: socketaddr!([127, 0, 0, 1], 1234), tvu: socketaddr!([127, 0, 0, 1], 1235), tvu_forwards: socketaddr!([127, 0, 0, 1], 1236), @@ -791,7 +791,7 @@ mod tests { let serve_repair_addr2 = socketaddr!([127, 0, 0, 2], 1243); let nxt = ContactInfo { - id: Pubkey::new_rand(), + id: solana_sdk::pubkey::new_rand(), gossip: socketaddr!([127, 0, 0, 1], 1234), tvu: socketaddr!([127, 0, 0, 1], 1235), tvu_forwards: socketaddr!([127, 0, 0, 1], 1236), @@ -967,12 +967,12 @@ mod tests { #[test] fn test_repair_with_repair_validators() { let cluster_slots = ClusterSlots::default(); - let me = ContactInfo::new_localhost(&Pubkey::new_rand(), timestamp()); + let me = ContactInfo::new_localhost(&solana_sdk::pubkey::new_rand(), timestamp()); let cluster_info = Arc::new(ClusterInfo::new_with_invalid_keypair(me.clone())); // Insert two peers on the network - let contact_info2 = ContactInfo::new_localhost(&Pubkey::new_rand(), timestamp()); - let contact_info3 = ContactInfo::new_localhost(&Pubkey::new_rand(), timestamp()); + let contact_info2 = ContactInfo::new_localhost(&solana_sdk::pubkey::new_rand(), timestamp()); + let contact_info3 = ContactInfo::new_localhost(&solana_sdk::pubkey::new_rand(), timestamp()); cluster_info.insert_info(contact_info2.clone()); cluster_info.insert_info(contact_info3.clone()); let serve_repair = ServeRepair::new(cluster_info); @@ -981,7 +981,7 @@ mod tests { // 1) repair validator set doesn't exist in gossip // 2) repair validator set only includes our own id // then no repairs should be generated - for pubkey in &[Pubkey::new_rand(), me.id] { + for pubkey in &[solana_sdk::pubkey::new_rand(), me.id] { let trusted_validators = Some(vec![*pubkey].into_iter().collect()); assert!(serve_repair.repair_peers(&trusted_validators, 1).is_empty()); assert!(serve_repair diff --git a/core/src/test_validator.rs b/core/src/test_validator.rs index 37d7f7ac6..a37a09b5b 100644 --- a/core/src/test_validator.rs +++ b/core/src/test_validator.rs @@ -66,7 +66,7 @@ impl TestValidator { mint_lamports, &contact_info.id, &Keypair::new(), - &Pubkey::new_rand(), + &solana_sdk::pubkey::new_rand(), 42, bootstrap_validator_lamports, solana_sdk::genesis_config::ClusterType::Development, diff --git a/core/src/verified_vote_packets.rs b/core/src/verified_vote_packets.rs index 1458fb64b..b6fc262d8 100644 --- a/core/src/verified_vote_packets.rs +++ b/core/src/verified_vote_packets.rs @@ -63,7 +63,7 @@ mod tests { #[test] fn test_get_latest_votes() { - let pubkey = Pubkey::new_rand(); + let pubkey = solana_sdk::pubkey::new_rand(); let label1 = CrdsValueLabel::Vote(0 as u8, pubkey); let label2 = CrdsValueLabel::Vote(1 as u8, pubkey); let mut verified_vote_packets = VerifiedVotePackets(HashMap::new()); @@ -107,7 +107,7 @@ mod tests { #[test] fn test_get_and_process_vote_packets() { let (s, r) = unbounded(); - let pubkey = Pubkey::new_rand(); + let pubkey = solana_sdk::pubkey::new_rand(); let label1 = CrdsValueLabel::Vote(0 as u8, pubkey); let label2 = CrdsValueLabel::Vote(1 as u8, pubkey); let mut update_version = 0; diff --git a/core/src/vote_stake_tracker.rs b/core/src/vote_stake_tracker.rs index a13a2f7e4..a5c051ac0 100644 --- a/core/src/vote_stake_tracker.rs +++ b/core/src/vote_stake_tracker.rs @@ -52,7 +52,7 @@ mod test { let total_epoch_stake = 10; let mut vote_stake_tracker = VoteStakeTracker::default(); for i in 0..10 { - let pubkey = Arc::new(Pubkey::new_rand()); + let pubkey = Arc::new(solana_sdk::pubkey::new_rand()); let (is_confirmed, is_new) = vote_stake_tracker.add_vote_pubkey(pubkey.clone(), 1, total_epoch_stake); let stake = vote_stake_tracker.stake(); diff --git a/core/src/window_service.rs b/core/src/window_service.rs index 598e1c81a..c0156822e 100644 --- a/core/src/window_service.rs +++ b/core/src/window_service.rs @@ -594,7 +594,7 @@ mod test { #[test] fn test_should_retransmit_and_persist() { - let me_id = Pubkey::new_rand(); + let me_id = solana_sdk::pubkey::new_rand(); let leader_keypair = Arc::new(Keypair::new()); let leader_pubkey = leader_keypair.pubkey(); let bank = Arc::new(Bank::new( diff --git a/core/tests/client.rs b/core/tests/client.rs index b74b96e0f..48aa8d73d 100644 --- a/core/tests/client.rs +++ b/core/tests/client.rs @@ -38,7 +38,7 @@ fn test_rpc_client() { ledger_path, .. } = TestValidator::run(); - let bob_pubkey = Pubkey::new_rand(); + let bob_pubkey = solana_sdk::pubkey::new_rand(); let client = RpcClient::new_socket(leader_data.rpc); diff --git a/core/tests/cluster_info.rs b/core/tests/cluster_info.rs index 5e82b5a0c..eca0e8886 100644 --- a/core/tests/cluster_info.rs +++ b/core/tests/cluster_info.rs @@ -72,7 +72,7 @@ fn run_simulation(stakes: &[u64], fanout: usize) { let timeout = 60 * 5; // describe the leader - let leader_info = ContactInfo::new_localhost(&Pubkey::new_rand(), 0); + let leader_info = ContactInfo::new_localhost(&solana_sdk::pubkey::new_rand(), 0); let cluster_info = ClusterInfo::new_with_invalid_keypair(leader_info.clone()); // setup staked nodes @@ -95,7 +95,7 @@ fn run_simulation(stakes: &[u64], fanout: usize) { chunk.iter().for_each(|i| { //distribute neighbors across threads to maximize parallel compute let batch_ix = *i as usize % batches.len(); - let node = ContactInfo::new_localhost(&Pubkey::new_rand(), 0); + let node = ContactInfo::new_localhost(&solana_sdk::pubkey::new_rand(), 0); staked_nodes.insert(node.id, stakes[*i - 1]); cluster_info.insert_info(node.clone()); let (s, r) = channel(); diff --git a/core/tests/crds_gossip.rs b/core/tests/crds_gossip.rs index 9abf00e6f..529768396 100644 --- a/core/tests/crds_gossip.rs +++ b/core/tests/crds_gossip.rs @@ -77,13 +77,13 @@ fn stakes(network: &Network) -> HashMap { fn star_network_create(num: usize) -> Network { let entry = CrdsValue::new_unsigned(CrdsData::ContactInfo(ContactInfo::new_localhost( - &Pubkey::new_rand(), + &solana_sdk::pubkey::new_rand(), 0, ))); let mut network: HashMap<_, _> = (1..num) .map(|_| { let new = CrdsValue::new_unsigned(CrdsData::ContactInfo(ContactInfo::new_localhost( - &Pubkey::new_rand(), + &solana_sdk::pubkey::new_rand(), 0, ))); let id = new.label().pubkey(); @@ -104,7 +104,7 @@ fn star_network_create(num: usize) -> Network { fn rstar_network_create(num: usize) -> Network { let entry = CrdsValue::new_unsigned(CrdsData::ContactInfo(ContactInfo::new_localhost( - &Pubkey::new_rand(), + &solana_sdk::pubkey::new_rand(), 0, ))); let mut origin = CrdsGossip::default(); @@ -114,7 +114,7 @@ fn rstar_network_create(num: usize) -> Network { let mut network: HashMap<_, _> = (1..num) .map(|_| { let new = CrdsValue::new_unsigned(CrdsData::ContactInfo(ContactInfo::new_localhost( - &Pubkey::new_rand(), + &solana_sdk::pubkey::new_rand(), 0, ))); let id = new.label().pubkey(); @@ -133,7 +133,7 @@ fn ring_network_create(num: usize) -> Network { let mut network: HashMap<_, _> = (0..num) .map(|_| { let new = CrdsValue::new_unsigned(CrdsData::ContactInfo(ContactInfo::new_localhost( - &Pubkey::new_rand(), + &solana_sdk::pubkey::new_rand(), 0, ))); let id = new.label().pubkey(); @@ -171,7 +171,7 @@ fn connected_staked_network_create(stakes: &[u64]) -> Network { let mut network: HashMap<_, _> = (0..num) .map(|n| { let new = CrdsValue::new_unsigned(CrdsData::ContactInfo(ContactInfo::new_localhost( - &Pubkey::new_rand(), + &solana_sdk::pubkey::new_rand(), 0, ))); let id = new.label().pubkey(); diff --git a/core/tests/rpc.rs b/core/tests/rpc.rs index 61406587b..44748a225 100644 --- a/core/tests/rpc.rs +++ b/core/tests/rpc.rs @@ -63,7 +63,7 @@ fn test_rpc_send_tx() { ledger_path, .. } = TestValidator::run(); - let bob_pubkey = Pubkey::new_rand(); + let bob_pubkey = solana_sdk::pubkey::new_rand(); let req = json_req!("getRecentBlockhash", json!([])); let json = post_rpc(req, &leader_data); @@ -128,7 +128,7 @@ fn test_rpc_invalid_requests() { ledger_path, .. } = TestValidator::run(); - let bob_pubkey = Pubkey::new_rand(); + let bob_pubkey = solana_sdk::pubkey::new_rand(); // test invalid get_balance request let req = json_req!("getBalance", json!(["invalid9999"])); @@ -173,7 +173,7 @@ fn test_rpc_subscriptions() { // Create transaction signatures to subscribe to let transactions: Vec = (0..1000) - .map(|_| system_transaction::transfer(&alice, &Pubkey::new_rand(), 1, genesis_hash)) + .map(|_| system_transaction::transfer(&alice, &solana_sdk::pubkey::new_rand(), 1, genesis_hash)) .collect(); let mut signature_set: HashSet = transactions .iter() diff --git a/dos/src/main.rs b/dos/src/main.rs index 00099c9fd..69b20508d 100644 --- a/dos/src/main.rs +++ b/dos/src/main.rs @@ -58,7 +58,7 @@ fn run_dos( if !nodes.is_empty() { let source = thread_rng().gen_range(0, nodes.len()); let mut contact = nodes[source].clone(); - contact.id = Pubkey::new_rand(); + contact.id = solana_sdk::pubkey::new_rand(); match data_type.as_str() { "repair_highest" => { let slot = 100; @@ -253,7 +253,7 @@ pub mod test { #[test] fn test_dos() { - let nodes = [ContactInfo::new_localhost(&Pubkey::new_rand(), timestamp())]; + let nodes = [ContactInfo::new_localhost(&solana_sdk::pubkey::new_rand(), timestamp())]; let entrypoint_addr = nodes[0].gossip; run_dos( &nodes, diff --git a/faucet/src/faucet.rs b/faucet/src/faucet.rs index 28e19398c..0094fb3cb 100644 --- a/faucet/src/faucet.rs +++ b/faucet/src/faucet.rs @@ -378,7 +378,7 @@ mod tests { #[test] fn test_faucet_build_airdrop_transaction() { - let to = Pubkey::new_rand(); + let to = solana_sdk::pubkey::new_rand(); let blockhash = Hash::default(); let request = FaucetRequest::GetAirdrop { lamports: 2, @@ -419,7 +419,7 @@ mod tests { #[test] fn test_process_faucet_request() { - let to = Pubkey::new_rand(); + let to = solana_sdk::pubkey::new_rand(); let blockhash = Hash::new(&to.as_ref()); let lamports = 50; let req = FaucetRequest::GetAirdrop { diff --git a/faucet/src/faucet_mock.rs b/faucet/src/faucet_mock.rs index 81760338e..b5e27b10d 100644 --- a/faucet/src/faucet_mock.rs +++ b/faucet/src/faucet_mock.rs @@ -16,7 +16,7 @@ pub fn request_airdrop_transaction( Err(Error::new(ErrorKind::Other, "Airdrop failed")) } else { let key = Keypair::new(); - let to = Pubkey::new_rand(); + let to = solana_sdk::pubkey::new_rand(); let blockhash = Hash::default(); let tx = system_transaction::transfer(&key, &to, lamports, blockhash); Ok(tx) diff --git a/faucet/tests/local-faucet.rs b/faucet/tests/local-faucet.rs index aeca323f7..399a0a645 100644 --- a/faucet/tests/local-faucet.rs +++ b/faucet/tests/local-faucet.rs @@ -12,7 +12,7 @@ use std::sync::mpsc::channel; #[test] fn test_local_faucet() { let keypair = Keypair::new(); - let to = Pubkey::new_rand(); + let to = solana_sdk::pubkey::new_rand(); let lamports = 50; let blockhash = Hash::new(&to.as_ref()); let create_instruction = system_instruction::transfer(&keypair.pubkey(), &to, lamports); diff --git a/genesis/src/main.rs b/genesis/src/main.rs index 6f4580926..b13e188d9 100644 --- a/genesis/src/main.rs +++ b/genesis/src/main.rs @@ -630,27 +630,27 @@ mod tests { let mut genesis_accounts = HashMap::new(); genesis_accounts.insert( - Pubkey::new_rand().to_string(), + solana_sdk::pubkey::new_rand().to_string(), Base64Account { - owner: Pubkey::new_rand().to_string(), + owner: solana_sdk::pubkey::new_rand().to_string(), balance: 2 as u64, executable: false, data: String::from("aGVsbG8="), }, ); genesis_accounts.insert( - Pubkey::new_rand().to_string(), + solana_sdk::pubkey::new_rand().to_string(), Base64Account { - owner: Pubkey::new_rand().to_string(), + owner: solana_sdk::pubkey::new_rand().to_string(), balance: 1 as u64, executable: true, data: String::from("aGVsbG8gd29ybGQ="), }, ); genesis_accounts.insert( - Pubkey::new_rand().to_string(), + solana_sdk::pubkey::new_rand().to_string(), Base64Account { - owner: Pubkey::new_rand().to_string(), + owner: solana_sdk::pubkey::new_rand().to_string(), balance: 3 as u64, executable: true, data: String::from("bWUgaGVsbG8gdG8gd29ybGQ="), @@ -703,27 +703,27 @@ mod tests { // Test more accounts can be appended let mut genesis_accounts1 = HashMap::new(); genesis_accounts1.insert( - Pubkey::new_rand().to_string(), + solana_sdk::pubkey::new_rand().to_string(), Base64Account { - owner: Pubkey::new_rand().to_string(), + owner: solana_sdk::pubkey::new_rand().to_string(), balance: 6 as u64, executable: true, data: String::from("eW91IGFyZQ=="), }, ); genesis_accounts1.insert( - Pubkey::new_rand().to_string(), + solana_sdk::pubkey::new_rand().to_string(), Base64Account { - owner: Pubkey::new_rand().to_string(), + owner: solana_sdk::pubkey::new_rand().to_string(), balance: 5 as u64, executable: false, data: String::from("bWV0YSBzdHJpbmc="), }, ); genesis_accounts1.insert( - Pubkey::new_rand().to_string(), + solana_sdk::pubkey::new_rand().to_string(), Base64Account { - owner: Pubkey::new_rand().to_string(), + owner: solana_sdk::pubkey::new_rand().to_string(), balance: 10 as u64, executable: false, data: String::from("YmFzZTY0IHN0cmluZw=="), @@ -788,7 +788,7 @@ mod tests { genesis_accounts2.insert( serde_json::to_string(&account_keypairs[0].to_bytes().to_vec()).unwrap(), Base64Account { - owner: Pubkey::new_rand().to_string(), + owner: solana_sdk::pubkey::new_rand().to_string(), balance: 20 as u64, executable: true, data: String::from("Y2F0IGRvZw=="), @@ -797,7 +797,7 @@ mod tests { genesis_accounts2.insert( serde_json::to_string(&account_keypairs[1].to_bytes().to_vec()).unwrap(), Base64Account { - owner: Pubkey::new_rand().to_string(), + owner: solana_sdk::pubkey::new_rand().to_string(), balance: 15 as u64, executable: false, data: String::from("bW9ua2V5IGVsZXBoYW50"), @@ -806,7 +806,7 @@ mod tests { genesis_accounts2.insert( serde_json::to_string(&account_keypairs[2].to_bytes().to_vec()).unwrap(), Base64Account { - owner: Pubkey::new_rand().to_string(), + owner: solana_sdk::pubkey::new_rand().to_string(), balance: 30 as u64, executable: true, data: String::from("Y29tYSBtb2Nh"), diff --git a/ledger/benches/protobuf.rs b/ledger/benches/protobuf.rs index cf83f6983..0d4442a75 100644 --- a/ledger/benches/protobuf.rs +++ b/ledger/benches/protobuf.rs @@ -16,7 +16,7 @@ use test::Bencher; fn create_rewards() -> Rewards { (0..100) .map(|i| Reward { - pubkey: Pubkey::new_rand().to_string(), + pubkey: solana_sdk::pubkey::new_rand().to_string(), lamports: 42 + i, post_balance: std::u64::MAX, reward_type: Some(RewardType::Fee), diff --git a/ledger/src/blockstore.rs b/ledger/src/blockstore.rs index 1d02e7ecb..246c3aeac 100644 --- a/ledger/src/blockstore.rs +++ b/ledger/src/blockstore.rs @@ -3475,9 +3475,9 @@ pub mod tests { for x in 0..num_entries { let transaction = Transaction::new_with_compiled_instructions( &[&Keypair::new()], - &[Pubkey::new_rand()], + &[solana_sdk::pubkey::new_rand()], Hash::default(), - vec![Pubkey::new_rand()], + vec![solana_sdk::pubkey::new_rand()], vec![CompiledInstruction::new(1, &(), vec![0])], ); entries.push(next_entry_mut(&mut Hash::default(), 0, vec![transaction])); @@ -6391,8 +6391,8 @@ pub mod tests { { let blockstore = Blockstore::open(&blockstore_path).unwrap(); - let address0 = Pubkey::new_rand(); - let address1 = Pubkey::new_rand(); + let address0 = solana_sdk::pubkey::new_rand(); + let address1 = solana_sdk::pubkey::new_rand(); let slot0 = 10; for x in 1..5 { @@ -6538,7 +6538,7 @@ pub mod tests { &[&Keypair::new()], &[*address], Hash::default(), - vec![Pubkey::new_rand()], + vec![solana_sdk::pubkey::new_rand()], vec![CompiledInstruction::new(1, &(), vec![0])], ); entries.push(next_entry_mut(&mut Hash::default(), 0, vec![transaction])); @@ -6548,8 +6548,8 @@ pub mod tests { entries } - let address0 = Pubkey::new_rand(); - let address1 = Pubkey::new_rand(); + let address0 = solana_sdk::pubkey::new_rand(); + let address1 = solana_sdk::pubkey::new_rand(); for slot in 2..=8 { let entries = make_slot_entries_with_transaction_addresses(&[ @@ -6772,9 +6772,9 @@ pub mod tests { for x in 0..4 { let transaction = Transaction::new_with_compiled_instructions( &[&Keypair::new()], - &[Pubkey::new_rand()], + &[solana_sdk::pubkey::new_rand()], Hash::default(), - vec![Pubkey::new_rand()], + vec![solana_sdk::pubkey::new_rand()], vec![CompiledInstruction::new(1, &(), vec![0])], ); transaction_status_cf @@ -6797,9 +6797,9 @@ pub mod tests { // Push transaction that will not have matching status, as a test case transactions.push(Transaction::new_with_compiled_instructions( &[&Keypair::new()], - &[Pubkey::new_rand()], + &[solana_sdk::pubkey::new_rand()], Hash::default(), - vec![Pubkey::new_rand()], + vec![solana_sdk::pubkey::new_rand()], vec![CompiledInstruction::new(1, &(), vec![0])], )); @@ -7256,7 +7256,7 @@ pub mod tests { let blockstore = Blockstore::open(&blockstore_path).unwrap(); let rewards: Rewards = (0..100) .map(|i| Reward { - pubkey: Pubkey::new_rand().to_string(), + pubkey: solana_sdk::pubkey::new_rand().to_string(), lamports: 42 + i, post_balance: std::u64::MAX, reward_type: Some(RewardType::Fee), diff --git a/ledger/src/blockstore_processor.rs b/ledger/src/blockstore_processor.rs index 9cc52134a..04c0b92f0 100644 --- a/ledger/src/blockstore_processor.rs +++ b/ledger/src/blockstore_processor.rs @@ -1805,7 +1805,7 @@ pub mod tests { #[test] fn test_process_ledger_simple() { solana_logger::setup(); - let leader_pubkey = Pubkey::new_rand(); + let leader_pubkey = solana_sdk::pubkey::new_rand(); let mint = 100; let hashes_per_tick = 10; let GenesisConfigInfo { @@ -2383,7 +2383,7 @@ pub mod tests { bank.last_blockhash(), 1, 0, - &Pubkey::new_rand(), + &solana_sdk::pubkey::new_rand(), )); next_entry_mut(&mut hash, 0, transactions) @@ -2532,7 +2532,7 @@ pub mod tests { .. } = create_genesis_config(11_000); let bank = Arc::new(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); @@ -2738,7 +2738,7 @@ pub mod tests { bank.last_blockhash(), 100, 100, - &Pubkey::new_rand(), + &solana_sdk::pubkey::new_rand(), )); transactions }) @@ -2873,11 +2873,11 @@ pub mod tests { // Create array of two transactions which throw different errors let account_not_found_tx = - system_transaction::transfer(&keypair, &Pubkey::new_rand(), 42, bank.last_blockhash()); + system_transaction::transfer(&keypair, &solana_sdk::pubkey::new_rand(), 42, bank.last_blockhash()); let account_not_found_sig = account_not_found_tx.signatures[0]; let mut account_loaded_twice = system_transaction::transfer( &mint_keypair, - &Pubkey::new_rand(), + &solana_sdk::pubkey::new_rand(), 42, bank.last_blockhash(), ); @@ -2925,7 +2925,7 @@ pub mod tests { let bank0 = Arc::new(Bank::new(&genesis_config)); bank0.freeze(); - 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)); // The new blockhash is going to be the hash of the last tick in the block let bank_1_blockhash = bank1.last_blockhash(); @@ -3148,7 +3148,7 @@ pub mod tests { Account::new(1, VoteState::size_of(), &solana_vote_program::id()); let versioned = VoteStateVersions::Current(Box::new(vote_state)); VoteState::serialize(&versioned, &mut vote_account.data).unwrap(); - (Pubkey::new_rand(), (stake, vote_account)) + (solana_sdk::pubkey::new_rand(), (stake, vote_account)) }) .collect_vec() }; diff --git a/ledger/src/genesis_utils.rs b/ledger/src/genesis_utils.rs index cdee96c89..65ca0a918 100644 --- a/ledger/src/genesis_utils.rs +++ b/ledger/src/genesis_utils.rs @@ -9,7 +9,7 @@ use solana_sdk::pubkey::Pubkey; pub fn create_genesis_config(mint_lamports: u64) -> GenesisConfigInfo { create_genesis_config_with_leader( mint_lamports, - &Pubkey::new_rand(), + &solana_sdk::pubkey::new_rand(), BOOTSTRAP_VALIDATOR_LAMPORTS, ) } diff --git a/ledger/src/leader_schedule.rs b/ledger/src/leader_schedule.rs index fc63c52b0..31c7ce89e 100644 --- a/ledger/src/leader_schedule.rs +++ b/ledger/src/leader_schedule.rs @@ -64,8 +64,8 @@ mod tests { #[test] fn test_leader_schedule_index() { - 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 leader_schedule = LeaderSchedule { slot_leaders: vec![pubkey0, pubkey1], }; @@ -77,9 +77,9 @@ mod tests { #[test] fn test_leader_schedule_basic() { let num_keys = 10; - let stakes: Vec<_> = (0..num_keys).map(|i| (Pubkey::new_rand(), i)).collect(); + let stakes: Vec<_> = (0..num_keys).map(|i| (solana_sdk::pubkey::new_rand(), i)).collect(); - let seed = Pubkey::new_rand(); + let seed = solana_sdk::pubkey::new_rand(); let mut seed_bytes = [0u8; 32]; seed_bytes.copy_from_slice(seed.as_ref()); let len = num_keys * 10; @@ -93,9 +93,9 @@ mod tests { #[test] fn test_repeated_leader_schedule() { let num_keys = 10; - let stakes: Vec<_> = (0..num_keys).map(|i| (Pubkey::new_rand(), i)).collect(); + let stakes: Vec<_> = (0..num_keys).map(|i| (solana_sdk::pubkey::new_rand(), i)).collect(); - let seed = Pubkey::new_rand(); + let seed = solana_sdk::pubkey::new_rand(); let mut seed_bytes = [0u8; 32]; seed_bytes.copy_from_slice(seed.as_ref()); let len = num_keys * 10; @@ -114,8 +114,8 @@ mod tests { #[test] fn test_repeated_leader_schedule_specific() { - let alice_pubkey = Pubkey::new_rand(); - let bob_pubkey = Pubkey::new_rand(); + let alice_pubkey = solana_sdk::pubkey::new_rand(); + let bob_pubkey = solana_sdk::pubkey::new_rand(); let stakes = vec![(alice_pubkey, 2), (bob_pubkey, 1)]; let seed = Pubkey::default(); diff --git a/ledger/src/leader_schedule_cache.rs b/ledger/src/leader_schedule_cache.rs index 104f89037..320403299 100644 --- a/ledger/src/leader_schedule_cache.rs +++ b/ledger/src/leader_schedule_cache.rs @@ -378,7 +378,7 @@ mod tests { #[test] fn test_next_leader_slot() { - let pubkey = Pubkey::new_rand(); + let pubkey = solana_sdk::pubkey::new_rand(); let mut genesis_config = create_genesis_config_with_leader( BOOTSTRAP_VALIDATOR_LAMPORTS, &pubkey, @@ -419,7 +419,7 @@ mod tests { assert_eq!( cache.next_leader_slot( - &Pubkey::new_rand(), // not in leader_schedule + &solana_sdk::pubkey::new_rand(), // not in leader_schedule 0, &bank, None, @@ -431,7 +431,7 @@ mod tests { #[test] fn test_next_leader_slot_blockstore() { - let pubkey = Pubkey::new_rand(); + let pubkey = solana_sdk::pubkey::new_rand(); let mut genesis_config = create_genesis_config_with_leader( BOOTSTRAP_VALIDATOR_LAMPORTS, &pubkey, @@ -501,7 +501,7 @@ mod tests { assert_eq!( cache.next_leader_slot( - &Pubkey::new_rand(), // not in leader_schedule + &solana_sdk::pubkey::new_rand(), // not in leader_schedule 0, &bank, Some(&blockstore), @@ -605,7 +605,7 @@ mod tests { assert_eq!(bank.get_epoch_and_slot_index(96).0, 2); assert!(cache.slot_leader_at(96, Some(&bank)).is_none()); - let bank2 = Bank::new_from_parent(&bank, &Pubkey::new_rand(), 95); + let bank2 = Bank::new_from_parent(&bank, &solana_sdk::pubkey::new_rand(), 95); assert!(bank2.epoch_vote_accounts(2).is_some()); // Set root for a slot in epoch 1, so that epoch 2 is now confirmed diff --git a/ledger/src/leader_schedule_utils.rs b/ledger/src/leader_schedule_utils.rs index 72bb80614..677e837bd 100644 --- a/ledger/src/leader_schedule_utils.rs +++ b/ledger/src/leader_schedule_utils.rs @@ -60,7 +60,7 @@ mod tests { #[test] fn test_leader_schedule_via_bank() { - let pubkey = Pubkey::new_rand(); + let pubkey = solana_sdk::pubkey::new_rand(); let genesis_config = create_genesis_config_with_leader(0, &pubkey, BOOTSTRAP_VALIDATOR_LAMPORTS) .genesis_config; @@ -82,7 +82,7 @@ mod tests { #[test] fn test_leader_scheduler1_basic() { - let pubkey = Pubkey::new_rand(); + let pubkey = solana_sdk::pubkey::new_rand(); let genesis_config = create_genesis_config_with_leader( BOOTSTRAP_VALIDATOR_LAMPORTS, &pubkey, @@ -95,8 +95,8 @@ mod tests { #[test] fn test_sort_stakes_basic() { - 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 mut stakes = vec![(pubkey0, 1), (pubkey1, 2)]; sort_stakes(&mut stakes); assert_eq!(stakes, vec![(pubkey1, 2), (pubkey0, 1)]); @@ -104,8 +104,8 @@ mod tests { #[test] fn test_sort_stakes_with_dup() { - 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 mut stakes = vec![(pubkey0, 1), (pubkey1, 2), (pubkey0, 1)]; sort_stakes(&mut stakes); assert_eq!(stakes, vec![(pubkey1, 2), (pubkey0, 1)]); @@ -114,7 +114,7 @@ mod tests { #[test] fn test_sort_stakes_with_equal_stakes() { let pubkey0 = Pubkey::default(); - let pubkey1 = Pubkey::new_rand(); + let pubkey1 = solana_sdk::pubkey::new_rand(); let mut stakes = vec![(pubkey0, 1), (pubkey1, 1)]; sort_stakes(&mut stakes); assert_eq!(stakes, vec![(pubkey1, 1), (pubkey0, 1)]); diff --git a/ledger/src/staking_utils.rs b/ledger/src/staking_utils.rs index 01c38684c..b2a90aa46 100644 --- a/ledger/src/staking_utils.rs +++ b/ledger/src/staking_utils.rs @@ -304,7 +304,7 @@ pub(crate) mod tests { #[test] fn test_to_staked_nodes() { let mut stakes = Vec::new(); - let node1 = Pubkey::new_rand(); + let node1 = solana_sdk::pubkey::new_rand(); // Node 1 has stake of 3 for i in 0..3 { @@ -321,7 +321,7 @@ pub(crate) mod tests { } // Node 1 has stake of 5 - let node2 = Pubkey::new_rand(); + let node2 = solana_sdk::pubkey::new_rand(); stakes.push(( 5, diff --git a/local-cluster/tests/local_cluster.rs b/local-cluster/tests/local_cluster.rs index bdb7045e0..79b7870fd 100644 --- a/local-cluster/tests/local_cluster.rs +++ b/local-cluster/tests/local_cluster.rs @@ -163,7 +163,7 @@ fn test_local_cluster_signature_subscribe() { .unwrap(); let mut transaction = - system_transaction::transfer(&cluster.funding_keypair, &Pubkey::new_rand(), 10, blockhash); + system_transaction::transfer(&cluster.funding_keypair, &solana_sdk::pubkey::new_rand(), 10, blockhash); let (mut sig_subscribe_client, receiver) = PubsubClient::signature_subscribe( &format!("ws://{}", &non_bootstrap_info.rpc_pubsub.to_string()), @@ -815,7 +815,7 @@ fn generate_frozen_account_panic(mut cluster: LocalCluster, frozen_account: Arc< .get_recent_blockhash_with_commitment(CommitmentConfig::recent()) .unwrap(); client - .async_transfer(1, &frozen_account, &Pubkey::new_rand(), blockhash) + .async_transfer(1, &frozen_account, &solana_sdk::pubkey::new_rand(), blockhash) .unwrap(); sleep(Duration::from_secs(1)); diff --git a/programs/bpf/benches/bpf_loader.rs b/programs/bpf/benches/bpf_loader.rs index 594def387..99822c8b2 100644 --- a/programs/bpf/benches/bpf_loader.rs +++ b/programs/bpf/benches/bpf_loader.rs @@ -211,8 +211,8 @@ fn bench_instruction_count_tuner(_bencher: &mut Bencher) { let mut measure = Measure::start("tune"); - let accounts = [RefCell::new(Account::new(1, 10000001, &Pubkey::new_rand()))]; - let keys = [Pubkey::new_rand()]; + let accounts = [RefCell::new(Account::new(1, 10000001, &solana_sdk::pubkey::new_rand()))]; + let keys = [solana_sdk::pubkey::new_rand()]; let keyed_accounts: Vec<_> = keys .iter() .zip(&accounts) @@ -223,7 +223,7 @@ fn bench_instruction_count_tuner(_bencher: &mut Bencher) { // Serialize account data let mut serialized = solana_bpf_loader_program::serialization::serialize_parameters( &bpf_loader::id(), - &Pubkey::new_rand(), + &solana_sdk::pubkey::new_rand(), &keyed_accounts, &instruction_data, ) diff --git a/programs/bpf/tests/programs.rs b/programs/bpf/tests/programs.rs index bee8f8af7..00c47c625 100644 --- a/programs/bpf/tests/programs.rs +++ b/programs/bpf/tests/programs.rs @@ -276,11 +276,11 @@ fn test_program_bpf_duplicate_accounts() { let bank_client = BankClient::new_shared(&bank); let program_id = load_bpf_program(&bank_client, &bpf_loader::id(), &mint_keypair, program); let payee_account = Account::new(10, 1, &program_id); - let payee_pubkey = Pubkey::new_rand(); + let payee_pubkey = solana_sdk::pubkey::new_rand(); bank.store_account(&payee_pubkey, &payee_account); let account = Account::new(10, 1, &program_id); - let pubkey = Pubkey::new_rand(); + let pubkey = solana_sdk::pubkey::new_rand(); let account_metas = vec![ AccountMeta::new(mint_keypair.pubkey(), true), AccountMeta::new(payee_pubkey, false), @@ -763,8 +763,8 @@ fn assert_instruction_count() { for program in programs.iter() { println!("Test program: {:?}", program.0); - let program_id = Pubkey::new_rand(); - let key = Pubkey::new_rand(); + let program_id = solana_sdk::pubkey::new_rand(); + let key = solana_sdk::pubkey::new_rand(); let mut account = RefCell::new(Account::default()); let parameter_accounts = vec![KeyedAccount::new(&key, false, &mut account)]; let count = run_program(program.0, &program_id, ¶meter_accounts[..], &[]).unwrap(); diff --git a/programs/bpf_loader/src/lib.rs b/programs/bpf_loader/src/lib.rs index 371f33cf6..32fdd9363 100644 --- a/programs/bpf_loader/src/lib.rs +++ b/programs/bpf_loader/src/lib.rs @@ -441,8 +441,8 @@ mod tests { #[test] fn test_bpf_loader_write() { - let program_id = Pubkey::new_rand(); - let program_key = Pubkey::new_rand(); + let program_id = solana_sdk::pubkey::new_rand(); + let program_key = solana_sdk::pubkey::new_rand(); let program_account = Account::new_ref(1, 0, &program_id); let keyed_accounts = vec![KeyedAccount::new(&program_key, false, &program_account)]; let instruction_data = bincode::serialize(&LoaderInstruction::Write { @@ -508,8 +508,8 @@ mod tests { #[test] fn test_bpf_loader_finalize() { - let program_id = Pubkey::new_rand(); - let program_key = Pubkey::new_rand(); + let program_id = solana_sdk::pubkey::new_rand(); + let program_key = solana_sdk::pubkey::new_rand(); let mut file = File::open("test_elfs/noop_aligned.so").expect("file open failed"); let mut elf = Vec::new(); let rent = Rent::default(); @@ -572,8 +572,8 @@ mod tests { #[test] fn test_bpf_loader_invoke_main() { - let program_id = Pubkey::new_rand(); - let program_key = Pubkey::new_rand(); + let program_id = solana_sdk::pubkey::new_rand(); + let program_key = solana_sdk::pubkey::new_rand(); // Create program account let mut file = File::open("test_elfs/noop_aligned.so").expect("file open failed"); @@ -646,7 +646,7 @@ mod tests { ); // Case: With duplicate accounts - let duplicate_key = Pubkey::new_rand(); + let duplicate_key = solana_sdk::pubkey::new_rand(); let parameter_account = Account::new_ref(1, 0, &program_id); let mut keyed_accounts = vec![KeyedAccount::new(&program_key, false, &program_account)]; keyed_accounts.push(KeyedAccount::new(&duplicate_key, false, ¶meter_account)); @@ -664,8 +664,8 @@ mod tests { #[test] fn test_bpf_loader_serialize_unaligned() { - let program_id = Pubkey::new_rand(); - let program_key = Pubkey::new_rand(); + let program_id = solana_sdk::pubkey::new_rand(); + let program_key = solana_sdk::pubkey::new_rand(); // Create program account let mut file = File::open("test_elfs/noop_unaligned.so").expect("file open failed"); @@ -690,7 +690,7 @@ mod tests { ); // Case: With duplicate accounts - let duplicate_key = Pubkey::new_rand(); + let duplicate_key = solana_sdk::pubkey::new_rand(); let parameter_account = Account::new_ref(1, 0, &program_id); let mut keyed_accounts = vec![KeyedAccount::new(&program_key, false, &program_account)]; keyed_accounts.push(KeyedAccount::new(&duplicate_key, false, ¶meter_account)); @@ -708,8 +708,8 @@ mod tests { #[test] fn test_bpf_loader_serialize_aligned() { - let program_id = Pubkey::new_rand(); - let program_key = Pubkey::new_rand(); + let program_id = solana_sdk::pubkey::new_rand(); + let program_key = solana_sdk::pubkey::new_rand(); // Create program account let mut file = File::open("test_elfs/noop_aligned.so").expect("file open failed"); @@ -734,7 +734,7 @@ mod tests { ); // Case: With duplicate accounts - let duplicate_key = Pubkey::new_rand(); + let duplicate_key = solana_sdk::pubkey::new_rand(); let parameter_account = Account::new_ref(1, 0, &program_id); let mut keyed_accounts = vec![KeyedAccount::new(&program_key, false, &program_account)]; keyed_accounts.push(KeyedAccount::new(&duplicate_key, false, ¶meter_account)); @@ -776,8 +776,8 @@ mod tests { #[test] #[ignore] fn test_fuzz() { - let program_id = Pubkey::new_rand(); - let program_key = Pubkey::new_rand(); + let program_id = solana_sdk::pubkey::new_rand(); + let program_key = solana_sdk::pubkey::new_rand(); // Create program account let mut file = File::open("test_elfs/noop_aligned.so").expect("file open failed"); diff --git a/programs/bpf_loader/src/serialization.rs b/programs/bpf_loader/src/serialization.rs index 751394bac..9fec0f046 100644 --- a/programs/bpf_loader/src/serialization.rs +++ b/programs/bpf_loader/src/serialization.rs @@ -262,9 +262,9 @@ mod tests { #[test] fn test_serialize_parameters() { - let program_id = Pubkey::new_rand(); - let dup_key = Pubkey::new_rand(); - let keys = vec![dup_key, dup_key, Pubkey::new_rand(), Pubkey::new_rand()]; + let program_id = solana_sdk::pubkey::new_rand(); + let dup_key = solana_sdk::pubkey::new_rand(); + let keys = vec![dup_key, dup_key, solana_sdk::pubkey::new_rand(), solana_sdk::pubkey::new_rand()]; let accounts = [ RefCell::new(Account { lamports: 1, diff --git a/programs/bpf_loader/src/syscalls.rs b/programs/bpf_loader/src/syscalls.rs index 6d5b93841..bf04d7b91 100644 --- a/programs/bpf_loader/src/syscalls.rs +++ b/programs/bpf_loader/src/syscalls.rs @@ -1289,7 +1289,7 @@ mod tests { #[test] fn test_translate_type() { // Pubkey - let pubkey = Pubkey::new_rand(); + let pubkey = solana_sdk::pubkey::new_rand(); let addr = &pubkey as *const _ as u64; let regions = vec![MemoryRegion { addr_host: addr, @@ -1301,9 +1301,9 @@ mod tests { // Instruction let instruction = Instruction::new( - Pubkey::new_rand(), + solana_sdk::pubkey::new_rand(), &"foobar", - vec![AccountMeta::new(Pubkey::new_rand(), false)], + vec![AccountMeta::new(solana_sdk::pubkey::new_rand(), false)], ); let addr = &instruction as *const _ as u64; let mut regions = vec![MemoryRegion { @@ -1350,7 +1350,7 @@ mod tests { assert_eq!(data, translated_data); // Pubkeys - let mut data = vec![Pubkey::new_rand(); 5]; + let mut data = vec![solana_sdk::pubkey::new_rand(); 5]; let addr = data.as_ptr() as *const _ as u64; let regions = vec![MemoryRegion { addr_host: addr, @@ -1360,7 +1360,7 @@ mod tests { let translated_data = translate_slice!(Pubkey, 100, data.len(), ®ions, &bpf_loader::id()).unwrap(); assert_eq!(data, translated_data); - data[0] = Pubkey::new_rand(); // Both should point to same place + data[0] = solana_sdk::pubkey::new_rand(); // Both should point to same place assert_eq!(data, translated_data); } diff --git a/programs/budget/src/budget_expr.rs b/programs/budget/src/budget_expr.rs index 9e43018d2..c5584eee0 100644 --- a/programs/budget/src/budget_expr.rs +++ b/programs/budget/src/budget_expr.rs @@ -306,8 +306,8 @@ mod tests { #[test] fn test_future_payment() { let dt = Utc.ymd(2014, 11, 14).and_hms(8, 9, 10); - 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 mut expr = BudgetExpr::new_future_payment(dt, &from, 42, &to); expr.apply_witness(&Witness::Timestamp(dt), &from); @@ -319,8 +319,8 @@ mod tests { // Ensure timestamp will only be acknowledged if it came from the // whitelisted public key. let dt = Utc.ymd(2014, 11, 14).and_hms(8, 9, 10); - 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 mut expr = BudgetExpr::new_future_payment(dt, &from, 42, &to); let orig_expr = expr.clone(); @@ -344,8 +344,8 @@ mod tests { } #[test] fn test_2_2_multisig_payment() { - let from0 = Pubkey::new_rand(); - let from1 = Pubkey::new_rand(); + let from0 = solana_sdk::pubkey::new_rand(); + let from1 = solana_sdk::pubkey::new_rand(); let to = Pubkey::default(); let mut expr = BudgetExpr::new_2_2_multisig_payment(&from0, &from1, 42, &to); @@ -355,9 +355,9 @@ mod tests { #[test] fn test_multisig_after_sig() { - let from0 = Pubkey::new_rand(); - let from1 = Pubkey::new_rand(); - let from2 = Pubkey::new_rand(); + let from0 = solana_sdk::pubkey::new_rand(); + let from1 = solana_sdk::pubkey::new_rand(); + let from2 = solana_sdk::pubkey::new_rand(); let to = Pubkey::default(); let expr = BudgetExpr::new_2_2_multisig_payment(&from0, &from1, 42, &to); @@ -370,8 +370,8 @@ mod tests { #[test] fn test_multisig_after_ts() { - let from0 = Pubkey::new_rand(); - let from1 = Pubkey::new_rand(); + let from0 = solana_sdk::pubkey::new_rand(); + let from1 = solana_sdk::pubkey::new_rand(); let dt = Utc.ymd(2014, 11, 11).and_hms(7, 7, 7); let to = Pubkey::default(); diff --git a/programs/budget/src/budget_instruction.rs b/programs/budget/src/budget_instruction.rs index 297c0ab9c..fc4a83ae9 100644 --- a/programs/budget/src/budget_instruction.rs +++ b/programs/budget/src/budget_instruction.rs @@ -167,18 +167,18 @@ mod tests { #[test] fn test_budget_instruction_verify() { - let alice_pubkey = Pubkey::new_rand(); - let bob_pubkey = Pubkey::new_rand(); - let budget_pubkey = Pubkey::new_rand(); + let alice_pubkey = solana_sdk::pubkey::new_rand(); + let bob_pubkey = solana_sdk::pubkey::new_rand(); + let budget_pubkey = solana_sdk::pubkey::new_rand(); payment(&alice_pubkey, &bob_pubkey, &budget_pubkey, 1); // No panic! indicates success. } #[test] #[should_panic] fn test_budget_instruction_overspend() { - let alice_pubkey = Pubkey::new_rand(); - let bob_pubkey = Pubkey::new_rand(); - let budget_pubkey = Pubkey::new_rand(); + let alice_pubkey = solana_sdk::pubkey::new_rand(); + let bob_pubkey = solana_sdk::pubkey::new_rand(); + let budget_pubkey = solana_sdk::pubkey::new_rand(); let expr = BudgetExpr::new_payment(2, &bob_pubkey); create_account(&alice_pubkey, &budget_pubkey, 1, expr); } @@ -186,9 +186,9 @@ mod tests { #[test] #[should_panic] fn test_budget_instruction_underspend() { - let alice_pubkey = Pubkey::new_rand(); - let bob_pubkey = Pubkey::new_rand(); - let budget_pubkey = Pubkey::new_rand(); + let alice_pubkey = solana_sdk::pubkey::new_rand(); + let bob_pubkey = solana_sdk::pubkey::new_rand(); + let budget_pubkey = solana_sdk::pubkey::new_rand(); let expr = BudgetExpr::new_payment(1, &bob_pubkey); create_account(&alice_pubkey, &budget_pubkey, 2, expr); } diff --git a/programs/budget/src/budget_processor.rs b/programs/budget/src/budget_processor.rs index 797bee321..c4685a0df 100644 --- a/programs/budget/src/budget_processor.rs +++ b/programs/budget/src/budget_processor.rs @@ -250,7 +250,7 @@ mod tests { let alice_pubkey = alice_keypair.pubkey(); let budget_keypair = Keypair::new(); let budget_pubkey = budget_keypair.pubkey(); - let bob_pubkey = Pubkey::new_rand(); + let bob_pubkey = solana_sdk::pubkey::new_rand(); let mut instructions = budget_instruction::payment(&alice_pubkey, &bob_pubkey, &budget_pubkey, 1); @@ -271,7 +271,7 @@ mod tests { let (bank, alice_keypair) = create_bank(10_000); let bank_client = BankClient::new(bank); let alice_pubkey = alice_keypair.pubkey(); - let bob_pubkey = Pubkey::new_rand(); + let bob_pubkey = solana_sdk::pubkey::new_rand(); let budget_keypair = Keypair::new(); let budget_pubkey = budget_keypair.pubkey(); let instructions = @@ -292,8 +292,8 @@ mod tests { // Initialize BudgetState let budget_keypair = Keypair::new(); let budget_pubkey = budget_keypair.pubkey(); - let bob_pubkey = Pubkey::new_rand(); - let witness = Pubkey::new_rand(); + let bob_pubkey = solana_sdk::pubkey::new_rand(); + let witness = solana_sdk::pubkey::new_rand(); let instructions = budget_instruction::when_signed( &alice_pubkey, &bob_pubkey, @@ -341,7 +341,7 @@ mod tests { // Initialize BudgetState let budget_keypair = Keypair::new(); let budget_pubkey = budget_keypair.pubkey(); - let bob_pubkey = Pubkey::new_rand(); + let bob_pubkey = solana_sdk::pubkey::new_rand(); let dt = Utc::now(); let instructions = budget_instruction::on_date( &alice_pubkey, @@ -389,8 +389,8 @@ mod tests { let alice_pubkey = alice_keypair.pubkey(); let budget_keypair = Keypair::new(); let budget_pubkey = budget_keypair.pubkey(); - let bob_pubkey = Pubkey::new_rand(); - let mallory_pubkey = Pubkey::new_rand(); + let bob_pubkey = solana_sdk::pubkey::new_rand(); + let mallory_pubkey = solana_sdk::pubkey::new_rand(); let dt = Utc::now(); let instructions = budget_instruction::on_date( @@ -460,7 +460,7 @@ mod tests { let alice_pubkey = alice_keypair.pubkey(); let budget_keypair = Keypair::new(); let budget_pubkey = budget_keypair.pubkey(); - let bob_pubkey = Pubkey::new_rand(); + let bob_pubkey = solana_sdk::pubkey::new_rand(); let dt = Utc::now(); let instructions = budget_instruction::on_date( @@ -518,7 +518,7 @@ mod tests { #[test] fn test_pay_when_account_data() { let (bank, alice_keypair) = create_bank(42); - let game_pubkey = Pubkey::new_rand(); + let game_pubkey = solana_sdk::pubkey::new_rand(); let game_account = Account { lamports: 1, data: vec![1, 2, 3], diff --git a/programs/config/src/config_processor.rs b/programs/config/src/config_processor.rs index 95996722c..533ede121 100644 --- a/programs/config/src/config_processor.rs +++ b/programs/config/src/config_processor.rs @@ -138,7 +138,7 @@ mod tests { } fn create_config_account(keys: Vec<(Pubkey, bool)>) -> (Keypair, RefCell) { - let from_pubkey = Pubkey::new_rand(); + let from_pubkey = solana_sdk::pubkey::new_rand(); let config_keypair = Keypair::new(); let config_pubkey = config_keypair.pubkey(); @@ -239,9 +239,9 @@ mod tests { #[test] fn test_process_store_with_additional_signers() { solana_logger::setup(); - let pubkey = Pubkey::new_rand(); - let signer0_pubkey = Pubkey::new_rand(); - let signer1_pubkey = Pubkey::new_rand(); + let pubkey = solana_sdk::pubkey::new_rand(); + let signer0_pubkey = solana_sdk::pubkey::new_rand(); + let signer1_pubkey = solana_sdk::pubkey::new_rand(); let keys = vec![ (pubkey, false), (signer0_pubkey, true), @@ -275,8 +275,8 @@ mod tests { #[test] fn test_process_store_without_config_signer() { solana_logger::setup(); - let pubkey = Pubkey::new_rand(); - let signer0_pubkey = Pubkey::new_rand(); + let pubkey = solana_sdk::pubkey::new_rand(); + let signer0_pubkey = solana_sdk::pubkey::new_rand(); let keys = vec![(pubkey, false), (signer0_pubkey, true)]; let (config_keypair, _) = create_config_account(keys.clone()); let config_pubkey = config_keypair.pubkey(); @@ -295,8 +295,8 @@ mod tests { #[test] fn test_process_store_with_bad_additional_signer() { solana_logger::setup(); - let signer0_pubkey = Pubkey::new_rand(); - let signer1_pubkey = Pubkey::new_rand(); + let signer0_pubkey = solana_sdk::pubkey::new_rand(); + let signer1_pubkey = solana_sdk::pubkey::new_rand(); let signer0_account = RefCell::new(Account::default()); let signer1_account = RefCell::new(Account::default()); let keys = vec![(signer0_pubkey, true)]; @@ -332,10 +332,10 @@ mod tests { #[test] fn test_config_updates() { solana_logger::setup(); - let pubkey = Pubkey::new_rand(); - let signer0_pubkey = Pubkey::new_rand(); - let signer1_pubkey = Pubkey::new_rand(); - let signer2_pubkey = Pubkey::new_rand(); + let pubkey = solana_sdk::pubkey::new_rand(); + let signer0_pubkey = solana_sdk::pubkey::new_rand(); + let signer1_pubkey = solana_sdk::pubkey::new_rand(); + let signer2_pubkey = solana_sdk::pubkey::new_rand(); let signer0_account = RefCell::new(Account::default()); let signer1_account = RefCell::new(Account::default()); let signer2_account = RefCell::new(Account::default()); @@ -417,8 +417,8 @@ mod tests { #[test] fn test_config_updates_requiring_config() { solana_logger::setup(); - let pubkey = Pubkey::new_rand(); - let signer0_pubkey = Pubkey::new_rand(); + let pubkey = solana_sdk::pubkey::new_rand(); + let signer0_pubkey = solana_sdk::pubkey::new_rand(); let signer0_account = RefCell::new(Account::default()); let keys = vec![ (pubkey, false), @@ -479,8 +479,8 @@ mod tests { #[test] fn test_config_initialize_no_panic() { - let from_pubkey = Pubkey::new_rand(); - let config_pubkey = Pubkey::new_rand(); + let from_pubkey = solana_sdk::pubkey::new_rand(); + let config_pubkey = solana_sdk::pubkey::new_rand(); let instructions = config_instruction::create_account::(&from_pubkey, &config_pubkey, 1, vec![]); let accounts = vec![]; diff --git a/programs/failure/tests/failure.rs b/programs/failure/tests/failure.rs index 7d0f6cde6..9bbc716a6 100644 --- a/programs/failure/tests/failure.rs +++ b/programs/failure/tests/failure.rs @@ -11,7 +11,7 @@ use solana_sdk::transaction::TransactionError; #[test] fn test_program_native_failure() { let (genesis_config, alice_keypair) = create_genesis_config(50); - let program_id = Pubkey::new_rand(); + let program_id = solana_sdk::pubkey::new_rand(); let bank = Bank::new(&genesis_config); bank.add_native_program("solana_failure_program", &program_id); diff --git a/programs/ownable/src/ownable_processor.rs b/programs/ownable/src/ownable_processor.rs index 3e6a2724a..11a83ddb2 100644 --- a/programs/ownable/src/ownable_processor.rs +++ b/programs/ownable/src/ownable_processor.rs @@ -151,9 +151,9 @@ mod tests { #[test] fn test_ownable_missing_owner_signature() { - let mut account_owner_pubkey = Pubkey::new_rand(); + let mut account_owner_pubkey = solana_sdk::pubkey::new_rand(); let owner_pubkey = account_owner_pubkey; - let new_owner_pubkey = Pubkey::new_rand(); + let new_owner_pubkey = solana_sdk::pubkey::new_rand(); let account = Account::new_ref(1, 0, &system_program::id()); let owner_keyed_account = KeyedAccount::new(&owner_pubkey, false, &account); // <-- Attack! Setting owner without the original owner's signature. let err = set_owner( @@ -167,10 +167,10 @@ mod tests { #[test] fn test_ownable_incorrect_owner() { - let mut account_owner_pubkey = Pubkey::new_rand(); - let new_owner_pubkey = Pubkey::new_rand(); + let mut account_owner_pubkey = solana_sdk::pubkey::new_rand(); + let new_owner_pubkey = solana_sdk::pubkey::new_rand(); let account = Account::new_ref(1, 0, &system_program::id()); - let mallory_pubkey = Pubkey::new_rand(); // <-- Attack! Signing with wrong pubkey + let mallory_pubkey = solana_sdk::pubkey::new_rand(); // <-- Attack! Signing with wrong pubkey let owner_keyed_account = KeyedAccount::new(&mallory_pubkey, true, &account); let err = set_owner( &mut account_owner_pubkey, diff --git a/programs/stake/src/stake_instruction.rs b/programs/stake/src/stake_instruction.rs index cd279a410..03e6a0662 100644 --- a/programs/stake/src/stake_instruction.rs +++ b/programs/stake/src/stake_instruction.rs @@ -623,7 +623,7 @@ mod tests { process_instruction(&withdraw( &Pubkey::default(), &Pubkey::default(), - &Pubkey::new_rand(), + &solana_sdk::pubkey::new_rand(), 100, None, )), diff --git a/programs/stake/src/stake_state.rs b/programs/stake/src/stake_state.rs index d4d23b8d5..0eadf93c2 100644 --- a/programs/stake/src/stake_state.rs +++ b/programs/stake/src/stake_state.rs @@ -1103,7 +1103,7 @@ mod tests { #[test] fn test_authorized_authorize() { - let staker = Pubkey::new_rand(); + let staker = solana_sdk::pubkey::new_rand(); let mut authorized = Authorized::auto(&staker); let mut signers = HashSet::new(); assert_eq!( @@ -1155,7 +1155,7 @@ mod tests { ..Clock::default() }; - let vote_pubkey = Pubkey::new_rand(); + let vote_pubkey = solana_sdk::pubkey::new_rand(); let mut vote_state = VoteState::default(); for i in 0..1000 { vote_state.process_slot_vote_unchecked(i); @@ -1163,7 +1163,7 @@ mod tests { let vote_account = RefCell::new(vote_state::create_account( &vote_pubkey, - &Pubkey::new_rand(), + &solana_sdk::pubkey::new_rand(), 0, 100, )); @@ -1173,7 +1173,7 @@ mod tests { .set_state(&VoteStateVersions::Current(Box::new(vote_state))) .unwrap(); - let stake_pubkey = Pubkey::new_rand(); + let stake_pubkey = solana_sdk::pubkey::new_rand(); let stake_lamports = 42; let stake_account = Account::new_ref_data_with_space( stake_lamports, @@ -1609,14 +1609,14 @@ mod tests { #[test] fn test_stake_initialize() { - let stake_pubkey = Pubkey::new_rand(); + let stake_pubkey = solana_sdk::pubkey::new_rand(); let stake_lamports = 42; let stake_account = Account::new_ref(stake_lamports, std::mem::size_of::(), &id()); // unsigned keyed account let stake_keyed_account = KeyedAccount::new(&stake_pubkey, false, &stake_account); - let custodian = Pubkey::new_rand(); + let custodian = solana_sdk::pubkey::new_rand(); // not enough balance for rent... assert_eq!( @@ -1673,7 +1673,7 @@ mod tests { #[test] fn test_deactivate() { - let stake_pubkey = Pubkey::new_rand(); + let stake_pubkey = solana_sdk::pubkey::new_rand(); let stake_lamports = 42; let stake_account = Account::new_ref_data_with_space( stake_lamports, @@ -1697,10 +1697,10 @@ mod tests { ); // Staking - let vote_pubkey = Pubkey::new_rand(); + let vote_pubkey = solana_sdk::pubkey::new_rand(); let vote_account = RefCell::new(vote_state::create_account( &vote_pubkey, - &Pubkey::new_rand(), + &solana_sdk::pubkey::new_rand(), 0, 100, )); @@ -1739,7 +1739,7 @@ mod tests { #[test] fn test_set_lockup() { - let stake_pubkey = Pubkey::new_rand(); + let stake_pubkey = solana_sdk::pubkey::new_rand(); let stake_lamports = 42; let stake_account = Account::new_ref_data_with_space( stake_lamports, @@ -1757,7 +1757,7 @@ mod tests { ); // initalize the stake - let custodian = Pubkey::new_rand(); + let custodian = solana_sdk::pubkey::new_rand(); stake_keyed_account .initialize( &Authorized::auto(&stake_pubkey), @@ -1788,10 +1788,10 @@ mod tests { ); // delegate stake - let vote_pubkey = Pubkey::new_rand(); + let vote_pubkey = solana_sdk::pubkey::new_rand(); let vote_account = RefCell::new(vote_state::create_account( &vote_pubkey, - &Pubkey::new_rand(), + &solana_sdk::pubkey::new_rand(), 0, 100, )); @@ -1836,7 +1836,7 @@ mod tests { #[test] fn test_optional_lockup() { - let stake_pubkey = Pubkey::new_rand(); + let stake_pubkey = solana_sdk::pubkey::new_rand(); let stake_lamports = 42; let stake_account = Account::new_ref_data_with_space( stake_lamports, @@ -1847,7 +1847,7 @@ mod tests { .expect("stake_account"); let stake_keyed_account = KeyedAccount::new(&stake_pubkey, false, &stake_account); - let custodian = Pubkey::new_rand(); + let custodian = solana_sdk::pubkey::new_rand(); stake_keyed_account .initialize( &Authorized::auto(&stake_pubkey), @@ -1916,7 +1916,7 @@ mod tests { panic!(); } - let new_custodian = Pubkey::new_rand(); + let new_custodian = solana_sdk::pubkey::new_rand(); assert_eq!( stake_keyed_account.set_lockup( &LockupArgs { @@ -1950,7 +1950,7 @@ mod tests { #[test] fn test_withdraw_stake() { - let stake_pubkey = Pubkey::new_rand(); + let stake_pubkey = solana_sdk::pubkey::new_rand(); let stake_lamports = 42; let stake_account = Account::new_ref_data_with_space( stake_lamports, @@ -1962,7 +1962,7 @@ mod tests { let mut clock = Clock::default(); - let to = Pubkey::new_rand(); + let to = solana_sdk::pubkey::new_rand(); let to_account = Account::new_ref(1, 0, &system_program::id()); let to_keyed_account = KeyedAccount::new(&to, false, &to_account); @@ -2001,7 +2001,7 @@ mod tests { // lockup let stake_keyed_account = KeyedAccount::new(&stake_pubkey, true, &stake_account); - let custodian = Pubkey::new_rand(); + let custodian = solana_sdk::pubkey::new_rand(); stake_keyed_account .initialize( &Authorized::auto(&stake_pubkey), @@ -2030,10 +2030,10 @@ mod tests { ); // Stake some lamports (available lamports for withdrawals will reduce to zero) - let vote_pubkey = Pubkey::new_rand(); + let vote_pubkey = solana_sdk::pubkey::new_rand(); let vote_account = RefCell::new(vote_state::create_account( &vote_pubkey, - &Pubkey::new_rand(), + &solana_sdk::pubkey::new_rand(), 0, 100, )); @@ -2124,7 +2124,7 @@ mod tests { #[test] fn test_withdraw_stake_before_warmup() { - let stake_pubkey = Pubkey::new_rand(); + let stake_pubkey = solana_sdk::pubkey::new_rand(); let total_lamports = 100; let stake_lamports = 42; let stake_account = Account::new_ref_data_with_space( @@ -2139,17 +2139,17 @@ mod tests { let mut future = Clock::default(); future.epoch += 16; - let to = Pubkey::new_rand(); + let to = solana_sdk::pubkey::new_rand(); let to_account = Account::new_ref(1, 0, &system_program::id()); let to_keyed_account = KeyedAccount::new(&to, false, &to_account); let stake_keyed_account = KeyedAccount::new(&stake_pubkey, true, &stake_account); // Stake some lamports (available lamports for withdrawals will reduce) - let vote_pubkey = Pubkey::new_rand(); + let vote_pubkey = solana_sdk::pubkey::new_rand(); let vote_account = RefCell::new(vote_state::create_account( &vote_pubkey, - &Pubkey::new_rand(), + &solana_sdk::pubkey::new_rand(), 0, 100, )); @@ -2195,7 +2195,7 @@ mod tests { #[test] fn test_withdraw_stake_invalid_state() { - let stake_pubkey = Pubkey::new_rand(); + let stake_pubkey = solana_sdk::pubkey::new_rand(); let total_lamports = 100; let stake_account = Account::new_ref_data_with_space( total_lamports, @@ -2205,7 +2205,7 @@ mod tests { ) .expect("stake_account"); - let to = Pubkey::new_rand(); + let to = solana_sdk::pubkey::new_rand(); let to_account = Account::new_ref(1, 0, &system_program::id()); let to_keyed_account = KeyedAccount::new(&to, false, &to_account); let stake_keyed_account = KeyedAccount::new(&stake_pubkey, true, &stake_account); @@ -2224,8 +2224,8 @@ mod tests { #[test] fn test_withdraw_lockup() { - let stake_pubkey = Pubkey::new_rand(); - let custodian = Pubkey::new_rand(); + let stake_pubkey = solana_sdk::pubkey::new_rand(); + let custodian = solana_sdk::pubkey::new_rand(); let total_lamports = 100; let stake_account = Account::new_ref_data_with_space( total_lamports, @@ -2242,7 +2242,7 @@ mod tests { ) .expect("stake_account"); - let to = Pubkey::new_rand(); + let to = solana_sdk::pubkey::new_rand(); let to_account = Account::new_ref(1, 0, &system_program::id()); let to_keyed_account = KeyedAccount::new(&to, false, &to_account); @@ -2299,7 +2299,7 @@ mod tests { #[test] fn test_withdraw_identical_authorities() { - let stake_pubkey = Pubkey::new_rand(); + let stake_pubkey = solana_sdk::pubkey::new_rand(); let custodian = stake_pubkey; let total_lamports = 100; let stake_account = Account::new_ref_data_with_space( @@ -2317,7 +2317,7 @@ mod tests { ) .expect("stake_account"); - let to = Pubkey::new_rand(); + let to = solana_sdk::pubkey::new_rand(); let to_account = Account::new_ref(1, 0, &system_program::id()); let to_keyed_account = KeyedAccount::new(&to, false, &to_account); @@ -2586,7 +2586,7 @@ mod tests { #[test] fn test_authorize_uninit() { - let new_authority = Pubkey::new_rand(); + let new_authority = solana_sdk::pubkey::new_rand(); let stake_lamports = 42; let stake_account = Account::new_ref_data_with_space( stake_lamports, @@ -2606,7 +2606,7 @@ mod tests { #[test] fn test_authorize_lockup() { - let stake_authority = Pubkey::new_rand(); + let stake_authority = solana_sdk::pubkey::new_rand(); let stake_lamports = 42; let stake_account = Account::new_ref_data_with_space( stake_lamports, @@ -2616,14 +2616,14 @@ mod tests { ) .expect("stake_account"); - let to = Pubkey::new_rand(); + let to = solana_sdk::pubkey::new_rand(); let to_account = Account::new_ref(1, 0, &system_program::id()); let to_keyed_account = KeyedAccount::new(&to, false, &to_account); let clock = Clock::default(); let stake_keyed_account = KeyedAccount::new(&stake_authority, true, &stake_account); - let stake_pubkey0 = Pubkey::new_rand(); + let stake_pubkey0 = solana_sdk::pubkey::new_rand(); let signers = vec![stake_authority].into_iter().collect(); assert_eq!( stake_keyed_account.authorize(&signers, &stake_pubkey0, StakeAuthorize::Staker), @@ -2643,7 +2643,7 @@ mod tests { } // A second authorization signed by the stake_keyed_account should fail - let stake_pubkey1 = Pubkey::new_rand(); + let stake_pubkey1 = solana_sdk::pubkey::new_rand(); assert_eq!( stake_keyed_account.authorize(&signers, &stake_pubkey1, StakeAuthorize::Staker), Err(InstructionError::MissingRequiredSignature) @@ -2652,7 +2652,7 @@ mod tests { let signers0 = vec![stake_pubkey0].into_iter().collect(); // Test a second authorization by the newly authorized pubkey - let stake_pubkey2 = Pubkey::new_rand(); + let stake_pubkey2 = solana_sdk::pubkey::new_rand(); assert_eq!( stake_keyed_account.authorize(&signers0, &stake_pubkey2, StakeAuthorize::Staker), Ok(()) @@ -2705,7 +2705,7 @@ mod tests { #[test] fn test_authorize_with_seed() { - let base_pubkey = Pubkey::new_rand(); + let base_pubkey = solana_sdk::pubkey::new_rand(); let seed = "42"; let withdrawer_pubkey = Pubkey::create_with_seed(&base_pubkey, &seed, &id()).unwrap(); let stake_lamports = 42; @@ -2722,7 +2722,7 @@ mod tests { let stake_keyed_account = KeyedAccount::new(&withdrawer_pubkey, true, &stake_account); - let new_authority = Pubkey::new_rand(); + let new_authority = solana_sdk::pubkey::new_rand(); // Wrong seed assert_eq!( @@ -2787,7 +2787,7 @@ mod tests { #[test] fn test_authorize_override() { - let withdrawer_pubkey = Pubkey::new_rand(); + let withdrawer_pubkey = solana_sdk::pubkey::new_rand(); let stake_lamports = 42; let stake_account = Account::new_ref_data_with_space( stake_lamports, @@ -2800,7 +2800,7 @@ mod tests { let stake_keyed_account = KeyedAccount::new(&withdrawer_pubkey, true, &stake_account); // Authorize a staker pubkey and move the withdrawer key into cold storage. - let new_authority = Pubkey::new_rand(); + let new_authority = solana_sdk::pubkey::new_rand(); let signers = vec![withdrawer_pubkey].into_iter().collect(); assert_eq!( stake_keyed_account.authorize(&signers, &new_authority, StakeAuthorize::Staker), @@ -2808,7 +2808,7 @@ mod tests { ); // Attack! The stake key (a hot key) is stolen and used to authorize a new staker. - let mallory_pubkey = Pubkey::new_rand(); + let mallory_pubkey = solana_sdk::pubkey::new_rand(); let signers = vec![new_authority].into_iter().collect(); assert_eq!( stake_keyed_account.authorize(&signers, &mallory_pubkey, StakeAuthorize::Staker), @@ -2816,7 +2816,7 @@ mod tests { ); // Verify the original staker no longer has access. - let new_stake_pubkey = Pubkey::new_rand(); + let new_stake_pubkey = solana_sdk::pubkey::new_rand(); assert_eq!( stake_keyed_account.authorize(&signers, &new_stake_pubkey, StakeAuthorize::Staker), Err(InstructionError::MissingRequiredSignature) @@ -2839,7 +2839,7 @@ mod tests { #[test] fn test_split_source_uninitialized() { - let stake_pubkey = Pubkey::new_rand(); + let stake_pubkey = solana_sdk::pubkey::new_rand(); let stake_lamports = 42; let stake_account = Account::new_ref_data_with_space( stake_lamports, @@ -2849,7 +2849,7 @@ mod tests { ) .expect("stake_account"); - let split_stake_pubkey = Pubkey::new_rand(); + let split_stake_pubkey = solana_sdk::pubkey::new_rand(); let split_stake_account = Account::new_ref_data_with_space( 0, &StakeState::Uninitialized, @@ -2886,7 +2886,7 @@ mod tests { #[test] fn test_split_split_not_uninitialized() { - let stake_pubkey = Pubkey::new_rand(); + let stake_pubkey = solana_sdk::pubkey::new_rand(); let stake_lamports = 42; let stake_account = Account::new_ref_data_with_space( stake_lamports, @@ -2896,7 +2896,7 @@ mod tests { ) .expect("stake_account"); - let split_stake_pubkey = Pubkey::new_rand(); + let split_stake_pubkey = solana_sdk::pubkey::new_rand(); let split_stake_account = Account::new_ref_data_with_space( 0, &StakeState::Initialized(Meta::auto(&stake_pubkey)), @@ -2938,7 +2938,7 @@ mod tests { #[test] fn test_split_more_than_staked() { - let stake_pubkey = Pubkey::new_rand(); + let stake_pubkey = solana_sdk::pubkey::new_rand(); let stake_lamports = 42; let stake_account = Account::new_ref_data_with_space( stake_lamports, @@ -2951,7 +2951,7 @@ mod tests { ) .expect("stake_account"); - let split_stake_pubkey = Pubkey::new_rand(); + let split_stake_pubkey = solana_sdk::pubkey::new_rand(); let split_stake_account = Account::new_ref_data_with_space( 0, &StakeState::Uninitialized, @@ -2972,8 +2972,8 @@ mod tests { #[test] fn test_split_with_rent() { - let stake_pubkey = Pubkey::new_rand(); - let split_stake_pubkey = Pubkey::new_rand(); + let stake_pubkey = solana_sdk::pubkey::new_rand(); + let split_stake_pubkey = solana_sdk::pubkey::new_rand(); let stake_lamports = 42; let rent_exempt_reserve = 10; let signers = vec![stake_pubkey].into_iter().collect(); @@ -3073,10 +3073,10 @@ mod tests { #[test] fn test_split() { - let stake_pubkey = Pubkey::new_rand(); + let stake_pubkey = solana_sdk::pubkey::new_rand(); let stake_lamports = 42; - let split_stake_pubkey = Pubkey::new_rand(); + let split_stake_pubkey = solana_sdk::pubkey::new_rand(); let signers = vec![stake_pubkey].into_iter().collect(); // test splitting both an Initialized stake and a Staked stake @@ -3165,11 +3165,11 @@ mod tests { #[test] fn test_split_100_percent_of_source() { - let stake_pubkey = Pubkey::new_rand(); + let stake_pubkey = solana_sdk::pubkey::new_rand(); let stake_lamports = 42; let rent_exempt_reserve = 10; - let split_stake_pubkey = Pubkey::new_rand(); + let split_stake_pubkey = solana_sdk::pubkey::new_rand(); let signers = vec![stake_pubkey].into_iter().collect(); let meta = Meta { @@ -3262,9 +3262,9 @@ mod tests { #[test] fn test_merge() { - let stake_pubkey = Pubkey::new_rand(); - let source_stake_pubkey = Pubkey::new_rand(); - let authorized_pubkey = Pubkey::new_rand(); + let stake_pubkey = solana_sdk::pubkey::new_rand(); + let source_stake_pubkey = solana_sdk::pubkey::new_rand(); + let authorized_pubkey = solana_sdk::pubkey::new_rand(); let stake_lamports = 42; let signers = vec![authorized_pubkey].into_iter().collect(); @@ -3335,10 +3335,10 @@ mod tests { #[test] fn test_merge_incorrect_authorized_staker() { - let stake_pubkey = Pubkey::new_rand(); - let source_stake_pubkey = Pubkey::new_rand(); - let authorized_pubkey = Pubkey::new_rand(); - let wrong_authorized_pubkey = Pubkey::new_rand(); + let stake_pubkey = solana_sdk::pubkey::new_rand(); + let source_stake_pubkey = solana_sdk::pubkey::new_rand(); + let authorized_pubkey = solana_sdk::pubkey::new_rand(); + let wrong_authorized_pubkey = solana_sdk::pubkey::new_rand(); let stake_lamports = 42; let signers = vec![authorized_pubkey].into_iter().collect(); @@ -3402,9 +3402,9 @@ mod tests { #[test] fn test_merge_invalid_account_data() { - let stake_pubkey = Pubkey::new_rand(); - let source_stake_pubkey = Pubkey::new_rand(); - let authorized_pubkey = Pubkey::new_rand(); + let stake_pubkey = solana_sdk::pubkey::new_rand(); + let source_stake_pubkey = solana_sdk::pubkey::new_rand(); + let authorized_pubkey = solana_sdk::pubkey::new_rand(); let stake_lamports = 42; let signers = vec![authorized_pubkey].into_iter().collect(); @@ -3452,9 +3452,9 @@ mod tests { #[test] fn test_merge_active_stake() { - let stake_pubkey = Pubkey::new_rand(); - let source_stake_pubkey = Pubkey::new_rand(); - let authorized_pubkey = Pubkey::new_rand(); + let stake_pubkey = solana_sdk::pubkey::new_rand(); + let source_stake_pubkey = solana_sdk::pubkey::new_rand(); + let authorized_pubkey = solana_sdk::pubkey::new_rand(); let stake_lamports = 42; let signers = vec![authorized_pubkey].into_iter().collect(); @@ -3505,7 +3505,7 @@ mod tests { #[test] fn test_lockup_is_expired() { - let custodian = Pubkey::new_rand(); + let custodian = solana_sdk::pubkey::new_rand(); let lockup = Lockup { epoch: 1, unix_timestamp: 1, @@ -3587,7 +3587,7 @@ mod tests { #[test] fn test_authorize_delegated_stake() { - let stake_pubkey = Pubkey::new_rand(); + let stake_pubkey = solana_sdk::pubkey::new_rand(); let stake_lamports = 42; let stake_account = Account::new_ref_data_with_space( stake_lamports, @@ -3599,10 +3599,10 @@ mod tests { let clock = Clock::default(); - let vote_pubkey = Pubkey::new_rand(); + let vote_pubkey = solana_sdk::pubkey::new_rand(); let vote_account = RefCell::new(vote_state::create_account( &vote_pubkey, - &Pubkey::new_rand(), + &solana_sdk::pubkey::new_rand(), 0, 100, )); @@ -3623,7 +3623,7 @@ mod tests { // deactivate, so we can re-delegate stake_keyed_account.deactivate(&clock, &signers).unwrap(); - let new_staker_pubkey = Pubkey::new_rand(); + let new_staker_pubkey = solana_sdk::pubkey::new_rand(); assert_eq!( stake_keyed_account.authorize(&signers, &new_staker_pubkey, StakeAuthorize::Staker), Ok(()) @@ -3632,17 +3632,17 @@ mod tests { StakeState::authorized_from(&stake_keyed_account.try_account_ref().unwrap()).unwrap(); assert_eq!(authorized.staker, new_staker_pubkey); - let other_pubkey = Pubkey::new_rand(); + let other_pubkey = solana_sdk::pubkey::new_rand(); let other_signers = vec![other_pubkey].into_iter().collect(); // Use unsigned stake_keyed_account to test other signers let stake_keyed_account = KeyedAccount::new(&stake_pubkey, false, &stake_account); - let new_voter_pubkey = Pubkey::new_rand(); + let new_voter_pubkey = solana_sdk::pubkey::new_rand(); let vote_state = VoteState::default(); let new_vote_account = RefCell::new(vote_state::create_account( &new_voter_pubkey, - &Pubkey::new_rand(), + &solana_sdk::pubkey::new_rand(), 0, 100, )); diff --git a/programs/vest/src/vest_processor.rs b/programs/vest/src/vest_processor.rs index 2dc574811..cd4b11f90 100644 --- a/programs/vest/src/vest_processor.rs +++ b/programs/vest/src/vest_processor.rs @@ -260,11 +260,11 @@ mod tests { #[test] fn test_verify_account_unauthorized() { // Ensure client can't sneak in with an untrusted date account. - let date_pubkey = Pubkey::new_rand(); + let date_pubkey = solana_sdk::pubkey::new_rand(); let account = Account::new_ref(1, 0, &solana_config_program::id()); let keyed_account = KeyedAccount::new(&date_pubkey, false, &account); - let mallory_pubkey = Pubkey::new_rand(); // <-- Attack! Not the expected account. + let mallory_pubkey = solana_sdk::pubkey::new_rand(); // <-- Attack! Not the expected account. assert_eq!( verify_account(&keyed_account, &mallory_pubkey).unwrap_err(), VestError::Unauthorized.into() @@ -274,7 +274,7 @@ mod tests { #[test] fn test_verify_signed_account_missing_signature() { // Ensure client can't sneak in with an unsigned account. - let date_pubkey = Pubkey::new_rand(); + let date_pubkey = solana_sdk::pubkey::new_rand(); let account = Account::new_ref(1, 0, &solana_config_program::id()); let keyed_account = KeyedAccount::new(&date_pubkey, false, &account); // <-- Attack! Unsigned transaction. @@ -287,7 +287,7 @@ mod tests { #[test] fn test_verify_date_account_incorrect_program_id() { // Ensure client can't sneak in with a non-Config account. - let date_pubkey = Pubkey::new_rand(); + let date_pubkey = solana_sdk::pubkey::new_rand(); let account = Account::new_ref(1, 0, &id()); // <-- Attack! Pass Vest account where Config account is expected. let keyed_account = KeyedAccount::new(&date_pubkey, false, &account); assert_eq!( @@ -299,7 +299,7 @@ mod tests { #[test] fn test_verify_date_account_uninitialized_config() { // Ensure no panic when `get_config_data()` returns an error. - let date_pubkey = Pubkey::new_rand(); + let date_pubkey = solana_sdk::pubkey::new_rand(); let account = Account::new_ref(1, 0, &solana_config_program::id()); // <-- Attack! Zero space. let keyed_account = KeyedAccount::new(&date_pubkey, false, &account); assert_eq!( @@ -311,7 +311,7 @@ mod tests { #[test] fn test_verify_date_account_invalid_date_config() { // Ensure no panic when `deserialize::()` returns an error. - let date_pubkey = Pubkey::new_rand(); + let date_pubkey = solana_sdk::pubkey::new_rand(); let account = Account::new_ref(1, 1, &solana_config_program::id()); // Attack! 1 byte, enough to sneak by `get_config_data()`, but not DateConfig deserialize. let keyed_account = KeyedAccount::new(&date_pubkey, false, &account); assert_eq!( @@ -323,7 +323,7 @@ mod tests { #[test] fn test_verify_date_account_deserialize() { // Ensure no panic when `deserialize::()` returns an error. - let date_pubkey = Pubkey::new_rand(); + let date_pubkey = solana_sdk::pubkey::new_rand(); let account = Account::new_ref(1, 1, &solana_config_program::id()); // Attack! 1 byte, enough to sneak by `get_config_data()`, but not DateConfig deserialize. let keyed_account = KeyedAccount::new(&date_pubkey, false, &account); assert_eq!( @@ -340,11 +340,11 @@ mod tests { let mut instructions = vest_instruction::create_account( &alice_keypair.pubkey(), - &Pubkey::new_rand(), + &solana_sdk::pubkey::new_rand(), &contract_keypair.pubkey(), - &Pubkey::new_rand(), + &solana_sdk::pubkey::new_rand(), Utc::now().date(), - &Pubkey::new_rand(), + &solana_sdk::pubkey::new_rand(), 1, ); instructions[1].accounts = vec![]; //