From 859785ac1d092b647e655a815b1ed0622db64a66 Mon Sep 17 00:00:00 2001 From: ackintosh Date: Wed, 8 Jun 2022 11:34:23 +0900 Subject: [PATCH 01/10] Test the pruning using randomly generated input --- Cargo.lock | 29 +++- beacon_node/lighthouse_network/Cargo.toml | 2 + beacon_node/lighthouse_network/src/lib.rs | 4 + .../src/peer_manager/mod.rs | 153 ++++++++++++++++++ 4 files changed, 186 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 1dcc10b8570..727e9fb5d7e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -594,7 +594,7 @@ dependencies = [ "eth2_ssz_types", "ethereum-types 0.12.1", "quickcheck 0.9.2", - "quickcheck_macros", + "quickcheck_macros 0.9.1", "smallvec", "tree_hash", ] @@ -1477,6 +1477,16 @@ dependencies = [ "regex", ] +[[package]] +name = "env_logger" +version = "0.8.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a19187fea3ac7e84da7dacf48de0c45d63c6a76f9490dae389aead16c243fce3" +dependencies = [ + "log", + "regex", +] + [[package]] name = "env_logger" version = "0.9.0" @@ -3444,6 +3454,8 @@ dependencies = [ "lru", "parking_lot 0.12.0", "prometheus-client", + "quickcheck 1.0.3", + "quickcheck_macros 1.0.0", "rand 0.8.5", "regex", "serde", @@ -3627,7 +3639,7 @@ dependencies = [ "ethereum-types 0.12.1", "lazy_static", "quickcheck 0.9.2", - "quickcheck_macros", + "quickcheck_macros 0.9.1", "safe_arith", ] @@ -4776,6 +4788,8 @@ version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "588f6378e4dd99458b60ec275b4477add41ce4fa9f64dcba6f15adccb19b50d6" dependencies = [ + "env_logger 0.8.4", + "log", "rand 0.8.5", ] @@ -4790,6 +4804,17 @@ dependencies = [ "syn", ] +[[package]] +name = "quickcheck_macros" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b22a693222d716a9587786f37ac3f6b4faedb5b80c23914e7303ff5a1d8016e9" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "quicksink" version = "0.1.2" diff --git a/beacon_node/lighthouse_network/Cargo.toml b/beacon_node/lighthouse_network/Cargo.toml index 3ec86b3d128..e58e2838a90 100644 --- a/beacon_node/lighthouse_network/Cargo.toml +++ b/beacon_node/lighthouse_network/Cargo.toml @@ -52,6 +52,8 @@ slog-async = "2.5.0" tempfile = "3.1.0" exit-future = "0.2.0" void = "1" +quickcheck = "1.0.3" +quickcheck_macros = "1.0.0" [features] libp2p-websocket = [] diff --git a/beacon_node/lighthouse_network/src/lib.rs b/beacon_node/lighthouse_network/src/lib.rs index f679b7e6572..c35999508b3 100644 --- a/beacon_node/lighthouse_network/src/lib.rs +++ b/beacon_node/lighthouse_network/src/lib.rs @@ -5,6 +5,10 @@ #[macro_use] extern crate lazy_static; +#[cfg(test)] +#[macro_use(quickcheck)] +extern crate quickcheck_macros; + pub mod behaviour; mod config; diff --git a/beacon_node/lighthouse_network/src/peer_manager/mod.rs b/beacon_node/lighthouse_network/src/peer_manager/mod.rs index 9c8d41194c8..9ce62112449 100644 --- a/beacon_node/lighthouse_network/src/peer_manager/mod.rs +++ b/beacon_node/lighthouse_network/src/peer_manager/mod.rs @@ -2051,4 +2051,157 @@ mod tests { assert!(connected_peers.contains(&peers[6])); assert!(connected_peers.contains(&peers[7])); } + + // Test properties PeerManager should have using randomly generated input. + #[cfg(test)] + mod property_based_tests { + use crate::peer_manager::config::DEFAULT_TARGET_PEERS; + use crate::peer_manager::tests::build_peer_manager; + use crate::rpc::MetaData; + use libp2p::PeerId; + use quickcheck::{Arbitrary, Gen, TestResult}; + use tokio::runtime::Runtime; + use types::Unsigned; + use types::{EthSpec, MainnetEthSpec as E}; + + #[derive(Clone, Debug)] + struct PeerCondition { + direction: Direction, + attestation_subnets: Vec, + sync_committee_subnets: Vec, + } + + impl Arbitrary for PeerCondition { + fn arbitrary(g: &mut Gen) -> Self { + PeerCondition { + direction: Direction::arbitrary(g), + attestation_subnets: Vec::arbitrary(g), + sync_committee_subnets: Vec::arbitrary(g), + } + } + } + + #[derive(Clone, Debug)] + enum Direction { + Outgoing, + Incoming, + } + + impl Arbitrary for Direction { + fn arbitrary(g: &mut Gen) -> Self { + g.choose(&[Direction::Outgoing, Direction::Incoming]) + .unwrap() + .clone() + } + } + + #[derive(Clone, Debug)] + struct AttestationSubnetId(usize); + + impl Arbitrary for AttestationSubnetId { + fn arbitrary(g: &mut Gen) -> Self { + let len = ::SubnetBitfieldLength::to_usize(); + let id_range = (0..len).collect::>(); + AttestationSubnetId(*g.choose(&id_range).unwrap()) + } + } + + #[derive(Clone, Debug)] + struct SyncCommitteeSubnetId(usize); + + impl Arbitrary for SyncCommitteeSubnetId { + fn arbitrary(g: &mut Gen) -> Self { + let len = ::SyncCommitteeSubnetCount::to_usize(); + let id_range = (0..len).collect::>(); + SyncCommitteeSubnetId(*g.choose(&id_range).unwrap()) + } + } + + #[quickcheck] + fn prune_excess_peers(peer_conditions: Vec) -> TestResult { + let target_peer_count = DEFAULT_TARGET_PEERS; + let rt = Runtime::new().unwrap(); + + rt.block_on(async move { + let mut peer_manager = build_peer_manager(target_peer_count).await; + + // Create peers based on the randomly generated conditions. + for condition in &peer_conditions { + let peer = PeerId::random(); + let mut attnets = crate::types::EnrAttestationBitfield::::new(); + let mut syncnets = crate::types::EnrSyncCommitteeBitfield::::new(); + + match condition.direction { + Direction::Incoming => { + peer_manager.inject_connect_ingoing( + &peer, + "/ip4/0.0.0.0".parse().unwrap(), + None, + ); + } + Direction::Outgoing => { + peer_manager.inject_connect_outgoing( + &peer, + "/ip4/0.0.0.0".parse().unwrap(), + None, + ); + } + } + + for id in &condition.attestation_subnets { + attnets.set(id.0, true).unwrap(); + } + + for id in &condition.sync_committee_subnets { + syncnets.set(id.0, true).unwrap(); + } + + let metadata = crate::rpc::MetaDataV2 { + seq_number: 0, + attnets, + syncnets, + }; + + peer_manager + .network_globals + .peers + .write() + .peer_info_mut(&peer) + .unwrap() + .set_meta_data(MetaData::V2(metadata)); + + let long_lived_subnets = peer_manager + .network_globals + .peers + .read() + .peer_info(&peer) + .unwrap() + .long_lived_subnets(); + for subnet in long_lived_subnets { + peer_manager + .network_globals + .peers + .write() + .add_subscription(&peer, subnet); + } + } + + // Perform the heartbeat. + peer_manager.heartbeat(); + + if peer_conditions.len() <= target_peer_count { + // We expect to keep the number of peers since no need to prune peers in this case. + TestResult::from_bool( + peer_manager.network_globals.connected_or_dialing_peers() + == peer_conditions.len(), + ) + } else { + TestResult::from_bool( + peer_manager.network_globals.connected_or_dialing_peers() + == target_peer_count, + ) + } + }) + } + } } From b24b000143080f195abd63661212594412f8f847 Mon Sep 17 00:00:00 2001 From: ackintosh Date: Wed, 8 Jun 2022 11:46:42 +0900 Subject: [PATCH 02/10] Tweak importing --- beacon_node/lighthouse_network/src/lib.rs | 4 ---- beacon_node/lighthouse_network/src/peer_manager/mod.rs | 1 + 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/beacon_node/lighthouse_network/src/lib.rs b/beacon_node/lighthouse_network/src/lib.rs index c35999508b3..f679b7e6572 100644 --- a/beacon_node/lighthouse_network/src/lib.rs +++ b/beacon_node/lighthouse_network/src/lib.rs @@ -5,10 +5,6 @@ #[macro_use] extern crate lazy_static; -#[cfg(test)] -#[macro_use(quickcheck)] -extern crate quickcheck_macros; - pub mod behaviour; mod config; diff --git a/beacon_node/lighthouse_network/src/peer_manager/mod.rs b/beacon_node/lighthouse_network/src/peer_manager/mod.rs index 9ce62112449..b1e25be92f6 100644 --- a/beacon_node/lighthouse_network/src/peer_manager/mod.rs +++ b/beacon_node/lighthouse_network/src/peer_manager/mod.rs @@ -2060,6 +2060,7 @@ mod tests { use crate::rpc::MetaData; use libp2p::PeerId; use quickcheck::{Arbitrary, Gen, TestResult}; + use quickcheck_macros::quickcheck; use tokio::runtime::Runtime; use types::Unsigned; use types::{EthSpec, MainnetEthSpec as E}; From 0b5646a89b56ea87d35f900fa6d952259c1fd6e5 Mon Sep 17 00:00:00 2001 From: ackintosh Date: Wed, 8 Jun 2022 14:40:17 +0900 Subject: [PATCH 03/10] Add scores to PeerCondition --- .../src/peer_manager/mod.rs | 31 +++++++------------ 1 file changed, 11 insertions(+), 20 deletions(-) diff --git a/beacon_node/lighthouse_network/src/peer_manager/mod.rs b/beacon_node/lighthouse_network/src/peer_manager/mod.rs index b1e25be92f6..f1a1caa460a 100644 --- a/beacon_node/lighthouse_network/src/peer_manager/mod.rs +++ b/beacon_node/lighthouse_network/src/peer_manager/mod.rs @@ -2070,6 +2070,8 @@ mod tests { direction: Direction, attestation_subnets: Vec, sync_committee_subnets: Vec, + score: f64, + gossipsub_score: f64, } impl Arbitrary for PeerCondition { @@ -2078,6 +2080,8 @@ mod tests { direction: Direction::arbitrary(g), attestation_subnets: Vec::arbitrary(g), sync_committee_subnets: Vec::arbitrary(g), + score: f64::arbitrary(g), + gossipsub_score: f64::arbitrary(g), } } } @@ -2163,27 +2167,14 @@ mod tests { syncnets, }; - peer_manager - .network_globals - .peers - .write() - .peer_info_mut(&peer) - .unwrap() - .set_meta_data(MetaData::V2(metadata)); + let mut peer_db = peer_manager.network_globals.peers.write(); + let peer_info = peer_db.peer_info_mut(&peer).unwrap(); + peer_info.set_meta_data(MetaData::V2(metadata)); + peer_info.set_gossipsub_score(condition.gossipsub_score); + peer_info.add_to_score(condition.score); - let long_lived_subnets = peer_manager - .network_globals - .peers - .read() - .peer_info(&peer) - .unwrap() - .long_lived_subnets(); - for subnet in long_lived_subnets { - peer_manager - .network_globals - .peers - .write() - .add_subscription(&peer, subnet); + for subnet in peer_info.long_lived_subnets() { + peer_db.add_subscription(&peer, subnet); } } From ac5fe1bd2ce1ad825b562d72a47daa00fe60e448 Mon Sep 17 00:00:00 2001 From: ackintosh Date: Sat, 18 Jun 2022 08:30:51 +0900 Subject: [PATCH 04/10] Recompute score to apply the change to gossipsub socre --- beacon_node/lighthouse_network/src/peer_manager/peerdb/score.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/beacon_node/lighthouse_network/src/peer_manager/peerdb/score.rs b/beacon_node/lighthouse_network/src/peer_manager/peerdb/score.rs index 3b67c442d7e..accc0b60c59 100644 --- a/beacon_node/lighthouse_network/src/peer_manager/peerdb/score.rs +++ b/beacon_node/lighthouse_network/src/peer_manager/peerdb/score.rs @@ -223,6 +223,7 @@ impl RealScore { #[cfg(test)] pub fn set_gossipsub_score(&mut self, score: f64) { self.gossipsub_score = score; + self.update_state(); } /// Applies time-based logic such as decay rates to the score. From f6b2bb33150284c099c88f2e1707394a2709f101 Mon Sep 17 00:00:00 2001 From: ackintosh Date: Sat, 18 Jun 2022 09:24:11 +0900 Subject: [PATCH 05/10] Downgrade quickcheck to consolidate the versions dependent, and remove unnecessary Arbitrary impls --- Cargo.lock | 31 +----- beacon_node/lighthouse_network/Cargo.toml | 4 +- .../src/peer_manager/mod.rs | 103 +++++++----------- 3 files changed, 47 insertions(+), 91 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 727e9fb5d7e..848cdb13c5d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -594,7 +594,7 @@ dependencies = [ "eth2_ssz_types", "ethereum-types 0.12.1", "quickcheck 0.9.2", - "quickcheck_macros 0.9.1", + "quickcheck_macros", "smallvec", "tree_hash", ] @@ -1477,16 +1477,6 @@ dependencies = [ "regex", ] -[[package]] -name = "env_logger" -version = "0.8.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a19187fea3ac7e84da7dacf48de0c45d63c6a76f9490dae389aead16c243fce3" -dependencies = [ - "log", - "regex", -] - [[package]] name = "env_logger" version = "0.9.0" @@ -3454,8 +3444,8 @@ dependencies = [ "lru", "parking_lot 0.12.0", "prometheus-client", - "quickcheck 1.0.3", - "quickcheck_macros 1.0.0", + "quickcheck 0.9.2", + "quickcheck_macros", "rand 0.8.5", "regex", "serde", @@ -3639,7 +3629,7 @@ dependencies = [ "ethereum-types 0.12.1", "lazy_static", "quickcheck 0.9.2", - "quickcheck_macros 0.9.1", + "quickcheck_macros", "safe_arith", ] @@ -4788,8 +4778,6 @@ version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "588f6378e4dd99458b60ec275b4477add41ce4fa9f64dcba6f15adccb19b50d6" dependencies = [ - "env_logger 0.8.4", - "log", "rand 0.8.5", ] @@ -4804,17 +4792,6 @@ dependencies = [ "syn", ] -[[package]] -name = "quickcheck_macros" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b22a693222d716a9587786f37ac3f6b4faedb5b80c23914e7303ff5a1d8016e9" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - [[package]] name = "quicksink" version = "0.1.2" diff --git a/beacon_node/lighthouse_network/Cargo.toml b/beacon_node/lighthouse_network/Cargo.toml index e58e2838a90..7c114359e31 100644 --- a/beacon_node/lighthouse_network/Cargo.toml +++ b/beacon_node/lighthouse_network/Cargo.toml @@ -52,8 +52,8 @@ slog-async = "2.5.0" tempfile = "3.1.0" exit-future = "0.2.0" void = "1" -quickcheck = "1.0.3" -quickcheck_macros = "1.0.0" +quickcheck = "0.9.2" +quickcheck_macros = "0.9.1" [features] libp2p-websocket = [] diff --git a/beacon_node/lighthouse_network/src/peer_manager/mod.rs b/beacon_node/lighthouse_network/src/peer_manager/mod.rs index f1a1caa460a..ee870fd9d2e 100644 --- a/beacon_node/lighthouse_network/src/peer_manager/mod.rs +++ b/beacon_node/lighthouse_network/src/peer_manager/mod.rs @@ -2067,61 +2067,43 @@ mod tests { #[derive(Clone, Debug)] struct PeerCondition { - direction: Direction, - attestation_subnets: Vec, - sync_committee_subnets: Vec, + outgoing: bool, + attestation_net_bitfield: Vec, + sync_committee_net_bitfield: Vec, score: f64, gossipsub_score: f64, } impl Arbitrary for PeerCondition { - fn arbitrary(g: &mut Gen) -> Self { + fn arbitrary(g: &mut G) -> Self { + let attestation_net_bitfield = { + let len = ::SubnetBitfieldLength::to_usize(); + let mut bitfield = vec![]; + for _ in 0..len { + bitfield.push(bool::arbitrary(g)); + } + bitfield + }; + + let sync_committee_net_bitfield = { + let len = ::SyncCommitteeSubnetCount::to_usize(); + let mut bitfield = vec![]; + for _ in 0..len { + bitfield.push(bool::arbitrary(g)); + } + bitfield + }; + PeerCondition { - direction: Direction::arbitrary(g), - attestation_subnets: Vec::arbitrary(g), - sync_committee_subnets: Vec::arbitrary(g), + outgoing: bool::arbitrary(g), + attestation_net_bitfield, + sync_committee_net_bitfield, score: f64::arbitrary(g), gossipsub_score: f64::arbitrary(g), } } } - #[derive(Clone, Debug)] - enum Direction { - Outgoing, - Incoming, - } - - impl Arbitrary for Direction { - fn arbitrary(g: &mut Gen) -> Self { - g.choose(&[Direction::Outgoing, Direction::Incoming]) - .unwrap() - .clone() - } - } - - #[derive(Clone, Debug)] - struct AttestationSubnetId(usize); - - impl Arbitrary for AttestationSubnetId { - fn arbitrary(g: &mut Gen) -> Self { - let len = ::SubnetBitfieldLength::to_usize(); - let id_range = (0..len).collect::>(); - AttestationSubnetId(*g.choose(&id_range).unwrap()) - } - } - - #[derive(Clone, Debug)] - struct SyncCommitteeSubnetId(usize); - - impl Arbitrary for SyncCommitteeSubnetId { - fn arbitrary(g: &mut Gen) -> Self { - let len = ::SyncCommitteeSubnetCount::to_usize(); - let id_range = (0..len).collect::>(); - SyncCommitteeSubnetId(*g.choose(&id_range).unwrap()) - } - } - #[quickcheck] fn prune_excess_peers(peer_conditions: Vec) -> TestResult { let target_peer_count = DEFAULT_TARGET_PEERS; @@ -2136,29 +2118,26 @@ mod tests { let mut attnets = crate::types::EnrAttestationBitfield::::new(); let mut syncnets = crate::types::EnrSyncCommitteeBitfield::::new(); - match condition.direction { - Direction::Incoming => { - peer_manager.inject_connect_ingoing( - &peer, - "/ip4/0.0.0.0".parse().unwrap(), - None, - ); - } - Direction::Outgoing => { - peer_manager.inject_connect_outgoing( - &peer, - "/ip4/0.0.0.0".parse().unwrap(), - None, - ); - } + if condition.outgoing { + peer_manager.inject_connect_outgoing( + &peer, + "/ip4/0.0.0.0".parse().unwrap(), + None, + ); + } else { + peer_manager.inject_connect_ingoing( + &peer, + "/ip4/0.0.0.0".parse().unwrap(), + None, + ); } - for id in &condition.attestation_subnets { - attnets.set(id.0, true).unwrap(); + for (i, value) in condition.attestation_net_bitfield.iter().enumerate() { + attnets.set(i, *value).unwrap(); } - for id in &condition.sync_committee_subnets { - syncnets.set(id.0, true).unwrap(); + for (i, value) in condition.sync_committee_net_bitfield.iter().enumerate() { + syncnets.set(i, *value).unwrap(); } let metadata = crate::rpc::MetaDataV2 { From b7bf5dd9ed618c5bc10dfbcb85322ef6945e7854 Mon Sep 17 00:00:00 2001 From: Akihito Nakano Date: Thu, 23 Jun 2022 14:25:27 +0900 Subject: [PATCH 06/10] Update beacon_node/lighthouse_network/src/peer_manager/mod.rs Co-authored-by: Divma <26765164+divagant-martian@users.noreply.github.com> --- beacon_node/lighthouse_network/src/peer_manager/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/beacon_node/lighthouse_network/src/peer_manager/mod.rs b/beacon_node/lighthouse_network/src/peer_manager/mod.rs index ee870fd9d2e..a36f474e951 100644 --- a/beacon_node/lighthouse_network/src/peer_manager/mod.rs +++ b/beacon_node/lighthouse_network/src/peer_manager/mod.rs @@ -2087,7 +2087,7 @@ mod tests { let sync_committee_net_bitfield = { let len = ::SyncCommitteeSubnetCount::to_usize(); - let mut bitfield = vec![]; + let mut bitfield = Vec::with_capacity(len); for _ in 0..len { bitfield.push(bool::arbitrary(g)); } From e81003309460464e8aea4e8e908ede2b981ed822 Mon Sep 17 00:00:00 2001 From: Akihito Nakano Date: Thu, 23 Jun 2022 14:25:41 +0900 Subject: [PATCH 07/10] Update beacon_node/lighthouse_network/src/peer_manager/mod.rs Co-authored-by: Divma <26765164+divagant-martian@users.noreply.github.com> --- beacon_node/lighthouse_network/src/peer_manager/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/beacon_node/lighthouse_network/src/peer_manager/mod.rs b/beacon_node/lighthouse_network/src/peer_manager/mod.rs index a36f474e951..08f91993f38 100644 --- a/beacon_node/lighthouse_network/src/peer_manager/mod.rs +++ b/beacon_node/lighthouse_network/src/peer_manager/mod.rs @@ -2078,7 +2078,7 @@ mod tests { fn arbitrary(g: &mut G) -> Self { let attestation_net_bitfield = { let len = ::SubnetBitfieldLength::to_usize(); - let mut bitfield = vec![]; + let mut bitfield = Vec::with_capacity(len); for _ in 0..len { bitfield.push(bool::arbitrary(g)); } From 10e5de5f69bc40ca1e41c5d939241b543bb4f1dc Mon Sep 17 00:00:00 2001 From: Akihito Nakano Date: Thu, 23 Jun 2022 14:26:11 +0900 Subject: [PATCH 08/10] Update beacon_node/lighthouse_network/src/peer_manager/mod.rs Co-authored-by: Divma <26765164+divagant-martian@users.noreply.github.com> --- .../lighthouse_network/src/peer_manager/mod.rs | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/beacon_node/lighthouse_network/src/peer_manager/mod.rs b/beacon_node/lighthouse_network/src/peer_manager/mod.rs index 08f91993f38..6269b691324 100644 --- a/beacon_node/lighthouse_network/src/peer_manager/mod.rs +++ b/beacon_node/lighthouse_network/src/peer_manager/mod.rs @@ -2160,17 +2160,10 @@ mod tests { // Perform the heartbeat. peer_manager.heartbeat(); - if peer_conditions.len() <= target_peer_count { - // We expect to keep the number of peers since no need to prune peers in this case. - TestResult::from_bool( - peer_manager.network_globals.connected_or_dialing_peers() - == peer_conditions.len(), - ) - } else { - TestResult::from_bool( - peer_manager.network_globals.connected_or_dialing_peers() - == target_peer_count, - ) + TestResult::from_bool( + peer_manager.network_globals.connected_or_dialing_peers() + == target_peer_count.min(peer_conditions.len()), + ) } }) } From b1e5bf8a488697e60e86198195fa32b9dba72e23 Mon Sep 17 00:00:00 2001 From: Diva M Date: Thu, 23 Jun 2022 09:59:38 -0500 Subject: [PATCH 09/10] fix wrong } --- Cargo.lock | 2 +- beacon_node/lighthouse_network/src/peer_manager/mod.rs | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 6271af5b4b8..3455ca8efa5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3450,7 +3450,7 @@ dependencies = [ "lru", "parking_lot 0.12.1", "prometheus-client", - "quickcheck 0.9.2", + "quickcheck", "quickcheck_macros", "rand 0.8.5", "regex", diff --git a/beacon_node/lighthouse_network/src/peer_manager/mod.rs b/beacon_node/lighthouse_network/src/peer_manager/mod.rs index d08913ea226..966f81fd88a 100644 --- a/beacon_node/lighthouse_network/src/peer_manager/mod.rs +++ b/beacon_node/lighthouse_network/src/peer_manager/mod.rs @@ -2161,7 +2161,6 @@ mod tests { peer_manager.network_globals.connected_or_dialing_peers() == target_peer_count.min(peer_conditions.len()), ) - } }) } } From 7a151a504d83f357e89a2b62b928126600264687 Mon Sep 17 00:00:00 2001 From: Diva M Date: Thu, 23 Jun 2022 11:09:20 -0500 Subject: [PATCH 10/10] discard tests that don't have excess peers --- beacon_node/lighthouse_network/src/peer_manager/mod.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/beacon_node/lighthouse_network/src/peer_manager/mod.rs b/beacon_node/lighthouse_network/src/peer_manager/mod.rs index 966f81fd88a..4b2b81060fd 100644 --- a/beacon_node/lighthouse_network/src/peer_manager/mod.rs +++ b/beacon_node/lighthouse_network/src/peer_manager/mod.rs @@ -2104,6 +2104,9 @@ mod tests { #[quickcheck] fn prune_excess_peers(peer_conditions: Vec) -> TestResult { let target_peer_count = DEFAULT_TARGET_PEERS; + if peer_conditions.len() < target_peer_count { + return TestResult::discard(); + } let rt = Runtime::new().unwrap(); rt.block_on(async move {