示例#1
0
 async def test_verbose_failure():
     env = set_env()
     sut = Controller(env)
     sut.daemon_request = mock.Mock()
     sut.daemon_request.return_value = coro(
         raise_exception('some unhandled error'))
     await sut.transaction_get('ff' * 32, True)
示例#2
0
 async def test_verbose_ignore_by_backend():
     env = set_env()
     sut = Controller(env)
     sut.daemon_request = mock.Mock()
     sut.daemon_request.return_value = coro('11' * 32)
     res = await sut.transaction_get('ff' * 32, True)
     assert res == '11' * 32
示例#3
0
 async def test_no_verbose():
     env = set_env()
     sut = Controller(env)
     sut.daemon_request = mock.Mock()
     response = 'cafebabe' * 64
     sut.daemon_request.return_value = coro(response)
     res = await sut.transaction_get('ff' * 32)
     assert res == response
示例#4
0
    async def test_verbose_ok():
        env = set_env()
        sut = Controller(env)
        sut.daemon_request = mock.Mock()
        response = {"hex": "00" * 32, "blockhash": "ff" * 32}
        sut.daemon_request.return_value = coro(response)
        res = await sut.transaction_get('ff' * 32, True)
        assert res == response

        response = {"hex": "00" * 32, "blockhash": None}
        sut.daemon_request.return_value = coro(response)
        res = await sut.transaction_get('ff' * 32, True)
        assert res == response
def main():
    '''Set up logging and run the server.'''
    log_fmt = Env.default('LOG_FORMAT', '%(levelname)s:%(name)s:%(message)s')
    logging.basicConfig(level=logging.INFO, format=log_fmt)
    logging.info('ElectrumX server starting')
    try:
        controller = Controller(Env())
        controller.run()
    except Exception:
        traceback.print_exc()
        logging.critical('ElectrumX server terminated abnormally')
    else:
        logging.info('ElectrumX server terminated normally')
def main():
    '''Set up logging and run the server.'''
    log_fmt = Env.default('LOG_FORMAT', '%(levelname)s:%(name)s:%(message)s')
    handler = logging.StreamHandler(sys.stdout)
    handler.setFormatter(CompactFormatter(log_fmt))
    logger = make_logger('electrumx', handler=handler, level='INFO')

    logger.info('ElectrumX server starting')
    try:
        env = Env()
        logger.info(f'logging level: {env.log_level}')
        logger.setLevel(env.log_level)
        controller = Controller(env)
        controller.run()
    except Exception:
        traceback.print_exc()
        logger.critical('ElectrumX server terminated abnormally')
    else:
        logger.info('ElectrumX server terminated normally')
示例#7
0
 async def test_wrong_txhash():
     env = set_env()
     sut = Controller(env)
     sut.daemon_request = mock.Mock()
     await sut.transaction_get('cafe')
     sut.daemon_request.assert_not_called()