Skip to content

Commit

Permalink
removes legacy retransmit tests (solana-labs#29817)
Browse files Browse the repository at this point in the history
Retransmit code has moved to core/src/cluster_nodes.rs and has been
significantly revised.
gossip/tests/cluster_info.rs is testing the old code which is no longer
relevant.
  • Loading branch information
behzadnouri authored Jan 21, 2023
1 parent d75303f commit 590b751
Show file tree
Hide file tree
Showing 10 changed files with 2 additions and 444 deletions.
13 changes: 0 additions & 13 deletions bloom/src/bloom.rs
Original file line number Diff line number Diff line change
Expand Up @@ -199,19 +199,6 @@ impl<T: BloomHashIndex> AtomicBloom<T> {
bit.store(0u64, Ordering::Relaxed);
});
}

// Only for tests and simulations.
pub fn mock_clone(&self) -> Self {
Self {
keys: self.keys.clone(),
bits: self
.bits
.iter()
.map(|v| AtomicU64::new(v.load(Ordering::Relaxed)))
.collect(),
..*self
}
}
}

impl<T: BloomHashIndex> From<AtomicBloom<T>> for Bloom<T> {
Expand Down
27 changes: 0 additions & 27 deletions gossip/src/cluster_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -432,33 +432,6 @@ impl ClusterInfo {
me
}

// Should only be used by tests and simulations
pub fn clone_with_id(&self, new_id: &Pubkey) -> Self {
let mut my_contact_info = self.my_contact_info.read().unwrap().clone();
my_contact_info.id = *new_id;
ClusterInfo {
gossip: self.gossip.mock_clone(),
keypair: RwLock::new(self.keypair.read().unwrap().clone()),
entrypoints: RwLock::new(self.entrypoints.read().unwrap().clone()),
outbound_budget: self.outbound_budget.clone_non_atomic(),
my_contact_info: RwLock::new(my_contact_info),
ping_cache: Mutex::new(self.ping_cache.lock().unwrap().mock_clone()),
stats: GossipStats::default(),
socket: UdpSocket::bind("0.0.0.0:0").unwrap(),
local_message_pending_push_queue: Mutex::new(
self.local_message_pending_push_queue
.lock()
.unwrap()
.clone(),
),
contact_debug_interval: self.contact_debug_interval,
instance: RwLock::new(NodeInstance::new(&mut thread_rng(), *new_id, timestamp())),
contact_info_path: PathBuf::default(),
contact_save_interval: 0, // disabled
..*self
}
}

pub fn set_contact_debug_interval(&mut self, new: u64) {
self.contact_debug_interval = new;
}
Expand Down
18 changes: 0 additions & 18 deletions gossip/src/crds.rs
Original file line number Diff line number Diff line change
Expand Up @@ -642,24 +642,6 @@ impl Crds {
pub(crate) fn take_stats(&self) -> CrdsStats {
std::mem::take(&mut self.stats.lock().unwrap())
}

// Only for tests and simulations.
pub(crate) fn mock_clone(&self) -> Self {
Self {
table: self.table.clone(),
cursor: self.cursor,
shards: self.shards.clone(),
nodes: self.nodes.clone(),
votes: self.votes.clone(),
epoch_slots: self.epoch_slots.clone(),
duplicate_shreds: self.duplicate_shreds.clone(),
records: self.records.clone(),
entries: self.entries.clone(),
purged: self.purged.clone(),
shred_versions: self.shred_versions.clone(),
stats: Mutex::<CrdsStats>::default(),
}
}
}

impl Default for CrdsDataStats {
Expand Down
10 changes: 0 additions & 10 deletions gossip/src/crds_gossip.rs
Original file line number Diff line number Diff line change
Expand Up @@ -320,16 +320,6 @@ impl CrdsGossip {
self.pull.purge_failed_inserts(now);
rv
}

// Only for tests and simulations.
pub(crate) fn mock_clone(&self) -> Self {
let crds = self.crds.read().unwrap().mock_clone();
Self {
crds: RwLock::new(crds),
push: self.push.mock_clone(),
pull: self.pull.mock_clone(),
}
}
}

// Returns active and valid cluster nodes to gossip with.
Expand Down
10 changes: 0 additions & 10 deletions gossip/src/crds_gossip_pull.rs
Original file line number Diff line number Diff line change
Expand Up @@ -569,16 +569,6 @@ impl CrdsGossipPull {
stats.success,
)
}

