# 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(str(Quantity(121608561109507200000, 'H/s', precision=10)), '121.6085611095 EH/s')
        self.assertEqual(str(Quantity(1 / 121608561109507200000, 'ots', precision=10)), '8.2231052722 zots')
        self.assertEqual(str(Quantity(0.0000000001, 'm', precision=2)), '100.00 pm')
        self.assertEqual(str(Quantity(121608561109507200000000000000000)), '121608561.110 Y')
        self.assertEqual(str(Quantity(1/1216085611095072000000000000000)), '0.000 y')
        self.assertEqual(str(Quantity(1/1216085611095072000000000000000, precision=10)), '0.0000008223 y')
        self.assertEqual(str(Quantity(10, 'pound', precision=0)), '10 pound')
        self.assertEqual(str(Quantity(0)), '0.000')

    # Source: https://github.com/bitcoin/bips/blob/master/bip-0350.mediawiki
    def test_bech32m_valid(self):
        for addr, pubkeyhash in BECH32M_VALID:
            assert(pubkeyhash == addr_bech32_to_pubkeyhash(addr, include_witver=True).hex())
            prefix = addr.split('1')[0].lower()
            witver = change_base(addr.split('1')[1][0], 'bech32', 10)
            checksum_xor = addr_bech32_checksum(addr)
            addrc = pubkeyhash_to_addr_bech32(pubkeyhash, prefix, witver, checksum_xor=checksum_xor)
            assert(addr.lower() == addrc)

    def test_bech32_invalid(self):
        for addr, err in BECH32M_INVALID:
            try:
                addr_bech32_to_pubkeyhash(addr)
            except (EncodingError, TypeError) as e:
                assert (str(e) == err)


class TestEncodingConfig(unittest.TestCase):

    def test_config_opcodes(self):

# 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(str(Quantity(121608561109507200000, 'H/s', precision=10)), '121.6085611095 EH/s')
        self.assertEqual(str(Quantity(1 / 121608561109507200000, 'ots', precision=10)), '8.2231052722 zots')
        self.assertEqual(str(Quantity(0.0000000001, 'm', precision=2)), '100.00 pm')
        self.assertEqual(str(Quantity(121608561109507200000000000000000)), '121608561.110 Y')
        self.assertEqual(str(Quantity(1/1216085611095072000000000000000)), '0.000 y')
        self.assertEqual(str(Quantity(1/1216085611095072000000000000000, precision=10)), '0.0000008223 y')
        self.assertEqual(str(Quantity(10, 'pound', precision=0)), '10 pound')
        self.assertEqual(str(Quantity(0)), '0.000')

    # Source: https://github.com/bitcoin/bips/blob/master/bip-0350.mediawiki
    def test_bech32m_valid(self):
        for addr, pubkeyhash in BECH32M_VALID:
            assert(pubkeyhash == addr_bech32_to_pubkeyhash(addr, include_witver=True).hex())
            prefix = addr.split('1')[0].lower()
            witver = change_base(addr.split('1')[1][0], 'bech32', 10)
            checksum_xor = addr_bech32_checksum(addr)
            addrc = pubkeyhash_to_addr_bech32(pubkeyhash, prefix, witver, checksum_xor=checksum_xor)
            assert(addr.lower() == addrc)

    def test_bech32_invalid(self):
        for addr, err in BECH32M_INVALID:
            try:
                addr_bech32_to_pubkeyhash(addr)
            except (EncodingError, TypeError) as e:
                assert (str(e) == err)


class TestEncodingConfig(unittest.TestCase):

    def test_config_opcodes(self):

        self.assertEqual(op.op_checklocktimeverify, 177)