Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into dp/chore/test-cor…
Browse files Browse the repository at this point in the history
…e-listeners

* upstream/master:
  Add unit tests for core::nodes::NodeStream (libp2p#535)
  • Loading branch information
dvdplm committed Oct 5, 2018
2 parents 6341575 + d81f4e2 commit 961ca7f
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 16 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
target
Cargo.lock
.idea/**
CMakeLists.txt
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Right now everything including the crate organization is very much Work in Progr

## Documentation

This repository includes a facade crate named `libp2p`, which reexports the rest of the repository.
This repository includes a façade crate named `libp2p`, which reexports the rest of the repository.

For documentation, you are encouraged to clone this repository or add `libp2p` as a dependency in
your Cargo.toml and run `cargo doc`.
Expand Down
16 changes: 8 additions & 8 deletions core/src/nodes/handled_node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,21 +45,21 @@ pub trait NodeHandler<TSubstream> {
/// The handler is responsible for upgrading the substream to whatever protocol it wants.
fn inject_substream(&mut self, substream: TSubstream, endpoint: NodeHandlerEndpoint<Self::OutboundOpenInfo>);

/// Indicates the handler that the inbound part of the muxer has been closed, and that
/// Indicates to the handler that the inbound part of the muxer has been closed, and that
/// therefore no more inbound substream will be produced.
fn inject_inbound_closed(&mut self);

/// Indicates the handler that an outbound substream failed to open because the outbound
/// Indicates to the handler that an outbound substream failed to open because the outbound
/// part of the muxer has been closed.
fn inject_outbound_closed(&mut self, user_data: Self::OutboundOpenInfo);

/// Indicates the handler that the multiaddr future has resolved.
/// Indicates to the handler that the multiaddr future has resolved.
fn inject_multiaddr(&mut self, multiaddr: Result<Multiaddr, IoError>);

/// Injects an event coming from the outside in the handler.
/// Injects an event coming from the outside into the handler.
fn inject_event(&mut self, event: Self::InEvent);

/// Indicates the node that it should shut down. After that, it is expected that `poll()`
/// Indicates that the node that it should shut down. After that, it is expected that `poll()`
/// returns `Ready(None)` as soon as possible.
///
/// This method allows an implementation to perform a graceful shutdown of the substreams, and
Expand All @@ -78,7 +78,7 @@ pub enum NodeHandlerEndpoint<TOutboundOpenInfo> {
Listener,
}

/// Event produces by a handler.
/// Event produced by a handler.
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
pub enum NodeHandlerEvent<TOutboundOpenInfo, TCustom> {
/// Require a new outbound substream to be opened with the remote.
Expand All @@ -88,7 +88,7 @@ pub enum NodeHandlerEvent<TOutboundOpenInfo, TCustom> {
Custom(TCustom),
}

/// Event produces by a handler.
/// Event produced by a handler.
impl<TOutboundOpenInfo, TCustom> NodeHandlerEvent<TOutboundOpenInfo, TCustom> {
/// If this is `OutboundSubstreamRequest`, maps the content to something else.
#[inline]
Expand Down Expand Up @@ -173,7 +173,7 @@ where
self.node.is_none()
}

/// Indicates the handled node that it should shut down. After calling this method, the
/// Indicates to the handled node that it should shut down. After calling this method, the
/// `Stream` will end in the not-so-distant future.
///
/// After this method returns, `is_shutting_down()` should return true.
Expand Down
7 changes: 0 additions & 7 deletions core/src/nodes/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -455,13 +455,6 @@ mod node_stream {
]);
}

#[test]
fn prints_pretty_debug_info() {
let mut ns = build_node_stream();
ns.open_substream(b"ba be".to_vec()).unwrap();
assert_eq!(format!("{:?}", ns), "NodeStream { address: None, inbound_finished: false, outbound_finished: false, outbound_substreams: 1 }");
}

#[test]
fn poll_returns_not_ready_when_there_is_nothing_to_do() {
let mut task = MockTask::new();
Expand Down

0 comments on commit 961ca7f

Please sign in to comment.