latest.ipv8.test.peerdiscovery.test_network

Module Contents

Classes

MockPeerObserver

A peer observer that simply stores all added and removed peers.

TestNetwork

Tests related to the Network class.

Functions

_generate_peer(→ latest.ipv8.peer.Peer)

Generate a Peer with a real private key and a fake address.

latest.ipv8.test.peerdiscovery.test_network._generate_peer() latest.ipv8.peer.Peer

Generate a Peer with a real private key and a fake address.

class latest.ipv8.test.peerdiscovery.test_network.MockPeerObserver

Bases: latest.ipv8.peerdiscovery.network.PeerObserver

A peer observer that simply stores all added and removed peers.

on_peer_added(peer: latest.ipv8.peer.Peer) None

Callback for when a peer is added.

on_peer_removed(peer: latest.ipv8.peer.Peer) None

Callback for when a peer is removed.

class latest.ipv8.test.peerdiscovery.test_network.TestNetwork(methodName: str = 'runTest')

Bases: latest.ipv8.test.base.TestBase

Tests related to the Network class.

peers
serialized_ipv4_len = 7
setUp() None

Create a new empty Network instance.

test_discover_address() None

Check registration of introducer and introduced when a new address is discovered.

The introducer should be verified and not walkable. The introduced should not be verified and walkable.

test_discover_address_duplicate() None

Check registration of introducer and introduced when the same address is discovered twice.

test_discover_address_known() None

Check if an address is already known, the network isn’t updated.

test_discover_address_known_parent_deceased() None

Check if an address is already known, the new introducer adopts the introduced.

test_discover_address_blacklist() None

Check if an address is in the blacklist, the network isn’t updated.

test_discover_address_multiple() None

Check if a single peer can perform multiple introductions.

test_get_introductions_from_cache_no_refresh() None

Cache entries in the introduction cache should not refresh.

This is to avoid dead peers sticking around the cache for too long.

test_discover_services() None

Check if services are properly registered for a peer.

test_discover_services_unverified() None

Check if services are properly registered for an unverified peer.

test_discover_services_update() None

Check if services are properly combined for a peer.

test_discover_services_update_overlap() None

Check if services are properly combined when discovered services overlap.

test_discover_services_address_update() None

Check if an address update gets processed correctly.

test_discover_services_cache() None

Check if services cache updates properly.

test_add_verified_peer_new() None

Check if a new verified peer can be added to the network.

test_add_verified_peer_blacklist() None

Check if a new verified peer can be added to the network.

test_add_verified_peer_duplicate() None

Check if an already verified (by slightly changed) peer doesn’t cause duplicates in the network.

test_add_verified_peer_promote() None

Check if a peer can be promoted from an address to a verified peer.

test_get_verified_by_address() None

Check if we can find a peer in our network by its address.

test_get_verified_by_address_cache_pop() None

When the cache if full, pop the least-used entry.

test_get_verified_by_address_cache_refresh() None

Asking for the same peer twice should land it back on top of the cleanup stack.

test_get_verified_by_public_key() None

Check if we can find a peer in our network by its public key.

test_remove_by_address() None

Check if we can remove a peer from our network by its address.

test_remove_by_address_unverified() None

Check if we can remove an unverified peer from our network by its address.

test_remove_by_address_unknown() None

Removing unknown peers should not affect other peers.

test_remove_by_address_no_services() None

Check if we can remove a peer from our network if it doesn’t have services by address.

test_remove_peer() None

Check if we can remove a peer from our network.

test_remove_peer_external() None

Check if we can remove an externally created peer from our network.

test_remove_peer_unknown() None

Removing unknown peers should not affect other peers.

test_get_walkable_by_service() None

Check if we can retrieve walkable addresses by parent service id.

test_snapshot_only_verified() None

Check if a snapshot poperly serializes verified peers.

test_snapshot_verified_and_unverified() None

Check if a snapshot poperly serializes only verified peers.

test_snapshot_only_unverified() None

Check if a snapshot is empty without verified peers.

test_snapshot_no_peers() None

Check if a snapshot is empty without verified peers.

test_load_snapshot() None

Check if peers can be properly loaded from a snapshot.

test_load_snapshot_empty() None

Check if no peers are loaded from an empty snapshot.

test_load_snapshot_malformed() None

Check if no peers are loaded from a malformed snapshot.

test_load_snapshot_truncated() None

Check if as many peers as possible are loaded from a truncated snapshot.

test_cache_reconstruct() None

Check if services caches are reconstructed properly.

This test is based on https://github.com/Tribler/py-ipv8/issues/1131

test_add_peer_observer() None

Check if an added observer becomes part of the registered observers.

test_remove_peer_observer() None

Check if an added observer can be removed.

test_notify_peer_addition() None

Check if peer observers are notified of newly added peers, when adding verified peers normally.

test_notify_peer_addition_discover() None

Check if peer observers are notified of newly added peers, when they aid in address discovery.

test_notify_peer_addition_known_address() None

Check if peer observers are notified of newly added peers, with known addresses.

test_notify_peer_removal() None

Check if peer observers are notified of removed peers, when removing verified peers normally.

test_notify_peer_removal_by_address() None

Check if peer observers are notified of removed peers, when removing a peer by its address.

test_notify_peer_removal_by_address_many() None

Check if peer observers are notified of multiple removed peers, when removing them by their address.

Because peers may share addresses, multiple peers could be removed with the removal of one address.