always return close peers from findValue
This commit is contained in:
parent
6033399f05
commit
f0b49fc153
2 changed files with 3 additions and 3 deletions
|
@ -77,6 +77,7 @@ class KademliaRPC:
|
|||
|
||||
response = {
|
||||
b'token': self.make_token(rpc_contact.compact_ip()),
|
||||
b'contacts': self.find_node(rpc_contact, key)
|
||||
}
|
||||
|
||||
if self.protocol.protocol_version:
|
||||
|
@ -93,8 +94,6 @@ class KademliaRPC:
|
|||
peers.append(self.compact_address())
|
||||
if peers:
|
||||
response[key] = peers
|
||||
else:
|
||||
response[b'contacts'] = self.find_node(rpc_contact, key)
|
||||
return response
|
||||
|
||||
def refresh_token(self): # TODO: this needs to be called periodically
|
||||
|
|
|
@ -81,8 +81,9 @@ class TestProtocol(AsyncioTestCase):
|
|||
self.assertListEqual([peer2_from_peer1], peer1.data_store.get_storing_contacts())
|
||||
peer1.data_store.completed_blobs.add(binascii.hexlify(b'2' * 48).decode())
|
||||
find_value_response = peer1.node_rpc.find_value(peer3, b'2' * 48)
|
||||
self.assertEqual(len(find_value_response[b'contacts']), 0)
|
||||
self.assertSetEqual(
|
||||
{b'2' * 48, b'token', b'protocolVersion'}, set(find_value_response.keys())
|
||||
{b'2' * 48, b'token', b'protocolVersion', b'contacts'}, set(find_value_response.keys())
|
||||
)
|
||||
self.assertEqual(2, len(find_value_response[b'2' * 48]))
|
||||
self.assertEqual(find_value_response[b'2' * 48][0], peer2_from_peer1.compact_address_tcp())
|
||||
|
|
Loading…
Reference in a new issue