Skip to content

Commit

Permalink
Remove unused pubkey::Pubkey imports
Browse files Browse the repository at this point in the history
  • Loading branch information
mvines committed Oct 20, 2020
1 parent 4a6b3af commit e26a425
Show file tree
Hide file tree
Showing 44 changed files with 218 additions and 85 deletions.
1 change: 0 additions & 1 deletion account-decoder/src/parse_stake.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,6 @@ impl From<Delegation> for UiDelegation {
mod test {
use super::*;
use bincode::serialize;
use solana_sdk::pubkey::Pubkey;

#[test]
fn test_parse_stake() {
Expand Down
1 change: 0 additions & 1 deletion banking-bench/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ use solana_perf::packet::to_packets_chunked;
use solana_runtime::{bank::Bank, bank_forks::BankForks};
use solana_sdk::{
hash::Hash,
pubkey::Pubkey,
signature::Keypair,
signature::Signature,
system_transaction,
Expand Down
2 changes: 1 addition & 1 deletion banks-client/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ mod tests {
use super::*;
use solana_banks_server::banks_server::start_local_server;
use solana_runtime::{bank::Bank, bank_forks::BankForks, genesis_utils::create_genesis_config};
use solana_sdk::{message::Message, pubkey::Pubkey, signature::Signer, system_instruction};
use solana_sdk::{message::Message, signature::Signer, system_instruction};
use std::sync::{Arc, RwLock};
use tarpc::transport;
use tokio::{runtime::Runtime, time::delay_for};
Expand Down
5 changes: 4 additions & 1 deletion cli/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2367,7 +2367,10 @@ 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(solana_sdk::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();
Expand Down
1 change: 0 additions & 1 deletion cli/tests/vote.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ use solana_faucet::faucet::run_local_faucet;
use solana_sdk::{
account_utils::StateMut,
commitment_config::CommitmentConfig,
pubkey::Pubkey,
signature::{Keypair, Signer},
};
use solana_vote_program::vote_state::{VoteAuthorize, VoteState, VoteStateVersions};
Expand Down
5 changes: 4 additions & 1 deletion core/benches/crds_shards.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@ use test::Bencher;
const CRDS_SHARDS_BITS: u32 = 8;

fn new_test_crds_value() -> VersionedCrdsValue {
let data = CrdsData::ContactInfo(ContactInfo::new_localhost(&solana_sdk::pubkey::new_rand(), timestamp()));
let data = CrdsData::ContactInfo(ContactInfo::new_localhost(
&solana_sdk::pubkey::new_rand(),
timestamp(),
));
VersionedCrdsValue::new(timestamp(), CrdsValue::new_unsigned(data))
}

Expand Down
1 change: 0 additions & 1 deletion core/src/broadcast_stage/broadcast_fake_shreds_run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,6 @@ impl BroadcastRun for BroadcastFakeShredsRun {
mod tests {
use super::*;
use crate::contact_info::ContactInfo;
use solana_sdk::pubkey::Pubkey;
use std::net::{IpAddr, Ipv4Addr, SocketAddr};

#[test]
Expand Down
15 changes: 11 additions & 4 deletions core/src/cluster_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2736,8 +2736,11 @@ mod tests {
//check that a gossip nodes always show up as spies
let (node, _, _) = ClusterInfo::spy_node(&solana_sdk::pubkey::new_rand(), 0);
assert!(ClusterInfo::is_spy_node(&node));
let (node, _, _) =
ClusterInfo::gossip_node(&solana_sdk::pubkey::new_rand(), &"1.1.1.1:1111".parse().unwrap(), 0);
let (node, _, _) = ClusterInfo::gossip_node(
&solana_sdk::pubkey::new_rand(),
&"1.1.1.1:1111".parse().unwrap(),
0,
);
assert!(ClusterInfo::is_spy_node(&node));
}

Expand Down Expand Up @@ -2955,8 +2958,12 @@ 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(&solana_sdk::pubkey::new_rand(), &socketaddr!(0, port), port_range, ip);
let node = Node::new_with_external_ip(
&solana_sdk::pubkey::new_rand(),
&socketaddr!(0, port),
port_range,
ip,
);

check_node_sockets(&node, ip, port_range);

Expand Down
12 changes: 8 additions & 4 deletions core/src/commitment_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -377,17 +377,20 @@ mod tests {

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 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 = 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 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 = 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 mut vote_account3 =
vote_state::create_account(&pk3, &solana_sdk::pubkey::new_rand(), 0, 1);
let stake_account3 = stake_state::create_account(
&sk3,
&pk3,
Expand All @@ -397,7 +400,8 @@ mod tests {
);
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 mut vote_account4 =
vote_state::create_account(&pk4, &solana_sdk::pubkey::new_rand(), 0, 1);
let stake_account4 = stake_state::create_account(
&sk4,
&pk4,
Expand Down
4 changes: 3 additions & 1 deletion core/src/crds.rs
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,9 @@ mod test {
}

let mut crds = Crds::default();
let pubkeys: Vec<_> = std::iter::repeat_with(solana_sdk::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 {
Expand Down
7 changes: 4 additions & 3 deletions core/src/crds_shards.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,14 +135,15 @@ mod test {
use crate::contact_info::ContactInfo;
use crate::crds_value::{CrdsData, CrdsValue};
use rand::{thread_rng, Rng};
use solana_sdk::pubkey::Pubkey;
use solana_sdk::timing::timestamp;
use std::collections::HashSet;
use std::ops::Index;

fn new_test_crds_value() -> VersionedCrdsValue {
let data =
CrdsData::ContactInfo(ContactInfo::new_localhost(&solana_sdk::pubkey::new_rand(), timestamp()));
let data = CrdsData::ContactInfo(ContactInfo::new_localhost(
&solana_sdk::pubkey::new_rand(),
timestamp(),
));
VersionedCrdsValue::new(timestamp(), CrdsValue::new_unsigned(data))
}

Expand Down
12 changes: 10 additions & 2 deletions core/src/replay_stage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2596,7 +2596,11 @@ 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, &solana_sdk::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());
}
Expand All @@ -2612,7 +2616,11 @@ 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, &solana_sdk::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());
}
Expand Down
1 change: 0 additions & 1 deletion core/src/retransmit_stage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -504,7 +504,6 @@ mod tests {
use solana_ledger::genesis_utils::{create_genesis_config, GenesisConfigInfo};
use solana_net_utils::find_available_port_in_range;
use solana_perf::packet::{Meta, Packet, Packets};
use solana_sdk::pubkey::Pubkey;
use std::net::{IpAddr, Ipv4Addr};

#[test]
Expand Down
29 changes: 22 additions & 7 deletions core/src/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4271,8 +4271,12 @@ pub mod tests {
);
SendTransactionService::new(tpu_address, &bank_forks, None, receiver);

let mut bad_transaction =
system_transaction::transfer(&mint_keypair, &solana_sdk::pubkey::new_rand(), 42, Hash::default());
let mut bad_transaction = system_transaction::transfer(
&mint_keypair,
&solana_sdk::pubkey::new_rand(),
42,
Hash::default(),
);

// sendTransaction will fail because the blockhash is invalid
let req = format!(
Expand Down Expand Up @@ -4302,8 +4306,12 @@ pub mod tests {
r#"{"jsonrpc":"2.0","error":{"code":-32002,"message":"Transaction simulation failed: Transaction failed to sanitize accounts offsets correctly","data":{"err":"SanitizeFailure","logs":[]}},"id":1}"#.to_string(),
)
);
let mut bad_transaction =
system_transaction::transfer(&mint_keypair, &solana_sdk::pubkey::new_rand(), 42, recent_blockhash);
let mut bad_transaction = 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));
Expand Down Expand Up @@ -4397,7 +4405,12 @@ pub mod tests {

#[test]
fn test_rpc_verify_signature() {
let tx = system_transaction::transfer(&Keypair::new(), &solana_sdk::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]
Expand Down Expand Up @@ -5192,7 +5205,8 @@ pub mod tests {

#[test]
fn test_token_rpcs() {
let RpcHandler { io, meta, bank, .. } = start_rpc_handler_with_tx(&solana_sdk::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]);
Expand Down Expand Up @@ -5588,7 +5602,8 @@ pub mod tests {

#[test]
fn test_token_parsing() {
let RpcHandler { io, meta, bank, .. } = start_rpc_handler_with_tx(&solana_sdk::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]);
Expand Down
6 changes: 5 additions & 1 deletion core/src/rpc_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -550,7 +550,11 @@ 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![solana_sdk::pubkey::new_rand(), solana_sdk::pubkey::new_rand(), solana_sdk::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(),
Expand Down
7 changes: 5 additions & 2 deletions core/src/rpc_subscriptions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1249,8 +1249,11 @@ pub(crate) mod tests {
.process_transaction(&past_bank_tx)
.unwrap();

let next_bank =
Bank::new_from_parent(&bank_forks.banks[&0].clone(), &solana_sdk::pubkey::new_rand(), 1);
let next_bank = Bank::new_from_parent(
&bank_forks.banks[&0].clone(),
&solana_sdk::pubkey::new_rand(),
1,
);
bank_forks.insert(next_bank);

bank_forks
Expand Down
6 changes: 4 additions & 2 deletions core/src/serve_repair.rs
Original file line number Diff line number Diff line change
Expand Up @@ -971,8 +971,10 @@ mod tests {
let cluster_info = Arc::new(ClusterInfo::new_with_invalid_keypair(me.clone()));

// Insert two peers on the network
let contact_info2 = ContactInfo::new_localhost(&solana_sdk::pubkey::new_rand(), timestamp());
let contact_info3 = ContactInfo::new_localhost(&solana_sdk::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);
Expand Down
1 change: 0 additions & 1 deletion core/src/verified_vote_packets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ mod tests {
use crate::result::Error;
use crossbeam_channel::{unbounded, RecvTimeoutError};
use solana_perf::packet::{Meta, Packet};
use solana_sdk::pubkey::Pubkey;

#[test]
fn test_get_latest_votes() {
Expand Down
3 changes: 1 addition & 2 deletions core/tests/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ use solana_runtime::{
genesis_utils::{create_genesis_config, GenesisConfigInfo},
};
use solana_sdk::{
commitment_config::CommitmentConfig, pubkey::Pubkey, rpc_port, signature::Signer,
system_transaction,
commitment_config::CommitmentConfig, rpc_port, signature::Signer, system_transaction,
};
use std::{
fs::remove_dir_all,
Expand Down
8 changes: 5 additions & 3 deletions core/tests/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ use solana_client::{
use solana_core::contact_info::ContactInfo;
use solana_core::{rpc_pubsub::gen_client::Client as PubsubClient, test_validator::TestValidator};
use solana_sdk::{
commitment_config::CommitmentConfig, hash::Hash, pubkey::Pubkey, signature::Signer,
system_transaction, transaction::Transaction,
commitment_config::CommitmentConfig, hash::Hash, signature::Signer, system_transaction,
transaction::Transaction,
};
use std::{
collections::HashSet,
Expand Down Expand Up @@ -173,7 +173,9 @@ fn test_rpc_subscriptions() {

// Create transaction signatures to subscribe to
let transactions: Vec<Transaction> = (0..1000)
.map(|_| system_transaction::transfer(&alice, &solana_sdk::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<String> = transactions
.iter()
Expand Down
5 changes: 4 additions & 1 deletion dos/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,10 @@ pub mod test {

#[test]
fn test_dos() {
let nodes = [ContactInfo::new_localhost(&solana_sdk::pubkey::new_rand(), timestamp())];
let nodes = [ContactInfo::new_localhost(
&solana_sdk::pubkey::new_rand(),
timestamp(),
)];
let entrypoint_addr = nodes[0].gossip;
run_dos(
&nodes,
Expand Down
1 change: 0 additions & 1 deletion faucet/tests/local-faucet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ use solana_faucet::faucet::{request_airdrop_transaction, run_local_faucet};
use solana_sdk::{
hash::Hash,
message::Message,
pubkey::Pubkey,
signature::{Keypair, Signer},
system_instruction,
transaction::Transaction,
Expand Down
1 change: 0 additions & 1 deletion genesis/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -615,7 +615,6 @@ fn main() -> Result<(), Box<dyn error::Error>> {
mod tests {
use super::*;
use solana_sdk::genesis_config::GenesisConfig;
use solana_sdk::pubkey::Pubkey;
use std::collections::HashMap;
use std::fs::remove_file;
use std::io::Write;
Expand Down
14 changes: 11 additions & 3 deletions ledger/src/blockstore_processor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2872,8 +2872,12 @@ pub mod tests {
let keypair = Keypair::new();

// Create array of two transactions which throw different errors
let account_not_found_tx =
system_transaction::transfer(&keypair, &solana_sdk::pubkey::new_rand(), 42, bank.last_blockhash());
let account_not_found_tx = 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,
Expand Down Expand Up @@ -2925,7 +2929,11 @@ pub mod tests {
let bank0 = Arc::new(Bank::new(&genesis_config));
bank0.freeze();

let bank1 = Arc::new(Bank::new_from_parent(&bank0, &solana_sdk::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();
Expand Down
1 change: 0 additions & 1 deletion ledger/src/genesis_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ pub use solana_runtime::genesis_utils::{
create_genesis_config_with_leader, create_genesis_config_with_leader_ex, GenesisConfigInfo,
BOOTSTRAP_VALIDATOR_LAMPORTS,
};
use solana_sdk::pubkey::Pubkey;

// same as genesis_config::create_genesis_config, but with bootstrap_validator staking logic
// for the core crate tests
Expand Down
Loading

0 comments on commit e26a425

Please sign in to comment.