コード例 #1
0
ファイル: test_bucket.py プロジェクト: No9/drogulus
 def test_remove_contact_with_bad_id(self):
     """
     Ensures a ValueError exception is raised if one attempts to remove a
     non-existent contact from a k-bucket.
     """
     range_min = 12345
     range_max = 98765
     bucket = Bucket(range_min, range_max)
     contact = PeerNode("12345", "192.168.0.2", 8888, 123)
     bucket.add_contact(contact)
     with self.assertRaises(ValueError):
         bucket.remove_contact("54321")
コード例 #2
0
ファイル: test_bucket.py プロジェクト: waseem18/drogulus
 def test_remove_contact_with_bad_id(self):
     """
     Ensures a ValueError exception is raised if one attempts to remove a
     non-existent contact from a k-bucket.
     """
     range_min = 12345
     range_max = 98765
     bucket = Bucket(range_min, range_max)
     contact = PeerNode("12345", "192.168.0.2", 8888, 123)
     bucket.add_contact(contact)
     with self.assertRaises(ValueError):
         bucket.remove_contact("54321")
コード例 #3
0
ファイル: test_bucket.py プロジェクト: No9/drogulus
 def test_remove_contact(self):
     """
     Ensures it is possible to remove a contact with a certain ID from the
     k-bucket.
     """
     range_min = 12345
     range_max = 98765
     bucket = Bucket(range_min, range_max)
     for i in range(K):
         contact = PeerNode(PUBLIC_KEY, "192.168.0.%d" % i, 9999, 123)
         contact.network_id = hex(i)
         bucket.add_contact(contact)
     for i in range(K):
         bucket.remove_contact(hex(i))
         self.assertFalse(hex(i) in bucket._contacts,
                          "Could not remove contact with id %s" % hex(i))
コード例 #4
0
ファイル: test_bucket.py プロジェクト: waseem18/drogulus
 def test_remove_contact(self):
     """
     Ensures it is possible to remove a contact with a certain ID from the
     k-bucket.
     """
     range_min = 12345
     range_max = 98765
     bucket = Bucket(range_min, range_max)
     for i in range(K):
         contact = PeerNode(PUBLIC_KEY, "192.168.0.%d" % i, 9999, 123)
         contact.network_id = hex(i)
         bucket.add_contact(contact)
     for i in range(K):
         bucket.remove_contact(hex(i))
         self.assertFalse(
             hex(i) in bucket._contacts,
             "Could not remove contact with id %s" % hex(i))