tribler.test_unit.core.tunnel.test_discovery

Classes

MockTriblerTunnelCommunity

A mocked TriblerTunnelCommunity.

TestGoldenRatioStrategy

Tests for the GoldenRatioStrategy class.

Module Contents

class tribler.test_unit.core.tunnel.test_discovery.MockTriblerTunnelCommunity(settings: ipv8.community.CommunitySettings)

Bases: ipv8.community.Community

A mocked TriblerTunnelCommunity.

settings_class
community_id = b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'
exit_candidates = []
candidates
send_introduction_request
get_candidates(flag: int) list

Get exit candidates.

get_peers() set[ipv8.peer.Peer]

Get all known peers.

class tribler.test_unit.core.tunnel.test_discovery.TestGoldenRatioStrategy

Bases: ipv8.test.base.TestBase[MockTriblerTunnelCommunity]

Tests for the GoldenRatioStrategy class.

setUp() None

Create two peers.

test_invariant() None

If we are not at our target peer count, don’t do anything.

test_remove_normal() None

If we have a normal node and an exit node, check if enforcing a ratio of 0.0 removes the normal node.

test_remove_exit() None

If we have a normal node and an exit node, check if enforcing a ratio of 1.0 removes the exit node.

test_send_introduction_request() None

If a node has sent us its peer_flag, check if an introduction_request is sent.