# Path: bitcoinlib/encoding.py
# def to_hexstring(string):
#     """
#     Convert bytes, string to a hexadecimal string. Use instead of built-in hex() method if format
#     of input string is not known.
# 
#     >>> to_hexstring(b'\\x12\\xaa\\xdd')
#     '12aadd'
# 
#     :param string: Variable to convert to hex string
#     :type string: bytes, str
# 
#     :return: hexstring
#     """
#     if not string:
#         return ''
#     try:
#         bytes.fromhex(string)
#         return string
#     except (ValueError, TypeError):
#         pass
# 
#     if not isinstance(string, bytes):
#         string = bytes(string, 'utf8')
#     return string.hex()
# 
# Path: tests/test_custom.py
# class CustomAssertions:
# 
#     def assertDictEqualExt(self, result_dict, expected_dict, none_allowed=None):
#         """
#         Compare dictionaries, skip items not found in expected dictionary.
# 
#         Lists and recursion's in dictionaries are allowed.
# 
#         :param result_dict: First dictionary with results
#         :type result_dict: dict
#         :param expected_dict: Second dictionary with expected values
#         :type expected_dict: dict
#         :param none_allowed: List of fields for which None value in result_dict is allowed
#         :type none_allowed: list
# 
#         :return bool: Dictionaries are identical?
#         """
#         if none_allowed is None:
#             none_allowed = []
#         if not isinstance(expected_dict, dict):
#             if expected_dict == result_dict:
#                 return True
#             else:
#                 raise AssertionError("Different value for %s != %s" % (result_dict, expected_dict))
#         expected_keys = expected_dict.keys()
#         for k in result_dict:
#             if k not in expected_keys:
#                 continue
#             if isinstance(result_dict[k], dict):
#                 self.assertDictEqualExt(result_dict[k], expected_dict[k], none_allowed)
#             elif isinstance(result_dict[k], list):
#                 for i in range(len(result_dict[k])):
#                     if not isinstance(expected_dict[k], list):
#                         raise AssertionError("No list expected for %s attribute, expected '%s' but received: '%s'" %
#                                              (k, expected_dict[k], result_dict[k]))
#                     self.assertDictEqualExt(result_dict[k][i], expected_dict[k][i], none_allowed)
#             elif result_dict[k] != expected_dict[k]:
#                 if isinstance(result_dict[k], datetime):
#                     if result_dict[k].date() == expected_dict[k].date():
#                         continue
#                 if result_dict[k] is not None or k not in none_allowed:
#                     raise AssertionError("Different value for '%s': %s != %s" % (k, result_dict[k], expected_dict[k]))


import unittest
import logging
    import mysql.connector
    import psycopg2
    from parameterized import parameterized_class
    from psycopg2 import sql
    from psycopg2.extensions import ISOLATION_LEVEL_AUTOCOMMIT
from bitcoinlib.services.services import *
from bitcoinlib.encoding import to_hexstring
from tests.test_custom import CustomAssertions
MAXIMUM_ESTIMATED_FEE_DIFFERENCE = 3.00  # Maximum difference from average estimated fee before test_estimatefee fails.
# Use value above >0, and 1 for 100%

DATABASEFILE_CACHE_UNITTESTS = os.path.join(str(BCL_DATABASE_DIR), 'bitcoinlibcache.unittest.sqlite')
DATABASEFILE_CACHE_UNITTESTS2 = os.path.join(str(BCL_DATABASE_DIR), 'bitcoinlibcache2.unittest.sqlite')
DATABASE_CACHE_POSTGRESQL = 'postgresql://postgres:postgres@localhost:5432/bitcoinlibcache.unittest'
# FIXME: MySQL databases are not supported. Not allowed to create indexes/primary keys on binary fields
DATABASE_CACHE_MYSQL = 'mysql://root:root@localhost:3306/bitcoinlibcache.unittest'
DATABASES_CACHE = [
    DATABASEFILE_CACHE_UNITTESTS2,
]
if UNITTESTS_FULL_DATABASE_TEST:
    DATABASES_CACHE += [
        DATABASE_CACHE_POSTGRESQL,
        DATABASE_CACHE_MYSQL
    ]

TIMEOUT_TEST = 2


# Wrapper class for the Service client: Set cache_uri, timeout and ignore provider priority
class ServiceTest(Service):

    def __init__(self, network=DEFAULT_NETWORK, min_providers=1, max_providers=1, providers=None,
                 timeout=TIMEOUT_TEST, cache_uri=DATABASEFILE_CACHE_UNITTESTS, ignore_priority=True,
                 exclude_providers=None, max_errors=SERVICE_MAX_ERRORS, strict=True):
        super(self.__class__, self).__init__(network, min_providers, max_providers, providers, timeout, cache_uri,
                                             ignore_priority, exclude_providers, max_errors, strict)



