Merge pull request #899 from lbryio/small_test_fix

fix bug found in test_EncryptedFileCreator.py,
This commit is contained in:
Umpei Kay Kurokawa 2017-09-13 14:23:48 -04:00 committed by GitHub
commit 216d5cd4d0

View file

@ -17,7 +17,6 @@ from tests.util import mk_db_and_blob_dir, rm_db_and_blob_dir
MB = 2**20 MB = 2**20
def iv_generator(): def iv_generator():
while True: while True:
yield '3' * AES.block_size yield '3' * AES.block_size
@ -34,18 +33,20 @@ class CreateEncryptedFileTest(unittest.TestCase):
yield self.blob_manager.stop() yield self.blob_manager.stop()
rm_db_and_blob_dir(self.tmp_db_dir, self.tmp_blob_dir) rm_db_and_blob_dir(self.tmp_db_dir, self.tmp_blob_dir)
@defer.inlineCallbacks
def create_file(self, filename): def create_file(self, filename):
session = mock.Mock(spec=Session.Session)(None, None) session = mock.Mock(spec=Session.Session)(None, None)
hash_announcer = DHTHashAnnouncer.DHTHashAnnouncer(None, None) hash_announcer = DHTHashAnnouncer.DHTHashAnnouncer(None, None)
self.blob_manager = BlobManager.DiskBlobManager(hash_announcer, self.tmp_blob_dir, self.tmp_db_dir) self.blob_manager = BlobManager.DiskBlobManager(hash_announcer, self.tmp_blob_dir, self.tmp_db_dir)
session.blob_manager = self.blob_manager session.blob_manager = self.blob_manager
session.blob_manager.setup() yield session.blob_manager.setup()
session.db_dir = self.tmp_db_dir session.db_dir = self.tmp_db_dir
manager = mock.Mock(spec=EncryptedFileManager.EncryptedFileManager)() manager = mock.Mock(spec=EncryptedFileManager.EncryptedFileManager)()
handle = mocks.GenFile(3*MB, '1') handle = mocks.GenFile(3*MB, '1')
key = '2'*AES.block_size key = '2'*AES.block_size
return EncryptedFileCreator.create_lbry_file( out = yield EncryptedFileCreator.create_lbry_file(
session, manager, filename, handle, key, iv_generator()) session, manager, filename, handle, key, iv_generator())
defer.returnValue(out)
def test_can_create_file(self): def test_can_create_file(self):
expected_stream_hash = ('41e6b247d923d191b154fb6f1b8529d6ddd6a73d65c357b1acb7' expected_stream_hash = ('41e6b247d923d191b154fb6f1b8529d6ddd6a73d65c357b1acb7'