aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rwxr-xr-xtest/functional/feature_anchors.py1
-rwxr-xr-xtest/functional/feature_config_args.py1
-rwxr-xr-xtest/functional/test_framework/test_framework.py9
-rw-r--r--test/functional/test_framework/util.py8
4 files changed, 13 insertions, 6 deletions
diff --git a/test/functional/feature_anchors.py b/test/functional/feature_anchors.py
index 24bb02bc90..c39f6e6d4b 100755
--- a/test/functional/feature_anchors.py
+++ b/test/functional/feature_anchors.py
@@ -23,6 +23,7 @@ def check_node_connections(*, node, num_in, num_out):
class AnchorsTest(BitcoinTestFramework):
def set_test_params(self):
self.num_nodes = 1
+ self.disable_autoconnect = False
def setup_network(self):
self.setup_nodes()
diff --git a/test/functional/feature_config_args.py b/test/functional/feature_config_args.py
index de9d0d2e80..5a23df8a13 100755
--- a/test/functional/feature_config_args.py
+++ b/test/functional/feature_config_args.py
@@ -17,6 +17,7 @@ class ConfArgsTest(BitcoinTestFramework):
self.num_nodes = 1
self.supports_cli = False
self.wallet_names = []
+ self.disable_autoconnect = False
def test_config_file_parser(self):
self.stop_node(0)
diff --git a/test/functional/test_framework/test_framework.py b/test/functional/test_framework/test_framework.py
index 40360c54a0..6d8e6ef45c 100755
--- a/test/functional/test_framework/test_framework.py
+++ b/test/functional/test_framework/test_framework.py
@@ -112,6 +112,9 @@ class BitcoinTestFramework(metaclass=BitcoinTestMetaClass):
# By default the wallet is not required. Set to true by skip_if_no_wallet().
# When False, we ignore wallet_names regardless of what it is.
self.requires_wallet = False
+ # Disable ThreadOpenConnections by default, so that adding entries to
+ # addrman will not result in automatic connections to them.
+ self.disable_autoconnect = True
self.set_test_params()
assert self.wallet_names is None or len(self.wallet_names) <= self.num_nodes
if self.options.timeout_factor == 0 :
@@ -711,7 +714,7 @@ class BitcoinTestFramework(metaclass=BitcoinTestMetaClass):
if not os.path.isdir(cache_node_dir):
self.log.debug("Creating cache directory {}".format(cache_node_dir))
- initialize_datadir(self.options.cachedir, CACHE_NODE_ID, self.chain)
+ initialize_datadir(self.options.cachedir, CACHE_NODE_ID, self.chain, self.disable_autoconnect)
self.nodes.append(
TestNode(
CACHE_NODE_ID,
@@ -769,7 +772,7 @@ class BitcoinTestFramework(metaclass=BitcoinTestMetaClass):
self.log.debug("Copy cache directory {} to node {}".format(cache_node_dir, i))
to_dir = get_datadir_path(self.options.tmpdir, i)
shutil.copytree(cache_node_dir, to_dir)
- initialize_datadir(self.options.tmpdir, i, self.chain) # Overwrite port/rpcport in bitcoin.conf
+ initialize_datadir(self.options.tmpdir, i, self.chain, self.disable_autoconnect) # Overwrite port/rpcport in bitcoin.conf
def _initialize_chain_clean(self):
"""Initialize empty blockchain for use by the test.
@@ -777,7 +780,7 @@ class BitcoinTestFramework(metaclass=BitcoinTestMetaClass):
Create an empty blockchain and num_nodes wallets.
Useful if a test case wants complete control over initialization."""
for i in range(self.num_nodes):
- initialize_datadir(self.options.tmpdir, i, self.chain)
+ initialize_datadir(self.options.tmpdir, i, self.chain, self.disable_autoconnect)
def skip_if_no_py3_zmq(self):
"""Attempt to import the zmq package and skip the test if the import fails."""
diff --git a/test/functional/test_framework/util.py b/test/functional/test_framework/util.py
index b0f15ddafe..a9a6adcfc8 100644
--- a/test/functional/test_framework/util.py
+++ b/test/functional/test_framework/util.py
@@ -337,17 +337,17 @@ def rpc_url(datadir, i, chain, rpchost):
################
-def initialize_datadir(dirname, n, chain):
+def initialize_datadir(dirname, n, chain, disable_autoconnect=True):
datadir = get_datadir_path(dirname, n)
if not os.path.isdir(datadir):
os.makedirs(datadir)
- write_config(os.path.join(datadir, "bitcoin.conf"), n=n, chain=chain)
+ write_config(os.path.join(datadir, "bitcoin.conf"), n=n, chain=chain, disable_autoconnect=disable_autoconnect)
os.makedirs(os.path.join(datadir, 'stderr'), exist_ok=True)
os.makedirs(os.path.join(datadir, 'stdout'), exist_ok=True)
return datadir
-def write_config(config_path, *, n, chain, extra_config=""):
+def write_config(config_path, *, n, chain, extra_config="", disable_autoconnect=True):
# Translate chain subdirectory name to config name
if chain == 'testnet3':
chain_name_conf_arg = 'testnet'
@@ -375,6 +375,8 @@ def write_config(config_path, *, n, chain, extra_config=""):
f.write("shrinkdebugfile=0\n")
# To improve SQLite wallet performance so that the tests don't timeout, use -unsafesqlitesync
f.write("unsafesqlitesync=1\n")
+ if disable_autoconnect:
+ f.write("connect=0\n")
f.write(extra_config)