3.0.ipv8.test.messaging.test_payload_dataclass ============================================== .. py:module:: 3.0.ipv8.test.messaging.test_payload_dataclass Attributes ---------- .. autoapisummary:: 3.0.ipv8.test.messaging.test_payload_dataclass.varlenH 3.0.ipv8.test.messaging.test_payload_dataclass.T Classes ------- .. autoapisummary:: 3.0.ipv8.test.messaging.test_payload_dataclass.NativeBool 3.0.ipv8.test.messaging.test_payload_dataclass.NativeInt 3.0.ipv8.test.messaging.test_payload_dataclass.NativeBytes 3.0.ipv8.test.messaging.test_payload_dataclass.NativeStr 3.0.ipv8.test.messaging.test_payload_dataclass.SerializerType 3.0.ipv8.test.messaging.test_payload_dataclass.NestedType 3.0.ipv8.test.messaging.test_payload_dataclass.NestedListType 3.0.ipv8.test.messaging.test_payload_dataclass.ListIntType 3.0.ipv8.test.messaging.test_payload_dataclass.ListBoolType 3.0.ipv8.test.messaging.test_payload_dataclass.Unknown 3.0.ipv8.test.messaging.test_payload_dataclass.A 3.0.ipv8.test.messaging.test_payload_dataclass.B 3.0.ipv8.test.messaging.test_payload_dataclass.FwdDataclass 3.0.ipv8.test.messaging.test_payload_dataclass.StripMsgId 3.0.ipv8.test.messaging.test_payload_dataclass.FwdMsgId 3.0.ipv8.test.messaging.test_payload_dataclass.EverythingItem 3.0.ipv8.test.messaging.test_payload_dataclass.Everything 3.0.ipv8.test.messaging.test_payload_dataclass.TestDataclassPayload Module Contents --------------- .. py:data:: varlenH .. py:data:: T .. py:class:: NativeBool(*args: Any, **kwargs) Bases: :py:obj:`3.0.ipv8.messaging.payload_dataclass.DataClassPayload` A single boolean payload. .. py:attribute:: a :type: bool .. py:class:: NativeInt(*args: Any, **kwargs) Bases: :py:obj:`3.0.ipv8.messaging.payload_dataclass.DataClassPayload` A single integer payload. .. py:attribute:: a :type: int .. py:class:: NativeBytes(*args: Any, **kwargs) Bases: :py:obj:`3.0.ipv8.messaging.payload_dataclass.DataClassPayload` A single bytes payload. .. py:attribute:: a :type: bytes .. py:class:: NativeStr(*args: Any, **kwargs) Bases: :py:obj:`3.0.ipv8.messaging.payload_dataclass.DataClassPayload` A single string payload. .. py:attribute:: a :type: str .. py:class:: SerializerType(*args: Any, **kwargs) Bases: :py:obj:`3.0.ipv8.messaging.payload_dataclass.DataClassPayload` A ``Serializer`` format payload. .. py:attribute:: a :type: varlenH .. py:class:: NestedType(*args: Any, **kwargs) Bases: :py:obj:`3.0.ipv8.messaging.payload_dataclass.DataClassPayload` A single nested payload. .. py:attribute:: a :type: NativeInt .. py:class:: NestedListType(*args: Any, **kwargs) Bases: :py:obj:`3.0.ipv8.messaging.payload_dataclass.DataClassPayload` A single list of nested payload. .. py:attribute:: a :type: list[NativeInt] .. py:class:: ListIntType(*args: Any, **kwargs) Bases: :py:obj:`3.0.ipv8.messaging.payload_dataclass.DataClassPayload` A single list of integers. .. py:attribute:: a :type: list[int] .. py:class:: ListBoolType(*args: Any, **kwargs) Bases: :py:obj:`3.0.ipv8.messaging.payload_dataclass.DataClassPayload` A single list of booleans. .. py:attribute:: a :type: list[bool] .. py:class:: Unknown(*args: Any, **kwargs) Bases: :py:obj:`3.0.ipv8.messaging.payload_dataclass.DataClassPayload` To whomever is reading this and wondering why dict is not supported: use a nested payload instead. .. py:attribute:: a :type: dict .. py:class:: A(*args: Any, **kwargs) Bases: :py:obj:`3.0.ipv8.messaging.payload_dataclass.DataClassPayload` A payload consisting of two integers. .. py:attribute:: a :type: int .. py:attribute:: b :type: int .. py:class:: B(*args: Any, **kwargs) Bases: :py:obj:`3.0.ipv8.messaging.payload_dataclass.DataClassPayload` A payload consisting of two integers, of which one has a default value. .. py:attribute:: a :type: int .. py:attribute:: b :type: int :value: 3 .. py:class:: FwdDataclass(*args: Any, **kwargs) Bases: :py:obj:`3.0.ipv8.messaging.payload_dataclass.DataClassPayload` A payload to test if the dataclass overwrite forwards its arguments to the "real" dataclass. .. py:attribute:: a :type: int .. py:class:: StripMsgId(*args: Any, **kwargs) Bases: :py:obj:`3.0.ipv8.messaging.payload_dataclass.DataClassPayload` Payload to make sure that the message id is not seen as a field. .. py:attribute:: a :type: int .. py:attribute:: msg_id :value: 1 .. py:attribute:: names :value: [] .. py:attribute:: format_list :value: [] .. py:class:: FwdMsgId(*args: Any, **kwargs) Bases: :py:obj:`3.0.ipv8.messaging.payload_dataclass.DataClassPayload`\ [\ :py:obj:`1`\ ] Payload that specfies the message id as an argument to the dataclass overwrite. .. py:attribute:: a :type: int .. py:class:: EverythingItem(*args: Any, **kwargs) Bases: :py:obj:`3.0.ipv8.messaging.payload_dataclass.DataClassPayload` An item for the following Everything payload. .. py:attribute:: a :type: bool .. py:class:: Everything(*args: Any, **kwargs) Bases: :py:obj:`3.0.ipv8.messaging.payload_dataclass.DataClassPayload` Dataclass payload that includes all functionality. .. py:attribute:: a :type: int .. py:attribute:: b :type: bytes .. py:attribute:: c :type: varlenH .. py:attribute:: d :type: EverythingItem .. py:attribute:: e :type: list[EverythingItem] .. py:attribute:: f :type: str .. py:attribute:: g :type: list[int] .. py:attribute:: h :type: list[bool] .. py:class:: TestDataclassPayload(methodName: str = 'runTest') Bases: :py:obj:`3.0.ipv8.test.base.TestBase` Tests for dataclass-based payloads. .. py:method:: _pack_and_unpack(payload: type[T], instance: object) -> T :staticmethod: Serialize and unserialize an instance of payload. :param payload: the payload class to serialize for :type payload: type(Payload) :param instance: the payload instance to serialize :type instance: Payload :return: the repacked instance .. py:method:: test_base_unnamed() -> None Check if the wrapper returns the payload correctly with unnamed arguments. .. py:method:: test_base_named() -> None Check if the wrapper returns the payload correctly with named arguments. .. py:method:: test_pass_default() -> None Check if the wrapper forwards default values. .. py:method:: test_pass_default_overwrite() -> None Check if the wrapper correctly overwrites default values. .. py:method:: test_nativebool_t_payload() -> None Check if unpacked BitPayload(true) works correctly. .. py:method:: test_nativebool_f_payload() -> None Check if unpacked BitPayload(false) works correctly. .. py:method:: test_nativeint_negative_payload() -> None Check if unpacked NativeInt(-1) works correctly. .. py:method:: test_nativeint_zero_payload() -> None Check if unpacked NativeInt(0) works correctly. .. py:method:: test_nativeint_positive_payload() -> None Check if unpacked NativeInt(1) works correctly. .. py:method:: test_nativebytes_empty_payload() -> None Check if unpacked NativeBytes(b'') works correctly. .. py:method:: test_nativebytes_filled_payload() -> None Check if unpacked NativeBytes(b'hi') works correctly. .. py:method:: test_nativestr_empty_payload() -> None Check if unpacked NativeStr('') works correctly. .. py:method:: test_nativestr_filled_payload() -> None Check if unpacked NativeStr('hi') works correctly. .. py:method:: test_serializertype_payload() -> None Check if a custom SerializerType ("varlenH") works correctly. .. py:method:: test_nested_payload() -> None Check if a nested payload works correctly. .. py:method:: test_native_intlist_payload() -> None Check if a list of native types works correctly. .. py:method:: test_native_boollist_payload() -> None Check if a list of native types works correctly. .. py:method:: test_nestedlist_empty_payload() -> None Check if an empty list of nested payloads works correctly. .. py:method:: test_nestedlist_filled_payload() -> None Check if a list of nested payloads works correctly. .. py:method:: test_unknown_payload() -> None Check if an unknown type raises an error. .. py:method:: test_fwd_args() -> None Check if ``dataclass_payload`` forwards its arguments to ``dataclass``. We forward ``eq=False`` because it's easy to test. .. py:method:: test_strip_msg_id() -> None Check if the ``msg_id`` field is identified and stripped. .. py:method:: test_fwd_msg_id() -> None Check if the ``msg_id`` argument sets the Payload ``msg_id``. .. py:method:: test_everything() -> None Check if the wrapper handles all of the different data types together.