Ejemplo n.º 1
0
 def test_bucket_for_gives_correct_bucket(self):
     self.em.add(self.ce)
     d1 = hash.distance(self.s.ipp, self.ce)
     assert self.em._buckets[d1] is self.em.bucket_for(self.ce)
     self.em.add(self.fe)
     d2 = hash.distance(self.s.ipp, self.fe)
     assert self.em._buckets[d2] == self.em.bucket_for(self.fe)
Ejemplo n.º 2
0
 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
Ejemplo n.º 3
0
 def test_distance_is_an_int(self):
     assert isinstance(hash.distance(selfipp, closeipp), int)
Ejemplo n.º 4
0
 def test_distance_correct_for_closeipp(self):
     assert hash.distance(selfipp, closeipp) == 1
Ejemplo n.º 5
0
 def test_distance_correct_for_faripp(self):
     assert hash.distance(selfipp, faripp) == 17
Ejemplo n.º 6
0
 def test_distance_is_commutative(self):
     assert hash.distance(selfipp, faripp) == hash.distance(faripp, selfipp)
Ejemplo n.º 7
0
 def test_distance_to_self_is_zero(self):
     assert hash.distance(selfipp, selfipp) == 0
Ejemplo n.º 8
0
 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)]