def join_community(self, my_member): self.my_member = my_member master_key = "3081a7301006072a8648ce3d020106052b81040027038192000403cbbfd2dfb67a7db66c88988df56f93fa6e7f982f9a6a0fa8898492c8b8cae23e10b159ace60b7047012082a5aa4c6e221d7e58107bb550436d57e046c11ab4f51f0ab18fa8f58d0346cc12d1cc2b61fc86fe5ed192309152e11e3f02489e30c7c971dd989e1ce5030ea0fb77d5220a92cceb567cbc94bc39ba246a42e215b55e9315b543ddeff0209e916f77c0d747".decode("HEX") master = Member(master_key) return AllChannelCommunity.join_community(master, self.my_member, self.my_member, integrate_with_tribler = False)
def test_incoming_channel_propagate(self): """ We will send a 'propagate-torrents' message from NODE to SELF with an infohash that is not in the local database, the associated .torrent should then be requested by SELF. """ community = AllChannelCommunity.create_community(self._my_member) address = self._dispersy.socket.get_address() # create node and ensure that SELF knows the node address node = AllChannelNode() node.init_socket() node.set_community(community) node.init_my_member() yield 0.1 # send a 'propagate-torrents' message with an infohash that SELF does not have packets = ["a"*22 for _ in range(10)] global_time = 10 node.send_message(node.create_channel_propagate(packets, global_time), address) yield 0.1 # # wait for the 'torrent-request' message from SELF to NODE # _, message = node.receive_message(addresses=[address], message_names=[u"torrent-request"]) # assert message.payload.infohash == infohash # cleanup community.create_dispersy_destroy_community(u"hard-kill")
def join_community(self, my_member): self.my_member = my_member master_key = "3081a7301006072a8648ce3d020106052b81040027038192000403cbbfd2dfb67a7db66c88988df56f93fa6e7f982f9a6a0fa8898492c8b8cae23e10b159ace60b7047012082a5aa4c6e221d7e58107bb550436d57e046c11ab4f51f0ab18fa8f58d0346cc12d1cc2b61fc86fe5ed192309152e11e3f02489e30c7c971dd989e1ce5030ea0fb77d5220a92cceb567cbc94bc39ba246a42e215b55e9315b543ddeff0209e916f77c0d747".decode( "HEX") master = Member(master_key) return AllChannelCommunity.join_community(master, self.my_member, self.my_member, integrate_with_tribler=False)
def test_outgoing_channel_propagate(self): """ We will send a 'propagate-torrents' message from SELF to NODE. Restrictions: - No duplicate infohashes. - No more than 50 infohashes. - At least 1 infohash must be given. - Infohashes must exist in SELF's database. """ community = AllChannelCommunity.create_community(self._my_member) address = self._dispersy.socket.get_address() # wait for a few seconds for Tribler to collect some torrents... yield 5.0 # create node and ensure that SELF knows the node address node = AllChannelNode() node.init_socket() node.set_community(community) node.init_my_member() yield 0.01 # send a 'propagate-torrents' message community.create_channel_propagate() yield 0.01 # wait for the 'propagate-torrents' message from SELF to NODE _, message = node.receive_message(addresses=[address], message_names=[u"propagate-torrents"]) assert 1 <= len(message.payload.infohashes) <= 50, "to few or to many infohashes" assert len(set(message.payload.infohashes)) == len(message.payload.infohashes), "duplicate infohashes" dprint(map(lambda infohash: infohash.encode("HEX"), message.payload.infohashes), lines=1) # cleanup community.create_dispersy_destroy_community(u"hard-kill")