latest.ipv8.test.dht.test_routing

Module Contents

Classes

FakeNode

A fake node.

TestNode

Tests related to the states of nodes.

TestBucket

Tests related to Buckets.

TestRoutingTable

Tests for routing tables.

class latest.ipv8.test.dht.test_routing.FakeNode(binary_prefix: str)

Bases: latest.ipv8.dht.routing.Node

A fake node.

property id: bytes

Our fixed testing id.

property status: int

Always return a good status.

class latest.ipv8.test.dht.test_routing.TestNode(methodName: str = 'runTest')

Bases: latest.ipv8.test.base.TestBase

Tests related to the states of nodes.

setUp() None

Create a single node.

test_init() None

Check if the defaults values of nodes are properly initialized.

test_status() None

Check if the status of nodes is correctly returned.

test_last_contact() None

Check if the last contact property is properly derived from the last queries and last response.

class latest.ipv8.test.dht.test_routing.TestBucket(methodName: str = 'runTest')

Bases: latest.ipv8.test.base.TestBase

Tests related to Buckets.

setUp() None

Create a single bucket with a prefix id of 01 and maximum size of 8.

test_owns() None

Check if a Bucket correctly identifies that prefixes that it should “own”.

test_get() None

Check if nodes can be retrieved by their id.

test_add() None

Check if adding a node to a bucket that it belongs to succeeds.

test_add_fail() None

Check if adding a node to a bucket that it does not belong to fails.

test_add_update() None

Check if nodes are merged together with their most recent data.

test_add_full() None

Check if nodes are not added to an already-full bucket.

test_add_cleanup() None

Check if nodes are not added to an already-full bucket, even if the existing nodes should be cleaned.

test_split() None

Check if buckets properly split into other buckets.

test_split_not_full() None

Check that non-full buckets do not allow splits.

class latest.ipv8.test.dht.test_routing.TestRoutingTable(methodName: str = 'runTest')

Bases: latest.ipv8.test.base.TestBase

Tests for routing tables.

setUp() None

Create a routing table for a fake node with prefix 1111111111111111111111111111111111111111.

test_add_single_node() None

Check that adding a node to the routing table inserts it into the trie.

test_add_multiple_nodes() None

Check that adding multiple nodes causes them to be inserted into the trie.

test_add_node_with_bucket_split() None

Check that overflowing the max size of a trie splits it.

test_add_node_full() None

Check that a node is dropped if another node already serves its (max size) prefix.

test_closest_nodes_single_bucket() None

Check if we can retrieve the closest nodes, in order, to a given id.

test_closest_nodes_multiple_buckets() None

Check if we can retrieve the closest nodes, in order, to a given id after a trie split.

test_closest_nodes_no_nodes() None

Check if we return False if no nodes are available as closest nodes.