If two nodes are connecting to each other at the same time, they should be connected, so each one has exactly one connection.
Connections that are initiated outside of the state machine (e.g. by Kademlia) should be present in the state machine.
Tests:
p2p_basic_connections(all_nodes_connections_are_symmetric)p2p_basic_connections(seed_connections_are_symmetric)
Tests:
We should accept an incoming connection from an arbitrary node.
Tests:
- p2p_basic_incoming(accept_connection)
- p2p_basic_incoming(accept_multiple_connections)
- solo_node_accept_incoming
- multi_node_connection_discovery/OCamlToRust (should be replaced with one with non-OCaml peer)
- TODO: fast-running short test
The Rust node should reject a connection from a peer if there is one with the same peer ID already.
Tests: TODO
The node shouldn't accept a connection from a peer that uses the same peer id as this one. This is either a program error (see above), network setup error, or a malicious node that uses the same peer ID.
Tests:
The node can obtain its address from other peers. It shouldn't use it when connecting to new peers.
Tests:
p2p_basic_outgoing(dont_connect_to_node_same_id)p2p_basic_outgoing(dont_connect_to_initial_peer_same_id)p2p_basic_outgoing(dont_connect_to_self_initial_peer)
TODO: what if the number of initial peers exceeds the max number of peers?
Node should be able to connect to initial peers eventually, even if initially they are not available.
If, for some reason, the node can't connect to enough peers (e.g. it is the first node in the network), it should keep retrying to those with failures (see also below).
TODO: Use cases where this is important.
Tests:
We should consider different reasons why the outgoing connection failed. The Rust node shouldn't reconnect too soon to a node that dropped the connection.
Tests: TODO
- solo_node_accept_incoming (TODO: should be replaced by one with Rust-only peer)
During this stage, the node queries its existing peers for more peers, thus getting more peer addresses.
See #148.
Tests: TODO
See #148.
To obtain a set of random peers, the Rust node performs a Kademlia query that returns a list of peers that are "close" to some random peer.
This step starts after Kademlia initialization is complete.
- multi_node_peer_discovery (partially, should be replaced with one with a non-OCaml peer)
- multi_node_connection_discovery/OCamlToRust (indirectly, should be replaced with one with a non-OCaml peer)
- TODO: fast-running Rust-only test
This is one of the requirements of LibP2P's Kademlia implementation. E.g. the node behind NAT shouldn't advertise its address obtained using external "what-is-my-IP"-like services.
Tests: TODO
If a Rust node is used as a seed node, OCaml nodes connected to it should be able to also discover and connect to each other.
The node should connect to as many peers as it is configured to (between min and max number).
The node should maintain a minimal number of peers in case it is disconnected from its existing peers.
Tests: TODO
Tests: TODO
Tests: TODO
Tests: TODO