Beispiel #1
0
 def test_responseReceived(self):
     # Make a query that we will "send"
     query = Query()
     query.rpctype = "ping"
     # Make the protocol and patch in our counter, transport, and reactor
     counter = Counter()
     k_messenger = KRPC_Sender(TreeRoutingTable, 2**50)
     k_messenger.transport = HollowTransport()
     k_messenger.responseReceived = counter
     # Send the query and receive the response
     k_messenger.sendQuery(query, address, timeout)
     self.assertTrue(query._transaction_id in k_messenger._transactions)
     # Make a response that we will "receive"
     response = query.build_response()
     response._from = 9
     k_messenger.datagramReceived(krpc_coder.encode(response), address)
     _restore_reactor()
     self.assertEquals(1, counter.count)
Beispiel #2
0
 def test_responseReceived(self):
     # Make a query that we will "send"
     query = Query()
     query.rpctype = "ping"
     # Make the protocol and patch in our counter, transport, and reactor
     counter = Counter()
     k_messenger = KRPC_Sender(TreeRoutingTable, 2**50)
     k_messenger.transport = HollowTransport()
     k_messenger.responseReceived = counter
     # Send the query and receive the response
     k_messenger.sendQuery(query, address, timeout)
     self.assertTrue(query._transaction_id in k_messenger._transactions)
     # Make a response that we will "receive"
     response = query.build_response()
     response._from = 9
     k_messenger.datagramReceived(krpc_coder.encode(response), address)
     _restore_reactor()
     self.assertEquals(1, counter.count)