Exemplo n.º 1
0
def test_default_protocols():
    key_pair = create_new_key_pair()
    swarm = initialize_default_swarm(key_pair)
    host = BasicHost(swarm)

    mux = host.get_mux()
    handlers = mux.handlers
    assert handlers == get_default_protocols()
Exemplo n.º 2
0
def test_default_protocols():
    key_pair = create_new_key_pair()
    swarm = initialize_default_swarm(key_pair)
    host = BasicHost(swarm)

    mux = host.get_mux()
    handlers = mux.handlers
    # NOTE: comparing keys for equality as handlers may be closures that do not compare in the way
    # this test is concerned with
    assert handlers.keys() == get_default_protocols(host).keys()
Exemplo n.º 3
0
 def __init__(
     self,
     network: INetworkService,
     default_protocols: "OrderedDict[TProtocol, StreamHandlerFn]" = None,
 ) -> None:
     self._network = network
     self._network.set_stream_handler(self._swarm_stream_handler)
     self.peerstore = self._network.peerstore
     # Protocol muxing
     default_protocols = default_protocols or get_default_protocols(self)
     self.multiselect = Multiselect(default_protocols)
     self.multiselect_client = MultiselectClient()