Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Remove peerset debug output test #2267

Merged
merged 3 commits into from
Apr 15, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion core/peerset/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ libp2p = { version = "0.6.0", default-features = false }
linked-hash-map = "0.5"
log = "0.4"
lru-cache = "0.1.2"
serde_json = "1.0.24"
serde_json = "1.0.24"
42 changes: 2 additions & 40 deletions core/peerset/src/slots.rs
Original file line number Diff line number Diff line change
Expand Up @@ -161,14 +161,14 @@ impl Slots {

/// Marks given peer as a reserved one.
pub fn mark_reserved(&mut self, peer_id: &PeerId) {
if let Some(_) = self.common.remove(peer_id) {
if self.common.remove(peer_id).is_some() {
self.reserved.insert(peer_id.clone(), ());
}
}

/// Marks given peer as not reserved one.
pub fn mark_not_reserved(&mut self, peer_id: &PeerId) {
if let Some(_) = self.reserved.remove(peer_id) {
if self.reserved.remove(peer_id).is_some() {
self.common.insert(peer_id.clone(), ());
}
}
Expand All @@ -183,41 +183,3 @@ impl Slots {
self.reserved.contains_key(peer_id)
}
}

#[cfg(test)]
mod tests {
use libp2p::PeerId;
use super::{Slots, SlotType};

#[test]
fn test_slots_debug() {
let reserved_peer = PeerId::random();
let reserved_peer2 = PeerId::random();
let common_peer = PeerId::random();
let mut slots = Slots::new(10);

slots.add_peer(reserved_peer.clone(), SlotType::Reserved);
slots.add_peer(reserved_peer2.clone(), SlotType::Reserved);
slots.add_peer(common_peer.clone(), SlotType::Common);

let expected = format!("Slots {{
max_slots: 10,
reserved: [
PeerId(
{:?}
),
PeerId(
{:?}
)
],
common: [
PeerId(
{:?}
)
]
}}", reserved_peer.to_base58(), reserved_peer2.to_base58(), common_peer.to_base58());

let s = format!("{:#?}", slots);
assert_eq!(expected, s);
}
}
2 changes: 1 addition & 1 deletion srml/support/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ once_cell = { version = "0.1.6", default-features = false, optional = true }
bitmask = { version = "0.5", default-features = false }

[dev-dependencies]
pretty_assertions = "0.5.1"
pretty_assertions = "0.6.1"

[features]
default = ["std"]
Expand Down