diff --git a/tests/unit/wallet/test_account.py b/tests/unit/wallet/test_account.py index a9b41d180..d754071f3 100644 --- a/tests/unit/wallet/test_account.py +++ b/tests/unit/wallet/test_account.py @@ -1,14 +1,14 @@ -from lbry.testcase import AsyncioTestCase -from lbry.blockchain import Ledger +from lbry import Config, Ledger from lbry.db import Database, tables from lbry.wallet import Account, SingleKey, HierarchicalDeterministic +from lbry.testcase import AsyncioTestCase class AccountTestCase(AsyncioTestCase): async def asyncSetUp(self): - self.ledger = Ledger() - self.db = Database(self.ledger, 'sqlite:///:memory:') + self.ledger = Ledger(Config.with_null_dir().set(db_url='sqlite:///:memory:')) + self.db = Database(self.ledger) await self.db.open() self.addCleanup(self.db.close) @@ -350,8 +350,8 @@ class AccountEncryptionTests(AccountTestCase): 'address_generator': {'name': 'single-address'} } - def test_encrypt_wallet(self): - account = Account.from_dict(self.ledger, self.db, self.unencrypted_account) + async def test_encrypt_wallet(self): + account = await Account.from_dict(self.ledger, self.db, self.unencrypted_account) account.init_vectors = { 'seed': self.init_vector, 'private_key': self.init_vector @@ -398,11 +398,11 @@ class AccountEncryptionTests(AccountTestCase): self.assertEqual(account.to_dict()['seed'], self.unencrypted_account['seed']) self.assertEqual(account.to_dict()['private_key'], self.unencrypted_account['private_key']) - def test_encrypt_decrypt_read_only_account(self): + async def test_encrypt_decrypt_read_only_account(self): account_data = self.unencrypted_account.copy() del account_data['seed'] del account_data['private_key'] - account = Account.from_dict(self.ledger, self.db, account_data) + account = await Account.from_dict(self.ledger, self.db, account_data) encrypted = account.to_dict('password') self.assertFalse(encrypted['seed']) self.assertFalse(encrypted['private_key']) diff --git a/tests/unit/wallet/test_coinselection.py b/tests/unit/wallet/test_coinselection.py index cfd007132..d2605d565 100644 --- a/tests/unit/wallet/test_coinselection.py +++ b/tests/unit/wallet/test_coinselection.py @@ -1,10 +1,12 @@ from unittest import TestCase from types import GeneratorType -from lbry.blockchain import Ledger +from lbry import Config, Ledger from lbry.constants import CENT from lbry.testcase import get_output as utxo -from lbry.wallet.coinselection import CoinSelector, OutputEffectiveAmountEstimator, MAXIMUM_TRIES +from lbry.wallet.coinselection import ( + CoinSelector, OutputEffectiveAmountEstimator, MAXIMUM_TRIES +) def search(*args, **kwargs): @@ -15,7 +17,7 @@ def search(*args, **kwargs): class BaseSelectionTestCase(TestCase): def setUp(self): - self.ledger = Ledger() + self.ledger = Ledger(Config.with_null_dir()) def estimates(self, *args): txos = args[0] if isinstance(args[0], (GeneratorType, list)) else args diff --git a/tests/unit/wallet/test_manager.py b/tests/unit/wallet/test_manager.py index a2e33d2aa..f699dd6e8 100644 --- a/tests/unit/wallet/test_manager.py +++ b/tests/unit/wallet/test_manager.py @@ -2,12 +2,8 @@ import os import shutil import tempfile - +from lbry import Config, Ledger, Database, WalletManager, Wallet, Account from lbry.testcase import AsyncioTestCase -from lbry.blockchain.ledger import Ledger -from lbry.wallet import WalletManager, Wallet, Account -from lbry.db import Database -from lbry.conf import Config class TestWalletManager(AsyncioTestCase): @@ -15,10 +11,10 @@ class TestWalletManager(AsyncioTestCase): async def asyncSetUp(self): self.temp_dir = tempfile.mkdtemp() self.addCleanup(shutil.rmtree, self.temp_dir) - self.ledger = Ledger(Config( - wallet_dir=self.temp_dir + self.ledger = Ledger(Config.with_same_dir(self.temp_dir).set( + db_url="sqlite:///:memory:" )) - self.db = Database.from_memory(self.ledger) + self.db = Database(self.ledger) async def test_ensure_path_exists(self): wm = WalletManager(self.ledger, self.db) diff --git a/tests/unit/wallet/test_wallet.py b/tests/unit/wallet/test_wallet.py index 0bd288a0c..087004877 100644 --- a/tests/unit/wallet/test_wallet.py +++ b/tests/unit/wallet/test_wallet.py @@ -2,20 +2,17 @@ import tempfile from binascii import hexlify from unittest import TestCase, mock +from lbry import Config, Database, Ledger, Account, Wallet, WalletManager from lbry.testcase import AsyncioTestCase -from lbry.db import Database -from lbry.blockchain.ledger import Ledger -from lbry.wallet.manager import WalletManager -from lbry.wallet.wallet import ( - Account, Wallet, WalletStorage, TimestampedPreferences -) +from lbry.wallet.storage import WalletStorage +from lbry.wallet.preferences import TimestampedPreferences class WalletTestCase(AsyncioTestCase): async def asyncSetUp(self): - self.ledger = Ledger() - self.db = Database(self.ledger, 'sqlite:///:memory:') + self.ledger = Ledger(Config.with_null_dir()) + self.db = Database(self.ledger, "sqlite:///:memory:") await self.db.open() self.addCleanup(self.db.close)