3.0.ipv8.test.messaging.test_lazy_payload ========================================= .. py:module:: 3.0.ipv8.test.messaging.test_lazy_payload Attributes ---------- .. autoapisummary:: 3.0.ipv8.test.messaging.test_lazy_payload.skipUnlessPython310 Classes ------- .. autoapisummary:: 3.0.ipv8.test.messaging.test_lazy_payload.A 3.0.ipv8.test.messaging.test_lazy_payload.CompiledA 3.0.ipv8.test.messaging.test_lazy_payload.BitsPayload 3.0.ipv8.test.messaging.test_lazy_payload.CompiledBitsPayload 3.0.ipv8.test.messaging.test_lazy_payload.B 3.0.ipv8.test.messaging.test_lazy_payload.CompiledB 3.0.ipv8.test.messaging.test_lazy_payload.CompiledBAlt 3.0.ipv8.test.messaging.test_lazy_payload.C 3.0.ipv8.test.messaging.test_lazy_payload.CompiledC 3.0.ipv8.test.messaging.test_lazy_payload.CompiledCAlt 3.0.ipv8.test.messaging.test_lazy_payload.OldA 3.0.ipv8.test.messaging.test_lazy_payload.D 3.0.ipv8.test.messaging.test_lazy_payload.CompiledD 3.0.ipv8.test.messaging.test_lazy_payload.NewC 3.0.ipv8.test.messaging.test_lazy_payload.CompiledNewC 3.0.ipv8.test.messaging.test_lazy_payload.E 3.0.ipv8.test.messaging.test_lazy_payload.F 3.0.ipv8.test.messaging.test_lazy_payload.CompiledF 3.0.ipv8.test.messaging.test_lazy_payload.TestVariablePayload Module Contents --------------- .. py:data:: skipUnlessPython310 .. py:class:: A(*args: Any, **kwargs) Bases: :py:obj:`3.0.ipv8.messaging.lazy_payload.VariablePayload` A basic VariablePayload. .. py:attribute:: format_list :value: ['I', 'H'] .. py:attribute:: names :value: ['a', 'b'] .. py:class:: CompiledA(*args: Any, **kwargs) Bases: :py:obj:`A` Same as A but compiled. .. py:class:: BitsPayload(*args: Any, **kwargs) Bases: :py:obj:`3.0.ipv8.messaging.lazy_payload.VariablePayload` An unbalanced VariablePayload. .. py:attribute:: format_list :value: ['bits'] .. py:attribute:: names :value: ['flag0', 'flag1', 'flag2', 'flag3', 'flag4', 'flag5', 'flag6', 'flag7'] .. py:class:: CompiledBitsPayload(*args: Any, **kwargs) Bases: :py:obj:`BitsPayload` Same as BitsPayload but compiled. .. py:class:: B(*args: Any, **kwargs) Bases: :py:obj:`3.0.ipv8.messaging.lazy_payload.VariablePayload` A VariablePayload with a nested Payload. .. py:attribute:: format_list .. py:attribute:: names :value: ['a'] .. py:class:: CompiledB(*args: Any, **kwargs) Bases: :py:obj:`B` Same as B but compiled. .. py:class:: CompiledBAlt(*args: Any, **kwargs) Bases: :py:obj:`B` Overwritten format list for B. .. py:attribute:: format_list .. py:class:: C(*args: Any, **kwargs) Bases: :py:obj:`A` A VariablePayload with inherited fields. .. py:attribute:: format_list .. py:attribute:: names .. py:class:: CompiledC(*args: Any, **kwargs) Bases: :py:obj:`C` C but compiled. .. py:class:: CompiledCAlt(*args: Any, **kwargs) Bases: :py:obj:`CompiledA` C but compiled and inherited from compiled A. .. py:attribute:: format_list .. py:attribute:: names .. py:class:: OldA(a: int, b: int) Bases: :py:obj:`3.0.ipv8.messaging.payload.Payload` Old style Payload A. .. py:attribute:: format_list :value: ['I', 'H'] .. py:attribute:: a .. py:attribute:: b .. py:method:: to_pack_list() -> list[tuple] Create an old style pack list. .. py:method:: from_unpack_list(*args: object) -> OldA :classmethod: Unpack an OldA. .. py:class:: D(*args: Any, **kwargs) Bases: :py:obj:`3.0.ipv8.messaging.lazy_payload.VariablePayload` A mock payload for testing value fixing. .. py:attribute:: format_list :value: ['I'] .. py:attribute:: names :value: ['a'] .. py:method:: fix_pack_a(value: int) -> int Correct the known int value by adding one, still an int. .. py:method:: fix_unpack_a(value: int) -> int :classmethod: Uncorrect a given integer value by subtracting one, still an int. .. py:class:: CompiledD(*args: Any, **kwargs) Bases: :py:obj:`D` Same as D but compiled. .. py:class:: NewC(*args: Any, **kwargs) Bases: :py:obj:`3.0.ipv8.messaging.lazy_payload.VariablePayload`, :py:obj:`OldA` A VariablePayload with inherited fields. .. py:attribute:: format_list .. py:attribute:: names :value: ['a', 'b', 'c'] .. py:class:: CompiledNewC(*args: Any, **kwargs) Bases: :py:obj:`NewC` Same as NewC but compiled. .. py:class:: E(*args: Any, **kwargs) Bases: :py:obj:`3.0.ipv8.messaging.lazy_payload.VariablePayload` A VariablePayload with a list of payloads. .. py:attribute:: format_list .. py:attribute:: names :value: ['list_of_A'] .. py:class:: F(a: int, b: int = 3, **kwargs) Bases: :py:obj:`3.0.ipv8.messaging.lazy_payload.VariablePayload` A VariablePayload with a default value. .. py:attribute:: format_list :value: ['I', 'H'] .. py:attribute:: names :value: ['a', 'b'] .. py:class:: CompiledF(a: int, b: int = 3, **kwargs) Bases: :py:obj:`3.0.ipv8.messaging.lazy_payload.VariablePayload` A compiled VariablePayload with a default value. .. py:attribute:: format_list :value: ['I', 'H'] .. py:attribute:: names :value: ['a', 'b'] .. py:class:: TestVariablePayload(methodName: str = 'runTest') Bases: :py:obj:`3.0.ipv8.test.base.TestBase` Tests for VariablePaylods. .. py:method:: _pack_and_unpack(payload: type[3.0.ipv8.messaging.payload.Payload], instance: 3.0.ipv8.messaging.payload.Payload) -> 3.0.ipv8.messaging.payload.Payload 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_unnamed_compiled() -> None Check if the wrapper returns the payload correctly with unnamed arguments, compiled. .. py:method:: test_base_named() -> None Check if the wrapper returns the payload correctly with named arguments. .. py:method:: test_base_named_compiled() -> None Check if the wrapper returns the payload correctly with named arguments, compiled. .. py:method:: test_bits_payload() -> None Check if unpacked BitPayload works correctly. .. py:method:: test_bits_payload_compiled() -> None Check if unpacked compiled BitPayload works correctly. .. py:method:: test_inheritance() -> None Check if the wrapper allows for nested payloads. .. py:method:: test_inheritance_uncompiled_compiled() -> None Check if the wrapper allows for nested payloads, compiled. .. py:method:: test_inheritance_compiled_compiled() -> None Check if the wrapper allows for compiled nested payloads, compiled. .. py:method:: test_subclass() -> None Check if the wrapper allows for subclasses. .. py:method:: test_subclass_uncompiled_compiled() -> None Check if the wrapper allows for subclasses, compiled. .. py:method:: test_subclass_compiled_compiled() -> None Check if the wrapper allows for compiled subclasses, compiled. .. py:method:: test_old_subclass() -> None Check if the wrapper allows for subclasses from old-style Payloads. .. py:method:: test_old_subclass_compiled() -> None Check if the wrapper allows for subclasses from old-style Payloads, compiled. .. py:method:: test_custom_pack() -> None Check if the wire-format manipulation rules are applied correctly. .. py:method:: test_custom_pack_compiled() -> None Check if the wire-format manipulation rules are applied correctly, compiled. .. py:method:: test_payload_list() -> None Check if unpacked payload lists works correctly. .. py:method:: test_pass_default() -> None Check if default values are forwarded. .. py:method:: test_pass_default_compiled() -> None Check if default values are forwarded, compiled. .. py:method:: test_pass_default_overwrite() -> None Check if default values are correctly overwritten. .. py:method:: test_pass_default_overwrite_compiled() -> None Check if default values are correctly overwritten, compiled. .. py:method:: test_plain_mismatch_list() -> None Check if a VariablePayload instance does not match anything but its own pattern. We intentionally check here for a list of values equal to the __init__ arguments, which is the default. If this test fails, you probably screwed up the class-level sub-pattern. .. py:method:: test_compiled_mismatch_list() -> None Check if a compiled VariablePayload instance does not match anything but its own pattern. We intentionally check here for a list of values equal to the __init__ arguments, which is the default. If this test fails, you probably screwed up the class-level sub-pattern. .. py:method:: test_plain_match_pattern() -> None Check if a VariablePayload instance matches its own pattern. .. py:method:: test_compiled_match_pattern() -> None Check if a compiled VariablePayload instance matches its own pattern.