diff --git a/account-decoder/src/parse_stake.rs b/account-decoder/src/parse_stake.rs index 557a6e54ce70ae..86dc88e80a1031 100644 --- a/account-decoder/src/parse_stake.rs +++ b/account-decoder/src/parse_stake.rs @@ -134,7 +134,6 @@ impl From for UiDelegation { mod test { use super::*; use bincode::serialize; - use solana_sdk::pubkey::Pubkey; #[test] fn test_parse_stake() { diff --git a/banking-bench/src/main.rs b/banking-bench/src/main.rs index 4e54b8f3787216..67b61a8fd3e913 100644 --- a/banking-bench/src/main.rs +++ b/banking-bench/src/main.rs @@ -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, diff --git a/banks-client/src/lib.rs b/banks-client/src/lib.rs index 238c38c697960a..9bb74b37b5147f 100644 --- a/banks-client/src/lib.rs +++ b/banks-client/src/lib.rs @@ -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}; diff --git a/cli/src/cli.rs b/cli/src/cli.rs index 7f28a80501c20d..5d4f1d438dd54f 100644 --- a/cli/src/cli.rs +++ b/cli/src/cli.rs @@ -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(); diff --git a/cli/tests/vote.rs b/cli/tests/vote.rs index 0d23a78f2d5b6e..0bcf668310de52 100644 --- a/cli/tests/vote.rs +++ b/cli/tests/vote.rs @@ -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}; diff --git a/core/benches/crds_shards.rs b/core/benches/crds_shards.rs index 171d1970db9e6f..ba3fb5b3d4f046 100644 --- a/core/benches/crds_shards.rs +++ b/core/benches/crds_shards.rs @@ -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)) } diff --git a/core/src/broadcast_stage/broadcast_fake_shreds_run.rs b/core/src/broadcast_stage/broadcast_fake_shreds_run.rs index 664975ed5753db..ce512c6a043925 100644 --- a/core/src/broadcast_stage/broadcast_fake_shreds_run.rs +++ b/core/src/broadcast_stage/broadcast_fake_shreds_run.rs @@ -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] diff --git a/core/src/cluster_info.rs b/core/src/cluster_info.rs index ac4dab09156722..afe5f84fecde14 100644 --- a/core/src/cluster_info.rs +++ b/core/src/cluster_info.rs @@ -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)); } @@ -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); diff --git a/core/src/commitment_service.rs b/core/src/commitment_service.rs index 24e1437d5646ab..7742c7e1aac5ab 100644 --- a/core/src/commitment_service.rs +++ b/core/src/commitment_service.rs @@ -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, @@ -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, diff --git a/core/src/crds.rs b/core/src/crds.rs index cfab54459c5af1..3182011e6fe0eb 100644 --- a/core/src/crds.rs +++ b/core/src/crds.rs @@ -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 { diff --git a/core/src/crds_shards.rs b/core/src/crds_shards.rs index 60676304c1276d..9ff54628a0e2b3 100644 --- a/core/src/crds_shards.rs +++ b/core/src/crds_shards.rs @@ -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)) } diff --git a/core/src/replay_stage.rs b/core/src/replay_stage.rs index 5526ce07a52352..bbac7babe1525d 100644 --- a/core/src/replay_stage.rs +++ b/core/src/replay_stage.rs @@ -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()); } @@ -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()); } diff --git a/core/src/retransmit_stage.rs b/core/src/retransmit_stage.rs index c15116305065e2..e32a7527077578 100644 --- a/core/src/retransmit_stage.rs +++ b/core/src/retransmit_stage.rs @@ -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] diff --git a/core/src/rpc.rs b/core/src/rpc.rs index 9bd9d88f6ca378..c3335454391403 100644 --- a/core/src/rpc.rs +++ b/core/src/rpc.rs @@ -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!( @@ -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)); @@ -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] @@ -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]); @@ -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]); diff --git a/core/src/rpc_service.rs b/core/src/rpc_service.rs index 3229585d538e2a..43b9566e24e293 100644 --- a/core/src/rpc_service.rs +++ b/core/src/rpc_service.rs @@ -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(), diff --git a/core/src/rpc_subscriptions.rs b/core/src/rpc_subscriptions.rs index b497f826153439..0e71472859a54e 100644 --- a/core/src/rpc_subscriptions.rs +++ b/core/src/rpc_subscriptions.rs @@ -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 diff --git a/core/src/serve_repair.rs b/core/src/serve_repair.rs index 9543118ab1e00f..aa8b661a34dbcd 100644 --- a/core/src/serve_repair.rs +++ b/core/src/serve_repair.rs @@ -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); diff --git a/core/src/verified_vote_packets.rs b/core/src/verified_vote_packets.rs index b6fc262d87c887..280ddcaa8a6d0b 100644 --- a/core/src/verified_vote_packets.rs +++ b/core/src/verified_vote_packets.rs @@ -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() { diff --git a/core/tests/client.rs b/core/tests/client.rs index 48aa8d73d04c58..2fa2a05c7b6b7b 100644 --- a/core/tests/client.rs +++ b/core/tests/client.rs @@ -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, diff --git a/core/tests/rpc.rs b/core/tests/rpc.rs index 44748a22562304..505b5c0e73213c 100644 --- a/core/tests/rpc.rs +++ b/core/tests/rpc.rs @@ -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, @@ -173,7 +173,9 @@ fn test_rpc_subscriptions() { // Create transaction signatures to subscribe to let transactions: Vec = (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 = transactions .iter() diff --git a/dos/src/main.rs b/dos/src/main.rs index 69b20508dc03d5..4d32273bc4a3be 100644 --- a/dos/src/main.rs +++ b/dos/src/main.rs @@ -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, diff --git a/faucet/tests/local-faucet.rs b/faucet/tests/local-faucet.rs index 399a0a645ef510..28ec2f02fb601d 100644 --- a/faucet/tests/local-faucet.rs +++ b/faucet/tests/local-faucet.rs @@ -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, diff --git a/genesis/src/main.rs b/genesis/src/main.rs index b13e188d9aed36..b1cc646ec9fbad 100644 --- a/genesis/src/main.rs +++ b/genesis/src/main.rs @@ -615,7 +615,6 @@ fn main() -> Result<(), Box> { 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; diff --git a/ledger/src/blockstore_processor.rs b/ledger/src/blockstore_processor.rs index 04c0b92f0b7e51..28f17ff68bf6f7 100644 --- a/ledger/src/blockstore_processor.rs +++ b/ledger/src/blockstore_processor.rs @@ -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, @@ -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(); diff --git a/ledger/src/genesis_utils.rs b/ledger/src/genesis_utils.rs index 65ca0a91828d42..6d1e124097e58c 100644 --- a/ledger/src/genesis_utils.rs +++ b/ledger/src/genesis_utils.rs @@ -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 diff --git a/ledger/src/leader_schedule.rs b/ledger/src/leader_schedule.rs index 31c7ce89e4a491..e2ca2662bfe8ed 100644 --- a/ledger/src/leader_schedule.rs +++ b/ledger/src/leader_schedule.rs @@ -77,7 +77,9 @@ mod tests { #[test] fn test_leader_schedule_basic() { let num_keys = 10; - let stakes: Vec<_> = (0..num_keys).map(|i| (solana_sdk::pubkey::new_rand(), i)).collect(); + let stakes: Vec<_> = (0..num_keys) + .map(|i| (solana_sdk::pubkey::new_rand(), i)) + .collect(); let seed = solana_sdk::pubkey::new_rand(); let mut seed_bytes = [0u8; 32]; @@ -93,7 +95,9 @@ mod tests { #[test] fn test_repeated_leader_schedule() { let num_keys = 10; - let stakes: Vec<_> = (0..num_keys).map(|i| (solana_sdk::pubkey::new_rand(), i)).collect(); + let stakes: Vec<_> = (0..num_keys) + .map(|i| (solana_sdk::pubkey::new_rand(), i)) + .collect(); let seed = solana_sdk::pubkey::new_rand(); let mut seed_bytes = [0u8; 32]; diff --git a/local-cluster/tests/local_cluster.rs b/local-cluster/tests/local_cluster.rs index 3e7f39ea9dc59b..c667d4c4fe81c7 100644 --- a/local-cluster/tests/local_cluster.rs +++ b/local-cluster/tests/local_cluster.rs @@ -161,8 +161,12 @@ fn test_local_cluster_signature_subscribe() { .get_recent_blockhash_with_commitment(CommitmentConfig::recent()) .unwrap(); - let mut transaction = - system_transaction::transfer(&cluster.funding_keypair, &solana_sdk::pubkey::new_rand(), 10, blockhash); + let mut transaction = 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()), @@ -814,7 +818,12 @@ 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, &solana_sdk::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_loader/src/serialization.rs b/programs/bpf_loader/src/serialization.rs index 9fec0f0465427d..b2d0948dd3330e 100644 --- a/programs/bpf_loader/src/serialization.rs +++ b/programs/bpf_loader/src/serialization.rs @@ -264,7 +264,12 @@ mod tests { fn test_serialize_parameters() { 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 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/failure/tests/failure.rs b/programs/failure/tests/failure.rs index 9bbc716a66f819..8194e66e7f6336 100644 --- a/programs/failure/tests/failure.rs +++ b/programs/failure/tests/failure.rs @@ -4,7 +4,6 @@ use solana_runtime::loader_utils::create_invoke_instruction; use solana_sdk::client::SyncClient; use solana_sdk::genesis_config::create_genesis_config; use solana_sdk::instruction::InstructionError; -use solana_sdk::pubkey::Pubkey; use solana_sdk::signature::Signer; use solana_sdk::transaction::TransactionError; diff --git a/runtime/benches/accounts_index.rs b/runtime/benches/accounts_index.rs index 2f45a0ab3c2733..8e78e9cb42ee43 100644 --- a/runtime/benches/accounts_index.rs +++ b/runtime/benches/accounts_index.rs @@ -10,7 +10,9 @@ use test::Bencher; #[bench] fn bench_accounts_index(bencher: &mut Bencher) { const NUM_PUBKEYS: usize = 10_000; - let pubkeys: Vec<_> = (0..NUM_PUBKEYS).map(|_| solana_sdk::pubkey::new_rand()).collect(); + let pubkeys: Vec<_> = (0..NUM_PUBKEYS) + .map(|_| solana_sdk::pubkey::new_rand()) + .collect(); const NUM_FORKS: u64 = 16; diff --git a/runtime/src/accounts_db.rs b/runtime/src/accounts_db.rs index 1ef83860577e47..a3de2f9518333e 100644 --- a/runtime/src/accounts_db.rs +++ b/runtime/src/accounts_db.rs @@ -4861,7 +4861,9 @@ pub mod tests { let accounts = AccountsDB::new_single(); let pubkey_count = 100; - let pubkeys: Vec<_> = (0..pubkey_count).map(|_| solana_sdk::pubkey::new_rand()).collect(); + let pubkeys: Vec<_> = (0..pubkey_count) + .map(|_| solana_sdk::pubkey::new_rand()) + .collect(); let some_lamport = 223; let no_data = 0; @@ -4925,7 +4927,9 @@ pub mod tests { let accounts = AccountsDB::new_single(); let pubkey_count = 100; - let pubkeys: Vec<_> = (0..pubkey_count).map(|_| solana_sdk::pubkey::new_rand()).collect(); + let pubkeys: Vec<_> = (0..pubkey_count) + .map(|_| solana_sdk::pubkey::new_rand()) + .collect(); let some_lamport = 223; let no_data = 0; @@ -5104,7 +5108,11 @@ pub mod tests { ); // any random program data accounts assert_eq!( - AccountsDB::account_balance_for_capitalization(10, &solana_sdk::pubkey::new_rand(), false), + AccountsDB::account_balance_for_capitalization( + 10, + &solana_sdk::pubkey::new_rand(), + false + ), 10 ); } diff --git a/runtime/src/bank.rs b/runtime/src/bank.rs index 1c76e4a83868e0..3d02bc851c4a87 100644 --- a/runtime/src/bank.rs +++ b/runtime/src/bank.rs @@ -4248,7 +4248,12 @@ mod tests { fn test_bank_capitalization() { let bank = Arc::new(Bank::new(&GenesisConfig { accounts: (0..42) - .map(|_| (solana_sdk::pubkey::new_rand(), Account::new(42, 0, &Pubkey::default()))) + .map(|_| { + ( + solana_sdk::pubkey::new_rand(), + Account::new(42, 0, &Pubkey::default()), + ) + }) .collect(), cluster_type: ClusterType::MainnetBeta, ..GenesisConfig::default() @@ -4825,7 +4830,11 @@ mod tests { }; let root_bank = Arc::new(Bank::new(&genesis_config)); - let bank = create_child_bank_for_rent_test(&root_bank, &genesis_config, solana_sdk::pubkey::new_rand()); + let bank = create_child_bank_for_rent_test( + &root_bank, + &genesis_config, + solana_sdk::pubkey::new_rand(), + ); let account_pubkey = solana_sdk::pubkey::new_rand(); let account_balance = 1; @@ -5909,7 +5918,8 @@ mod tests { assert!(bank.rewards.read().unwrap().is_empty()); let vote_id = solana_sdk::pubkey::new_rand(); - let mut vote_account = vote_state::create_account(&vote_id, &solana_sdk::pubkey::new_rand(), 50, 100); + let mut vote_account = + vote_state::create_account(&vote_id, &solana_sdk::pubkey::new_rand(), 50, 100); let (stake_id1, stake_account1) = crate::stakes::tests::create_stake_account(123, &vote_id); let (stake_id2, stake_account2) = crate::stakes::tests::create_stake_account(456, &vote_id); @@ -7359,7 +7369,11 @@ mod tests { let bank0 = Arc::new(Bank::new(&genesis_config)); // Bank 1 - 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, + )); // Bank 2 let bank2 = Bank::new_from_parent(&bank0, &solana_sdk::pubkey::new_rand(), 2); @@ -8274,7 +8288,11 @@ mod tests { let nonce_tx = Transaction::new_signed_with_payer( &[ system_instruction::advance_nonce_account(&nonce_pubkey, &nonce_pubkey), - system_instruction::transfer(&custodian_pubkey, &solana_sdk::pubkey::new_rand(), 100_000), + system_instruction::transfer( + &custodian_pubkey, + &solana_sdk::pubkey::new_rand(), + 100_000, + ), ], Some(&custodian_pubkey), &[&custodian_keypair, &nonce_keypair], diff --git a/runtime/src/bloom.rs b/runtime/src/bloom.rs index a49ccb9bfa7048..4efea1f60056f2 100644 --- a/runtime/src/bloom.rs +++ b/runtime/src/bloom.rs @@ -318,9 +318,10 @@ mod test { assert!(bloom.contains(hash_value)); } // Round trip, inserting new hash values. - let more_hash_values: Vec<_> = std::iter::repeat_with(|| solana_sdk::hash::new_rand(&mut rng)) - .take(1000) - .collect(); + let more_hash_values: Vec<_> = + std::iter::repeat_with(|| solana_sdk::hash::new_rand(&mut rng)) + .take(1000) + .collect(); let bloom: AtomicBloom<_> = bloom.into(); assert_eq!(bloom.num_bits, 9731); assert_eq!(bloom.bits.len(), (9731 + 63) / 64); diff --git a/runtime/src/message_processor.rs b/runtime/src/message_processor.rs index 4575b7f947ead4..2650205fcc4082 100644 --- a/runtime/src/message_processor.rs +++ b/runtime/src/message_processor.rs @@ -867,7 +867,10 @@ mod tests { #[test] fn test_verify_account_references() { - let accounts = vec![(solana_sdk::pubkey::new_rand(), RefCell::new(Account::default()))]; + let accounts = vec![( + solana_sdk::pubkey::new_rand(), + RefCell::new(Account::default()), + )]; assert!(MessageProcessor::verify_account_references(&accounts).is_ok()); diff --git a/runtime/src/rent_collector.rs b/runtime/src/rent_collector.rs index d9698b2e3be0a5..759340d4df26cf 100644 --- a/runtime/src/rent_collector.rs +++ b/runtime/src/rent_collector.rs @@ -152,8 +152,8 @@ mod tests { RentCollector::default().clone_with_epoch(new_epoch, ClusterType::Development); // collect rent on a newly-created account - let collected = - rent_collector.collect_from_created_account(&solana_sdk::pubkey::new_rand(), &mut created_account); + let collected = rent_collector + .collect_from_created_account(&solana_sdk::pubkey::new_rand(), &mut created_account); assert!(created_account.lamports < old_lamports); assert_eq!(created_account.lamports + collected, old_lamports); assert_ne!(created_account.rent_epoch, old_epoch); diff --git a/runtime/src/stakes.rs b/runtime/src/stakes.rs index 95cb89b6847bd1..4fd36b30899091 100644 --- a/runtime/src/stakes.rs +++ b/runtime/src/stakes.rs @@ -191,7 +191,8 @@ pub mod tests { // set up some dummies for a staked node (( vote ) ( stake )) pub fn create_staked_node_accounts(stake: u64) -> ((Pubkey, Account), (Pubkey, Account)) { let vote_pubkey = solana_sdk::pubkey::new_rand(); - let vote_account = vote_state::create_account(&vote_pubkey, &solana_sdk::pubkey::new_rand(), 0, 1); + let vote_account = + vote_state::create_account(&vote_pubkey, &solana_sdk::pubkey::new_rand(), 0, 1); ( (vote_pubkey, vote_account), create_stake_account(stake, &vote_pubkey), @@ -218,7 +219,8 @@ pub mod tests { epoch: Epoch, ) -> ((Pubkey, Account), (Pubkey, Account)) { let vote_pubkey = solana_sdk::pubkey::new_rand(); - let vote_account = vote_state::create_account(&vote_pubkey, &solana_sdk::pubkey::new_rand(), 0, 1); + let vote_account = + vote_state::create_account(&vote_pubkey, &solana_sdk::pubkey::new_rand(), 0, 1); ( (vote_pubkey, vote_account), create_warming_stake_account(stake, epoch, &vote_pubkey), diff --git a/runtime/src/transaction_batch.rs b/runtime/src/transaction_batch.rs index 1fb64ea2e199b1..5002927ddd74d7 100644 --- a/runtime/src/transaction_batch.rs +++ b/runtime/src/transaction_batch.rs @@ -62,7 +62,7 @@ impl<'a, 'b> Drop for TransactionBatch<'a, 'b> { mod tests { use super::*; use crate::genesis_utils::{create_genesis_config_with_leader, GenesisConfigInfo}; - use solana_sdk::{pubkey::Pubkey, signature::Keypair, system_transaction}; + use solana_sdk::{signature::Keypair, system_transaction}; #[test] fn test_transaction_batch() { diff --git a/runtime/tests/bank.rs b/runtime/tests/bank.rs index 98aefcff5494be..5e9e118dec5423 100644 --- a/runtime/tests/bank.rs +++ b/runtime/tests/bank.rs @@ -1,5 +1,5 @@ use solana_runtime::bank::Bank; -use solana_sdk::{genesis_config::create_genesis_config, hash::hash, pubkey::Pubkey}; +use solana_sdk::{genesis_config::create_genesis_config, hash::hash}; use std::{sync::Arc, thread::Builder}; #[test] diff --git a/runtime/tests/noop.rs b/runtime/tests/noop.rs index 7a6b1cda0c5d89..f7233830b55fce 100644 --- a/runtime/tests/noop.rs +++ b/runtime/tests/noop.rs @@ -1,9 +1,7 @@ use solana_runtime::{ bank::Bank, bank_client::BankClient, loader_utils::create_invoke_instruction, }; -use solana_sdk::{ - client::SyncClient, genesis_config::create_genesis_config, pubkey::Pubkey, signature::Signer, -}; +use solana_sdk::{client::SyncClient, genesis_config::create_genesis_config, signature::Signer}; #[test] fn test_program_native_noop() { diff --git a/runtime/tests/stake.rs b/runtime/tests/stake.rs index 6efd3dc05a5841..55b0bd65ecaf48 100644 --- a/runtime/tests/stake.rs +++ b/runtime/tests/stake.rs @@ -105,7 +105,11 @@ fn test_stake_create_and_split_single_signature() { genesis_config, mint_keypair: staker_keypair, .. - } = create_genesis_config_with_leader(100_000_000_000, &solana_sdk::pubkey::new_rand(), 1_000_000); + } = create_genesis_config_with_leader( + 100_000_000_000, + &solana_sdk::pubkey::new_rand(), + 1_000_000, + ); let staker_pubkey = staker_keypair.pubkey(); @@ -172,7 +176,11 @@ fn test_stake_create_and_split_to_existing_system_account() { genesis_config, mint_keypair: staker_keypair, .. - } = create_genesis_config_with_leader(100_000_000_000, &solana_sdk::pubkey::new_rand(), 1_000_000); + } = create_genesis_config_with_leader( + 100_000_000_000, + &solana_sdk::pubkey::new_rand(), + 1_000_000, + ); let staker_pubkey = staker_keypair.pubkey(); @@ -255,7 +263,11 @@ fn test_stake_account_lifetime() { genesis_config, mint_keypair, .. - } = create_genesis_config_with_leader(100_000_000_000, &solana_sdk::pubkey::new_rand(), 1_000_000); + } = create_genesis_config_with_leader( + 100_000_000_000, + &solana_sdk::pubkey::new_rand(), + 1_000_000, + ); let bank = Bank::new(&genesis_config); let mint_pubkey = mint_keypair.pubkey(); let mut bank = Arc::new(bank); @@ -495,7 +507,11 @@ fn test_create_stake_account_from_seed() { genesis_config, mint_keypair, .. - } = create_genesis_config_with_leader(100_000_000_000, &solana_sdk::pubkey::new_rand(), 1_000_000); + } = create_genesis_config_with_leader( + 100_000_000_000, + &solana_sdk::pubkey::new_rand(), + 1_000_000, + ); let bank = Bank::new(&genesis_config); let mint_pubkey = mint_keypair.pubkey(); let bank = Arc::new(bank); diff --git a/sdk/src/genesis_config.rs b/sdk/src/genesis_config.rs index afc8ab9c128453..58631b408ff76f 100644 --- a/sdk/src/genesis_config.rs +++ b/sdk/src/genesis_config.rs @@ -310,7 +310,10 @@ mod tests { faucet_keypair.pubkey(), Account::new(10_000, 0, &Pubkey::default()), ); - config.add_account(solana_sdk::pubkey::new_rand(), Account::new(1, 0, &Pubkey::default())); + config.add_account( + solana_sdk::pubkey::new_rand(), + Account::new(1, 0, &Pubkey::default()), + ); config.add_native_instruction_processor("hi".to_string(), solana_sdk::pubkey::new_rand()); assert_eq!(config.accounts.len(), 2); diff --git a/sdk/src/pubkey.rs b/sdk/src/pubkey.rs index 0793d4cb3083a1..b359547977eccc 100644 --- a/sdk/src/pubkey.rs +++ b/sdk/src/pubkey.rs @@ -300,7 +300,12 @@ mod tests { #[test] fn test_create_with_seed() { - assert!(Pubkey::create_with_seed(&solana_sdk::pubkey::new_rand(), "☉", &solana_sdk::pubkey::new_rand()).is_ok()); + assert!(Pubkey::create_with_seed( + &solana_sdk::pubkey::new_rand(), + "☉", + &solana_sdk::pubkey::new_rand() + ) + .is_ok()); assert_eq!( Pubkey::create_with_seed( &solana_sdk::pubkey::new_rand(), @@ -336,7 +341,12 @@ mod tests { ) .is_ok()); - assert!(Pubkey::create_with_seed(&solana_sdk::pubkey::new_rand(), "", &solana_sdk::pubkey::new_rand(),).is_ok()); + assert!(Pubkey::create_with_seed( + &solana_sdk::pubkey::new_rand(), + "", + &solana_sdk::pubkey::new_rand(), + ) + .is_ok()); assert_eq!( Pubkey::create_with_seed( diff --git a/storage-bigtable/src/bigtable.rs b/storage-bigtable/src/bigtable.rs index 5bf8c95b26cb14..a0ac3e7336f89b 100644 --- a/storage-bigtable/src/bigtable.rs +++ b/storage-bigtable/src/bigtable.rs @@ -635,7 +635,7 @@ mod tests { use super::*; use crate::StoredConfirmedBlock; use prost::Message; - use solana_sdk::{hash::Hash, pubkey::Pubkey, signature::Keypair, system_transaction}; + use solana_sdk::{hash::Hash, signature::Keypair, system_transaction}; use solana_storage_proto::convert::generated; use solana_transaction_status::{ ConfirmedBlock, TransactionStatusMeta, TransactionWithStatusMeta, diff --git a/transaction-status/src/parse_accounts.rs b/transaction-status/src/parse_accounts.rs index ea44347952e7e5..d20afd067fa14b 100644 --- a/transaction-status/src/parse_accounts.rs +++ b/transaction-status/src/parse_accounts.rs @@ -23,7 +23,7 @@ pub fn parse_accounts(message: &Message) -> Vec { #[cfg(test)] mod test { use super::*; - use solana_sdk::{message::MessageHeader, pubkey::Pubkey}; + use solana_sdk::message::MessageHeader; #[test] fn test_parse_accounts() {