The only approach that I can imagine while containing the test inside test_getnetworkinfo() is this, but I don't really like it:
$ git diff
diff --git a/test/functional/rpc_net.py b/test/functional/rpc_net.py
index 1a4d1b44ff..9acfe8ef83 100755
--- a/test/functional/rpc_net.py
+++ b/test/functional/rpc_net.py
@@ -24,6 +24,7 @@ from test_framework.util import (
assert_greater_than,
assert_raises_rpc_error,
p2p_port,
+ write_config,
)
from test_framework.wallet import MiniWallet
@@ -64,16 +65,12 @@ class NetTest(BitcoinTestFramework):
self.num_nodes = 2
self.extra_args = [
["-minrelaytxfee=0.00001000"],
- [
- "-minrelaytxfee=0.00000500",
- "-privatebroadcast",
- ],
+ ["-minrelaytxfee=0.00000500"],
]
# Specify a non-working proxy to make sure no actual connections to public IPs are attempted
for args in self.extra_args:
args.append("-proxy=127.0.0.1:1")
self.supports_cli = False
- self.disable_autoconnect = False
def run_test(self):
# We need miniwallet to make a transaction
@@ -218,7 +215,17 @@ class NetTest(BitcoinTestFramework):
assert_equal(info['connections_in'], 1)
assert_equal(info['connections_out'], 1)
assert_equal(info['privatebroadcast'], "disabled")
+
+ # Temporarily rewrite node 1's config without connect=0 so that
+ # -privatebroadcast (which is incompatible with -connect) can be tested.
+ write_config(self.nodes[1].datadir_path / "bitcoin.conf", n=1, chain=self.chain, disable_autoconnect=False)
+ self.restart_node(1, extra_args=["-minrelaytxfee=0.00000500", "-proxy=127.0.0.1:1", "-privatebroadcast"])
assert_equal(self.nodes[1].getnetworkinfo()['privatebroadcast'], "enabled")
+ write_config(self.nodes[1].datadir_path / "bitcoin.conf", n=1, chain=self.chain, extra_config="bind=127.0.0.1\n")
+ self.restart_node(1, extra_args=self.extra_args[1])
+ self.connect_nodes(0, 1)
+ self.sync_all()
with self.nodes[0].assert_debug_log(expected_msgs=['SetNetworkActive: false\n']):
self.nodes[0].setnetworkactive(state=False)