diff --git a/tests/unit/blob_exchange/test_transfer_blob.py b/tests/unit/blob_exchange/test_transfer_blob.py index b6339f375..8968116af 100644 --- a/tests/unit/blob_exchange/test_transfer_blob.py +++ b/tests/unit/blob_exchange/test_transfer_blob.py @@ -28,9 +28,10 @@ def mock_config(): class BlobExchangeTestBase(AsyncioTestCase): async def asyncSetUp(self): self.loop = asyncio.get_event_loop() - + self.client_wallet_dir = tempfile.mkdtemp() self.client_dir = tempfile.mkdtemp() self.server_dir = tempfile.mkdtemp() + self.addCleanup(shutil.rmtree, self.client_wallet_dir) self.addCleanup(shutil.rmtree, self.client_dir) self.addCleanup(shutil.rmtree, self.server_dir) self.server_config = Config(data_dir=self.server_dir, download_dir=self.server_dir, wallet=self.server_dir, @@ -39,8 +40,8 @@ class BlobExchangeTestBase(AsyncioTestCase): self.server_blob_manager = BlobManager(self.loop, self.server_dir, self.server_storage, self.server_config) self.server = BlobServer(self.loop, self.server_blob_manager, 'bQEaw42GXsgCAGio1nxFncJSyRmnztSCjP') - self.client_config = Config(data_dir=self.client_dir, download_dir=self.client_dir, wallet=self.client_dir, - fixed_peers=[]) + self.client_config = Config(data_dir=self.client_dir, download_dir=self.client_dir, + wallet=self.client_wallet_dir, fixed_peers=[]) self.client_storage = SQLiteStorage(self.client_config, os.path.join(self.client_dir, "lbrynet.sqlite")) self.client_blob_manager = BlobManager(self.loop, self.client_dir, self.client_storage, self.client_config) self.client_peer_manager = PeerManager(self.loop) diff --git a/tests/unit/stream/test_stream_manager.py b/tests/unit/stream/test_stream_manager.py index 8c17f61e4..fa307d65f 100644 --- a/tests/unit/stream/test_stream_manager.py +++ b/tests/unit/stream/test_stream_manager.py @@ -65,7 +65,7 @@ def get_claim_transaction(claim_name, claim=b''): ) -async def get_mock_wallet(sd_hash, storage, balance=10.0, fee=None): +async def get_mock_wallet(sd_hash, storage, wallet_dir, balance=10.0, fee=None): claim = Claim() if fee: if fee['currency'] == 'LBC': @@ -97,7 +97,7 @@ async def get_mock_wallet(sd_hash, storage, balance=10.0, fee=None): wallet = Wallet() ledger = Ledger({ - 'db': Database(':memory:'), + 'db': Database(os.path.join(wallet_dir, 'blockchain.db')), 'headers': FakeHeaders(514082) }) await ledger.db.open() @@ -136,7 +136,8 @@ class TestStreamManager(BlobExchangeTestBase): self.loop, self.server_blob_manager.blob_dir, file_path, old_sort=old_sort ) self.sd_hash = descriptor.sd_hash - self.mock_wallet, self.uri = await get_mock_wallet(self.sd_hash, self.client_storage, balance, fee) + self.mock_wallet, self.uri = await get_mock_wallet(self.sd_hash, self.client_storage, self.client_wallet_dir, + balance, fee) analytics_manager = AnalyticsManager( self.client_config, binascii.hexlify(generate_id()).decode(), diff --git a/tests/unit/wallet/test_transaction.py b/tests/unit/wallet/test_transaction.py index 7c0942cd0..c4cb22dcd 100644 --- a/tests/unit/wallet/test_transaction.py +++ b/tests/unit/wallet/test_transaction.py @@ -1,4 +1,7 @@ +import os import unittest +import tempfile +import shutil from binascii import hexlify, unhexlify from itertools import cycle @@ -302,9 +305,11 @@ class TestTransactionSigning(AsyncioTestCase): class TransactionIOBalancing(AsyncioTestCase): async def asyncSetUp(self): + wallet_dir = tempfile.mkdtemp() + self.addCleanup(shutil.rmtree, wallet_dir) self.ledger = Ledger({ - 'db': Database(':memory:'), - 'headers': Headers(':memory:') + 'db': Database(os.path.join(wallet_dir, 'blockchain.db')), + 'headers': Headers(':memory:'), }) await self.ledger.db.open() self.account = Account.from_dict(