diff --git a/lbrynet/core/server/DHTHashAnnouncer.py b/lbrynet/core/server/DHTHashAnnouncer.py index a1989bc88..073c60540 100644 --- a/lbrynet/core/server/DHTHashAnnouncer.py +++ b/lbrynet/core/server/DHTHashAnnouncer.py @@ -118,6 +118,7 @@ class DHTHashAnnouncer(object): log.debug("No nodes stored %s, retrying", blob_hash) result = yield do_store(blob_hash, announce_d) else: + result = {} log.warning("No nodes stored %s", blob_hash) else: result = store_nodes diff --git a/lbrynet/tests/unit/core/server/test_DHTHashAnnouncer.py b/lbrynet/tests/unit/core/server/test_DHTHashAnnouncer.py index 1f5b502ab..bc72fed68 100644 --- a/lbrynet/tests/unit/core/server/test_DHTHashAnnouncer.py +++ b/lbrynet/tests/unit/core/server/test_DHTHashAnnouncer.py @@ -4,17 +4,24 @@ from twisted.internet import defer, reactor from lbrynet.tests.util import random_lbry_hash from lbrynet.core.server.DHTHashAnnouncer import DHTHashAnnouncer - class MocDHTNode(object): - def __init__(self): + def __init__(self, announce_will_fail=False): + # if announce_will_fail is True, + # announceHaveBlob will return empty dict self.can_store = True self.blobs_announced = 0 + self.announce_will_fail = announce_will_fail @defer.inlineCallbacks def announceHaveBlob(self, blob): + if self.announce_will_fail: + return_val = {} + else: + return_val = {blob:["ab"*48]} + self.blobs_announced += 1 d = defer.Deferred(None) - reactor.callLater(1, d.callback, {blob: ["ab" * 48]}) + reactor.callLater(1, d.callback, return_val) result = yield d defer.returnValue(result) @@ -45,6 +52,13 @@ class DHTHashAnnouncerTest(unittest.TestCase): self.supplier = MocSupplier(self.blobs_to_announce) self.announcer.add_supplier(self.supplier) + @defer.inlineCallbacks + def test_announce_fail(self): + # test what happens when node.announceHaveBlob() returns empty dict + self.dht_node.announce_will_fail = True + d = yield self.announcer._announce_available_hashes() + yield d + @defer.inlineCallbacks def test_basic(self): d = self.announcer._announce_available_hashes()