update tests
This commit is contained in:
parent
6dbea6f4ab
commit
9d34e027f3
3 changed files with 15 additions and 8 deletions
|
@ -28,9 +28,10 @@ def mock_config():
|
||||||
class BlobExchangeTestBase(AsyncioTestCase):
|
class BlobExchangeTestBase(AsyncioTestCase):
|
||||||
async def asyncSetUp(self):
|
async def asyncSetUp(self):
|
||||||
self.loop = asyncio.get_event_loop()
|
self.loop = asyncio.get_event_loop()
|
||||||
|
self.client_wallet_dir = tempfile.mkdtemp()
|
||||||
self.client_dir = tempfile.mkdtemp()
|
self.client_dir = tempfile.mkdtemp()
|
||||||
self.server_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.client_dir)
|
||||||
self.addCleanup(shutil.rmtree, self.server_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,
|
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_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.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,
|
self.client_config = Config(data_dir=self.client_dir, download_dir=self.client_dir,
|
||||||
fixed_peers=[])
|
wallet=self.client_wallet_dir, fixed_peers=[])
|
||||||
self.client_storage = SQLiteStorage(self.client_config, os.path.join(self.client_dir, "lbrynet.sqlite"))
|
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_blob_manager = BlobManager(self.loop, self.client_dir, self.client_storage, self.client_config)
|
||||||
self.client_peer_manager = PeerManager(self.loop)
|
self.client_peer_manager = PeerManager(self.loop)
|
||||||
|
|
|
@ -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()
|
claim = Claim()
|
||||||
if fee:
|
if fee:
|
||||||
if fee['currency'] == 'LBC':
|
if fee['currency'] == 'LBC':
|
||||||
|
@ -97,7 +97,7 @@ async def get_mock_wallet(sd_hash, storage, balance=10.0, fee=None):
|
||||||
|
|
||||||
wallet = Wallet()
|
wallet = Wallet()
|
||||||
ledger = Ledger({
|
ledger = Ledger({
|
||||||
'db': Database(':memory:'),
|
'db': Database(os.path.join(wallet_dir, 'blockchain.db')),
|
||||||
'headers': FakeHeaders(514082)
|
'headers': FakeHeaders(514082)
|
||||||
})
|
})
|
||||||
await ledger.db.open()
|
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.loop, self.server_blob_manager.blob_dir, file_path, old_sort=old_sort
|
||||||
)
|
)
|
||||||
self.sd_hash = descriptor.sd_hash
|
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(
|
analytics_manager = AnalyticsManager(
|
||||||
self.client_config,
|
self.client_config,
|
||||||
binascii.hexlify(generate_id()).decode(),
|
binascii.hexlify(generate_id()).decode(),
|
||||||
|
|
|
@ -1,4 +1,7 @@
|
||||||
|
import os
|
||||||
import unittest
|
import unittest
|
||||||
|
import tempfile
|
||||||
|
import shutil
|
||||||
from binascii import hexlify, unhexlify
|
from binascii import hexlify, unhexlify
|
||||||
from itertools import cycle
|
from itertools import cycle
|
||||||
|
|
||||||
|
@ -302,9 +305,11 @@ class TestTransactionSigning(AsyncioTestCase):
|
||||||
class TransactionIOBalancing(AsyncioTestCase):
|
class TransactionIOBalancing(AsyncioTestCase):
|
||||||
|
|
||||||
async def asyncSetUp(self):
|
async def asyncSetUp(self):
|
||||||
|
wallet_dir = tempfile.mkdtemp()
|
||||||
|
self.addCleanup(shutil.rmtree, wallet_dir)
|
||||||
self.ledger = Ledger({
|
self.ledger = Ledger({
|
||||||
'db': Database(':memory:'),
|
'db': Database(os.path.join(wallet_dir, 'blockchain.db')),
|
||||||
'headers': Headers(':memory:')
|
'headers': Headers(':memory:'),
|
||||||
})
|
})
|
||||||
await self.ledger.db.open()
|
await self.ledger.db.open()
|
||||||
self.account = Account.from_dict(
|
self.account = Account.from_dict(
|
||||||
|
|
Loading…
Add table
Reference in a new issue