forked from LBRYCommunity/lbry-sdk
fixing wallet unit tests test_ledger.py and test_transactions.py
This commit is contained in:
parent
2b5e3204c0
commit
5afd446bb3
2 changed files with 28 additions and 34 deletions
|
@ -1,45 +1,25 @@
|
|||
from twisted.internet import defer
|
||||
from twisted.trial import unittest
|
||||
from lbrynet import conf
|
||||
from lbrynet.wallet.account import Account
|
||||
from lbrynet.wallet.database import WalletDatabase
|
||||
from lbrynet.wallet.transaction import Transaction, Output, Input
|
||||
from lbrynet.wallet.ledger import MainNetLedger
|
||||
from torba.wallet import Wallet
|
||||
|
||||
|
||||
class MockHeaders:
|
||||
def __init__(self, ledger):
|
||||
self.ledger = ledger
|
||||
self.height = 1
|
||||
|
||||
def __len__(self):
|
||||
return self.height
|
||||
|
||||
def __getitem__(self, height):
|
||||
return {'merkle_root': 'abcd04'}
|
||||
|
||||
|
||||
class MainNetTestLedger(MainNetLedger):
|
||||
headers_class = MockHeaders
|
||||
network_name = 'unittest'
|
||||
|
||||
def __init__(self):
|
||||
super(MainNetLedger, self).__init__({
|
||||
'db': WalletDatabase(':memory:')
|
||||
})
|
||||
|
||||
|
||||
class LedgerTestCase(unittest.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
conf.initialize_settings(False)
|
||||
self.ledger = MainNetTestLedger()
|
||||
super().setUp()
|
||||
self.ledger = MainNetLedger({
|
||||
'db': MainNetLedger.database_class(':memory:'),
|
||||
'headers': MainNetLedger.headers_class(':memory:')
|
||||
})
|
||||
self.account = Account.generate(self.ledger, Wallet(), "lbryum")
|
||||
return self.ledger.db.start()
|
||||
return self.ledger.db.open()
|
||||
|
||||
def tearDown(self):
|
||||
return self.ledger.db.stop()
|
||||
super().tearDown()
|
||||
return self.ledger.db.close()
|
||||
|
||||
|
||||
class BasicAccountingTests(LedgerTestCase):
|
||||
|
|
|
@ -5,11 +5,8 @@ from twisted.internet import defer
|
|||
from torba.constants import CENT, COIN, NULL_HASH32
|
||||
from torba.wallet import Wallet
|
||||
|
||||
from lbrynet.wallet.account import Account
|
||||
from lbrynet.wallet.ledger import MainNetLedger
|
||||
from lbrynet.wallet.database import WalletDatabase
|
||||
from lbrynet.wallet.transaction import Transaction, Output, Input
|
||||
from lbrynet.wallet.manager import LbryWalletManager
|
||||
|
||||
|
||||
FEE_PER_BYTE = 50
|
||||
|
@ -41,7 +38,16 @@ def get_claim_transaction(claim_name, claim=b''):
|
|||
class TestSizeAndFeeEstimation(unittest.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
self.ledger = MainNetLedger({'db': WalletDatabase(':memory:')})
|
||||
super().setUp()
|
||||
self.ledger = MainNetLedger({
|
||||
'db': MainNetLedger.database_class(':memory:'),
|
||||
'headers': MainNetLedger.headers_class(':memory:')
|
||||
})
|
||||
return self.ledger.db.open()
|
||||
|
||||
def tearDown(self):
|
||||
super().tearDown()
|
||||
return self.ledger.db.close()
|
||||
|
||||
def test_output_size_and_fee(self):
|
||||
txo = get_output()
|
||||
|
@ -216,8 +222,16 @@ class TestTransactionSerialization(unittest.TestCase):
|
|||
class TestTransactionSigning(unittest.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
self.ledger = MainNetLedger({'db': WalletDatabase(':memory:')})
|
||||
return self.ledger.db.start()
|
||||
super().setUp()
|
||||
self.ledger = MainNetLedger({
|
||||
'db': MainNetLedger.database_class(':memory:'),
|
||||
'headers': MainNetLedger.headers_class(':memory:')
|
||||
})
|
||||
return self.ledger.db.open()
|
||||
|
||||
def tearDown(self):
|
||||
super().tearDown()
|
||||
return self.ledger.db.close()
|
||||
|
||||
@defer.inlineCallbacks
|
||||
def test_sign(self):
|
||||
|
|
Loading…
Reference in a new issue