Exemplo n.º 1
0
    def setup(self):
        if RUN_NETWORK_TESTS:
            time.sleep(1) # Reduce test interdependence
        self.got_response = False
        self.got_timeout = False
        self.got_error = False
        self.found_nodes = False

        self.got_routing_response = False
        self.got_routing_error = False
        self.got_routing_timeout = False
        self.got_routing_nodes_found = False

        self.querier_mock = querier.QuerierMock(tc.CLIENT_ID)

        self.r = minitwisted.ThreadedReactor(task_interval=.01)
        self.rpc_m = rpc_manager.RPCManager(self.r,
                                            tc.CLIENT_ADDR[1])
        self.querier = querier.Querier(self.rpc_m,
                                            tc.CLIENT_NODE)
        self.querier_routing = querier.Querier(self.rpc_m,
                                               tc.CLIENT_NODE)
        self.querier_routing.set_on_response_received_callback(
            self.on_routing_response)
        self.querier_routing.set_on_error_received_callback(
            self.on_routing_error)
        self.querier_routing.set_on_timeout_callback(
            self.on_routing_timeout)
        self.querier_routing.set_on_nodes_found_callback(
            self.on_routing_nodes_found)
  
        self.r.start()
Exemplo n.º 2
0
    def setup(self):
        for n in tc.NODES + [tc.SERVER_NODE, tc.SERVER2_NODE]:
            n.is_ns = False
        for n in tc.NODES2 + [tc.CLIENT_NODE]:
            n.is_ns = True

        self.querier = querier.QuerierMock(tc.CLIENT_ID)
        self.routing_m = RoutingManager(tc.CLIENT_NODE, self.querier, tc.NODES)
Exemplo n.º 3
0
 def setup(self):
     self.got_peers = None
     querier_ = querier.QuerierMock(tc.CLIENT_ID)
     bootstrap_nodes = RoutingManagerMock().get_closest_rnodes(
         tc.INFO_HASH_ZERO)
     self.lookup = lookup_manager.GetPeersLookup(tc.CLIENT_ID, querier_, 2,
                                                 tc.INFO_HASH_ZERO,
                                                 self._callback,
                                                 bootstrap_nodes)
Exemplo n.º 4
0
 def setup(self):
     self.got_peers = None
     querier_ = querier.QuerierMock(tc.CLIENT_ID)
     routing_m = RoutingManagerMock()
     self.bootstrap_nodes = routing_m.get_closest_rnodes(tc.INFO_HASH_ZERO)
     self.lm = lookup_manager.LookupManager(tc.CLIENT_ID, querier_,
                                            routing_m, 2)
     self.lookup = self.lm.get_peers(tc.INFO_HASH, self._on_got_peers,
                                     tc.BT_PORT)