// Only for tests and simulations.
pub(crate) fn mock_clone(&self) -> Self {
let failed_inserts = self.failed_inserts.read().unwrap().clone();
Self {
failed_inserts: RwLock::new(failed_inserts),
num_pulls: AtomicUsize::new(self.num_pulls.load(Ordering::Relaxed)),
..*self
}
}
}

#[cfg(test)]
Expand Down
16 changes: 0 additions & 16 deletions gossip/src/crds_gossip_push.rs
Original file line number Diff line number Diff line change
Expand Up @@ -274,22 +274,6 @@ impl CrdsGossipPush {
let mut active_set = self.active_set.write().unwrap();
active_set.rotate(&mut rng, self.push_fanout * 3, network_size, &nodes, stakes)
}

// Only for tests and simulations.
pub(crate) fn mock_clone(&self) -> Self {
let active_set = self.active_set.read().unwrap().mock_clone();
let received_cache = self.received_cache.lock().unwrap().mock_clone();
let crds_cursor = *self.crds_cursor.lock().unwrap();
Self {
active_set: RwLock::new(active_set),
received_cache: Mutex::new(received_cache),
crds_cursor: Mutex::new(crds_cursor),
num_total: AtomicUsize::new(self.num_total.load(Ordering::Relaxed)),
num_old: AtomicUsize::new(self.num_old.load(Ordering::Relaxed)),
num_pushes: AtomicUsize::new(self.num_pushes.load(Ordering::Relaxed)),
..*self
}
}
}

#[cfg(test)]
Expand Down
21 changes: 0 additions & 21 deletions gossip/src/ping_pong.rs
Original file line number Diff line number Diff line change
Expand Up @@ -242,27 +242,6 @@ impl PingCache {
(check, ping)
}

// Only for tests and simulations.
pub(crate) fn mock_clone(&self) -> Self {
let mut clone = Self {
ttl: self.ttl,
rate_limit_delay: self.rate_limit_delay,
pings: LruCache::new(self.pings.cap()),
pongs: LruCache::new(self.pongs.cap()),
pending_cache: LruCache::new(self.pending_cache.cap()),
};
for (k, v) in self.pongs.iter().rev() {
clone.pings.put(*k, *v);
}
for (k, v) in self.pongs.iter().rev() {
clone.pongs.put(*k, *v);
}
for (k, v) in self.pending_cache.iter().rev() {
clone.pending_cache.put(*k, *v);
}
clone
}

/// Only for tests and simulations.
pub fn mock_pong(&mut self, node: Pubkey, socket: SocketAddr, now: Instant) {
self.pongs.put((node, socket), now);
Expand Down
13 changes: 0 additions & 13 deletions gossip/src/push_active_set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,19 +101,6 @@ impl PushActiveSet {
fn get_entry(&self, stake: Option<&u64>) -> &PushActiveSetEntry {
&self.0[get_stake_bucket(stake)]
}

// Only for tests and simulations.
pub(crate) fn mock_clone(&self) -> Self {
Self(std::array::from_fn(|k| {
PushActiveSetEntry(
self.0[k]
.0
.iter()
.map(|(&node, filter)| (node, filter.mock_clone()))
.collect(),
)
}))
}
}

impl PushActiveSetEntry {
Expand Down
4 changes: 2 additions & 2 deletions gossip/src/received_cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ impl ReceivedCache {
.flatten()
}

// Only for tests and simulations.
pub(crate) fn mock_clone(&self) -> Self {
#[cfg(test)]
fn mock_clone(&self) -> Self {
let mut cache = LruCache::new(self.0.cap());
for (&origin, entry) in self.0.iter().rev() {
cache.put(origin, entry.clone());
Expand Down
Loading

0 comments on commit 590b751

Please sign in to comment.