diff --git a/tests/unit/test_bip32.py b/tests/unit/test_bip32.py index 2854da74b..5bd9fc407 100644 --- a/tests/unit/test_bip32.py +++ b/tests/unit/test_bip32.py @@ -1,7 +1,7 @@ from binascii import unhexlify from twisted.trial import unittest from torba.bip32 import PubKey, PrivateKey, from_extended_key_string -from torba.coin.bitcoinsegwit import MainNetLedger +from torba.coin.bitcoinsegwit import MainNetLedger as ledger_class class BIP32Tests(unittest.TestCase): @@ -40,7 +40,10 @@ class BIP32Tests(unittest.TestCase): with self.assertRaisesRegex(ValueError, 'private key must be 32 bytes'): PrivateKey(None, b'abcd', b'abcd'*8, 0, 255) private_key = PrivateKey( - MainNetLedger({'db': True}), + ledger_class({ + 'db': ledger_class.database_class(':memory:'), + 'headers': ledger_class.headers_class(':memory:'), + }), unhexlify('2423f3dc6087d9683f73a684935abc0ccd8bc26370588f56653128c6a6f0bf7c'), b'abcd'*8, 0, 1 ) @@ -57,7 +60,10 @@ class BIP32Tests(unittest.TestCase): self.assertIsInstance(private_key.child(PrivateKey.HARDENED), PrivateKey) def test_from_extended_keys(self): - ledger = MainNetLedger({'db': True}) + ledger = ledger_class({ + 'db': ledger_class.database_class(':memory:'), + 'headers': ledger_class.headers_class(':memory:'), + }) self.assertIsInstance( from_extended_key_string( ledger, diff --git a/tests/unit/test_coinselection.py b/tests/unit/test_coinselection.py index a8d11880f..b3b577ce8 100644 --- a/tests/unit/test_coinselection.py +++ b/tests/unit/test_coinselection.py @@ -1,7 +1,7 @@ from twisted.trial import unittest from types import GeneratorType -from torba.coin.bitcoinsegwit import MainNetLedger +from torba.coin.bitcoinsegwit import MainNetLedger as ledger_class from torba.coinselection import CoinSelector, MAXIMUM_TRIES from torba.constants import CENT @@ -19,8 +19,11 @@ def search(*args, **kwargs): class BaseSelectionTestCase(unittest.TestCase): def setUp(self): - self.ledger = MainNetLedger({'db': MainNetLedger.database_class(':memory:')}) - return self.ledger.db.start() + self.ledger = ledger_class({ + 'db': ledger_class.database_class(':memory:'), + 'headers': ledger_class.headers_class(':memory:'), + }) + return self.ledger.db.open() def estimates(self, *args): txos = args[0] if isinstance(args[0], (GeneratorType, list)) else args