latest.ipv8.test.mocking.ipv8

Module Contents

Classes

MockIPv8

Manager for IPv8 related objects during tests.

class latest.ipv8.test.mocking.ipv8.MockIPv8(crypto_curve_or_peer: str | latest.ipv8.peer.Peer, overlay_class: type[latest.ipv8.types.Community], settings: latest.ipv8.community.CommunitySettings | None = None, create_dht: bool = False, enable_statistics: bool = False)

Manager for IPv8 related objects during tests.

Note that this is not the same as an IPv8 instance (nor is it a subclass)! However, many of the same functionalities are offered.

add_strategy(overlay: latest.ipv8.types.Overlay, strategy: latest.ipv8.peerdiscovery.discovery.DiscoveryStrategy, target_peers: int) None

Register a strategy to call every tick unless a target number of peers has been reached. If the target_peers is equal to -1, the strategy is always called.

get_overlay(overlay_cls: type[latest.ipv8.types.Overlay]) latest.ipv8.types.Overlay | None

Get any loaded overlay instance from a given class type, if it exists.

get_overlays(overlay_cls: type[latest.ipv8.types.Overlay]) Generator[latest.ipv8.types.Overlay]

Get all loaded overlay instances from a given class type.

unload_overlay(instance: latest.ipv8.types.Overlay) Awaitable

Unregister and unload a given overlay instance.

async stop() None

Stop all registered IPv8 strategies, unload all registered overlays and close the endpoint.