本文整理汇总了Python中drogulus.dht.routingtable.RoutingTable.blacklist方法的典型用法代码示例。如果您正苦于以下问题:Python RoutingTable.blacklist方法的具体用法?Python RoutingTable.blacklist怎么用?Python RoutingTable.blacklist使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类drogulus.dht.routingtable.RoutingTable
的用法示例。
在下文中一共展示了RoutingTable.blacklist方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_blacklist
# 需要导入模块: from drogulus.dht.routingtable import RoutingTable [as 别名]
# 或者: from drogulus.dht.routingtable.RoutingTable import blacklist [as 别名]
def test_blacklist(self):
"""
Ensures a misbehaving peer is correctly blacklisted. The remove_contact
method is called and the contact's id is added to the _blacklist set.
"""
parent_node_id = 'abc'
r = RoutingTable(parent_node_id)
contact = Contact('abc', '192.168.0.1', 9999, 0)
r.remove_contact = MagicMock()
r.blacklist(contact)
r.remove_contact.called_once_with(contact, True)
self.assertIn(contact.id, r._blacklist)
示例2: test_blacklist
# 需要导入模块: from drogulus.dht.routingtable import RoutingTable [as 别名]
# 或者: from drogulus.dht.routingtable.RoutingTable import blacklist [as 别名]
def test_blacklist(self):
"""
Ensures a misbehaving peer is correctly blacklisted. The remove_contact
method is called and the contact's public key is added to the
_blacklist set.
"""
parent_node_id = 'deadbeef'
r = RoutingTable(parent_node_id)
contact = PeerNode(PUBLIC_KEY, '192.168.0.1', 9999, 0)
r.remove_contact = MagicMock()
r.blacklist(contact)
r.remove_contact.called_once_with(contact, True)
self.assertIn(contact.public_key, r._blacklist)
示例3: test_add_contact_with_blacklisted_contact
# 需要导入模块: from drogulus.dht.routingtable import RoutingTable [as 别名]
# 或者: from drogulus.dht.routingtable.RoutingTable import blacklist [as 别名]
def test_add_contact_with_blacklisted_contact(self):
"""
If the newly discovered contact is, in fact, already in the local
node's blacklist then ensure it doesn't get re-added.
"""
parent_node_id = 'abc'
r = RoutingTable(parent_node_id)
contact1 = Contact(2, '192.168.0.1', 9999, 0)
contact2 = Contact(4, '192.168.0.2', 9999, 0)
r.blacklist(contact2)
r.add_contact(contact1)
self.assertEqual(len(r._buckets[0]), 1)
r.add_contact(contact2)
self.assertEqual(len(r._buckets[0]), 1)
示例4: test_add_contact_with_blacklisted_contact
# 需要导入模块: from drogulus.dht.routingtable import RoutingTable [as 别名]
# 或者: from drogulus.dht.routingtable.RoutingTable import blacklist [as 别名]
def test_add_contact_with_blacklisted_contact(self):
"""
If the newly discovered contact is, in fact, already in the local
node's blacklist then ensure it doesn't get re-added.
"""
parent_node_id = 'deadbeef'
r = RoutingTable(parent_node_id)
contact1 = PeerNode(PUBLIC_KEY, '192.168.0.1', 9999, 0)
contact1.network_id = hex(2)
contact2 = PeerNode(BAD_PUBLIC_KEY, '192.168.0.2', 9999, 0)
contact2.network_id = hex(4)
r.blacklist(contact2)
r.add_contact(contact1)
self.assertEqual(len(r._buckets[0]), 1)
r.add_contact(contact2)
self.assertEqual(len(r._buckets[0]), 1)