forked from LBRYCommunity/lbry-sdk
update tests
This commit is contained in:
parent
2e30ce9ae5
commit
0ab5dd28bc
5 changed files with 19 additions and 27 deletions
|
@ -15,6 +15,8 @@ from lbrynet.file_manager import EncryptedFileManager
|
|||
from lbrynet.tests import mocks
|
||||
from lbrynet.tests.util import mk_db_and_blob_dir, rm_db_and_blob_dir
|
||||
|
||||
from lbrynet.tests.mocks import Node
|
||||
|
||||
|
||||
class TestReflector(unittest.TestCase):
|
||||
def setUp(self):
|
||||
|
@ -61,7 +63,8 @@ class TestReflector(unittest.TestCase):
|
|||
use_upnp=False,
|
||||
wallet=wallet,
|
||||
blob_tracker_class=mocks.BlobAvailabilityTracker,
|
||||
external_ip="127.0.0.1"
|
||||
external_ip="127.0.0.1",
|
||||
dht_node_class=Node
|
||||
)
|
||||
|
||||
self.lbry_file_manager = EncryptedFileManager.EncryptedFileManager(self.session,
|
||||
|
@ -80,7 +83,8 @@ class TestReflector(unittest.TestCase):
|
|||
use_upnp=False,
|
||||
wallet=wallet,
|
||||
blob_tracker_class=mocks.BlobAvailabilityTracker,
|
||||
external_ip="127.0.0.1"
|
||||
external_ip="127.0.0.1",
|
||||
dht_node_class=Node
|
||||
)
|
||||
|
||||
self.server_blob_manager = BlobManager.DiskBlobManager(hash_announcer,
|
||||
|
@ -364,6 +368,7 @@ class TestReflector(unittest.TestCase):
|
|||
d.addCallback(lambda _: verify_stream_on_reflector())
|
||||
return d
|
||||
|
||||
|
||||
def iv_generator():
|
||||
iv = 0
|
||||
while True:
|
||||
|
|
|
@ -67,7 +67,7 @@ class TestStreamify(TestCase):
|
|||
blob_dir=self.blob_dir, peer_port=5553,
|
||||
use_upnp=False, rate_limiter=rate_limiter, wallet=wallet,
|
||||
blob_tracker_class=DummyBlobAvailabilityTracker,
|
||||
is_generous=self.is_generous, external_ip="127.0.0.1"
|
||||
is_generous=self.is_generous, external_ip="127.0.0.1", dht_node_class=mocks.Node
|
||||
)
|
||||
|
||||
self.lbry_file_manager = EncryptedFileManager(self.session, sd_identifier)
|
||||
|
@ -112,7 +112,7 @@ class TestStreamify(TestCase):
|
|||
self.session = Session(
|
||||
conf.ADJUSTABLE_SETTINGS['data_rate'][1], db_dir=self.db_dir, node_id="abcd",
|
||||
peer_finder=peer_finder, hash_announcer=hash_announcer,
|
||||
blob_dir=self.blob_dir, peer_port=5553,
|
||||
blob_dir=self.blob_dir, peer_port=5553, dht_node_class=mocks.Node,
|
||||
use_upnp=False, rate_limiter=rate_limiter, wallet=wallet,
|
||||
blob_tracker_class=DummyBlobAvailabilityTracker, external_ip="127.0.0.1"
|
||||
)
|
||||
|
|
|
@ -26,31 +26,18 @@ class MocDHTNode(object):
|
|||
defer.returnValue(result)
|
||||
|
||||
|
||||
class MocSupplier(object):
|
||||
def __init__(self, blobs_to_announce):
|
||||
self.blobs_to_announce = blobs_to_announce
|
||||
self.announced = False
|
||||
|
||||
def hashes_to_announce(self):
|
||||
if not self.announced:
|
||||
self.announced = True
|
||||
return defer.succeed(self.blobs_to_announce)
|
||||
else:
|
||||
return defer.succeed([])
|
||||
|
||||
def set_single_hash_announce_duration(self, seconds):
|
||||
pass
|
||||
|
||||
class DHTHashAnnouncerTest(unittest.TestCase):
|
||||
@defer.inlineCallbacks
|
||||
def setUp(self):
|
||||
self.num_blobs = 10
|
||||
self.blobs_to_announce = []
|
||||
for i in range(0, self.num_blobs):
|
||||
self.blobs_to_announce.append(random_lbry_hash())
|
||||
self.dht_node = MocDHTNode()
|
||||
self.announcer = DHTHashAnnouncer(self.dht_node, peer_port=3333)
|
||||
self.supplier = MocSupplier(self.blobs_to_announce)
|
||||
self.announcer.add_supplier(self.supplier)
|
||||
self.dht_node.peerPort = 3333
|
||||
self.dht_node.clock = reactor
|
||||
self.announcer = DHTHashAnnouncer(self.dht_node)
|
||||
yield self.announcer.add_hashes_to_announce(self.blobs_to_announce)
|
||||
|
||||
@defer.inlineCallbacks
|
||||
def test_announce_fail(self):
|
||||
|
|
|
@ -198,7 +198,7 @@ class NodeLookupTest(unittest.TestCase):
|
|||
h = hashlib.sha384()
|
||||
h.update('node1')
|
||||
node_id = str(h.digest())
|
||||
self.node = lbrynet.dht.node.Node(node_id, 4000, None, None, self._protocol)
|
||||
self.node = lbrynet.dht.node.Node(None, node_id=node_id, udpPort=4000, networkProtocol=self._protocol)
|
||||
self.updPort = 81173
|
||||
self.contactsAmount = 80
|
||||
# Reinitialise the routing table
|
||||
|
|
|
@ -2,16 +2,18 @@
|
|||
from Crypto.Cipher import AES
|
||||
import mock
|
||||
from twisted.trial import unittest
|
||||
from twisted.internet import defer
|
||||
from twisted.internet import defer, reactor
|
||||
|
||||
from lbrynet.database.storage import SQLiteStorage
|
||||
from lbrynet.core.StreamDescriptor import get_sd_info, BlobStreamDescriptorReader
|
||||
from lbrynet.core import BlobManager
|
||||
from lbrynet.core import Session
|
||||
from lbrynet.dht import hashannouncer
|
||||
from lbrynet.dht.node import Node
|
||||
from lbrynet.file_manager import EncryptedFileCreator
|
||||
from lbrynet.file_manager import EncryptedFileManager
|
||||
from lbrynet.tests import mocks
|
||||
from time import time
|
||||
from lbrynet.tests.util import mk_db_and_blob_dir, rm_db_and_blob_dir
|
||||
|
||||
MB = 2**20
|
||||
|
@ -32,10 +34,8 @@ class CreateEncryptedFileTest(unittest.TestCase):
|
|||
|
||||
self.session = mock.Mock(spec=Session.Session)(None, None)
|
||||
self.session.payment_rate_manager.min_blob_data_payment_rate = 0
|
||||
|
||||
hash_announcer = hashannouncer.DHTHashAnnouncer(None, None)
|
||||
self.blob_manager = BlobManager.DiskBlobManager(
|
||||
hash_announcer, self.tmp_blob_dir, SQLiteStorage(self.tmp_db_dir))
|
||||
hashannouncer.DummyHashAnnouncer(), self.tmp_blob_dir, SQLiteStorage(self.tmp_db_dir))
|
||||
self.session.blob_manager = self.blob_manager
|
||||
self.session.storage = self.session.blob_manager.storage
|
||||
self.file_manager = EncryptedFileManager.EncryptedFileManager(self.session, object())
|
||||
|
|
Loading…
Reference in a new issue