* Add pubkey_new_rand(), mark Pubkey::new_rand() deprecated (cherry picked from commit0e68ed6a8d) * Add hash_new_rand(), mark Hash::new_rand() as deprecated (cherry picked from commit76f11c7dae) * Run `codemod --extensions rs Pubkey::new_rand solana_sdk::pubkey::new_rand` (cherry picked from commit7bc073defe) # Conflicts: # programs/bpf/benches/bpf_loader.rs # runtime/benches/accounts.rs # runtime/src/accounts.rs * Run `codemod --extensions rs Hash::new_rand solana_sdk::hash::new_rand` (cherry picked from commit17c391121a) * Remove unused pubkey::Pubkey imports (cherry picked from commit959880db60) # Conflicts: # runtime/src/accounts_index.rs * Resolve conflicts Co-authored-by: Michael Vines <mvines@gmail.com>
This commit is contained in:
@@ -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,13 @@ 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);
|
||||
let (node, _, _) = ClusterInfo::gossip_node(
|
||||
&solana_sdk::pubkey::new_rand(),
|
||||
&"1.1.1.1:1111".parse().unwrap(),
|
||||
0,
|
||||
);
|
||||
assert!(ClusterInfo::is_spy_node(&node));
|
||||
}
|
||||
|
||||
@@ -2747,7 +2750,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 +2763,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 +2778,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 +2813,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 +2834,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 +2854,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 +2877,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 +2906,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 +2941,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),
|
||||
@@ -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(&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);
|
||||
|
||||
@@ -3221,7 +3228,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 +3387,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 +3437,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 +3588,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());
|
||||
|
||||
Reference in New Issue
Block a user