# 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
              b'\xd3F\x7f\xe5\x17\xae\x02 _l\xa4\x89LS\xcd\x8em&\xf7\x99uN\xb6\xfc\x0e\x86\xf6\x12\xd6\xdejL|' \
              b'\x07\xdcX \xa0\xe5\x18'
        self.assertEqual('e71a8dd83e79fbd62f72a3d0d8a81fddba535bd0f088fa8be14cd3467fe517ae5f6ca4894c53cd8e6d26f'
                         '799754eb6fc0e86f612d6de6a4c7c07dc5820a0e518', convert_der_sig(sig))

    def test_to_bytes_hex(self):
        self.assertEqual(b'\xde\xad\xbe\xef', to_bytes('deadbeef'))

    def test_to_bytes_nohex(self):
        self.assertEqual(b'deadbeefnohex', to_bytes('deadbeefnohex'))

    def test_to_bytes_nounhexlify(self):
        self.assertEqual(b'deadbeef', to_bytes('deadbeef', unhexlify=False))

    def test_to_bytes_unicode(self):
        self.assertEqual(b'\x07\xdcX \xa0\xe5\x18!]!,\xd5\x18\x8a\xe0,V5\xfa\xab',
                         to_bytes(u'07dc5820a0e518215d212cd5188ae02c5635faab'))

    def test_to_bytes_byteshex(self):
        self.assertEqual(b'\x07\xdcX \xa0\xe5\x18!]!,\xd5\x18\x8a\xe0,V5\xfa\xab',
                         to_bytes(b'07dc5820a0e518215d212cd5188ae02c5635faab'))

    def test_to_hexstring_string(self):
        self.assertEqual('deadbeef', to_hexstring('deadbeef'))

    def test_to_hexstring_bytes(self):
        self.assertEqual('707974686f6e6973636f6f6c', to_hexstring(b'pythoniscool'))

    def test_to_hexstring_bytes2(self):
        self.assertEqual('07dc5820a0e518215d212cd5188ae02c5635faab',

# 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

              b'\xd3F\x7f\xe5\x17\xae\x02 _l\xa4\x89LS\xcd\x8em&\xf7\x99uN\xb6\xfc\x0e\x86\xf6\x12\xd6\xdejL|' \
              b'\x07\xdcX \xa0\xe5\x18'
        self.assertEqual('e71a8dd83e79fbd62f72a3d0d8a81fddba535bd0f088fa8be14cd3467fe517ae5f6ca4894c53cd8e6d26f'
                         '799754eb6fc0e86f612d6de6a4c7c07dc5820a0e518', convert_der_sig(sig))

    def test_to_bytes_hex(self):
        self.assertEqual(b'\xde\xad\xbe\xef', to_bytes('deadbeef'))

    def test_to_bytes_nohex(self):
        self.assertEqual(b'deadbeefnohex', to_bytes('deadbeefnohex'))

    def test_to_bytes_nounhexlify(self):
        self.assertEqual(b'deadbeef', to_bytes('deadbeef', unhexlify=False))

    def test_to_bytes_unicode(self):
        self.assertEqual(b'\x07\xdcX \xa0\xe5\x18!]!,\xd5\x18\x8a\xe0,V5\xfa\xab',
                         to_bytes(u'07dc5820a0e518215d212cd5188ae02c5635faab'))

    def test_to_bytes_byteshex(self):
        self.assertEqual(b'\x07\xdcX \xa0\xe5\x18!]!,\xd5\x18\x8a\xe0,V5\xfa\xab',
                         to_bytes(b'07dc5820a0e518215d212cd5188ae02c5635faab'))

    def test_to_hexstring_string(self):
        self.assertEqual('deadbeef', to_hexstring('deadbeef'))

    def test_to_hexstring_bytes(self):
        self.assertEqual('707974686f6e6973636f6f6c', to_hexstring(b'pythoniscool'))

    def test_to_hexstring_bytes2(self):
        self.assertEqual('07dc5820a0e518215d212cd5188ae02c5635faab',

                         to_hexstring(b'\x07\xdcX \xa0\xe5\x18!]!,\xd5\x18\x8a\xe0,V5\xfa\xab'))