From 6ddf9d4f45a4b404129b639b6286d75373860b7c Mon Sep 17 00:00:00 2001 From: Egbert Bouman Date: Wed, 12 Aug 2020 13:49:54 +0200 Subject: [PATCH] Update IPv8 pointer --- src/anydex | 2 +- src/pyipv8 | 2 +- .../modules/libtorrent/download_state.py | 4 +- .../modules/tunnel/community/discovery.py | 4 +- .../modules/tunnel/community/payload.py | 45 +++++---- .../community/triblertunnel_community.py | 91 +++++++------------ .../test_full_session/test_tunnel_base.py | 4 +- .../modules/tunnel/tests/test_discovery.py | 4 +- .../tests/test_triblertunnel_community.py | 36 ++++---- 9 files changed, 84 insertions(+), 108 deletions(-) diff --git a/src/anydex b/src/anydex index 7d58edad5bb..18fbb100934 160000 --- a/src/anydex +++ b/src/anydex @@ -1 +1 @@ -Subproject commit 7d58edad5bbbcbd351a01fd35dd66fb53dbf3ef9 +Subproject commit 18fbb10093425396346c25da56026c58de229cae diff --git a/src/pyipv8 b/src/pyipv8 index 465cddd87ea..8b55295696b 160000 --- a/src/pyipv8 +++ b/src/pyipv8 @@ -1 +1 @@ -Subproject commit 465cddd87eaa73f4f974e21a125d4a38c4a0ff0c +Subproject commit 8b55295696b6e0493d77a7d099ae72ab6927c084 diff --git a/src/tribler-core/tribler_core/modules/libtorrent/download_state.py b/src/tribler-core/tribler_core/modules/libtorrent/download_state.py index d40b88d979a..dc5476fdf1f 100644 --- a/src/tribler-core/tribler_core/modules/libtorrent/download_state.py +++ b/src/tribler-core/tribler_core/modules/libtorrent/download_state.py @@ -5,7 +5,7 @@ """ import logging -from ipv8.messaging.anonymization.tunnel import PEER_FLAG_EXIT_ANY +from ipv8.messaging.anonymization.tunnel import PEER_FLAG_EXIT_BT from tribler_common.simpledefs import ( DLSTATUS_ALLOCATING_DISKSPACE, @@ -72,7 +72,7 @@ def get_status(self): @return DLSTATUS_* """ if not self.lt_status: return (DLSTATUS_CIRCUITS if not self.download.session.tunnel_community - or self.download.session.tunnel_community.get_candidates(PEER_FLAG_EXIT_ANY) + or self.download.session.tunnel_community.get_candidates(PEER_FLAG_EXIT_BT) else DLSTATUS_EXIT_NODES) if self.download.config.get_hops() > 0 else DLSTATUS_WAITING4HASHCHECK elif self.get_error(): return DLSTATUS_STOPPED_ON_ERROR diff --git a/src/tribler-core/tribler_core/modules/tunnel/community/discovery.py b/src/tribler-core/tribler_core/modules/tunnel/community/discovery.py index cc2d56c1e68..3e7535d36df 100644 --- a/src/tribler-core/tribler_core/modules/tunnel/community/discovery.py +++ b/src/tribler-core/tribler_core/modules/tunnel/community/discovery.py @@ -1,7 +1,7 @@ import time from random import sample -from ipv8.messaging.anonymization.tunnel import PEER_FLAG_EXIT_ANY +from ipv8.messaging.anonymization.tunnel import PEER_FLAG_EXIT_BT from ipv8.peerdiscovery.discovery import DiscoveryStrategy @@ -59,7 +59,7 @@ def take_step(self): peer_count = len(peers) if peer_count > self.target_peers: - exit_peers = set(self.overlay.get_candidates(PEER_FLAG_EXIT_ANY)) + exit_peers = set(self.overlay.get_candidates(PEER_FLAG_EXIT_BT)) exit_count = len(exit_peers) ratio = 1.0 - exit_count / peer_count # Peer count is > 0 per definition if ratio < self.golden_ratio: diff --git a/src/tribler-core/tribler_core/modules/tunnel/community/payload.py b/src/tribler-core/tribler_core/modules/tunnel/community/payload.py index f246bd8ac9b..6fe388a734c 100644 --- a/src/tribler-core/tribler_core/modules/tunnel/community/payload.py +++ b/src/tribler-core/tribler_core/modules/tunnel/community/payload.py @@ -1,10 +1,9 @@ from ipv8.attestation.trustchain.payload import HalfBlockPayload -from ipv8.messaging.lazy_payload import VariablePayload -from ipv8.messaging.payload import Payload +from ipv8.messaging.lazy_payload import VariablePayload, vp_compile class PayoutPayload(HalfBlockPayload): - + msg_id = 23 format_list = HalfBlockPayload.format_list + ["I", "I"] def __init__(self, public_key, sequence_number, link_public_key, link_sequence_number, previous_hash, @@ -42,7 +41,7 @@ def from_unpack_list(cls, *args): class BalanceResponsePayload(HalfBlockPayload): - + msg_id = 26 format_list = ["I"] + HalfBlockPayload.format_list def __init__(self, circuit_id, public_key, sequence_number, link_public_key, link_sequence_number, previous_hash, @@ -54,7 +53,7 @@ def __init__(self, circuit_id, public_key, sequence_number, link_public_key, lin @classmethod def from_half_block(cls, block, circuit_id): - return BalanceResponsePayload( + return cls( circuit_id, block.public_key, block.sequence_number, @@ -74,38 +73,36 @@ def to_pack_list(self): @classmethod def from_unpack_list(cls, *args): - return BalanceResponsePayload(*args) - + return cls(*args) -class BalanceRequestPayload(Payload): - format_list = ['I'] - - def __init__(self, circuit_id): - super(BalanceRequestPayload, self).__init__() - self._circuit_id = circuit_id +class RelayBalanceResponsePayload(BalanceResponsePayload): + msg_id = 27 - def to_pack_list(self): - data = [('I', self.circuit_id)] - return data +@vp_compile +class BalanceRequestPayload(VariablePayload): + msg_id = 24 + format_list = ['I'] + names = ['circuit_id'] - @classmethod - def from_unpack_list(cls, circuit_id): - return BalanceRequestPayload(circuit_id) - @property - def circuit_id(self): - return self._circuit_id +@vp_compile +class RelayBalanceRequestPayload(VariablePayload): + msg_id = 25 + format_list = ['I'] + names = ['circuit_id'] +@vp_compile class HTTPRequestPayload(VariablePayload): - + msg_id = 28 format_list = ['I', 'I', 'varlenH', 'varlenH'] names = ['circuit_id', 'identifier', 'target', 'request'] +@vp_compile class HTTPResponsePayload(VariablePayload): - + msg_id = 29 format_list = ['I', 'I', 'H', 'H', 'varlenH'] names = ['circuit_id', 'identifier', 'part', 'total', 'response'] diff --git a/src/tribler-core/tribler_core/modules/tunnel/community/triblertunnel_community.py b/src/tribler-core/tribler_core/modules/tunnel/community/triblertunnel_community.py index 6f4ea6bcaf9..6fdf833864a 100644 --- a/src/tribler-core/tribler_core/modules/tunnel/community/triblertunnel_community.py +++ b/src/tribler-core/tribler_core/modules/tunnel/community/triblertunnel_community.py @@ -13,7 +13,7 @@ from ipv8.attestation.trustchain.block import EMPTY_PK from ipv8.messaging.anonymization.caches import CreateRequestCache -from ipv8.messaging.anonymization.community import message_to_payload, tc_lazy_wrapper_unsigned +from ipv8.messaging.anonymization.community import unpack_cell from ipv8.messaging.anonymization.hidden_services import HiddenTunnelCommunity from ipv8.messaging.anonymization.payload import ( EstablishIntroPayload, @@ -29,8 +29,9 @@ CIRCUIT_TYPE_RP_DOWNLOADER, CIRCUIT_TYPE_RP_SEEDER, EXIT_NODE, - PEER_FLAG_EXIT_ANY, - RelayRoute, + PEER_FLAG_EXIT_BT, + PEER_FLAG_EXIT_IPV8, + RelayRoute ) from ipv8.peer import Peer from ipv8.peerdiscovery.network import Network @@ -49,6 +50,8 @@ HTTPRequestPayload, HTTPResponsePayload, PayoutPayload, + RelayBalanceRequestPayload, + RelayBalanceResponsePayload ) from tribler_core.modules.tunnel.socks5.server import Socks5Server from tribler_core.utilities import path_util @@ -85,7 +88,8 @@ def __init__(self, *args, **kwargs): if self.tribler_session: if self.tribler_session.config.get_tunnel_community_exitnode_enabled(): - self.settings.peer_flags.add(PEER_FLAG_EXIT_ANY) + self.settings.peer_flags.add(PEER_FLAG_EXIT_BT) + self.settings.peer_flags.add(PEER_FLAG_EXIT_IPV8) self.settings.peer_flags.add(PEER_FLAG_EXIT_HTTP) if not socks_listen_ports: @@ -110,25 +114,14 @@ def __init__(self, *args, **kwargs): self.dispatcher.set_socks_servers(self.socks_servers) - self.decode_map.update({ - chr(23): self.on_payout_block, - }) - - self.decode_map_private.update({ - chr(24): self.on_balance_request_cell, - chr(25): self.on_relay_balance_request_cell, - chr(26): self.on_balance_response_cell, - chr(27): self.on_relay_balance_response_cell, - chr(28): self.on_http_request, - chr(29): self.on_http_response - }) - - message_to_payload["balance-request"] = (24, BalanceRequestPayload) - message_to_payload["relay-balance-request"] = (25, BalanceRequestPayload) - message_to_payload["balance-response"] = (26, BalanceResponsePayload) - message_to_payload["relay-balance-response"] = (27, BalanceResponsePayload) - message_to_payload["http-request"] = (28, HTTPRequestPayload) - message_to_payload["http-response"] = (29, HTTPResponsePayload) + self.add_message_handler(PayoutPayload, self.on_payout_block) + + self.add_cell_handler(BalanceRequestPayload, self.on_balance_request_cell) + self.add_cell_handler(RelayBalanceRequestPayload, self.on_relay_balance_request_cell) + self.add_cell_handler(BalanceResponsePayload, self.on_balance_response_cell) + self.add_cell_handler(RelayBalanceResponsePayload, self.on_relay_balance_response_cell) + self.add_cell_handler(HTTPRequestPayload, self.on_http_request) + self.add_cell_handler(HTTPResponsePayload, self.on_http_response) NO_CRYPTO_PACKETS.extend([24, 26]) @@ -151,7 +144,7 @@ def cache_exitnodes_to_disk(self): :returns: None """ exit_nodes = Network() - for peer in self.get_candidates(PEER_FLAG_EXIT_ANY): + for peer in self.get_candidates(PEER_FLAG_EXIT_BT): exit_nodes.add_verified_peer(peer) self.logger.debug('Writing exit nodes to cache: %s', self.exitnode_cache) with open(self.exitnode_cache, 'wb') as cache: @@ -238,8 +231,7 @@ def should_join_circuit(self, create_payload, previous_node_address): shared_secret, _, _ = self.crypto.generate_diffie_shared_secret(create_payload.key) self.relay_session_keys[circuit_id] = self.crypto.generate_session_keys(shared_secret) - self.send_cell(Peer(create_payload.node_public_key, previous_node_address), "balance-request", - BalanceRequestPayload(circuit_id)) + self.send_cell(Peer(create_payload.node_public_key, previous_node_address), BalanceRequestPayload(circuit_id)) self.directions.pop(circuit_id, None) self.relay_session_keys.pop(circuit_id, None) @@ -272,21 +264,19 @@ async def on_payout_block(self, source_address, data): self.logger.warning("Not proceeding with payout - received payout block is not valid") return - def on_balance_request_cell(self, source_address, data, _): - payload = self._ez_unpack_noauth(BalanceRequestPayload, data, global_time=False) - + @unpack_cell(BalanceRequestPayload) + def on_balance_request_cell(self, source_address, payload, _): if self.request_cache.has("create", payload.circuit_id): request = self.request_cache.get("create", payload.circuit_id) forwarding_relay = RelayRoute(request.from_circuit_id, request.peer) - self.send_cell(forwarding_relay.peer, "relay-balance-request", - BalanceRequestPayload(forwarding_relay.circuit_id)) + self.send_cell(forwarding_relay.peer, RelayBalanceRequestPayload(forwarding_relay.circuit_id)) elif self.request_cache.has("retry", payload.circuit_id): self.on_balance_request(payload) else: self.logger.warning("Circuit creation cache for id %s not found!", payload.circuit_id) - def on_relay_balance_request_cell(self, source_address, data, _): - payload = self._ez_unpack_noauth(BalanceRequestPayload, data, global_time=False) + @unpack_cell(RelayBalanceRequestPayload) + def on_relay_balance_request_cell(self, source_address, payload, _): self.on_balance_request(payload) def on_balance_request(self, payload): @@ -307,18 +297,12 @@ def on_balance_request(self, payload): # We either send the response directly or relay the response to the last verified hop circuit = self.circuits[payload.circuit_id] if not circuit.hops: - self.increase_bytes_sent(circuit, self.send_cell(circuit.peer, - "balance-response", - BalanceResponsePayload.from_half_block( - latest_block, circuit.circuit_id))) + self.send_cell(circuit.peer, BalanceResponsePayload.from_half_block(latest_block, circuit.circuit_id)) else: - self.increase_bytes_sent(circuit, self.send_cell(circuit.peer, - "relay-balance-response", - BalanceResponsePayload.from_half_block( - latest_block, circuit.circuit_id))) + self.send_cell(circuit.peer, RelayBalanceResponsePayload.from_half_block(latest_block, circuit.circuit_id)) - def on_balance_response_cell(self, source_address, data, _): - payload = self._ez_unpack_noauth(BalanceResponsePayload, data, global_time=False) + @unpack_cell(BalanceResponsePayload) + def on_balance_response_cell(self, source_address, payload, _): block = TriblerBandwidthBlock.from_payload(payload, self.serializer) if not block.transaction: self.on_token_balance(payload.circuit_id, 0) @@ -326,17 +310,15 @@ def on_balance_response_cell(self, source_address, data, _): self.on_token_balance(payload.circuit_id, block.transaction[b"total_up"] - block.transaction[b"total_down"]) - def on_relay_balance_response_cell(self, source_address, data, _): - payload = self._ez_unpack_noauth(BalanceResponsePayload, data, global_time=False) + @unpack_cell(RelayBalanceResponsePayload) + def on_relay_balance_response_cell(self, source_address, payload, _): block = TriblerBandwidthBlock.from_payload(payload, self.serializer) # At this point, we don't have the circuit ID of the follow-up hop. We have to iterate over the items in the # request cache and find the link to the next hop. for cache in self.request_cache._identifiers.values(): if isinstance(cache, CreateRequestCache) and cache.from_circuit_id == payload.circuit_id: - self.send_cell(cache.to_peer, - "balance-response", - BalanceResponsePayload.from_half_block(block, cache.to_circuit_id)) + self.send_cell(cache.to_peer, BalanceResponsePayload.from_half_block(block, cache.to_circuit_id)) def readd_bittorrent_peers(self): for torrent, peers in list(self.bittorrent_peers.items()): @@ -602,7 +584,7 @@ async def unload(self): def get_lookup_info_hash(self, info_hash): return hashlib.sha1(b'tribler anonymous download' + hexlify(info_hash).encode('utf-8')).digest() - @tc_lazy_wrapper_unsigned(HTTPRequestPayload) + @unpack_cell(HTTPRequestPayload) async def on_http_request(self, source_address, payload, circuit_id): if circuit_id not in self.exit_sockets: self.logger.warning("Received unexpected http-request") @@ -652,11 +634,11 @@ async def on_http_request(self, source_address, payload, circuit_id): num_cells = math.ceil(len(response) / MAX_HTTP_PACKET_SIZE) for i in range(num_cells): - self.send_cell(source_address, "http-response", + self.send_cell(source_address, HTTPResponsePayload(circuit_id, payload.identifier, i, num_cells, response[i*MAX_HTTP_PACKET_SIZE:(i+1)*MAX_HTTP_PACKET_SIZE])) - @tc_lazy_wrapper_unsigned(HTTPResponsePayload) + @unpack_cell(HTTPResponsePayload) def on_http_response(self, source_address, payload, circuit_id): if not self.request_cache.has("http-request", payload.identifier): self.logger.warning("Received unexpected http-response") @@ -689,11 +671,8 @@ async def perform_http_request(self, destination, request, hops=1): raise RuntimeError('No HTTP exits available') cache = self.request_cache.add(HTTPRequestCache(self, circuit.circuit_id)) - self.increase_bytes_sent(circuit, self.send_cell(circuit.peer, "http-request", - HTTPRequestPayload(circuit.circuit_id, - cache.number, - encode_address(*destination), - request))) + self.send_cell(circuit.peer, HTTPRequestPayload(circuit.circuit_id, cache.number, + encode_address(*destination), request)) return await cache.response_future diff --git a/src/tribler-core/tribler_core/modules/tunnel/test_full_session/test_tunnel_base.py b/src/tribler-core/tribler_core/modules/tunnel/test_full_session/test_tunnel_base.py index 271d4e9bf99..9720e9533da 100644 --- a/src/tribler-core/tribler_core/modules/tunnel/test_full_session/test_tunnel_base.py +++ b/src/tribler-core/tribler_core/modules/tunnel/test_full_session/test_tunnel_base.py @@ -1,7 +1,7 @@ from asyncio import all_tasks, gather, sleep from ipv8.keyvault.crypto import ECCrypto -from ipv8.messaging.anonymization.tunnel import PEER_FLAG_EXIT_ANY +from ipv8.messaging.anonymization.tunnel import PEER_FLAG_EXIT_BT from ipv8.peer import Peer from ipv8.peerdiscovery.community import DiscoveryCommunity from ipv8.peerdiscovery.network import Network @@ -114,7 +114,7 @@ async def load_tunnel_community_in_session(self, session, exitnode=False, start_ overlay = self.test_class(tunnel_peer, session.ipv8.endpoint, session.ipv8.network, tribler_session=session, settings={"max_circuits": 1}) if exitnode: - overlay.settings.peer_flags.add(PEER_FLAG_EXIT_ANY) + overlay.settings.peer_flags.add(PEER_FLAG_EXIT_BT) overlay._use_main_thread = False overlay.dht_provider = MockDHTProvider(Peer(overlay.my_peer.key, overlay.my_estimated_wan)) overlay.settings.remove_tunnel_delay = 0 diff --git a/src/tribler-core/tribler_core/modules/tunnel/tests/test_discovery.py b/src/tribler-core/tribler_core/modules/tunnel/tests/test_discovery.py index 70a9bfa4e73..67a2d2566b3 100644 --- a/src/tribler-core/tribler_core/modules/tunnel/tests/test_discovery.py +++ b/src/tribler-core/tribler_core/modules/tunnel/tests/test_discovery.py @@ -2,7 +2,7 @@ from unittest.mock import Mock from ipv8.keyvault.crypto import default_eccrypto -from ipv8.messaging.anonymization.tunnel import PEER_FLAG_EXIT_ANY +from ipv8.messaging.anonymization.tunnel import PEER_FLAG_EXIT_BT from ipv8.peer import Peer from ipv8.peerdiscovery.network import Network @@ -16,7 +16,7 @@ def __init__(self): self.network = Network() def get_candidates(self, flag): - return self.exit_candidates if flag == PEER_FLAG_EXIT_ANY else [] + return self.exit_candidates if flag == PEER_FLAG_EXIT_BT else [] def get_peers(self): return self.network.verified_peers diff --git a/src/tribler-core/tribler_core/modules/tunnel/tests/test_triblertunnel_community.py b/src/tribler-core/tribler_core/modules/tunnel/tests/test_triblertunnel_community.py index c82315f86bb..cc298e9b61f 100644 --- a/src/tribler-core/tribler_core/modules/tunnel/tests/test_triblertunnel_community.py +++ b/src/tribler-core/tribler_core/modules/tunnel/tests/test_triblertunnel_community.py @@ -11,7 +11,7 @@ CIRCUIT_STATE_READY, CIRCUIT_TYPE_RP_DOWNLOADER, CIRCUIT_TYPE_RP_SEEDER, - PEER_FLAG_EXIT_ANY, + PEER_FLAG_EXIT_BT, ) from ipv8.peer import Peer from ipv8.test.base import TestBase @@ -69,7 +69,7 @@ async def assign_exit_node(self, node_nr): """ exit_node = self.create_node() self.nodes.append(exit_node) # So it could be properly removed on exit - exit_node.overlay.settings.peer_flags.add(PEER_FLAG_EXIT_ANY) + exit_node.overlay.settings.peer_flags.add(PEER_FLAG_EXIT_BT) public_peer = Peer(exit_node.my_peer.public_key, exit_node.my_peer.address) self.nodes[node_nr].network.add_verified_peer(public_peer) self.nodes[node_nr].network.discover_services(public_peer, exit_node.overlay.master_peer.mid) @@ -87,10 +87,10 @@ async def test_backup_exitnodes(self): """ # 1. Add and exit node exit_node = self.create_node() - exit_node.overlay.settings.peer_flags.add(PEER_FLAG_EXIT_ANY) + exit_node.overlay.settings.peer_flags.add(PEER_FLAG_EXIT_BT) self.add_node_to_experiment(exit_node) self.nodes[0].overlay.candidates[exit_node.my_peer] = exit_node.overlay.settings.peer_flags - self.assertGreaterEqual(len(self.nodes[0].overlay.get_candidates(PEER_FLAG_EXIT_ANY)), 1) + self.assertGreaterEqual(len(self.nodes[0].overlay.get_candidates(PEER_FLAG_EXIT_BT)), 1) # 2. Unload self.nodes[0].overlay.cache_exitnodes_to_disk() self.nodes[0].network.verified_peers = set() @@ -99,7 +99,7 @@ async def test_backup_exitnodes(self): self.nodes[0].overlay.restore_exitnodes_from_disk() # 4. Check if exit node was contacted await self.deliver_messages() - self.assertGreaterEqual(len(self.nodes[0].overlay.get_candidates(PEER_FLAG_EXIT_ANY)), 1) + self.assertGreaterEqual(len(self.nodes[0].overlay.get_candidates(PEER_FLAG_EXIT_BT)), 1) def test_readd_bittorrent_peers(self): """ @@ -280,7 +280,7 @@ async def test_payouts(self): self.add_node_to_experiment(self.create_node()) # Build a tunnel - self.nodes[2].overlay.settings.peer_flags.add(PEER_FLAG_EXIT_ANY) + self.nodes[2].overlay.settings.peer_flags.add(PEER_FLAG_EXIT_BT) await self.introduce_nodes() self.nodes[0].overlay.build_tunnels(2) await self.deliver_messages(timeout=.5) @@ -305,7 +305,7 @@ async def test_circuit_reject_too_many(self): Test whether a circuit is rejected by an exit node if it already joined the max number of circuits """ self.add_node_to_experiment(self.create_node()) - self.nodes[1].overlay.settings.peer_flags.add(PEER_FLAG_EXIT_ANY) + self.nodes[1].overlay.settings.peer_flags.add(PEER_FLAG_EXIT_BT) self.nodes[1].overlay.settings.max_joined_circuits = 0 await self.introduce_nodes() self.nodes[0].overlay.build_tunnels(1) @@ -363,7 +363,7 @@ async def test_payouts_invalid_block(self): self.add_node_to_experiment(self.create_node()) # Build a tunnel - self.nodes[1].overlay.settings.peer_flags.add(PEER_FLAG_EXIT_ANY) + self.nodes[1].overlay.settings.peer_flags.add(PEER_FLAG_EXIT_BT) await self.introduce_nodes() self.nodes[0].overlay.build_tunnels(1) await self.deliver_messages(timeout=.5) @@ -385,7 +385,7 @@ async def test_decline_competing_slot(self): Test whether a circuit is not created when a node does not have enough balance for a competing slot """ self.add_node_to_experiment(self.create_node()) - self.nodes[1].overlay.settings.peer_flags.add(PEER_FLAG_EXIT_ANY) + self.nodes[1].overlay.settings.peer_flags.add(PEER_FLAG_EXIT_BT) await self.introduce_nodes() self.nodes[1].overlay.random_slots = [] self.nodes[1].overlay.competing_slots = [(1000, 1234)] @@ -401,7 +401,7 @@ async def test_win_competing_slot(self): Test whether a circuit is created when a node has enough balance for a competing slot """ self.add_node_to_experiment(self.create_node()) - self.nodes[1].overlay.settings.peer_flags.add(PEER_FLAG_EXIT_ANY) + self.nodes[1].overlay.settings.peer_flags.add(PEER_FLAG_EXIT_BT) await self.introduce_nodes() self.nodes[1].overlay.random_slots = [] self.nodes[1].overlay.competing_slots = [(-1000, 1234)] @@ -417,7 +417,7 @@ async def test_empty_competing_slot(self): Test whether a circuit is created when a node takes an empty competing slot """ self.add_node_to_experiment(self.create_node()) - self.nodes[1].overlay.settings.peer_flags.add(PEER_FLAG_EXIT_ANY) + self.nodes[1].overlay.settings.peer_flags.add(PEER_FLAG_EXIT_BT) await self.introduce_nodes() self.nodes[1].overlay.random_slots = [] self.nodes[1].overlay.competing_slots = [(0, None)] @@ -434,7 +434,7 @@ async def test_win_competing_slot_exit(self): """ self.add_node_to_experiment(self.create_node()) self.add_node_to_experiment(self.create_node()) - self.nodes[2].overlay.settings.peer_flags.add(PEER_FLAG_EXIT_ANY) + self.nodes[2].overlay.settings.peer_flags.add(PEER_FLAG_EXIT_BT) await self.introduce_nodes() self.nodes[2].overlay.random_slots = [] self.nodes[2].overlay.competing_slots = [(-1000, 1234)] @@ -451,7 +451,7 @@ async def test_win_competing_slot_relay(self): """ self.add_node_to_experiment(self.create_node()) self.add_node_to_experiment(self.create_node()) - self.nodes[2].overlay.settings.peer_flags.add(PEER_FLAG_EXIT_ANY) + self.nodes[2].overlay.settings.peer_flags.add(PEER_FLAG_EXIT_BT) await self.introduce_nodes() self.nodes[1].overlay.random_slots = [] self.nodes[1].overlay.competing_slots = [(-1000, 1234)] @@ -468,7 +468,7 @@ async def test_payout_on_competition_kick(self): """ self.add_node_to_experiment(self.create_node()) self.add_node_to_experiment(self.create_node()) - self.nodes[2].overlay.settings.peer_flags.add(PEER_FLAG_EXIT_ANY) + self.nodes[2].overlay.settings.peer_flags.add(PEER_FLAG_EXIT_BT) await self.introduce_nodes() # Make sure that there's a token disbalance between node 0 and 1 @@ -502,7 +502,7 @@ async def test_intro_point_slot(self): Test whether a introduction point occupies a slot """ self.add_node_to_experiment(self.create_node()) - self.nodes[1].overlay.settings.peer_flags.add(PEER_FLAG_EXIT_ANY) + self.nodes[1].overlay.settings.peer_flags.add(PEER_FLAG_EXIT_BT) await self.introduce_nodes() circuit = self.nodes[0].overlay.create_circuit(1) @@ -511,7 +511,7 @@ async def test_intro_point_slot(self): exit_socket = list(self.nodes[1].overlay.exit_sockets.values())[0] self.assertTrue(exit_socket.circuit_id in self.nodes[1].overlay.random_slots) - self.nodes[0].overlay.send_cell(circuit.peer, 'establish-intro', + self.nodes[0].overlay.send_cell(circuit.peer, EstablishIntroPayload(circuit.circuit_id, int(random() * 2 ** 16), b'', b'')) await self.deliver_messages() self.assertFalse(exit_socket.circuit_id in self.nodes[1].overlay.random_slots) @@ -524,7 +524,7 @@ async def test_create_circuit_without_wallet(self): self.add_node_to_experiment(self.create_node()) await self.nodes[0].overlay.bandwidth_wallet.shutdown_task_manager() self.nodes[0].overlay.bandwidth_wallet = None - self.nodes[1].overlay.settings.peer_flags.add(PEER_FLAG_EXIT_ANY) + self.nodes[1].overlay.settings.peer_flags.add(PEER_FLAG_EXIT_BT) await self.introduce_nodes() # Initialize the slots @@ -543,7 +543,7 @@ async def test_reject_callback(self): """ reject_future = Future() self.add_node_to_experiment(self.create_node()) - self.nodes[1].overlay.settings.peer_flags.add(PEER_FLAG_EXIT_ANY) + self.nodes[1].overlay.settings.peer_flags.add(PEER_FLAG_EXIT_BT) await self.introduce_nodes() # Make sure that there's a token disbalance between node 0 and 1