Changeset View
Changeset View
Standalone View
Standalone View
test/functional/p2p_add_connections.py
#!/usr/bin/env python3 | #!/usr/bin/env python3 | ||||
# Copyright (c) 2020 The Bitcoin Core developers | # Copyright (c) 2020 The Bitcoin Core developers | ||||
# Distributed under the MIT software license, see the accompanying | # Distributed under the MIT software license, see the accompanying | ||||
# file COPYING or http://www.opensource.org/licenses/mit-license.php. | # file COPYING or http://www.opensource.org/licenses/mit-license.php. | ||||
"""Test add_outbound_p2p_connection test framework functionality""" | """Test add_outbound_p2p_connection test framework functionality""" | ||||
import random | import random | ||||
from test_framework.messages import NODE_AVALANCHE, NODE_NETWORK | from test_framework.messages import NODE_AVALANCHE, NODE_NETWORK | ||||
from test_framework.p2p import P2PInterface | from test_framework.p2p import P2PInterface | ||||
from test_framework.test_framework import BitcoinTestFramework | from test_framework.test_framework import BitcoinTestFramework | ||||
from test_framework.util import assert_equal, check_node_connections | from test_framework.util import assert_equal, check_node_connections | ||||
# From net.h | # From net.h | ||||
MAX_OUTBOUND_FULL_RELAY_CONNECTIONS = 16 | MAX_OUTBOUND_FULL_RELAY_CONNECTIONS = 16 | ||||
MAX_AVALANCHE_OUTBOUND_CONNECTIONS = 16 | |||||
MAX_BLOCK_RELAY_ONLY_CONNECTIONS = 2 | MAX_BLOCK_RELAY_ONLY_CONNECTIONS = 2 | ||||
# Override DEFAULT_MAX_AVALANCHE_OUTBOUND_CONNECTIONS with | |||||
# -maxavalancheoutbound | |||||
MAX_AVALANCHE_OUTBOUND_CONNECTIONS = 12 | |||||
class P2PFeelerReceiver(P2PInterface): | class P2PFeelerReceiver(P2PInterface): | ||||
def on_version(self, message): | def on_version(self, message): | ||||
# The bitcoind node closes feeler connections as soon as a version | # The bitcoind node closes feeler connections as soon as a version | ||||
# message is received from the test framework. Don't send any responses | # message is received from the test framework. Don't send any responses | ||||
# to the node's version message since the connection will already be | # to the node's version message since the connection will already be | ||||
# closed. | # closed. | ||||
pass | pass | ||||
class P2PAddConnections(BitcoinTestFramework): | class P2PAddConnections(BitcoinTestFramework): | ||||
def set_test_params(self): | def set_test_params(self): | ||||
self.num_nodes = 2 | self.num_nodes = 2 | ||||
self.extra_args = [["-enableavalanche=1"], []] | self.extra_args = [ | ||||
[ | |||||
"-enableavalanche=1", | |||||
f"-maxavalancheoutbound={MAX_AVALANCHE_OUTBOUND_CONNECTIONS}" | |||||
], | |||||
[] | |||||
] | |||||
def setup_network(self): | def setup_network(self): | ||||
self.setup_nodes() | self.setup_nodes() | ||||
# Don't connect the nodes | # Don't connect the nodes | ||||
def add_outbounds(self, node, quantity, conn_type): | def add_outbounds(self, node, quantity, conn_type): | ||||
services = NODE_NETWORK | services = NODE_NETWORK | ||||
if conn_type == "avalanche": | if conn_type == "avalanche": | ||||
▲ Show 20 Lines • Show All 175 Lines • Show Last 20 Lines |