2.13.ipv8.test.mocking.endpoint

Module Contents

Classes

Functions

Attributes

2.13.ipv8.test.mocking.endpoint.internet
async 2.13.ipv8.test.mocking.endpoint.crash_event_loop(forwarded_exception: Exception) None

Raise an exception on the event loop.

Parameters:

forwarded_exception – the exception instance to raise.

class 2.13.ipv8.test.mocking.endpoint.MockEndpoint(lan_address: 2.13.ipv8.types.Address, wan_address: 2.13.ipv8.types.Address)

Bases: 2.13.ipv8.messaging.interfaces.endpoint.Endpoint

Endpoint that registers an address in the “internet” dictionary instead of using The Internet.

SEND_INET_EXCEPTION_TO_LOOP = True

Raise an uncaught AssertionError on the asyncio event loop if attempting to send to an unknown address. Useful for use in defensively-programmed code: bypasses most exception handling.

assert_open() None

Throw an assertion error if this endpoint is not open.

is_open() bool

Check if this endpoint is open.

get_address() 2.13.ipv8.types.Address

Get our own registered WAN address.

send(socket_address: 2.13.ipv8.types.Address, packet: bytes) None

Route a message through the “internet” dictionary.

WARNING: We schedule a call on the event loop. Otherwise, you can easily create infinite loops!

open() None

Set this endpoint to be open.

close(timeout: float = 0.0) None

Close this endpoint.

reset_byte_counters() None

Reset our byte counters (we have none).

class 2.13.ipv8.test.mocking.endpoint.AddressTester(endpoint: 2.13.ipv8.messaging.interfaces.endpoint.Endpoint)

Bases: 2.13.ipv8.messaging.interfaces.endpoint.EndpointListener

Generating addresses that are on our physical machine’s actual physical LAN can lead to issues.

singleton
classmethod get_singleton(endpoint: 2.13.ipv8.messaging.interfaces.endpoint.Endpoint) AddressTester

Create a singleton AddressTester, you only need one.

on_packet(packet: tuple[2.13.ipv8.types.Address, bytes]) None

This should never be called.

is_lan(address: str) bool

Check if the given address is on our physical LAN.

class 2.13.ipv8.test.mocking.endpoint.AutoMockEndpoint

Bases: MockEndpoint

Randomly generate LAN + WAN addresses that are globally unique and register them in the “internet” dictionary.

IPV6_ADDRESSES
_generate_address() 2.13.ipv8.messaging.interfaces.udp.endpoint.UDPv4Address | 2.13.ipv8.messaging.interfaces.udp.endpoint.UDPv6Address
_is_lan(address: 2.13.ipv8.types.Address) bool

Avoid false positives for the actual machine’s lan.

_generate_unique_address() 2.13.ipv8.types.Address
class 2.13.ipv8.test.mocking.endpoint.MockEndpointListener(endpoint: 2.13.ipv8.messaging.interfaces.endpoint.Endpoint, main_thread: bool = False)

Bases: 2.13.ipv8.messaging.interfaces.endpoint.EndpointListener

Listener that simply stores all data sent to it.

on_packet(packet: tuple[2.13.ipv8.types.Address, bytes]) None

Callback for when packets are received: simply store them.