# Path: bitcoinlib/encoding.py
# def to_hexstring(string):
#     """
#     Convert bytes, string to a hexadecimal string. Use instead of built-in hex() method if format
#     of input string is not known.
# 
#     >>> to_hexstring(b'\\x12\\xaa\\xdd')
#     '12aadd'
# 
#     :param string: Variable to convert to hex string
#     :type string: bytes, str
# 
#     :return: hexstring
#     """
#     if not string:
#         return ''
#     try:
#         bytes.fromhex(string)
#         return string
#     except (ValueError, TypeError):
#         pass
# 
#     if not isinstance(string, bytes):
#         string = bytes(string, 'utf8')
#     return string.hex()
# 
# Path: tests/test_custom.py
# class CustomAssertions:
# 
#     def assertDictEqualExt(self, result_dict, expected_dict, none_allowed=None):
#         """
#         Compare dictionaries, skip items not found in expected dictionary.
# 
#         Lists and recursion's in dictionaries are allowed.
# 
#         :param result_dict: First dictionary with results
#         :type result_dict: dict
#         :param expected_dict: Second dictionary with expected values
#         :type expected_dict: dict
#         :param none_allowed: List of fields for which None value in result_dict is allowed
#         :type none_allowed: list
# 
#         :return bool: Dictionaries are identical?
#         """
#         if none_allowed is None:
#             none_allowed = []
#         if not isinstance(expected_dict, dict):
#             if expected_dict == result_dict:
#                 return True
#             else:
#                 raise AssertionError("Different value for %s != %s" % (result_dict, expected_dict))
#         expected_keys = expected_dict.keys()
#         for k in result_dict:
#             if k not in expected_keys:
#                 continue
#             if isinstance(result_dict[k], dict):
#                 self.assertDictEqualExt(result_dict[k], expected_dict[k], none_allowed)
#             elif isinstance(result_dict[k], list):
#                 for i in range(len(result_dict[k])):
#                     if not isinstance(expected_dict[k], list):
#                         raise AssertionError("No list expected for %s attribute, expected '%s' but received: '%s'" %
#                                              (k, expected_dict[k], result_dict[k]))
#                     self.assertDictEqualExt(result_dict[k][i], expected_dict[k][i], none_allowed)
#             elif result_dict[k] != expected_dict[k]:
#                 if isinstance(result_dict[k], datetime):
#                     if result_dict[k].date() == expected_dict[k].date():
#                         continue
#                 if result_dict[k] is not None or k not in none_allowed:
#                     raise AssertionError("Different value for '%s': %s != %s" % (k, result_dict[k], expected_dict[k]))


# Path: tests/test_services.py
import unittest
import logging
    import mysql.connector
    import psycopg2
    from parameterized import parameterized_class
    from psycopg2 import sql
    from psycopg2.extensions import ISOLATION_LEVEL_AUTOCOMMIT
from bitcoinlib.services.services import *
from bitcoinlib.encoding import to_hexstring
from tests.test_custom import CustomAssertions

MAXIMUM_ESTIMATED_FEE_DIFFERENCE = 3.00  # Maximum difference from average estimated fee before test_estimatefee fails.
# Use value above >0, and 1 for 100%

DATABASEFILE_CACHE_UNITTESTS = os.path.join(str(BCL_DATABASE_DIR), 'bitcoinlibcache.unittest.sqlite')
DATABASEFILE_CACHE_UNITTESTS2 = os.path.join(str(BCL_DATABASE_DIR), 'bitcoinlibcache2.unittest.sqlite')
DATABASE_CACHE_POSTGRESQL = 'postgresql://postgres:postgres@localhost:5432/bitcoinlibcache.unittest'
# FIXME: MySQL databases are not supported. Not allowed to create indexes/primary keys on binary fields
DATABASE_CACHE_MYSQL = 'mysql://root:root@localhost:3306/bitcoinlibcache.unittest'
DATABASES_CACHE = [
    DATABASEFILE_CACHE_UNITTESTS2,
]
if UNITTESTS_FULL_DATABASE_TEST:
    DATABASES_CACHE += [
        DATABASE_CACHE_POSTGRESQL,
        DATABASE_CACHE_MYSQL
    ]

TIMEOUT_TEST = 2


# Wrapper class for the Service client: Set cache_uri, timeout and ignore provider priority
class ServiceTest(Service):

    def __init__(self, network=DEFAULT_NETWORK, min_providers=1, max_providers=1, providers=None,
                 timeout=TIMEOUT_TEST, cache_uri=DATABASEFILE_CACHE_UNITTESTS, ignore_priority=True,
                 exclude_providers=None, max_errors=SERVICE_MAX_ERRORS, strict=True):
        super(self.__class__, self).__init__(network, min_providers, max_providers, providers, timeout, cache_uri,
                                             ignore_priority, exclude_providers, max_errors, strict)



class TestService(unittest.TestCase, CustomAssertions):