3.0.ipv8.test.peerdiscovery.test_network ======================================== .. py:module:: 3.0.ipv8.test.peerdiscovery.test_network Classes ------- .. autoapisummary:: 3.0.ipv8.test.peerdiscovery.test_network.MockPeerObserver 3.0.ipv8.test.peerdiscovery.test_network.TestNetwork Functions --------- .. autoapisummary:: 3.0.ipv8.test.peerdiscovery.test_network._generate_peer Module Contents --------------- .. py:function:: _generate_peer() -> 3.0.ipv8.peer.Peer Generate a Peer with a real private key and a fake address. .. py:class:: MockPeerObserver Bases: :py:obj:`3.0.ipv8.peerdiscovery.network.PeerObserver` A peer observer that simply stores all added and removed peers. .. py:attribute:: observed_additions :value: [] .. py:attribute:: observed_removals :value: [] .. py:method:: on_peer_added(peer: 3.0.ipv8.peer.Peer) -> None Callback for when a peer is added. .. py:method:: on_peer_removed(peer: 3.0.ipv8.peer.Peer) -> None Callback for when a peer is removed. .. py:class:: TestNetwork(methodName: str = 'runTest') Bases: :py:obj:`3.0.ipv8.test.base.TestBase` Tests related to the Network class. .. py:attribute:: peers .. py:attribute:: serialized_ipv4_len :value: 7 .. py:method:: setUp() -> None Create a new empty Network instance. .. py:method:: 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. .. py:method:: test_discover_address_duplicate() -> None Check registration of introducer and introduced when the same address is discovered twice. .. py:method:: test_discover_address_known() -> None Check if an address is already known, the network isn't updated. .. py:method:: test_discover_address_known_parent_deceased() -> None Check if an address is already known, the new introducer adopts the introduced. .. py:method:: test_discover_address_blacklist() -> None Check if an address is in the blacklist, the network isn't updated. .. py:method:: test_discover_address_multiple() -> None Check if a single peer can perform multiple introductions. .. py:method:: 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. .. py:method:: test_discover_services() -> None Check if services are properly registered for a peer. .. py:method:: test_discover_services_unverified() -> None Check if services are properly registered for an unverified peer. .. py:method:: test_discover_services_update() -> None Check if services are properly combined for a peer. .. py:method:: test_discover_services_update_overlap() -> None Check if services are properly combined when discovered services overlap. .. py:method:: test_discover_services_address_update() -> None Check if an address update gets processed correctly. .. py:method:: test_discover_services_cache() -> None Check if services cache updates properly. .. py:method:: test_add_verified_peer_new() -> None Check if a new verified peer can be added to the network. .. py:method:: test_add_verified_peer_blacklist() -> None Check if a new verified peer can be added to the network. .. py:method:: test_add_verified_peer_duplicate() -> None Check if an already verified (by slightly changed) peer doesn't cause duplicates in the network. .. py:method:: test_add_verified_peer_promote() -> None Check if a peer can be promoted from an address to a verified peer. .. py:method:: test_get_verified_by_address() -> None Check if we can find a peer in our network by its address. .. py:method:: test_get_verified_by_address_cache_pop() -> None When the cache if full, pop the least-used entry. .. py:method:: test_get_verified_by_address_cache_refresh() -> None Asking for the same peer twice should land it back on top of the cleanup stack. .. py:method:: test_get_verified_by_public_key() -> None Check if we can find a peer in our network by its public key. .. py:method:: test_remove_by_address() -> None Check if we can remove a peer from our network by its address. .. py:method:: test_remove_by_address_unverified() -> None Check if we can remove an unverified peer from our network by its address. .. py:method:: test_remove_by_address_unknown() -> None Removing unknown peers should not affect other peers. .. py:method:: 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. .. py:method:: test_remove_peer() -> None Check if we can remove a peer from our network. .. py:method:: test_remove_peer_external() -> None Check if we can remove an externally created peer from our network. .. py:method:: test_remove_peer_unknown() -> None Removing unknown peers should not affect other peers. .. py:method:: test_get_walkable_by_service() -> None Check if we can retrieve walkable addresses by parent service id. .. py:method:: test_snapshot_only_verified() -> None Check if a snapshot poperly serializes verified peers. .. py:method:: test_snapshot_verified_and_unverified() -> None Check if a snapshot poperly serializes only verified peers. .. py:method:: test_snapshot_only_unverified() -> None Check if a snapshot is empty without verified peers. .. py:method:: test_snapshot_no_peers() -> None Check if a snapshot is empty without verified peers. .. py:method:: test_load_snapshot() -> None Check if peers can be properly loaded from a snapshot. .. py:method:: test_load_snapshot_empty() -> None Check if no peers are loaded from an empty snapshot. .. py:method:: test_load_snapshot_malformed() -> None Check if no peers are loaded from a malformed snapshot. .. py:method:: test_load_snapshot_truncated() -> None Check if as many peers as possible are loaded from a truncated snapshot. .. py:method:: test_cache_reconstruct() -> None Check if services caches are reconstructed properly. This test is based on https://github.com/Tribler/py-ipv8/issues/1131 .. py:method:: test_add_peer_observer() -> None Check if an added observer becomes part of the registered observers. .. py:method:: test_remove_peer_observer() -> None Check if an added observer can be removed. .. py:method:: test_notify_peer_addition() -> None Check if peer observers are notified of newly added peers, when adding verified peers normally. .. py:method:: test_notify_peer_addition_discover() -> None Check if peer observers are notified of newly added peers, when they aid in address discovery. .. py:method:: test_notify_peer_addition_known_address() -> None Check if peer observers are notified of newly added peers, with known addresses. .. py:method:: test_notify_peer_removal() -> None Check if peer observers are notified of removed peers, when removing verified peers normally. .. py:method:: test_notify_peer_removal_by_address() -> None Check if peer observers are notified of removed peers, when removing a peer by its address. .. py:method:: 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.