mirror of
https://github.com/dashpay/dash.git
synced 2024-12-26 12:32:48 +01:00
Merge #11641: qa: Only allow disconnecting all NodeConns
faaa7db
qa: Only allow disconnecting all NodeConns (MarcoFalke)
Pull request description:
Disconnecting the connection with `index=0` makes no sense when there are more than one connections, as the list "rotates around" and populates index 0 after `del`.
Just disconnect all NodeConns in any case.
Tree-SHA512: e5cf540823fccb31634b5a11501f54222be89862e80ccafc28bc06726480f8d2153b8c1b6f859fa6a6d087876251d48a6c6035bccdaaf16831e300bc17ff613d
This commit is contained in:
commit
7adeea3b0f
@ -54,7 +54,7 @@ class MaxUploadTest(BitcoinTestFramework):
|
|||||||
# p2p_conns[2] will test resetting the counters
|
# p2p_conns[2] will test resetting the counters
|
||||||
p2p_conns = []
|
p2p_conns = []
|
||||||
|
|
||||||
for i in range(3):
|
for _ in range(3):
|
||||||
p2p_conns.append(self.nodes[0].add_p2p_connection(TestNode()))
|
p2p_conns.append(self.nodes[0].add_p2p_connection(TestNode()))
|
||||||
|
|
||||||
NetworkThread().start() # Start up network handling in another thread
|
NetworkThread().start() # Start up network handling in another thread
|
||||||
@ -139,8 +139,7 @@ class MaxUploadTest(BitcoinTestFramework):
|
|||||||
|
|
||||||
self.log.info("Peer 2 able to download old block")
|
self.log.info("Peer 2 able to download old block")
|
||||||
|
|
||||||
for i in range(3):
|
self.nodes[0].disconnect_p2ps()
|
||||||
self.nodes[0].disconnect_p2p()
|
|
||||||
|
|
||||||
#stop and start node 0 with 1MB maxuploadtarget, whitelist 127.0.0.1
|
#stop and start node 0 with 1MB maxuploadtarget, whitelist 127.0.0.1
|
||||||
self.log.info("Restarting nodes with -whitelist=127.0.0.1")
|
self.log.info("Restarting nodes with -whitelist=127.0.0.1")
|
||||||
|
@ -206,7 +206,7 @@ class AcceptBlockTest(BitcoinTestFramework):
|
|||||||
# The node should have requested the blocks at some point, so
|
# The node should have requested the blocks at some point, so
|
||||||
# disconnect/reconnect first
|
# disconnect/reconnect first
|
||||||
|
|
||||||
self.nodes[0].disconnect_p2p()
|
self.nodes[0].disconnect_p2ps()
|
||||||
test_node = self.nodes[0].add_p2p_connection(NodeConnCB())
|
test_node = self.nodes[0].add_p2p_connection(NodeConnCB())
|
||||||
|
|
||||||
test_node.wait_for_verack()
|
test_node.wait_for_verack()
|
||||||
@ -291,7 +291,7 @@ class AcceptBlockTest(BitcoinTestFramework):
|
|||||||
except AssertionError:
|
except AssertionError:
|
||||||
test_node.wait_for_disconnect()
|
test_node.wait_for_disconnect()
|
||||||
|
|
||||||
self.nodes[0].disconnect_p2p()
|
self.nodes[0].disconnect_p2ps()
|
||||||
test_node = self.nodes[0].add_p2p_connection(NodeConnCB())
|
test_node = self.nodes[0].add_p2p_connection(NodeConnCB())
|
||||||
|
|
||||||
NetworkThread().start() # Start up network handling in another thread
|
NetworkThread().start() # Start up network handling in another thread
|
||||||
|
@ -125,8 +125,7 @@ class P2PLeakTest(BitcoinTestFramework):
|
|||||||
assert not unsupported_service_bit5_node.connected
|
assert not unsupported_service_bit5_node.connected
|
||||||
assert not unsupported_service_bit7_node.connected
|
assert not unsupported_service_bit7_node.connected
|
||||||
|
|
||||||
for _ in range(5):
|
self.nodes[0].disconnect_p2ps()
|
||||||
self.nodes[0].disconnect_p2p()
|
|
||||||
|
|
||||||
# Wait until all connections are closed
|
# Wait until all connections are closed
|
||||||
wait_until(lambda: len(self.nodes[0].getpeerinfo()) == 0)
|
wait_until(lambda: len(self.nodes[0].getpeerinfo()) == 0)
|
||||||
|
@ -182,13 +182,14 @@ class TestNode():
|
|||||||
assert self.p2ps, "No p2p connection"
|
assert self.p2ps, "No p2p connection"
|
||||||
return self.p2ps[0]
|
return self.p2ps[0]
|
||||||
|
|
||||||
def disconnect_p2p(self, index=0):
|
def disconnect_p2ps(self):
|
||||||
"""Close the p2p connection to the node."""
|
"""Close all p2p connections to the node."""
|
||||||
# Connection could have already been closed by other end. Calling disconnect_p2p()
|
for p in self.p2ps:
|
||||||
# on an already disconnected p2p connection is not an error.
|
# Connection could have already been closed by other end.
|
||||||
if self.p2ps[index].connection is not None:
|
if p.connection is not None:
|
||||||
self.p2ps[index].connection.disconnect_node()
|
p.connection.disconnect_node()
|
||||||
del self.p2ps[index]
|
self.p2ps = []
|
||||||
|
|
||||||
|
|
||||||
class TestNodeCLI():
|
class TestNodeCLI():
|
||||||
"""Interface to bitcoin-cli for an individual node"""
|
"""Interface to bitcoin-cli for an individual node"""
|
||||||
|
Loading…
Reference in New Issue
Block a user