# Path: rlp/codec.py
# def decode(rlp, sedes=None, strict=True, recursive_cache=False, **kwargs):
#     """Decode an RLP encoded object.
# 
#     If the deserialized result `obj` has an attribute :attr:`_cached_rlp` (e.g. if `sedes` is a
#     subclass of :class:`rlp.Serializable`) it will be set to `rlp`, which will improve performance
#     on subsequent :func:`rlp.encode` calls. Bear in mind however that `obj` needs to make sure that
#     this value is updated whenever one of its fields changes or prevent such changes entirely
#     (:class:`rlp.sedes.Serializable` does the latter).
# 
#     :param sedes: an object implementing a function ``deserialize(code)`` which will be applied
#                   after decoding, or ``None`` if no deserialization should be performed
#     :param \*\*kwargs: additional keyword arguments that will be passed to the deserializer
#     :param strict: if false inputs that are longer than necessary don't cause an exception
#     :returns: the decoded and maybe deserialized Python object
#     :raises: :exc:`rlp.DecodingError` if the input string does not end after the root item and
#              `strict` is true
#     :raises: :exc:`rlp.DeserializationError` if the deserialization fails
#     """
#     if not is_bytes(rlp):
#         raise DecodingError('Can only decode RLP bytes, got type %s' % type(rlp).__name__, rlp)
# 
#     item, per_item_rlp = decode_raw(rlp, strict, recursive_cache)
# 
#     if len(per_item_rlp) == 0:
#         per_item_rlp = [rlp]
# 
#     if sedes:
#         obj = sedes.deserialize(item, **kwargs)
#         if is_sequence(obj) or hasattr(obj, '_cached_rlp'):
#             _apply_rlp_cache(obj, per_item_rlp, recursive_cache)
#         return obj
#     else:
#         return item
# 
# Path: rlp/exceptions.py
# class DecodingError(RLPException):
#     """Exception raised if decoding fails.
# 
#     :ivar rlp: the RLP string that could not be decoded
#     """
# 
#     def __init__(self, message, rlp):
#         super(DecodingError, self).__init__(message)
#         self.rlp = rlp


import pytest
from rlp import decode, DecodingError


invalid_rlp = (
    b'',
    b'\x00\xab',
    b'\x00\x00\xff',
    b'\x83dogcat',
    b'\x83do',
    b'\xc7\xc0\xc1\xc0\xc3\xc0\xc1\xc0\xff',
    b'\xc7\xc0\xc1\xc0\xc3\xc0\xc1'
    b'\x81\x02',
    b'\xb8\x00',
    b'\xb9\x00\x00',
    b'\xba\x00\x02\xff\xff',
    b'\x81\x54'
)


def test_invalid_rlp():
    for serial in invalid_rlp:

# Path: rlp/codec.py
# def decode(rlp, sedes=None, strict=True, recursive_cache=False, **kwargs):
#     """Decode an RLP encoded object.
# 
#     If the deserialized result `obj` has an attribute :attr:`_cached_rlp` (e.g. if `sedes` is a
#     subclass of :class:`rlp.Serializable`) it will be set to `rlp`, which will improve performance
#     on subsequent :func:`rlp.encode` calls. Bear in mind however that `obj` needs to make sure that
#     this value is updated whenever one of its fields changes or prevent such changes entirely
#     (:class:`rlp.sedes.Serializable` does the latter).
# 
#     :param sedes: an object implementing a function ``deserialize(code)`` which will be applied
#                   after decoding, or ``None`` if no deserialization should be performed
#     :param \*\*kwargs: additional keyword arguments that will be passed to the deserializer
#     :param strict: if false inputs that are longer than necessary don't cause an exception
#     :returns: the decoded and maybe deserialized Python object
#     :raises: :exc:`rlp.DecodingError` if the input string does not end after the root item and
#              `strict` is true
#     :raises: :exc:`rlp.DeserializationError` if the deserialization fails
#     """
#     if not is_bytes(rlp):
#         raise DecodingError('Can only decode RLP bytes, got type %s' % type(rlp).__name__, rlp)
# 
#     item, per_item_rlp = decode_raw(rlp, strict, recursive_cache)
# 
#     if len(per_item_rlp) == 0:
#         per_item_rlp = [rlp]
# 
#     if sedes:
#         obj = sedes.deserialize(item, **kwargs)
#         if is_sequence(obj) or hasattr(obj, '_cached_rlp'):
#             _apply_rlp_cache(obj, per_item_rlp, recursive_cache)
#         return obj
#     else:
#         return item
# 
# Path: rlp/exceptions.py
# class DecodingError(RLPException):
#     """Exception raised if decoding fails.
# 
#     :ivar rlp: the RLP string that could not be decoded
#     """
# 
#     def __init__(self, message, rlp):
#         super(DecodingError, self).__init__(message)
#         self.rlp = rlp


# Path: tests/test_invalid.py
import pytest
from rlp import decode, DecodingError



invalid_rlp = (
    b'',
    b'\x00\xab',
    b'\x00\x00\xff',
    b'\x83dogcat',
    b'\x83do',
    b'\xc7\xc0\xc1\xc0\xc3\xc0\xc1\xc0\xff',
    b'\xc7\xc0\xc1\xc0\xc3\xc0\xc1'
    b'\x81\x02',
    b'\xb8\x00',
    b'\xb9\x00\x00',
    b'\xba\x00\x02\xff\xff',
    b'\x81\x54'
)


def test_invalid_rlp():
    for serial in invalid_rlp:

        with pytest.raises(DecodingError):