From 4a0fc8b69ed839b74f1d23abb2798702f95ecacc Mon Sep 17 00:00:00 2001 From: Kittywhiskers Van Gogh <63189531+kwvg@users.noreply.github.com> Date: Thu, 19 Sep 2024 11:21:16 +0000 Subject: [PATCH 1/2] test: don't attempt to (dis)connect nodes to/from themselves --- test/functional/feature_dip3_v19.py | 3 +-- test/functional/feature_llmq_chainlocks.py | 4 +--- test/functional/feature_llmq_evo.py | 3 +-- test/functional/feature_llmq_rotation.py | 3 +-- test/functional/feature_mnehf.py | 2 +- test/functional/test_framework/test_framework.py | 8 ++++++++ 6 files changed, 13 insertions(+), 10 deletions(-) diff --git a/test/functional/feature_dip3_v19.py b/test/functional/feature_dip3_v19.py index fd987c7be2181..1f2376d62e3d0 100755 --- a/test/functional/feature_dip3_v19.py +++ b/test/functional/feature_dip3_v19.py @@ -54,8 +54,7 @@ def run_test(self): null_hash = format(0, "064x") for i in range(len(self.nodes)): - if i != 0: - self.connect_nodes(i, 0) + self.connect_nodes(i, 0) self.nodes[0].sporkupdate("SPORK_17_QUORUM_DKG_ENABLED", 0) self.wait_for_sporks_same() diff --git a/test/functional/feature_llmq_chainlocks.py b/test/functional/feature_llmq_chainlocks.py index 72f2cd6f93c8a..a7dfc132cca17 100755 --- a/test/functional/feature_llmq_chainlocks.py +++ b/test/functional/feature_llmq_chainlocks.py @@ -23,13 +23,11 @@ def set_test_params(self): self.set_dash_test_params(5, 4, fast_dip3_enforcement=True) def run_test(self): - # Connect all nodes to node1 so that we always have the whole network connected # Otherwise only masternode connections will be established between nodes, which won't propagate TXs/blocks # Usually node0 is the one that does this, but in this test we isolate it multiple times for i in range(len(self.nodes)): - if i != 1: - self.connect_nodes(i, 1) + self.connect_nodes(i, 1) self.test_coinbase_best_cl(self.nodes[0], expected_cl_in_cb=False) diff --git a/test/functional/feature_llmq_evo.py b/test/functional/feature_llmq_evo.py index e3a95cea676af..1135bedda48a7 100755 --- a/test/functional/feature_llmq_evo.py +++ b/test/functional/feature_llmq_evo.py @@ -58,8 +58,7 @@ def run_test(self): null_hash = format(0, "064x") for i in range(len(self.nodes)): - if i != 0: - self.connect_nodes(i, 0) + self.connect_nodes(i, 0) self.nodes[0].sporkupdate("SPORK_17_QUORUM_DKG_ENABLED", 0) self.nodes[0].sporkupdate("SPORK_2_INSTANTSEND_ENABLED", 1) diff --git a/test/functional/feature_llmq_rotation.py b/test/functional/feature_llmq_rotation.py index 8bfcbbd6a60b5..c8f9f4543709d 100755 --- a/test/functional/feature_llmq_rotation.py +++ b/test/functional/feature_llmq_rotation.py @@ -65,8 +65,7 @@ def run_test(self): # Usually node0 is the one that does this, but in this test we isolate it multiple times for i in range(len(self.nodes)): - if i != 1: - self.connect_nodes(i, 0) + self.connect_nodes(i, 0) self.nodes[0].sporkupdate("SPORK_17_QUORUM_DKG_ENABLED", 0) self.wait_for_sporks_same() diff --git a/test/functional/feature_mnehf.py b/test/functional/feature_mnehf.py index cadbbbc2caa95..6d78ac42777ab 100755 --- a/test/functional/feature_mnehf.py +++ b/test/functional/feature_mnehf.py @@ -43,7 +43,7 @@ def restart_all_nodes(self, params=None): self.stop_node(index) self.start_masternode(mn) for i in range(1, self.num_nodes): - self.connect_nodes(i, 0) + self.connect_nodes(i, 0) def slowly_generate_batch(self, amount): self.log.info(f"Slowly generate {amount} blocks") diff --git a/test/functional/test_framework/test_framework.py b/test/functional/test_framework/test_framework.py index d94a17f56f76d..40f8f87e44676 100755 --- a/test/functional/test_framework/test_framework.py +++ b/test/functional/test_framework/test_framework.py @@ -692,6 +692,10 @@ def wait_for_node_exit(self, i, timeout): self.nodes[i].process.wait(timeout) def connect_nodes(self, a, b): + # A node cannot connect to itself, bail out early + if (a == b): + return + def connect_nodes_helper(from_connection, node_num): ip_port = "127.0.0.1:" + str(p2p_port(node_num)) from_connection.addnode(ip_port, "onetry") @@ -706,6 +710,10 @@ def connect_nodes_helper(from_connection, node_num): connect_nodes_helper(self.nodes[a], b) def disconnect_nodes(self, a, b): + # A node cannot disconnect from itself, bail out early + if (a == b): + return + def disconnect_nodes_helper(from_connection, node_num): def get_peer_ids(): result = [] From 40f2ab906ca8fa1912daff0461b82419ef1de253 Mon Sep 17 00:00:00 2001 From: Kittywhiskers Van Gogh <63189531+kwvg@users.noreply.github.com> Date: Sun, 22 Sep 2024 16:29:46 +0000 Subject: [PATCH 2/2] test: don't attempt to reconnect already connected nodes --- test/functional/feature_dip3_v19.py | 3 --- test/functional/feature_llmq_chainlocks.py | 2 +- test/functional/feature_llmq_evo.py | 3 --- test/functional/feature_llmq_rotation.py | 3 --- test/functional/rpc_net.py | 1 - 5 files changed, 1 insertion(+), 11 deletions(-) diff --git a/test/functional/feature_dip3_v19.py b/test/functional/feature_dip3_v19.py index 1f2376d62e3d0..f5c1a5e59c9c2 100755 --- a/test/functional/feature_dip3_v19.py +++ b/test/functional/feature_dip3_v19.py @@ -53,9 +53,6 @@ def run_test(self): self.test_node = self.nodes[0].add_p2p_connection(TestP2PConn()) null_hash = format(0, "064x") - for i in range(len(self.nodes)): - self.connect_nodes(i, 0) - self.nodes[0].sporkupdate("SPORK_17_QUORUM_DKG_ENABLED", 0) self.wait_for_sporks_same() diff --git a/test/functional/feature_llmq_chainlocks.py b/test/functional/feature_llmq_chainlocks.py index a7dfc132cca17..7cebc7c5ca04f 100755 --- a/test/functional/feature_llmq_chainlocks.py +++ b/test/functional/feature_llmq_chainlocks.py @@ -26,7 +26,7 @@ def run_test(self): # Connect all nodes to node1 so that we always have the whole network connected # Otherwise only masternode connections will be established between nodes, which won't propagate TXs/blocks # Usually node0 is the one that does this, but in this test we isolate it multiple times - for i in range(len(self.nodes)): + for i in range(2, len(self.nodes)): self.connect_nodes(i, 1) self.test_coinbase_best_cl(self.nodes[0], expected_cl_in_cb=False) diff --git a/test/functional/feature_llmq_evo.py b/test/functional/feature_llmq_evo.py index 1135bedda48a7..a247bcf31c3b2 100755 --- a/test/functional/feature_llmq_evo.py +++ b/test/functional/feature_llmq_evo.py @@ -57,9 +57,6 @@ def run_test(self): self.test_node = self.nodes[0].add_p2p_connection(TestP2PConn()) null_hash = format(0, "064x") - for i in range(len(self.nodes)): - self.connect_nodes(i, 0) - self.nodes[0].sporkupdate("SPORK_17_QUORUM_DKG_ENABLED", 0) self.nodes[0].sporkupdate("SPORK_2_INSTANTSEND_ENABLED", 1) self.wait_for_sporks_same() diff --git a/test/functional/feature_llmq_rotation.py b/test/functional/feature_llmq_rotation.py index c8f9f4543709d..988e2719d812d 100755 --- a/test/functional/feature_llmq_rotation.py +++ b/test/functional/feature_llmq_rotation.py @@ -64,9 +64,6 @@ def run_test(self): # Otherwise only masternode connections will be established between nodes, which won't propagate TXs/blocks # Usually node0 is the one that does this, but in this test we isolate it multiple times - for i in range(len(self.nodes)): - self.connect_nodes(i, 0) - self.nodes[0].sporkupdate("SPORK_17_QUORUM_DKG_ENABLED", 0) self.wait_for_sporks_same() diff --git a/test/functional/rpc_net.py b/test/functional/rpc_net.py index 1972a949844df..7eab8898f8cf4 100755 --- a/test/functional/rpc_net.py +++ b/test/functional/rpc_net.py @@ -213,7 +213,6 @@ def test_getnetworkinfo(self): self.log.info('Test extended connections info') # Connect nodes both ways. - self.connect_nodes(0, 1) self.connect_nodes(1, 0) assert_equal(self.nodes[1].getnetworkinfo()['connections'], 2)