forked from LBRYCommunity/lbry-sdk
disabled cryptonator.com in tests, removed references to torba
This commit is contained in:
parent
26d0a7c742
commit
87c7ce588e
13 changed files with 27 additions and 130 deletions
|
@ -225,7 +225,7 @@ def ensure_directory_exists(path: str):
|
|||
pathlib.Path(path).mkdir(parents=True, exist_ok=True)
|
||||
|
||||
|
||||
LOG_MODULES = ('lbry', 'torba', 'aioupnp')
|
||||
LOG_MODULES = 'lbry', 'aioupnp'
|
||||
|
||||
|
||||
def setup_logging(logger: logging.Logger, args: argparse.Namespace, conf: Config):
|
||||
|
@ -241,7 +241,6 @@ def setup_logging(logger: logging.Logger, args: argparse.Namespace, conf: Config
|
|||
logger.getChild(module_name).addHandler(handler)
|
||||
|
||||
logger.getChild('lbry').setLevel(logging.INFO)
|
||||
logger.getChild('torba').setLevel(logging.INFO)
|
||||
logger.getChild('aioupnp').setLevel(logging.WARNING)
|
||||
logger.getChild('aiohttp').setLevel(logging.CRITICAL)
|
||||
|
||||
|
|
|
@ -145,7 +145,7 @@ class WalletComponent(Component):
|
|||
return result
|
||||
|
||||
async def start(self):
|
||||
log.info("Starting torba wallet")
|
||||
log.info("Starting wallet")
|
||||
self.wallet_manager = await LbryWalletManager.from_lbrynet_config(self.conf)
|
||||
await self.wallet_manager.start()
|
||||
|
||||
|
|
|
@ -856,8 +856,7 @@ class Daemon(metaclass=JSONRPCServerType):
|
|||
'platform': (str) platform string,
|
||||
'os_release': (str) os release string,
|
||||
'os_system': (str) os name,
|
||||
'lbrynet_version': (str) lbrynet version,
|
||||
'torba_version': (str) torba version,
|
||||
'version': (str) lbrynet version,
|
||||
'build': (str) "dev" | "qa" | "rc" | "release",
|
||||
}
|
||||
"""
|
||||
|
|
|
@ -4,6 +4,7 @@ import asyncio
|
|||
import logging
|
||||
from decimal import Decimal
|
||||
from typing import Optional, Iterable, Type
|
||||
from aiohttp.client_exceptions import ContentTypeError
|
||||
from lbry.error import InvalidExchangeRateResponseError, CurrencyConversionError
|
||||
from lbry.utils import aiohttp_request
|
||||
from lbry.wallet.dewies import lbc_to_dewies
|
||||
|
@ -58,7 +59,12 @@ class MarketFeed:
|
|||
|
||||
async def get_response(self):
|
||||
async with aiohttp_request('get', self.url, params=self.params, timeout=self.request_timeout) as response:
|
||||
self._last_response = await response.json()
|
||||
try:
|
||||
self._last_response = await response.json()
|
||||
except ContentTypeError as e:
|
||||
self._last_response = {}
|
||||
log.warning("Could not parse exchange rate response from %s: %s", self.name, e.message)
|
||||
log.debug(await response.text())
|
||||
return self._last_response
|
||||
|
||||
async def get_rate(self):
|
||||
|
|
|
@ -24,7 +24,7 @@ if typing.TYPE_CHECKING:
|
|||
from lbry.wallet import LbryWalletManager
|
||||
from lbry.wallet.transaction import Transaction
|
||||
from lbry.extras.daemon.exchange_rate_manager import ExchangeRateManager
|
||||
from torba.client.wallet import Wallet
|
||||
from lbry.wallet.client.wallet import Wallet
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
|
|
|
@ -218,7 +218,6 @@ class IntegrationTestCase(AsyncioTestCase):
|
|||
LEDGER = lbry.wallet
|
||||
MANAGER = LbryWalletManager
|
||||
ENABLE_SEGWIT = False
|
||||
VERBOSITY = logging.WARN
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super().__init__(*args, **kwargs)
|
||||
|
@ -232,7 +231,7 @@ class IntegrationTestCase(AsyncioTestCase):
|
|||
|
||||
async def asyncSetUp(self):
|
||||
self.conductor = Conductor(
|
||||
ledger_module=self.LEDGER, manager_module=self.MANAGER, verbosity=self.VERBOSITY,
|
||||
ledger_module=self.LEDGER, manager_module=self.MANAGER,
|
||||
enable_segwit=self.ENABLE_SEGWIT, seed=self.SEED
|
||||
)
|
||||
await self.conductor.start_blockchain()
|
||||
|
|
|
@ -1,89 +0,0 @@
|
|||
import logging
|
||||
import argparse
|
||||
import asyncio
|
||||
import aiohttp
|
||||
|
||||
from torba.orchstr8.node import Conductor, get_ledger_from_environment, get_blockchain_node_from_ledger
|
||||
from torba.orchstr8.service import ConductorService
|
||||
|
||||
|
||||
def get_argument_parser():
|
||||
parser = argparse.ArgumentParser(
|
||||
prog="torba"
|
||||
)
|
||||
subparsers = parser.add_subparsers(dest='command', help='sub-command help')
|
||||
|
||||
subparsers.add_parser("gui", help="Start Qt GUI.")
|
||||
|
||||
subparsers.add_parser("download", help="Download blockchain node binary.")
|
||||
|
||||
start = subparsers.add_parser("start", help="Start orchstr8 service.")
|
||||
start.add_argument("--blockchain", help="Start blockchain node.", action="store_true")
|
||||
start.add_argument("--spv", help="Start SPV server.", action="store_true")
|
||||
start.add_argument("--wallet", help="Start wallet daemon.", action="store_true")
|
||||
|
||||
generate = subparsers.add_parser("generate", help="Call generate method on running orchstr8 instance.")
|
||||
generate.add_argument("blocks", type=int, help="Number of blocks to generate")
|
||||
|
||||
subparsers.add_parser("transfer", help="Call transfer method on running orchstr8 instance.")
|
||||
return parser
|
||||
|
||||
|
||||
async def run_remote_command(command, **kwargs):
|
||||
async with aiohttp.ClientSession() as session:
|
||||
async with session.post('http://localhost:7954/'+command, data=kwargs) as resp:
|
||||
print(resp.status)
|
||||
print(await resp.text())
|
||||
|
||||
|
||||
def main():
|
||||
parser = get_argument_parser()
|
||||
args = parser.parse_args()
|
||||
command = getattr(args, 'command', 'help')
|
||||
|
||||
if command == 'gui':
|
||||
from torba.workbench import main as start_app # pylint: disable=import-outside-toplevel
|
||||
return start_app()
|
||||
|
||||
loop = asyncio.get_event_loop()
|
||||
ledger = get_ledger_from_environment()
|
||||
|
||||
if command == 'download':
|
||||
logging.getLogger('blockchain').setLevel(logging.INFO)
|
||||
get_blockchain_node_from_ledger(ledger).ensure()
|
||||
|
||||
elif command == 'generate':
|
||||
loop.run_until_complete(run_remote_command(
|
||||
'generate', blocks=args.blocks
|
||||
))
|
||||
|
||||
elif command == 'start':
|
||||
|
||||
conductor = Conductor()
|
||||
if getattr(args, 'blockchain', False):
|
||||
loop.run_until_complete(conductor.start_blockchain())
|
||||
if getattr(args, 'spv', False):
|
||||
loop.run_until_complete(conductor.start_spv())
|
||||
if getattr(args, 'wallet', False):
|
||||
loop.run_until_complete(conductor.start_wallet())
|
||||
|
||||
service = ConductorService(conductor, loop)
|
||||
loop.run_until_complete(service.start())
|
||||
|
||||
try:
|
||||
print('========== Orchstr8 API Service Started ========')
|
||||
loop.run_forever()
|
||||
except KeyboardInterrupt:
|
||||
pass
|
||||
finally:
|
||||
loop.run_until_complete(service.stop())
|
||||
loop.run_until_complete(conductor.stop())
|
||||
|
||||
loop.close()
|
||||
|
||||
else:
|
||||
parser.print_help()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
|
@ -80,7 +80,7 @@ def normalize_text(seed):
|
|||
def load_words(language_name):
|
||||
if language_name == 'english':
|
||||
return english.words
|
||||
language_module = importlib.import_module('torba.words.'+language_name)
|
||||
language_module = importlib.import_module('lbry.wallet.client.words.'+language_name)
|
||||
return list(map(
|
||||
lambda s: unicodedata.normalize('NFKD', s),
|
||||
language_module.words
|
||||
|
|
|
@ -11,7 +11,7 @@ from lbry.wallet.orchstr8.service import ConductorService
|
|||
|
||||
def get_argument_parser():
|
||||
parser = argparse.ArgumentParser(
|
||||
prog="torba"
|
||||
prog="orchstr8"
|
||||
)
|
||||
subparsers = parser.add_subparsers(dest='command', help='sub-command help')
|
||||
|
||||
|
|
|
@ -48,25 +48,9 @@ def get_blockchain_node_from_ledger(ledger_module):
|
|||
)
|
||||
|
||||
|
||||
def set_logging(ledger_module, level, handler=None):
|
||||
modules = [
|
||||
'torba',
|
||||
'torba.client',
|
||||
'torba.server',
|
||||
'blockchain',
|
||||
ledger_module.__name__
|
||||
]
|
||||
for module_name in modules:
|
||||
module = logging.getLogger(module_name)
|
||||
module.setLevel(level)
|
||||
if handler is not None:
|
||||
module.addHandler(handler)
|
||||
|
||||
|
||||
class Conductor:
|
||||
|
||||
def __init__(self, ledger_module=None, manager_module=None, verbosity=logging.WARNING,
|
||||
enable_segwit=False, seed=None):
|
||||
def __init__(self, ledger_module=None, manager_module=None, enable_segwit=False, seed=None):
|
||||
self.ledger_module = ledger_module or get_ledger_from_environment()
|
||||
self.manager_module = manager_module or get_manager_from_environment()
|
||||
self.spv_module = get_spvserver_from_ledger(self.ledger_module)
|
||||
|
@ -78,8 +62,6 @@ class Conductor:
|
|||
self.manager_module, self.ledger_module.RegTestLedger, default_seed=seed
|
||||
)
|
||||
|
||||
set_logging(self.ledger_module, verbosity)
|
||||
|
||||
self.blockchain_started = False
|
||||
self.spv_started = False
|
||||
self.wallet_started = False
|
||||
|
|
|
@ -4,7 +4,7 @@ from aiohttp.web import Application, WebSocketResponse, json_response
|
|||
from aiohttp.http_websocket import WSMsgType, WSCloseCode
|
||||
|
||||
from lbry.wallet.client.util import satoshis_to_coins
|
||||
from .node import Conductor, set_logging
|
||||
from .node import Conductor
|
||||
|
||||
|
||||
PORT = 7954
|
||||
|
@ -58,9 +58,9 @@ class ConductorService:
|
|||
await self.app.cleanup()
|
||||
|
||||
async def start_stack(self, _):
|
||||
set_logging(
|
||||
self.stack.ledger_module, logging.DEBUG, WebSocketLogHandler(self.send_message)
|
||||
)
|
||||
#set_logging(
|
||||
# self.stack.ledger_module, logging.DEBUG, WebSocketLogHandler(self.send_message)
|
||||
#)
|
||||
self.stack.blockchain_started or await self.stack.start_blockchain()
|
||||
self.send_message({'type': 'service', 'name': 'blockchain', 'port': self.stack.blockchain_node.port})
|
||||
self.stack.spv_started or await self.stack.start_spv()
|
||||
|
|
|
@ -2,8 +2,8 @@ import logging
|
|||
import traceback
|
||||
import argparse
|
||||
import importlib
|
||||
from torba.server.env import Env
|
||||
from torba.server.server import Server
|
||||
from lbry.wallet.server.env import Env
|
||||
from lbry.wallet.server.server import Server
|
||||
|
||||
|
||||
def get_argument_parser():
|
||||
|
@ -26,15 +26,15 @@ def main():
|
|||
args = parser.parse_args()
|
||||
coin_class = get_coin_class(args.spvserver)
|
||||
logging.basicConfig(level=logging.INFO)
|
||||
logging.info('torba.server starting')
|
||||
logging.info('lbry.server starting')
|
||||
try:
|
||||
server = Server(Env(coin_class))
|
||||
server.run()
|
||||
except Exception:
|
||||
traceback.print_exc()
|
||||
logging.critical('torba.server terminated abnormally')
|
||||
logging.critical('lbry.server terminated abnormally')
|
||||
else:
|
||||
logging.info('torba.server terminated normally')
|
||||
logging.info('lbry.server terminated normally')
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
|
|
@ -1,12 +1,13 @@
|
|||
from decimal import Decimal
|
||||
from lbry.testcase import AsyncioTestCase
|
||||
from lbry.extras.daemon.exchange_rate_manager import ExchangeRate, ExchangeRateManager
|
||||
from lbry.extras.daemon.exchange_rate_manager import ExchangeRate, ExchangeRateManager, FEEDS
|
||||
|
||||
|
||||
class TestExchangeRateManager(AsyncioTestCase):
|
||||
|
||||
async def test_exchange_rate_manager(self):
|
||||
manager = ExchangeRateManager()
|
||||
# TODO: re-enable cryptonator.com
|
||||
manager = ExchangeRateManager(FEEDS[:-2])
|
||||
manager.start()
|
||||
self.addCleanup(manager.stop)
|
||||
for feed in manager.market_feeds:
|
||||
|
|
Loading…
Reference in a new issue