# Path: bitcoinlib/config/opcodes.py
# def op():
#     pass
# 
# Path: bitcoinlib/encoding.py
# def _bech32_polymod(values):
#     """
#     Internal function that computes the Bech32 checksum
#     """
#     generator = [0x3b6a57b2, 0x26508e6d, 0x1ea119fa, 0x3d4233dd, 0x2a1462b3]
#     chk = 1
#     for value in values:
#         top = chk >> 25
#         chk = (chk & 0x1ffffff) << 5 ^ value
#         for i in range(5):
#             chk ^= generator[i] if ((top >> i) & 1) else 0
#     return chk
# 
# def _codestring_to_array(codestring, base):
#     codestring = bytes(codestring, 'utf8')
#     codebase = code_strings[base]
#     array = []
#     for s in codestring:
#         try:
#             array.append(codebase.index(s))
#         except ValueError:
#             raise EncodingError("Character '%s' not found in codebase" % s)
#     return array


import unittest
from bitcoinlib.config.opcodes import op
from bitcoinlib.encoding import *
from bitcoinlib.encoding import _bech32_polymod, _codestring_to_array
        self.assertEqual('4c52127a72fb42b82439ab18697dcfcfb96ac63ba8209833b2e29f2302b8993f45e743412d65c7a571da70259d4'
                         'f6795e98af20e6e57603314a662a49c198199',
                         change_base(b'LR\x12zr\xfbB\xb8$9\xab\x18i}\xcf\xcf\xb9j\xc6;\xa8 \x983\xb2\xe2\x9f#\x02\xb8'
                                     b'\x99?E\xe7CA-e\xc7\xa5q\xdap%\x9dOg\x95\xe9\x8a\xf2\x0enW`3\x14\xa6b\xa4\x9c'
                                     b'\x19\x81\x99', 256, 16))

    def test_change_base_encodings_utf8(self):
        self.assertEqual('e782ba20e5ae8b20e69ab420e6b2bb20e4bcaf20e58f8a20e7819820e586b620e5bf9920e9808320e6b99820e8'
                         '898720e4be8b20e8ae9320e5bfa0',
                         change_base("為 宋 暴 治 伯 及 灘 冶 忙 逃 湘 艇 例 讓 忠", 256, 16))

    def test_change_base_list(self):
        self.assertEqual('00124c', change_base([b'\0', b'\x12', b'L'], 256, 16, 6))

    def test_change_base_bytes_as_string(self):
        s = '\xc8\xe9\t\x96\xc7\xc6\x08\x0e\xe0b\x84`\x0chN\xd9\x04\xd1L\\'
        self.assertEqual('c8e90996c7c6080ee06284600c684ed904d14c5c', change_base(s, 256, 16))

    def test_change_base_decimal_input_lenght_exception(self):
        self.assertRaisesRegexp(EncodingError, "For a decimal input a minimum output length is required",
                                change_base, 100, 10, 2)

    def test_encoding_exceptions(self):
        self.assertRaisesRegexp(EncodingError, "Unknown input format {}",
                                change_base, {}, 4, 2)
        self.assertRaisesRegexp(EncodingError, "Byteint must be a list or defined as bytes",
                                varbyteint_to_int, 'fd1027')
        self.assertRaisesRegexp(EncodingError, "Input must be a number type",
                                int_to_varbyteint, '1000')
        self.assertRaisesRegexp(TypeError, "String value expected", normalize_string, 100)

# Path: bitcoinlib/config/opcodes.py
# def op():
#     pass
# 
# Path: bitcoinlib/encoding.py
# def _bech32_polymod(values):
#     """
#     Internal function that computes the Bech32 checksum
#     """
#     generator = [0x3b6a57b2, 0x26508e6d, 0x1ea119fa, 0x3d4233dd, 0x2a1462b3]
#     chk = 1
#     for value in values:
#         top = chk >> 25
#         chk = (chk & 0x1ffffff) << 5 ^ value
#         for i in range(5):
#             chk ^= generator[i] if ((top >> i) & 1) else 0
#     return chk
# 
# def _codestring_to_array(codestring, base):
#     codestring = bytes(codestring, 'utf8')
#     codebase = code_strings[base]
#     array = []
#     for s in codestring:
#         try:
#             array.append(codebase.index(s))
#         except ValueError:
#             raise EncodingError("Character '%s' not found in codebase" % s)
#     return array


# Path: tests/test_encoding.py
import unittest
from bitcoinlib.config.opcodes import op
from bitcoinlib.encoding import *
from bitcoinlib.encoding import _bech32_polymod, _codestring_to_array

        self.assertEqual('4c52127a72fb42b82439ab18697dcfcfb96ac63ba8209833b2e29f2302b8993f45e743412d65c7a571da70259d4'
                         'f6795e98af20e6e57603314a662a49c198199',
                         change_base(b'LR\x12zr\xfbB\xb8$9\xab\x18i}\xcf\xcf\xb9j\xc6;\xa8 \x983\xb2\xe2\x9f#\x02\xb8'
                                     b'\x99?E\xe7CA-e\xc7\xa5q\xdap%\x9dOg\x95\xe9\x8a\xf2\x0enW`3\x14\xa6b\xa4\x9c'
                                     b'\x19\x81\x99', 256, 16))

    def test_change_base_encodings_utf8(self):
        self.assertEqual('e782ba20e5ae8b20e69ab420e6b2bb20e4bcaf20e58f8a20e7819820e586b620e5bf9920e9808320e6b99820e8'
                         '898720e4be8b20e8ae9320e5bfa0',
                         change_base("為 宋 暴 治 伯 及 灘 冶 忙 逃 湘 艇 例 讓 忠", 256, 16))

    def test_change_base_list(self):
        self.assertEqual('00124c', change_base([b'\0', b'\x12', b'L'], 256, 16, 6))

    def test_change_base_bytes_as_string(self):
        s = '\xc8\xe9\t\x96\xc7\xc6\x08\x0e\xe0b\x84`\x0chN\xd9\x04\xd1L\\'
        self.assertEqual('c8e90996c7c6080ee06284600c684ed904d14c5c', change_base(s, 256, 16))

    def test_change_base_decimal_input_lenght_exception(self):
        self.assertRaisesRegexp(EncodingError, "For a decimal input a minimum output length is required",
                                change_base, 100, 10, 2)

    def test_encoding_exceptions(self):
        self.assertRaisesRegexp(EncodingError, "Unknown input format {}",
                                change_base, {}, 4, 2)
        self.assertRaisesRegexp(EncodingError, "Byteint must be a list or defined as bytes",
                                varbyteint_to_int, 'fd1027')
        self.assertRaisesRegexp(EncodingError, "Input must be a number type",
                                int_to_varbyteint, '1000')
        self.assertRaisesRegexp(TypeError, "String value expected", normalize_string, 100)

        self.assertRaisesRegexp(EncodingError, "Encoding base32 not supported", pubkeyhash_to_addr, '123',