add response assertion to announce_to_peer
This commit is contained in:
parent
bdba263224
commit
df78f7ff9f
1 changed files with 5 additions and 5 deletions
|
@ -304,22 +304,22 @@ class Node(object):
|
||||||
if not responseMsg.nodeID in known_nodes:
|
if not responseMsg.nodeID in known_nodes:
|
||||||
log.warning("Responding node was not expected")
|
log.warning("Responding node was not expected")
|
||||||
defer.returnValue(responseMsg.nodeID)
|
defer.returnValue(responseMsg.nodeID)
|
||||||
n = known_nodes[responseMsg.nodeID]
|
remote_node = known_nodes[responseMsg.nodeID]
|
||||||
|
|
||||||
result = responseMsg.response
|
result = responseMsg.response
|
||||||
announced = False
|
announced = False
|
||||||
if 'token' in result:
|
if 'token' in result:
|
||||||
value['token'] = result['token']
|
value['token'] = result['token']
|
||||||
try:
|
try:
|
||||||
res = yield n.store(blob_hash, value, self.node_id)
|
res = yield remote_node.store(blob_hash, value)
|
||||||
log.info("Response to store request: %s", str(res))
|
assert res == "OK", "unexpected response: {}".format(res)
|
||||||
announced = True
|
announced = True
|
||||||
except protocol.TimeoutError:
|
except protocol.TimeoutError:
|
||||||
log.info("Timeout while storing blob_hash %s at %s",
|
log.info("Timeout while storing blob_hash %s at %s",
|
||||||
blob_hash.encode('hex')[:16], n.id.encode('hex'))
|
blob_hash.encode('hex')[:16], remote_node.id.encode('hex'))
|
||||||
except Exception as err:
|
except Exception as err:
|
||||||
log.error("Unexpected error while storing blob_hash %s at %s: %s",
|
log.error("Unexpected error while storing blob_hash %s at %s: %s",
|
||||||
blob_hash.encode('hex')[:16], n.id.encode('hex'), err)
|
blob_hash.encode('hex')[:16], remote_node.id.encode('hex'), err)
|
||||||
else:
|
else:
|
||||||
log.warning("missing token")
|
log.warning("missing token")
|
||||||
defer.returnValue(announced)
|
defer.returnValue(announced)
|
||||||
|
|
Loading…
Reference in a new issue