latest.ipv8.test.messaging.test_lazy_payload

Module Contents

Classes

A

A basic VariablePayload.

CompiledA

Same as A but compiled.

BitsPayload

An unbalanced VariablePayload.

CompiledBitsPayload

Same as BitsPayload but compiled.

B

A VariablePayload with a nested Payload.

CompiledB

Same as B but compiled.

CompiledBAlt

Overwritten format list for B.

C

A VariablePayload with inherited fields.

CompiledC

C but compiled.

CompiledCAlt

C but compiled and inherited from compiled A.

OldA

Old style Payload A.

D

A mock payload for testing value fixing.

CompiledD

Same as D but compiled.

NewC

A VariablePayload with inherited fields.

CompiledNewC

Same as NewC but compiled.

E

A VariablePayload with a list of payloads.

F

A VariablePayload with a default value.

CompiledF

A compiled VariablePayload with a default value.

TestVariablePayload

Tests for VariablePaylods.

Attributes

skipUnlessPython310

latest.ipv8.test.messaging.test_lazy_payload.skipUnlessPython310
class latest.ipv8.test.messaging.test_lazy_payload.A(*args: Any, **kwargs)

Bases: latest.ipv8.messaging.lazy_payload.VariablePayload

A basic VariablePayload.

format_list = ['I', 'H']
names = ['a', 'b']
class latest.ipv8.test.messaging.test_lazy_payload.CompiledA(*args: Any, **kwargs)

Bases: A

Same as A but compiled.

class latest.ipv8.test.messaging.test_lazy_payload.BitsPayload(*args: Any, **kwargs)

Bases: latest.ipv8.messaging.lazy_payload.VariablePayload

An unbalanced VariablePayload.

format_list = ['bits']
names = ['flag0', 'flag1', 'flag2', 'flag3', 'flag4', 'flag5', 'flag6', 'flag7']
class latest.ipv8.test.messaging.test_lazy_payload.CompiledBitsPayload(*args: Any, **kwargs)

Bases: BitsPayload

Same as BitsPayload but compiled.

class latest.ipv8.test.messaging.test_lazy_payload.B(*args: Any, **kwargs)

Bases: latest.ipv8.messaging.lazy_payload.VariablePayload

A VariablePayload with a nested Payload.

format_list
names = ['a']
class latest.ipv8.test.messaging.test_lazy_payload.CompiledB(*args: Any, **kwargs)

Bases: B

Same as B but compiled.

class latest.ipv8.test.messaging.test_lazy_payload.CompiledBAlt(*args: Any, **kwargs)

Bases: B

Overwritten format list for B.

format_list
class latest.ipv8.test.messaging.test_lazy_payload.C(*args: Any, **kwargs)

Bases: A

A VariablePayload with inherited fields.

format_list
names
class latest.ipv8.test.messaging.test_lazy_payload.CompiledC(*args: Any, **kwargs)

Bases: C

C but compiled.

class latest.ipv8.test.messaging.test_lazy_payload.CompiledCAlt(*args: Any, **kwargs)

Bases: CompiledA

C but compiled and inherited from compiled A.

format_list
names
class latest.ipv8.test.messaging.test_lazy_payload.OldA(a: int, b: int)

Bases: latest.ipv8.messaging.payload.Payload

Old style Payload A.

format_list = ['I', 'H']
to_pack_list() list[tuple]

Create an old style pack list.

classmethod from_unpack_list(*args: object) OldA

Unpack an OldA.

class latest.ipv8.test.messaging.test_lazy_payload.D(*args: Any, **kwargs)

Bases: latest.ipv8.messaging.lazy_payload.VariablePayload

A mock payload for testing value fixing.

format_list = ['I']
names = ['a']
fix_pack_a(value: int) int

Correct the known int value by adding one, still an int.

classmethod fix_unpack_a(value: int) int

Uncorrect a given integer value by subtracting one, still an int.

class latest.ipv8.test.messaging.test_lazy_payload.CompiledD(*args: Any, **kwargs)

