def test_distance_supports_hash_ipptuple_or_end(self): a = hash.distance(selfipp, faripp) b = hash.distance(hash.hexhash(selfipp), hash.hexhash(faripp)) c = hash.distance(hash.hexhash(selfipp), faripp) d = hash.distance(selfipp, hash.hexhash(faripp)) e = hash.distance(selfipp, End(faripp)) f = hash.distance(End(selfipp), faripp) g = hash.distance(End(selfipp), End(faripp)) assert a == b == c == d == e == f == g
def test_end_manager_add_end_adds_end_at_correct_distance(self): self.em.add(self.ce) bucket = self.em._buckets[hash.distance(self.s.ipp, self.ce)] assert bucket[hash.hexhash(self.ce)]
def setUp(self): self.seeking_far = Telex(other_dict={'+end': hash.hexhash(faripp)}) self.from_end = End(closeipp) self.t = handlers.EndHandler()
def test_hexhash_ipp_tuple(self): ipp_hash = 'bc117be99339576519af05e91d51376feabd4706' assert hash.hexhash(('127.0.0.1',5555)) == ipp_hash
def test_hexhash_ipp_str(self): ipp_hash = 'bc117be99339576519af05e91d51376feabd4706' assert hash.hexhash('127.0.0.1:5555') == ipp_hash
def test_hexhash_arbitrary_string(self): test_hash = 'a94a8fe5ccb19ba61c4c0873d391e987982fbbd3' assert hash.hexhash('test') == test_hash