Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tests for HandledNodesTasks #584

Merged
merged 75 commits into from
Nov 14, 2018

Conversation

dvdplm
Copy link
Contributor

@dvdplm dvdplm commented Oct 23, 2018

Based on #546

dvdplm added 30 commits October 3, 2018 11:16
…e-listeners

* upstream/master:
  Implement GET_PROVIDERS/ADD_PROVIDER Kademlia messages (libp2p#530)
  Make secio almost compile for asmjs/wasm (libp2p#519)
  Make it possible to accept/deny nodes in CollectionsStream (libp2p#512)
  Fix polling in handled_node.rs (libp2p#531)
  Remove notifying tasks (libp2p#528)
  Fix handler not properly shut down, and write test for this (libp2p#514)
  Use unsigned-varints, add BLAKE2 support in multihash (libp2p#525)
  Upgrade smallvec version to fix license issue (libp2p#526)
…e-listeners

* upstream/master:
  Add unit tests for core::nodes::NodeStream (libp2p#535)
…e-listeners

* upstream/master:
  Fix secio compied with --no-default-features (libp2p#545)
  multiaddr: explain the use of `&str` for `Unix`. (libp2p#543)
  Model HandshakeContext with explicit state transitions. (libp2p#532)
  multiaddr: add support for onion protocol. (libp2p#542)
…andled_node

* dp/chore/test-core-listeners:
  Prefer freestanding function
  Address grumbles
  Remove non-project specific stuff
  Address grumbles
Add HandlerState and use it in TestBuilder
Shorter test names
Track events as they reach the Handler
Describe complex test logic
…e-handled_node

* upstream/master:
  Add `StreamMuxer::flush`. (libp2p#534)
  Tests for nodes/listeners.rs (libp2p#541)
  Deny relative addresses for UNIX domain sockets (libp2p#548)
  Optimise `Multiaddr::append`. (libp2p#549)
@tomaka
Copy link
Member

tomaka commented Nov 2, 2018

Please remove the printlns, the diff is really verbose.

@dvdplm
Copy link
Contributor Author

dvdplm commented Nov 2, 2018

Done.

@tomaka
Copy link
Member

tomaka commented Nov 5, 2018

Just in general I think it's bad to have style changes in the same PR as something else (or even in general two different changes in the same PR). It's tolerable when there are two or three style changes, but not more. I'm not going to ask you to revert the style changes, but this really pollute the diff.

core/src/nodes/handled_node.rs Outdated Show resolved Hide resolved
core/src/nodes/handled_node_tasks.rs Outdated Show resolved Hide resolved
core/src/nodes/handled_node_tasks.rs Outdated Show resolved Hide resolved
core/src/nodes/handled_node_tasks.rs Outdated Show resolved Hide resolved

// Even though we set up the muxer outbound state to be `Closed` we
// still need to open a substream or the outbound state will never
// be checked.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be fixed in the non-test code.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll look into it, but I suspect that it's more of an artifact of the DummyMuxer than a fault of the actual code.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am wrong and you're right (and the comment is correct); the NodeStream does not check if the outbound state is open or closed (it does check the inbound state).

I'll open an issue and fix in separate PR, ok?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Issue #609

core/src/nodes/handled_node_tasks.rs Outdated Show resolved Hide resolved
@dvdplm
Copy link
Contributor Author

dvdplm commented Nov 5, 2018

ust in general I think it's bad to have style changes in the same PR as something else (or even in general two different changes in the same PR).

I agree with this, mixing things makes reviewing much harder than it needs to be.
I am not sure which style changes you refer to here, but I did run rustfmt on two of the test helper files (dummy_transport and dummy_muxer I think) which I think is ok, as the changes there are all relevant to the tests added here. I'll try to pay close attention to it going forward though.

Test Task.send_event() and id() using a HandledNodesTasks
…e-handled_node_tasks

* upstream/master:
  Inject event by value in ProtocolsHandler (libp2p#605)
  Add a PeriodicPingHandler and a PingListenHandler (libp2p#574)
  Fix stack overflow when printing a SubstreamRef (libp2p#599)
  Add a peer id generator (libp2p#583)
  eg. -> e.g.; ie. -> i.e. via repren (libp2p#592)
…e-handled_node_tasks

* upstream/master:
  Use vecdeque for fair polling (libp2p#610)
  Add back the Swarm (libp2p#613)
  Remove dependency on tokio_current_thread (libp2p#606)
  Use chashmap from crates (libp2p#615)
  Fix grammar in core/nodes etc. (libp2p#608)
@dvdplm dvdplm mentioned this pull request Nov 9, 2018
@dvdplm
Copy link
Contributor Author

dvdplm commented Nov 13, 2018

@tomaka I believe there are two outstanding issues here:

  1. Debug impl for HandledNodesTasks: do you like the suggested change there?
  2. test organization in submodules: do you want me to re-work that?

Other than the above, is there anything else I can do to move this forward?

@tomaka
Copy link
Member

tomaka commented Nov 13, 2018

Yes, please remove the hierarchy of sub-modules in the tests.

I disagree with the surprise factor for changing the Debug implementation. This struct is a collection of tasks, and every single collection in the Rust standard library uses this debug output. To me the reason why most Debug implementations simply print the struct layout is because programmers are lazy, not because it's the right thing to do.
Let's make @twittner decide?

@dvdplm
Copy link
Contributor Author

dvdplm commented Nov 14, 2018

Let's make @twittner decide?

I'll just make the change you prefer and if someone disagrees vehemently we can discuss it again. :)

…e-handled_node_tasks

* upstream/master:
  Tweaks, spelling and grammar (libp2p#629)
  Add a badge with a link to deps.rs (libp2p#630)
  Rewrite floodsub to use the ProtocolsHandler (libp2p#603)
  Add an IdentifyListen behaviour (libp2p#626)
  Add a custom derive for NetworkBehaviour (libp2p#619)
  Set the maximum size of Mplex messages to 1Mb (libp2p#622)
  Use expect rather than unwrap (libp2p#625)
  Make libp2p-websocket optional (libp2p#624)
  Add From<IpAddr> for Multiaddr (libp2p#623)
  Add implementations of NetworkBehaviour for ping (libp2p#618)
  Add a PeriodicIdentifyBehaviour (libp2p#617)
  Use upstream rust-secp256k1 (libp2p#616)
  Use yamux and aio-limited from crates.io (libp2p#621)
@dvdplm
Copy link
Contributor Author

dvdplm commented Nov 14, 2018

@tomaka ptal

@tomaka tomaka merged commit 513b97b into libp2p:master Nov 14, 2018
dvdplm added a commit to dvdplm/rust-libp2p that referenced this pull request Nov 14, 2018
…lection_stream

* upstream/master:
  Fix the concerns of libp2p#603 (libp2p#635)
  Tests for HandledNodesTasks (libp2p#584)
dvdplm added a commit to dvdplm/rust-libp2p that referenced this pull request Nov 15, 2018
…ample

* upstream/master:
  Fix the concerns of libp2p#603 (libp2p#635)
  Tests for HandledNodesTasks (libp2p#584)
  Tweaks, spelling and grammar (libp2p#629)
  Add a badge with a link to deps.rs (libp2p#630)
dvdplm added a commit to dvdplm/rust-libp2p that referenced this pull request Nov 16, 2018
…_swarm

* upstream/master: (33 commits)
  Behavior -> Behaviour (libp2p#650)
  Remove Send/Sync/'static reqs from ping (libp2p#652)
  Tests for CollectionStream (libp2p#588)
  Document the muxing module (libp2p#647)
  Document the core::upgrade module (libp2p#644)
  Send Close when shutting down gracefully, as per spec (libp2p#631)
  Remove the Send + 'static requirements for floodsub (libp2p#637)
  Move protocols_handler to the root (libp2p#643)
  Use a random sequence number in floodsub (libp2p#634)
  Split `ConnectionUpgrade`. (libp2p#642)
  Add an impl Debug for HandledNode (libp2p#628)
  minor typo in docs (libp2p#640)
  Update connected peers' topics on NodeEvent (libp2p#638)
  Fix the concerns of libp2p#603 (libp2p#635)
  Tests for HandledNodesTasks (libp2p#584)
  Tweaks, spelling and grammar (libp2p#629)
  Add a badge with a link to deps.rs (libp2p#630)
  Rewrite floodsub to use the ProtocolsHandler (libp2p#603)
  Add an IdentifyListen behaviour (libp2p#626)
  Add a custom derive for NetworkBehaviour (libp2p#619)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants