本文整理汇总了Python中dht.crawling.RPCFindResponse类的典型用法代码示例。如果您正苦于以下问题:Python RPCFindResponse类的具体用法?Python RPCFindResponse怎么用?Python RPCFindResponse使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了RPCFindResponse类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_happened
def test_happened(self):
response = (True, ("value", "some_value"))
r = RPCFindResponse(response)
self.assertTrue(r.happened())
response = (False, ("value", "some_value"))
r = RPCFindResponse(response)
self.assertFalse(r.happened())
示例2: test_hasValue
def test_hasValue(self):
response = (True, ("value", "some_value"))
r = RPCFindResponse(response)
self.assertTrue(r.hasValue())
response = (False, "a node")
r = RPCFindResponse(response)
self.assertFalse(r.hasValue())
示例3: test_getNodeList
def test_getNodeList(self):
node1 = Node(digest("id1"), "127.0.0.1", 12345, signed_pubkey=digest("key1"), vendor=True)
node2 = Node(digest("id2"), "127.0.0.1", 22222, signed_pubkey=digest("key2"), vendor=True)
node3 = Node(digest("id3"), "127.0.0.1", 77777, signed_pubkey=digest("key3"))
response = (True, (node1.getProto().SerializeToString(), node2.getProto().SerializeToString(), node3.getProto().SerializeToString(),
"sdfasdfsd"))
r = RPCFindResponse(response)
nodes = r.getNodeList()
self.assertEqual(nodes[0].getProto(), node1.getProto())
self.assertEqual(nodes[1].getProto(), node2.getProto())
self.assertEqual(nodes[2].getProto(), node3.getProto())
示例4: test_getNodeList
def test_getNodeList(self):
node1 = Node(digest("id1"), "127.0.0.1", 1234, digest("key1"), None, FULL_CONE, True)
node2 = Node(digest("id2"), "248.130.11.21", 1111, digest("key2"), None, FULL_CONE, True)
node3 = Node(digest("id3"), "987.567.23.1", 23456, digest("key3"), None, FULL_CONE, False)
response = (True, (node1.getProto().SerializeToString(), node2.getProto().SerializeToString(),
node3.getProto().SerializeToString(),
"sdfasdfsd"))
r = RPCFindResponse(response)
nodes = r.getNodeList()
self.assertEqual(nodes[0].getProto(), node1.getProto())
self.assertEqual(nodes[1].getProto(), node2.getProto())
self.assertEqual(nodes[2].getProto(), node3.getProto())
示例5: test_getValue
def test_getValue(self):
response = (True, ("value", "some_value"))
r = RPCFindResponse(response)
self.assertEqual(r.getValue(), ("some_value",))