Bases: D

Same as D but compiled.

class latest.ipv8.test.messaging.test_lazy_payload.NewC(*args: Any, **kwargs)

Bases: latest.ipv8.messaging.lazy_payload.VariablePayload, OldA

A VariablePayload with inherited fields.

format_list
names = ['a', 'b', 'c']
class latest.ipv8.test.messaging.test_lazy_payload.CompiledNewC(*args: Any, **kwargs)

Bases: NewC

Same as NewC but compiled.

class latest.ipv8.test.messaging.test_lazy_payload.E(*args: Any, **kwargs)

Bases: latest.ipv8.messaging.lazy_payload.VariablePayload

A VariablePayload with a list of payloads.

format_list = [None]
names = ['list_of_A']
class latest.ipv8.test.messaging.test_lazy_payload.F(a: int, b: int = 3, **kwargs)

Bases: latest.ipv8.messaging.lazy_payload.VariablePayload

A VariablePayload with a default value.

format_list = ['I', 'H']
names = ['a', 'b']
class latest.ipv8.test.messaging.test_lazy_payload.CompiledF(a: int, b: int = 3, **kwargs)

Bases: latest.ipv8.messaging.lazy_payload.VariablePayload

A compiled VariablePayload with a default value.

format_list = ['I', 'H']
names = ['a', 'b']
class latest.ipv8.test.messaging.test_lazy_payload.TestVariablePayload(methodName: str = 'runTest')

Bases: latest.ipv8.test.base.TestBase

Tests for VariablePaylods.

_pack_and_unpack(payload: type[latest.ipv8.messaging.payload.Payload], instance: latest.ipv8.messaging.payload.Payload) latest.ipv8.messaging.payload.Payload

Serialize and unserialize an instance of payload.

Parameters:
  • payload (type(Payload)) – the payload class to serialize for

  • instance (Payload) – the payload instance to serialize

Returns:

the repacked instance

test_base_unnamed() None

Check if the wrapper returns the payload correctly with unnamed arguments.

test_base_unnamed_compiled() None

Check if the wrapper returns the payload correctly with unnamed arguments, compiled.

test_base_named() None

Check if the wrapper returns the payload correctly with named arguments.

test_base_named_compiled() None

Check if the wrapper returns the payload correctly with named arguments, compiled.

test_bits_payload() None

Check if unpacked BitPayload works correctly.

test_bits_payload_compiled() None

Check if unpacked compiled BitPayload works correctly.

test_inheritance() None

Check if the wrapper allows for nested payloads.

test_inheritance_uncompiled_compiled() None

Check if the wrapper allows for nested payloads, compiled.

test_inheritance_compiled_compiled() None

Check if the wrapper allows for compiled nested payloads, compiled.

test_subclass() None

Check if the wrapper allows for subclasses.

test_subclass_uncompiled_compiled() None

Check if the wrapper allows for subclasses, compiled.

test_subclass_compiled_compiled() None

Check if the wrapper allows for compiled subclasses, compiled.

test_old_subclass() None

Check if the wrapper allows for subclasses from old-style Payloads.

test_old_subclass_compiled() None

Check if the wrapper allows for subclasses from old-style Payloads, compiled.

test_custom_pack() None

Check if the wire-format manipulation rules are applied correctly.

test_custom_pack_compiled() None

Check if the wire-format manipulation rules are applied correctly, compiled.

test_payload_list() None

Check if unpacked payload lists works correctly.

test_pass_default() None

Check if default values are forwarded.

test_pass_default_compiled() None

Check if default values are forwarded, compiled.

test_pass_default_overwrite() None

Check if default values are correctly overwritten.

test_pass_default_overwrite_compiled() None

Check if default values are correctly overwritten, compiled.

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.

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.

test_plain_match_pattern() None

Check if a VariablePayload instance matches its own pattern.

test_compiled_match_pattern() None

Check if a compiled VariablePayload instance matches its own pattern.