diff --git a/network/Cargo.toml b/network/Cargo.toml index 18df70b8efe7..35456f3365e7 100644 --- a/network/Cargo.toml +++ b/network/Cargo.toml @@ -25,9 +25,8 @@ exit-future = "0.2.0" futures-timer = "2.0" sp-blockchain = { git = "https://github.com/paritytech/substrate", branch = "master" } sp-api = { git = "https://github.com/paritytech/substrate", branch = "master" } -sp-keyring = { git = "https://github.com/paritytech/substrate", branch = "master" } wasm-timer = "0.2.4" [dev-dependencies] - +sp-keyring = { git = "https://github.com/paritytech/substrate", branch = "master" } sp-state-machine = { git = "https://github.com/paritytech/substrate", branch = "master" } diff --git a/network/src/legacy/gossip/mod.rs b/network/src/legacy/gossip/mod.rs index 6e80223b2730..7e97eb688b15 100644 --- a/network/src/legacy/gossip/mod.rs +++ b/network/src/legacy/gossip/mod.rs @@ -361,6 +361,7 @@ pub struct NewLeafActions { } impl NewLeafActions { + #[cfg(test)] pub fn new() -> Self { NewLeafActions { actions: Vec::new() } } diff --git a/network/src/protocol/mod.rs b/network/src/protocol/mod.rs index c194d6861d31..0ed2d9ac4395 100644 --- a/network/src/protocol/mod.rs +++ b/network/src/protocol/mod.rs @@ -66,7 +66,8 @@ pub const POLKADOT_PROTOCOL_NAME: &[u8] = b"/polkadot/1"; pub use crate::legacy::gossip::ChainContext; -pub mod tests; +#[cfg(test)] +mod tests; // Messages from the service API or network adapter. enum ServiceToWorkerMsg { @@ -118,6 +119,7 @@ enum ServiceToWorkerMsg { /// Used in tests to ensure that all other messages sent from the same /// thread have been flushed. Also executes arbitrary logic with the protocl /// handler. + #[cfg(test)] Synchronize(Box), } @@ -1006,6 +1008,7 @@ impl Worker where let _ = sender.send(checked_messages); } + #[cfg(test)] ServiceToWorkerMsg::Synchronize(callback) => { (callback)(&mut self.protocol_handler) } diff --git a/network/src/protocol/tests.rs b/network/src/protocol/tests.rs index ef0e7efcff9c..a1cad24be34d 100644 --- a/network/src/protocol/tests.rs +++ b/network/src/protocol/tests.rs @@ -52,7 +52,7 @@ struct Recorded { type GossipStreamEntry = (mpsc::UnboundedReceiver, oneshot::Sender<()>); #[derive(Default, Clone)] -pub struct MockGossip { +struct MockGossip { inner: Arc>>, gossip_messages: Arc>>, }