conslidated testcase
This commit is contained in:
parent
e8750275c9
commit
3ccfc09e01
49 changed files with 303 additions and 309 deletions
|
@ -47,7 +47,7 @@ Code | Name | Message
|
|||
401 | TransactionRejected | Transaction rejected, unknown reason.
|
||||
402 | TransactionFeeTooLow | Fee too low.
|
||||
403 | TransactionInvalidSignature | Invalid signature.
|
||||
404 | InsufficientFunds | Insufficient funds. -- determined by wallet prior to attempting to broadcast a tx; this is different for example from a TX being created and sent but then rejected by lbrycrd for unspendable utxos.
|
||||
404 | InsufficientFunds | Not enough funds to cover this transaction. -- determined by wallet prior to attempting to broadcast a tx; this is different for example from a TX being created and sent but then rejected by lbrycrd for unspendable utxos.
|
||||
405 | ChannelKeyNotFound | Channel signing key not found.
|
||||
406 | ChannelKeyInvalid | Channel signing key is out of date. -- For example, channel was updated but you don't have the updated key.
|
||||
407 | DataDownload | Failed to download blob. *generic*
|
||||
|
|
|
@ -161,7 +161,7 @@ class InsufficientFundsError(WalletError):
|
|||
"""
|
||||
|
||||
def __init__(self):
|
||||
super().__init__("Insufficient funds.")
|
||||
super().__init__("Not enough funds to cover this transaction.")
|
||||
|
||||
|
||||
class ChannelKeyNotFoundError(WalletError):
|
||||
|
|
|
@ -1,18 +1,33 @@
|
|||
import os
|
||||
import sys
|
||||
import json
|
||||
import shutil
|
||||
import tempfile
|
||||
import logging
|
||||
import tempfile
|
||||
import functools
|
||||
import asyncio
|
||||
from asyncio.runners import _cancel_all_tasks # type: ignore
|
||||
import unittest
|
||||
from unittest.case import _Outcome
|
||||
from typing import Optional
|
||||
from time import time
|
||||
from binascii import unhexlify
|
||||
from functools import partial
|
||||
|
||||
from lbry.wallet.testcase import IntegrationTestCase, WalletNode
|
||||
|
||||
import lbry.wallet
|
||||
from lbry.conf import Config
|
||||
from lbry.extras.daemon.Daemon import Daemon, jsonrpc_dumps_pretty
|
||||
from lbry.wallet import LbryWalletManager
|
||||
from lbry.wallet.account import Account
|
||||
from lbry.wallet.orchstr8 import Conductor
|
||||
from lbry.wallet.transaction import Transaction
|
||||
from lbry.wallet.client.wallet import Wallet
|
||||
from lbry.wallet.client.util import satoshis_to_coins
|
||||
from lbry.wallet.orchstr8.node import BlockchainNode, WalletNode
|
||||
from lbry.wallet.client.baseledger import BaseLedger
|
||||
from lbry.wallet.client.baseaccount import BaseAccount
|
||||
from lbry.wallet.client.basemanager import BaseWalletManager
|
||||
|
||||
from lbry.extras.daemon.Daemon import Daemon, jsonrpc_dumps_pretty
|
||||
from lbry.extras.daemon.Components import Component, WalletComponent
|
||||
from lbry.extras.daemon.Components import (
|
||||
DHT_COMPONENT, HASH_ANNOUNCER_COMPONENT, PEER_PROTOCOL_SERVER_COMPONENT,
|
||||
|
@ -28,6 +43,236 @@ from lbry.stream.reflector.server import ReflectorServer
|
|||
from lbry.blob_exchange.server import BlobServer
|
||||
|
||||
|
||||
class ColorHandler(logging.StreamHandler):
|
||||
|
||||
level_color = {
|
||||
logging.DEBUG: "black",
|
||||
logging.INFO: "light_gray",
|
||||
logging.WARNING: "yellow",
|
||||
logging.ERROR: "red"
|
||||
}
|
||||
|
||||
color_code = dict(
|
||||
black=30,
|
||||
red=31,
|
||||
green=32,
|
||||
yellow=33,
|
||||
blue=34,
|
||||
magenta=35,
|
||||
cyan=36,
|
||||
white=37,
|
||||
light_gray='0;37',
|
||||
dark_gray='1;30'
|
||||
)
|
||||
|
||||
def emit(self, record):
|
||||
try:
|
||||
msg = self.format(record)
|
||||
color_name = self.level_color.get(record.levelno, "black")
|
||||
color_code = self.color_code[color_name]
|
||||
stream = self.stream
|
||||
stream.write(f'\x1b[{color_code}m{msg}\x1b[0m')
|
||||
stream.write(self.terminator)
|
||||
self.flush()
|
||||
except Exception:
|
||||
self.handleError(record)
|
||||
|
||||
|
||||
HANDLER = ColorHandler(sys.stdout)
|
||||
HANDLER.setFormatter(
|
||||
logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
|
||||
)
|
||||
logging.getLogger().addHandler(HANDLER)
|
||||
|
||||
|
||||
class AsyncioTestCase(unittest.TestCase):
|
||||
# Implementation inspired by discussion:
|
||||
# https://bugs.python.org/issue32972
|
||||
|
||||
LOOP_SLOW_CALLBACK_DURATION = 0.2
|
||||
|
||||
maxDiff = None
|
||||
|
||||
async def asyncSetUp(self): # pylint: disable=C0103
|
||||
pass
|
||||
|
||||
async def asyncTearDown(self): # pylint: disable=C0103
|
||||
pass
|
||||
|
||||
def run(self, result=None): # pylint: disable=R0915
|
||||
orig_result = result
|
||||
if result is None:
|
||||
result = self.defaultTestResult()
|
||||
startTestRun = getattr(result, 'startTestRun', None) # pylint: disable=C0103
|
||||
if startTestRun is not None:
|
||||
startTestRun()
|
||||
|
||||
result.startTest(self)
|
||||
|
||||
testMethod = getattr(self, self._testMethodName) # pylint: disable=C0103
|
||||
if (getattr(self.__class__, "__unittest_skip__", False) or
|
||||
getattr(testMethod, "__unittest_skip__", False)):
|
||||
# If the class or method was skipped.
|
||||
try:
|
||||
skip_why = (getattr(self.__class__, '__unittest_skip_why__', '')
|
||||
or getattr(testMethod, '__unittest_skip_why__', ''))
|
||||
self._addSkip(result, self, skip_why)
|
||||
finally:
|
||||
result.stopTest(self)
|
||||
return
|
||||
expecting_failure_method = getattr(testMethod,
|
||||
"__unittest_expecting_failure__", False)
|
||||
expecting_failure_class = getattr(self,
|
||||
"__unittest_expecting_failure__", False)
|
||||
expecting_failure = expecting_failure_class or expecting_failure_method
|
||||
outcome = _Outcome(result)
|
||||
|
||||
self.loop = asyncio.new_event_loop() # pylint: disable=W0201
|
||||
asyncio.set_event_loop(self.loop)
|
||||
self.loop.set_debug(True)
|
||||
self.loop.slow_callback_duration = self.LOOP_SLOW_CALLBACK_DURATION
|
||||
|
||||
try:
|
||||
self._outcome = outcome
|
||||
|
||||
with outcome.testPartExecutor(self):
|
||||
self.setUp()
|
||||
self.loop.run_until_complete(self.asyncSetUp())
|
||||
if outcome.success:
|
||||
outcome.expecting_failure = expecting_failure
|
||||
with outcome.testPartExecutor(self, isTest=True):
|
||||
maybe_coroutine = testMethod()
|
||||
if asyncio.iscoroutine(maybe_coroutine):
|
||||
self.loop.run_until_complete(maybe_coroutine)
|
||||
outcome.expecting_failure = False
|
||||
with outcome.testPartExecutor(self):
|
||||
self.loop.run_until_complete(self.asyncTearDown())
|
||||
self.tearDown()
|
||||
|
||||
self.doAsyncCleanups()
|
||||
|
||||
try:
|
||||
_cancel_all_tasks(self.loop)
|
||||
self.loop.run_until_complete(self.loop.shutdown_asyncgens())
|
||||
finally:
|
||||
asyncio.set_event_loop(None)
|
||||
self.loop.close()
|
||||
|
||||
for test, reason in outcome.skipped:
|
||||
self._addSkip(result, test, reason)
|
||||
self._feedErrorsToResult(result, outcome.errors)
|
||||
if outcome.success:
|
||||
if expecting_failure:
|
||||
if outcome.expectedFailure:
|
||||
self._addExpectedFailure(result, outcome.expectedFailure)
|
||||
else:
|
||||
self._addUnexpectedSuccess(result)
|
||||
else:
|
||||
result.addSuccess(self)
|
||||
return result
|
||||
finally:
|
||||
result.stopTest(self)
|
||||
if orig_result is None:
|
||||
stopTestRun = getattr(result, 'stopTestRun', None) # pylint: disable=C0103
|
||||
if stopTestRun is not None:
|
||||
stopTestRun() # pylint: disable=E1102
|
||||
|
||||
# explicitly break reference cycles:
|
||||
# outcome.errors -> frame -> outcome -> outcome.errors
|
||||
# outcome.expectedFailure -> frame -> outcome -> outcome.expectedFailure
|
||||
outcome.errors.clear()
|
||||
outcome.expectedFailure = None
|
||||
|
||||
# clear the outcome, no more needed
|
||||
self._outcome = None
|
||||
|
||||
def doAsyncCleanups(self): # pylint: disable=C0103
|
||||
outcome = self._outcome or _Outcome()
|
||||
while self._cleanups:
|
||||
function, args, kwargs = self._cleanups.pop()
|
||||
with outcome.testPartExecutor(self):
|
||||
maybe_coroutine = function(*args, **kwargs)
|
||||
if asyncio.iscoroutine(maybe_coroutine):
|
||||
self.loop.run_until_complete(maybe_coroutine)
|
||||
|
||||
|
||||
class AdvanceTimeTestCase(AsyncioTestCase):
|
||||
|
||||
async def asyncSetUp(self):
|
||||
self._time = 0 # pylint: disable=W0201
|
||||
self.loop.time = functools.wraps(self.loop.time)(lambda: self._time)
|
||||
await super().asyncSetUp()
|
||||
|
||||
async def advance(self, seconds):
|
||||
while self.loop._ready:
|
||||
await asyncio.sleep(0)
|
||||
self._time += seconds
|
||||
await asyncio.sleep(0)
|
||||
while self.loop._ready:
|
||||
await asyncio.sleep(0)
|
||||
|
||||
|
||||
class IntegrationTestCase(AsyncioTestCase):
|
||||
|
||||
SEED = None
|
||||
LEDGER = lbry.wallet
|
||||
MANAGER = LbryWalletManager
|
||||
ENABLE_SEGWIT = False
|
||||
VERBOSITY = logging.WARN
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super().__init__(*args, **kwargs)
|
||||
self.conductor: Optional[Conductor] = None
|
||||
self.blockchain: Optional[BlockchainNode] = None
|
||||
self.wallet_node: Optional[WalletNode] = None
|
||||
self.manager: Optional[BaseWalletManager] = None
|
||||
self.ledger: Optional[BaseLedger] = None
|
||||
self.wallet: Optional[Wallet] = None
|
||||
self.account: Optional[BaseAccount] = None
|
||||
|
||||
async def asyncSetUp(self):
|
||||
self.conductor = Conductor(
|
||||
ledger_module=self.LEDGER, manager_module=self.MANAGER, verbosity=self.VERBOSITY,
|
||||
enable_segwit=self.ENABLE_SEGWIT, seed=self.SEED
|
||||
)
|
||||
await self.conductor.start_blockchain()
|
||||
self.addCleanup(self.conductor.stop_blockchain)
|
||||
await self.conductor.start_spv()
|
||||
self.addCleanup(self.conductor.stop_spv)
|
||||
await self.conductor.start_wallet()
|
||||
self.addCleanup(self.conductor.stop_wallet)
|
||||
self.blockchain = self.conductor.blockchain_node
|
||||
self.wallet_node = self.conductor.wallet_node
|
||||
self.manager = self.wallet_node.manager
|
||||
self.ledger = self.wallet_node.ledger
|
||||
self.wallet = self.wallet_node.wallet
|
||||
self.account = self.wallet_node.wallet.default_account
|
||||
|
||||
async def assertBalance(self, account, expected_balance: str): # pylint: disable=C0103
|
||||
balance = await account.get_balance()
|
||||
self.assertEqual(satoshis_to_coins(balance), expected_balance)
|
||||
|
||||
def broadcast(self, tx):
|
||||
return self.ledger.broadcast(tx)
|
||||
|
||||
async def on_header(self, height):
|
||||
if self.ledger.headers.height < height:
|
||||
await self.ledger.on_header.where(
|
||||
lambda e: e.height == height
|
||||
)
|
||||
return True
|
||||
|
||||
def on_transaction_id(self, txid, ledger=None):
|
||||
return (ledger or self.ledger).on_transaction.where(
|
||||
lambda e: e.tx.id == txid
|
||||
)
|
||||
|
||||
def on_transaction_address(self, tx, address):
|
||||
return self.ledger.on_transaction.where(
|
||||
lambda e: e.tx.id == tx.id and e.address == address
|
||||
)
|
||||
|
||||
|
||||
class FakeExchangeRateManager(ExchangeRateManager):
|
||||
|
||||
def __init__(self, market_feeds, rates):
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import struct
|
||||
import binascii
|
||||
from lbry.wallet.client.hash import double_sha256
|
||||
from lbry.crypto.hash import double_sha256
|
||||
|
||||
|
||||
class InvalidProofError(Exception):
|
||||
|
|
|
@ -10,7 +10,7 @@ from lbry.wallet.client.constants import COIN, NULL_HASH32
|
|||
from lbry.wallet.client.bcd_data_stream import BCDataStream
|
||||
from lbry.wallet.client.hash import TXRef, TXRefImmutable
|
||||
from lbry.wallet.client.util import ReadOnlyList
|
||||
from lbry.wallet.client.errors import InsufficientFundsError
|
||||
from lbry.error import InsufficientFundsError
|
||||
|
||||
if typing.TYPE_CHECKING:
|
||||
from lbry.wallet.client import baseledger, wallet as basewallet
|
||||
|
@ -514,7 +514,7 @@ class BaseTransaction:
|
|||
deficit = cost - payment
|
||||
spendables = await ledger.get_spendable_utxos(deficit, funding_accounts)
|
||||
if not spendables:
|
||||
raise InsufficientFundsError('Not enough funds to cover this transaction.')
|
||||
raise InsufficientFundsError()
|
||||
payment += sum(s.effective_amount for s in spendables)
|
||||
tx.add_inputs(s.txi for s in spendables)
|
||||
|
||||
|
|
|
@ -1,2 +0,0 @@
|
|||
class InsufficientFundsError(Exception):
|
||||
pass
|
|
@ -1,248 +0,0 @@
|
|||
import sys
|
||||
import logging
|
||||
import functools
|
||||
import asyncio
|
||||
from asyncio.runners import _cancel_all_tasks # type: ignore
|
||||
import unittest
|
||||
from unittest.case import _Outcome
|
||||
from typing import Optional
|
||||
|
||||
import lbry.wallet
|
||||
from lbry.wallet.orchstr8 import Conductor
|
||||
from lbry.wallet.orchstr8.node import BlockchainNode, WalletNode
|
||||
from lbry.wallet.client.baseledger import BaseLedger
|
||||
from lbry.wallet.client.baseaccount import BaseAccount
|
||||
from lbry.wallet.client.basemanager import BaseWalletManager
|
||||
from lbry.wallet.client.wallet import Wallet
|
||||
from lbry.wallet.client.util import satoshis_to_coins
|
||||
from lbry.wallet import LbryWalletManager
|
||||
|
||||
|
||||
class ColorHandler(logging.StreamHandler):
|
||||
|
||||
level_color = {
|
||||
logging.DEBUG: "black",
|
||||
logging.INFO: "light_gray",
|
||||
logging.WARNING: "yellow",
|
||||
logging.ERROR: "red"
|
||||
}
|
||||
|
||||
color_code = dict(
|
||||
black=30,
|
||||
red=31,
|
||||
green=32,
|
||||
yellow=33,
|
||||
blue=34,
|
||||
magenta=35,
|
||||
cyan=36,
|
||||
white=37,
|
||||
light_gray='0;37',
|
||||
dark_gray='1;30'
|
||||
)
|
||||
|
||||
def emit(self, record):
|
||||
try:
|
||||
msg = self.format(record)
|
||||
color_name = self.level_color.get(record.levelno, "black")
|
||||
color_code = self.color_code[color_name]
|
||||
stream = self.stream
|
||||
stream.write(f'\x1b[{color_code}m{msg}\x1b[0m')
|
||||
stream.write(self.terminator)
|
||||
self.flush()
|
||||
except Exception:
|
||||
self.handleError(record)
|
||||
|
||||
|
||||
HANDLER = ColorHandler(sys.stdout)
|
||||
HANDLER.setFormatter(
|
||||
logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
|
||||
)
|
||||
logging.getLogger().addHandler(HANDLER)
|
||||
|
||||
|
||||
class AsyncioTestCase(unittest.TestCase):
|
||||
# Implementation inspired by discussion:
|
||||
# https://bugs.python.org/issue32972
|
||||
|
||||
LOOP_SLOW_CALLBACK_DURATION = 0.2
|
||||
|
||||
maxDiff = None
|
||||
|
||||
async def asyncSetUp(self): # pylint: disable=C0103
|
||||
pass
|
||||
|
||||
async def asyncTearDown(self): # pylint: disable=C0103
|
||||
pass
|
||||
|
||||
def run(self, result=None): # pylint: disable=R0915
|
||||
orig_result = result
|
||||
if result is None:
|
||||
result = self.defaultTestResult()
|
||||
startTestRun = getattr(result, 'startTestRun', None) # pylint: disable=C0103
|
||||
if startTestRun is not None:
|
||||
startTestRun()
|
||||
|
||||
result.startTest(self)
|
||||
|
||||
testMethod = getattr(self, self._testMethodName) # pylint: disable=C0103
|
||||
if (getattr(self.__class__, "__unittest_skip__", False) or
|
||||
getattr(testMethod, "__unittest_skip__", False)):
|
||||
# If the class or method was skipped.
|
||||
try:
|
||||
skip_why = (getattr(self.__class__, '__unittest_skip_why__', '')
|
||||
or getattr(testMethod, '__unittest_skip_why__', ''))
|
||||
self._addSkip(result, self, skip_why)
|
||||
finally:
|
||||
result.stopTest(self)
|
||||
return
|
||||
expecting_failure_method = getattr(testMethod,
|
||||
"__unittest_expecting_failure__", False)
|
||||
expecting_failure_class = getattr(self,
|
||||
"__unittest_expecting_failure__", False)
|
||||
expecting_failure = expecting_failure_class or expecting_failure_method
|
||||
outcome = _Outcome(result)
|
||||
|
||||
self.loop = asyncio.new_event_loop() # pylint: disable=W0201
|
||||
asyncio.set_event_loop(self.loop)
|
||||
self.loop.set_debug(True)
|
||||
self.loop.slow_callback_duration = self.LOOP_SLOW_CALLBACK_DURATION
|
||||
|
||||
try:
|
||||
self._outcome = outcome
|
||||
|
||||
with outcome.testPartExecutor(self):
|
||||
self.setUp()
|
||||
self.loop.run_until_complete(self.asyncSetUp())
|
||||
if outcome.success:
|
||||
outcome.expecting_failure = expecting_failure
|
||||
with outcome.testPartExecutor(self, isTest=True):
|
||||
maybe_coroutine = testMethod()
|
||||
if asyncio.iscoroutine(maybe_coroutine):
|
||||
self.loop.run_until_complete(maybe_coroutine)
|
||||
outcome.expecting_failure = False
|
||||
with outcome.testPartExecutor(self):
|
||||
self.loop.run_until_complete(self.asyncTearDown())
|
||||
self.tearDown()
|
||||
|
||||
self.doAsyncCleanups()
|
||||
|
||||
try:
|
||||
_cancel_all_tasks(self.loop)
|
||||
self.loop.run_until_complete(self.loop.shutdown_asyncgens())
|
||||
finally:
|
||||
asyncio.set_event_loop(None)
|
||||
self.loop.close()
|
||||
|
||||
for test, reason in outcome.skipped:
|
||||
self._addSkip(result, test, reason)
|
||||
self._feedErrorsToResult(result, outcome.errors)
|
||||
if outcome.success:
|
||||
if expecting_failure:
|
||||
if outcome.expectedFailure:
|
||||
self._addExpectedFailure(result, outcome.expectedFailure)
|
||||
else:
|
||||
self._addUnexpectedSuccess(result)
|
||||
else:
|
||||
result.addSuccess(self)
|
||||
return result
|
||||
finally:
|
||||
result.stopTest(self)
|
||||
if orig_result is None:
|
||||
stopTestRun = getattr(result, 'stopTestRun', None) # pylint: disable=C0103
|
||||
if stopTestRun is not None:
|
||||
stopTestRun() # pylint: disable=E1102
|
||||
|
||||
# explicitly break reference cycles:
|
||||
# outcome.errors -> frame -> outcome -> outcome.errors
|
||||
# outcome.expectedFailure -> frame -> outcome -> outcome.expectedFailure
|
||||
outcome.errors.clear()
|
||||
outcome.expectedFailure = None
|
||||
|
||||
# clear the outcome, no more needed
|
||||
self._outcome = None
|
||||
|
||||
def doAsyncCleanups(self): # pylint: disable=C0103
|
||||
outcome = self._outcome or _Outcome()
|
||||
while self._cleanups:
|
||||
function, args, kwargs = self._cleanups.pop()
|
||||
with outcome.testPartExecutor(self):
|
||||
maybe_coroutine = function(*args, **kwargs)
|
||||
if asyncio.iscoroutine(maybe_coroutine):
|
||||
self.loop.run_until_complete(maybe_coroutine)
|
||||
|
||||
|
||||
class AdvanceTimeTestCase(AsyncioTestCase):
|
||||
|
||||
async def asyncSetUp(self):
|
||||
self._time = 0 # pylint: disable=W0201
|
||||
self.loop.time = functools.wraps(self.loop.time)(lambda: self._time)
|
||||
await super().asyncSetUp()
|
||||
|
||||
async def advance(self, seconds):
|
||||
while self.loop._ready:
|
||||
await asyncio.sleep(0)
|
||||
self._time += seconds
|
||||
await asyncio.sleep(0)
|
||||
while self.loop._ready:
|
||||
await asyncio.sleep(0)
|
||||
|
||||
|
||||
class IntegrationTestCase(AsyncioTestCase):
|
||||
|
||||
SEED = None
|
||||
LEDGER = lbry.wallet
|
||||
MANAGER = LbryWalletManager
|
||||
ENABLE_SEGWIT = False
|
||||
VERBOSITY = logging.WARN
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super().__init__(*args, **kwargs)
|
||||
self.conductor: Optional[Conductor] = None
|
||||
self.blockchain: Optional[BlockchainNode] = None
|
||||
self.wallet_node: Optional[WalletNode] = None
|
||||
self.manager: Optional[BaseWalletManager] = None
|
||||
self.ledger: Optional[BaseLedger] = None
|
||||
self.wallet: Optional[Wallet] = None
|
||||
self.account: Optional[BaseAccount] = None
|
||||
|
||||
async def asyncSetUp(self):
|
||||
self.conductor = Conductor(
|
||||
ledger_module=self.LEDGER, manager_module=self.MANAGER, verbosity=self.VERBOSITY,
|
||||
enable_segwit=self.ENABLE_SEGWIT, seed=self.SEED
|
||||
)
|
||||
await self.conductor.start_blockchain()
|
||||
self.addCleanup(self.conductor.stop_blockchain)
|
||||
await self.conductor.start_spv()
|
||||
self.addCleanup(self.conductor.stop_spv)
|
||||
await self.conductor.start_wallet()
|
||||
self.addCleanup(self.conductor.stop_wallet)
|
||||
self.blockchain = self.conductor.blockchain_node
|
||||
self.wallet_node = self.conductor.wallet_node
|
||||
self.manager = self.wallet_node.manager
|
||||
self.ledger = self.wallet_node.ledger
|
||||
self.wallet = self.wallet_node.wallet
|
||||
self.account = self.wallet_node.wallet.default_account
|
||||
|
||||
async def assertBalance(self, account, expected_balance: str): # pylint: disable=C0103
|
||||
balance = await account.get_balance()
|
||||
self.assertEqual(satoshis_to_coins(balance), expected_balance)
|
||||
|
||||
def broadcast(self, tx):
|
||||
return self.ledger.broadcast(tx)
|
||||
|
||||
async def on_header(self, height):
|
||||
if self.ledger.headers.height < height:
|
||||
await self.ledger.on_header.where(
|
||||
lambda e: e.height == height
|
||||
)
|
||||
return True
|
||||
|
||||
def on_transaction_id(self, txid, ledger=None):
|
||||
return (ledger or self.ledger).on_transaction.where(
|
||||
lambda e: e.tx.id == txid
|
||||
)
|
||||
|
||||
def on_transaction_address(self, tx, address):
|
||||
return self.ledger.on_transaction.where(
|
||||
lambda e: e.tx.id == tx.id and e.address == address
|
||||
)
|
|
@ -28,7 +28,7 @@ setup(
|
|||
entry_points={
|
||||
'console_scripts': [
|
||||
'lbrynet=lbry.extras.cli:main',
|
||||
'torba-server=torba.server.cli:main',
|
||||
'torba-server=lbry.wallet.server.cli:main',
|
||||
],
|
||||
},
|
||||
install_requires=[
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import logging
|
||||
from lbry.wallet.testcase import IntegrationTestCase
|
||||
from lbry.testcase import IntegrationTestCase
|
||||
|
||||
|
||||
class BlockchainReorganizationTests(IntegrationTestCase):
|
||||
|
|
|
@ -5,7 +5,7 @@ from binascii import unhexlify
|
|||
from urllib.request import urlopen
|
||||
|
||||
|
||||
from lbry.wallet.client.errors import InsufficientFundsError
|
||||
from lbry.error import InsufficientFundsError
|
||||
|
||||
from lbry.extras.daemon.Daemon import DEFAULT_PAGE_SIZE
|
||||
from lbry.testcase import CommandTestCase
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import contextlib
|
||||
from io import StringIO
|
||||
from lbry.wallet.testcase import AsyncioTestCase
|
||||
from lbry.testcase import AsyncioTestCase
|
||||
|
||||
from lbry.conf import Config
|
||||
from lbry.extras import cli
|
||||
|
|
|
@ -7,7 +7,7 @@ from lbry.dht import constants
|
|||
from lbry.dht.node import Node
|
||||
from lbry.dht import peer as dht_peer
|
||||
from lbry.dht.peer import PeerManager, make_kademlia_peer
|
||||
from lbry.wallet.testcase import AsyncioTestCase
|
||||
from lbry.testcase import AsyncioTestCase
|
||||
|
||||
|
||||
class DHTIntegrationTest(AsyncioTestCase):
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
from decimal import Decimal
|
||||
from lbry.wallet.testcase import AsyncioTestCase
|
||||
from lbry.testcase import AsyncioTestCase
|
||||
from lbry.extras.daemon.exchange_rate_manager import ExchangeRate, ExchangeRateManager
|
||||
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import asyncio
|
||||
|
||||
from lbry.wallet.testcase import IntegrationTestCase
|
||||
from lbry.testcase import IntegrationTestCase
|
||||
|
||||
import lbry.wallet
|
||||
from lbry.schema.claim import Claim
|
||||
|
|
|
@ -8,7 +8,7 @@ from unittest.mock import Mock
|
|||
from lbry.wallet.client.basenetwork import BaseNetwork
|
||||
from lbry.wallet.orchstr8.node import SPVNode
|
||||
from lbry.wallet.rpc import RPCSession
|
||||
from lbry.wallet.testcase import IntegrationTestCase, AsyncioTestCase
|
||||
from lbry.testcase import IntegrationTestCase, AsyncioTestCase
|
||||
|
||||
|
||||
class NetworkTests(IntegrationTestCase):
|
||||
|
|
|
@ -5,7 +5,8 @@ from binascii import hexlify, unhexlify
|
|||
from lbry.testcase import CommandTestCase
|
||||
from lbry.wallet.transaction import Transaction, Output
|
||||
from lbry.schema.compat import OldClaimMessage
|
||||
from lbry.wallet.client.hash import sha256, Base58
|
||||
from lbry.crypto.hash import sha256
|
||||
from lbry.crypto.base58 import Base58
|
||||
|
||||
|
||||
class BaseResolveTestCase(CommandTestCase):
|
||||
|
|
|
@ -1,10 +1,9 @@
|
|||
import logging
|
||||
import asyncio
|
||||
import random
|
||||
from itertools import chain
|
||||
|
||||
from lbry.wallet.transaction import Transaction, Output, Input
|
||||
from lbry.wallet.testcase import IntegrationTestCase
|
||||
from lbry.testcase import IntegrationTestCase
|
||||
from lbry.wallet.client.util import satoshis_to_coins, coins_to_satoshis
|
||||
|
||||
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
import lbry.wallet
|
||||
from lbry.extras.daemon import analytics
|
||||
|
||||
import unittest
|
||||
|
|
|
@ -2,7 +2,7 @@ import asyncio
|
|||
import tempfile
|
||||
import shutil
|
||||
import os
|
||||
from torba.testcase import AsyncioTestCase
|
||||
from lbry.testcase import AsyncioTestCase
|
||||
from lbry.error import InvalidDataError, InvalidBlobHashError
|
||||
from lbry.conf import Config
|
||||
from lbry.extras.daemon.storage import SQLiteStorage
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
import asyncio
|
||||
import tempfile
|
||||
import shutil
|
||||
import os
|
||||
from torba.testcase import AsyncioTestCase
|
||||
from lbry.testcase import AsyncioTestCase
|
||||
from lbry.conf import Config
|
||||
from lbry.extras.daemon.storage import SQLiteStorage
|
||||
from lbry.blob.blob_manager import BlobManager
|
||||
|
|
|
@ -6,7 +6,7 @@ import shutil
|
|||
import os
|
||||
|
||||
from lbry.blob_exchange.serialization import BlobRequest
|
||||
from torba.testcase import AsyncioTestCase
|
||||
from lbry.testcase import AsyncioTestCase
|
||||
from lbry.conf import Config
|
||||
from lbry.extras.daemon.storage import SQLiteStorage
|
||||
from lbry.blob.blob_manager import BlobManager
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
from torba.testcase import AsyncioTestCase
|
||||
from lbry.testcase import AsyncioTestCase
|
||||
import hashlib
|
||||
from lbry.extras.daemon.comment_client import sign_comment
|
||||
from lbry.extras.daemon.comment_client import is_comment_signed_by_channel
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import asyncio
|
||||
from torba.testcase import AsyncioTestCase, AdvanceTimeTestCase
|
||||
from lbry.testcase import AsyncioTestCase, AdvanceTimeTestCase
|
||||
|
||||
from lbry.conf import Config
|
||||
from lbry.extras.daemon.ComponentManager import ComponentManager
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import unittest
|
||||
import asyncio
|
||||
from lbry import utils
|
||||
from torba.testcase import AsyncioTestCase
|
||||
from lbry.testcase import AsyncioTestCase
|
||||
|
||||
|
||||
class CompareVersionTest(unittest.TestCase):
|
||||
|
|
|
@ -4,7 +4,7 @@ import unittest
|
|||
import asyncio
|
||||
import logging
|
||||
import hashlib
|
||||
from torba.testcase import AsyncioTestCase
|
||||
from lbry.testcase import AsyncioTestCase
|
||||
from lbry.conf import Config
|
||||
from lbry.extras.daemon.storage import SQLiteStorage
|
||||
from lbry.blob.blob_info import BlobInfo
|
||||
|
|
|
@ -4,7 +4,7 @@ from lbry.utils import generate_id
|
|||
from lbry.dht.protocol.routing_table import KBucket
|
||||
from lbry.dht.peer import PeerManager, make_kademlia_peer
|
||||
from lbry.dht import constants
|
||||
from torba.testcase import AsyncioTestCase
|
||||
from lbry.testcase import AsyncioTestCase
|
||||
|
||||
|
||||
def address_generator(address=(1, 2, 3, 4)):
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import asyncio
|
||||
import binascii
|
||||
from torba.testcase import AsyncioTestCase
|
||||
from lbry.testcase import AsyncioTestCase
|
||||
from tests import dht_mocks
|
||||
from lbry.dht.serialization.bencoding import bencode, bdecode
|
||||
from lbry.dht import constants
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import asyncio
|
||||
from torba.testcase import AsyncioTestCase
|
||||
from lbry.testcase import AsyncioTestCase
|
||||
from tests import dht_mocks
|
||||
from lbry.dht import constants
|
||||
from lbry.dht.node import Node
|
||||
|
|
|
@ -3,7 +3,7 @@ import typing
|
|||
import binascii
|
||||
import socket
|
||||
import asyncio
|
||||
from torba.testcase import AsyncioTestCase
|
||||
from lbry.testcase import AsyncioTestCase
|
||||
from tests import dht_mocks
|
||||
from lbry.conf import Config
|
||||
from lbry.dht import constants
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import asyncio
|
||||
import unittest
|
||||
import typing
|
||||
from torba.testcase import AsyncioTestCase
|
||||
from lbry.testcase import AsyncioTestCase
|
||||
from tests import dht_mocks
|
||||
from lbry.conf import Config
|
||||
from lbry.dht import constants
|
||||
|
|
|
@ -2,7 +2,7 @@ import asyncio
|
|||
import unittest
|
||||
from lbry.utils import generate_id
|
||||
from lbry.dht.peer import PeerManager, make_kademlia_peer
|
||||
from torba.testcase import AsyncioTestCase
|
||||
from lbry.testcase import AsyncioTestCase
|
||||
|
||||
|
||||
class PeerTest(AsyncioTestCase):
|
||||
|
|
|
@ -2,6 +2,7 @@ import unittest
|
|||
from unittest import mock
|
||||
import json
|
||||
|
||||
import lbry.wallet
|
||||
from lbry.conf import Config
|
||||
from lbry.extras.daemon.storage import SQLiteStorage
|
||||
from lbry.extras.daemon.ComponentManager import ComponentManager
|
||||
|
@ -11,7 +12,7 @@ from lbry.extras.daemon.Components import UPNP_COMPONENT, BLOB_COMPONENT
|
|||
from lbry.extras.daemon.Components import PEER_PROTOCOL_SERVER_COMPONENT, EXCHANGE_RATE_MANAGER_COMPONENT
|
||||
from lbry.extras.daemon.Daemon import Daemon as LBRYDaemon
|
||||
from lbry.wallet import LbryWalletManager
|
||||
from torba.client.wallet import Wallet
|
||||
from lbry.wallet.client.wallet import Wallet
|
||||
|
||||
from tests import test_utils
|
||||
# from tests.mocks import mock_conf_settings, FakeNetwork, FakeFileManager
|
||||
|
|
|
@ -8,8 +8,7 @@ from lbry.extras.daemon.exchange_rate_manager import (
|
|||
CryptonatorFeed, CryptonatorBTCFeed,
|
||||
BittrexFeed,
|
||||
)
|
||||
from torba.testcase import AsyncioTestCase
|
||||
from lbry.testcase import FakeExchangeRateManager, get_fake_exchange_rate_manager
|
||||
from lbry.testcase import AsyncioTestCase, FakeExchangeRateManager, get_fake_exchange_rate_manager
|
||||
from lbry.error import InvalidExchangeRateResponseError
|
||||
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@ import os
|
|||
import asyncio
|
||||
import tempfile
|
||||
import shutil
|
||||
from torba.testcase import AsyncioTestCase
|
||||
from lbry.testcase import AsyncioTestCase
|
||||
from lbry.conf import Config
|
||||
from lbry.extras.daemon.storage import SQLiteStorage
|
||||
from lbry.blob.blob_manager import BlobManager
|
||||
|
|
|
@ -5,7 +5,7 @@ import shutil
|
|||
import json
|
||||
|
||||
from lbry.blob.blob_file import BlobFile
|
||||
from torba.testcase import AsyncioTestCase
|
||||
from lbry.testcase import AsyncioTestCase
|
||||
from lbry.conf import Config
|
||||
from lbry.error import InvalidStreamDescriptorError
|
||||
from lbry.extras.daemon.storage import SQLiteStorage
|
||||
|
|
|
@ -8,11 +8,11 @@ from decimal import Decimal
|
|||
from tests.unit.blob_exchange.test_transfer_blob import BlobExchangeTestBase
|
||||
from lbry.testcase import get_fake_exchange_rate_manager
|
||||
from lbry.utils import generate_id
|
||||
from torba.client.errors import InsufficientFundsError
|
||||
from lbry.error import InsufficientFundsError
|
||||
from lbry.error import KeyFeeAboveMaxAllowedError, ResolveError, DownloadSDTimeoutError, DownloadDataTimeoutError
|
||||
from torba.client.wallet import Wallet
|
||||
from torba.client.constants import CENT, NULL_HASH32
|
||||
from torba.client.basenetwork import ClientSession
|
||||
from lbry.wallet.client.wallet import Wallet
|
||||
from lbry.wallet.client.constants import CENT, NULL_HASH32
|
||||
from lbry.wallet.client.basenetwork import ClientSession
|
||||
from lbry.conf import Config
|
||||
from lbry.wallet.ledger import MainNetLedger
|
||||
from lbry.wallet.transaction import Transaction, Input, Output
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
from binascii import hexlify
|
||||
from lbry.wallet.testcase import AsyncioTestCase
|
||||
from lbry.testcase import AsyncioTestCase
|
||||
from lbry.wallet.client.wallet import Wallet
|
||||
from lbry.wallet.ledger import MainNetLedger, WalletDatabase
|
||||
from lbry.wallet.header import Headers
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
from binascii import unhexlify, hexlify
|
||||
|
||||
from lbry.wallet.testcase import AsyncioTestCase
|
||||
from lbry.testcase import AsyncioTestCase
|
||||
|
||||
from tests.unit.wallet.key_fixtures import expected_ids, expected_privkeys, expected_hardened_privkeys
|
||||
from lbry.wallet.client.bip32 import PubKey, PrivateKey, from_extended_key_string
|
||||
|
|
|
@ -2,7 +2,7 @@ import unittest
|
|||
from binascii import hexlify, unhexlify
|
||||
|
||||
from lbry.wallet.claim_proofs import get_hash_for_outpoint, verify_proof
|
||||
from lbry.wallet.client.hash import double_sha256
|
||||
from lbry.crypto.hash import double_sha256
|
||||
|
||||
|
||||
class ClaimProofsTestCase(unittest.TestCase):
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
from types import GeneratorType
|
||||
|
||||
from lbry.wallet.testcase import AsyncioTestCase
|
||||
from lbry.testcase import AsyncioTestCase
|
||||
|
||||
from lbry.wallet import MainNetLedger as ledger_class
|
||||
from lbry.wallet.client.coinselection import CoinSelector, MAXIMUM_TRIES
|
||||
|
|
|
@ -11,8 +11,8 @@ from lbry.wallet.transaction import Transaction
|
|||
from lbry.wallet.client.wallet import Wallet
|
||||
from lbry.wallet.client.constants import COIN
|
||||
from lbry.wallet.client.basedatabase import query, interpolate, constraints_to_sql, AIOSQLite
|
||||
from lbry.wallet.client.hash import sha256
|
||||
from lbry.wallet.testcase import AsyncioTestCase
|
||||
from lbry.crypto.hash import sha256
|
||||
from lbry.testcase import AsyncioTestCase
|
||||
|
||||
from tests.unit.wallet.test_transaction import get_output, NULL_HASH
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
from unittest import TestCase, mock
|
||||
from lbry.wallet.client.hash import aes_decrypt, aes_encrypt, better_aes_decrypt, better_aes_encrypt
|
||||
from lbry.wallet.client.errors import InvalidPasswordError
|
||||
from lbry.crypto.crypt import aes_decrypt, aes_encrypt, better_aes_decrypt, better_aes_encrypt
|
||||
from lbry.error import InvalidPasswordError
|
||||
|
||||
|
||||
class TestAESEncryptDecrypt(TestCase):
|
||||
|
|
|
@ -3,9 +3,9 @@ import asyncio
|
|||
import tempfile
|
||||
from binascii import hexlify, unhexlify
|
||||
|
||||
from lbry.wallet.client.hash import sha256
|
||||
from lbry.crypto.hash import sha256
|
||||
from lbry.wallet.client.util import ArithUint256
|
||||
from lbry.wallet.testcase import AsyncioTestCase
|
||||
from lbry.testcase import AsyncioTestCase
|
||||
from lbry.wallet.ledger import Headers
|
||||
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import os
|
||||
from binascii import hexlify
|
||||
|
||||
from lbry.wallet.testcase import AsyncioTestCase
|
||||
from lbry.testcase import AsyncioTestCase
|
||||
from lbry.wallet.client.wallet import Wallet
|
||||
from lbry.wallet.account import Account
|
||||
from lbry.wallet.transaction import Transaction, Output, Input
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
from binascii import unhexlify
|
||||
|
||||
from lbry.wallet.testcase import AsyncioTestCase
|
||||
from lbry.testcase import AsyncioTestCase
|
||||
from lbry.wallet.client.constants import CENT, NULL_HASH32
|
||||
|
||||
from lbry.wallet.ledger import MainNetLedger
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
from lbry.wallet.stream import StreamController
|
||||
from lbry.wallet.tasks import TaskGroup
|
||||
from lbry.wallet.testcase import AsyncioTestCase
|
||||
from lbry.testcase import AsyncioTestCase
|
||||
|
||||
|
||||
class StreamControllerTestCase(AsyncioTestCase):
|
||||
|
|
|
@ -2,7 +2,7 @@ import unittest
|
|||
from binascii import hexlify, unhexlify
|
||||
from itertools import cycle
|
||||
|
||||
from lbry.wallet.testcase import AsyncioTestCase
|
||||
from lbry.testcase import AsyncioTestCase
|
||||
from lbry.wallet.client.constants import CENT, COIN, NULL_HASH32
|
||||
from lbry.wallet.client.wallet import Wallet
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@ import tempfile
|
|||
from binascii import hexlify
|
||||
|
||||
from unittest import TestCase, mock
|
||||
from lbry.wallet.testcase import AsyncioTestCase
|
||||
from lbry.testcase import AsyncioTestCase
|
||||
|
||||
from lbry.wallet.ledger import MainNetLedger, RegTestLedger
|
||||
from lbry.wallet.client.basemanager import BaseWalletManager
|
||||
|
|
|
@ -4,7 +4,6 @@ envlist = py37-integration
|
|||
[testenv]
|
||||
deps =
|
||||
coverage
|
||||
../torba
|
||||
|
||||
extras = test
|
||||
changedir = {toxinidir}/tests
|
||||
|
|
Loading…
Reference in a new issue