Skip to content

Commit

Permalink
Merge #6289: test: avoid node (dis)connections in functional tests th…
Browse files Browse the repository at this point in the history
…at are invalid or likely to fail

40f2ab9 test: don't attempt to reconnect already connected nodes (Kittywhiskers Van Gogh)
4a0fc8b test: don't attempt to (dis)connect nodes to/from themselves (Kittywhiskers Van Gogh)

Pull request description:

  ## Additional Information

  * Dependency for #6276

  ## Checklist:

  - [x] I have performed a self-review of my own code
  - [x] I have commented my code, particularly in hard-to-understand areas
  - [x] I have added or updated relevant unit/integration/functional/e2e tests
  - [x] I have made corresponding changes to the documentation **(note: N/A)**
  - [x] I have assigned this pull request to a milestone _(for repository code-owners and collaborators only)_

ACKs for top commit:
  UdjinM6:
    utACK 40f2ab9

Tree-SHA512: aaaeedabeb6b8ef77187fc14db1888c39863daf66afda93b8c8bc1dbbdf3ff6734445fd296d5b1034da6104e2d7cfcacf26b97b7be0a697b7a99f3671b6cb9a2
  • Loading branch information
PastaPastaPasta committed Oct 1, 2024
2 parents 9612287 + 40f2ab9 commit e493d59
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 18 deletions.
4 changes: 0 additions & 4 deletions test/functional/feature_dip3_v19.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,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)):
if i != 0:
self.connect_nodes(i, 0)

self.nodes[0].sporkupdate("SPORK_17_QUORUM_DKG_ENABLED", 0)
self.wait_for_sporks_same()

Expand Down
6 changes: 2 additions & 4 deletions test/functional/feature_llmq_chainlocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,11 @@ def set_test_params(self):
self.set_dash_test_params(5, 4)

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)
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)

Expand Down
4 changes: 0 additions & 4 deletions test/functional/feature_llmq_evo.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +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)):
if 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)
self.wait_for_sporks_same()
Expand Down
4 changes: 0 additions & 4 deletions test/functional/feature_llmq_rotation.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +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)):
if i != 1:
self.connect_nodes(i, 0)

self.nodes[0].sporkupdate("SPORK_17_QUORUM_DKG_ENABLED", 0)
self.wait_for_sporks_same()

Expand Down
2 changes: 1 addition & 1 deletion test/functional/feature_mnehf.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
1 change: 0 additions & 1 deletion test/functional/rpc_net.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
8 changes: 8 additions & 0 deletions test/functional/test_framework/test_framework.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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 = []
Expand Down

0 comments on commit e493d59

Please sign in to comment.