Skip to content

Commit adc41cf

Browse files
author
MarcoFalke
committed
Merge bitcoin#26805: tests: Use unique port for ZMQ tests to allow for multiple test instances
c6119f4 tests: Use unique port for ZMQ tests (Andrew Chow) Pull request description: The ZMQ interface tests should use unique ports as we do for the p2p and rpc ports so that multiple instances of the test can be run at the same time. Without this, the test may hang until killed, or fail. ACKs for top commit: MarcoFalke: ACK c6119f4 Tree-SHA512: 2ca3ed2f35e5a83d7ab83740674fed362a8d146dc751156cfe100133a591347cd1ac9d164046f1744d65451a57c52cb22d3bb2161105f421f8f655c4a2512c59
2 parents 911a40e + c6119f4 commit adc41cf

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

test/functional/interface_zmq.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
from test_framework.util import (
2323
assert_equal,
2424
assert_raises_rpc_error,
25+
p2p_port,
2526
)
2627
from test_framework.wallet import (
2728
MiniWallet,
@@ -106,6 +107,7 @@ def set_test_params(self):
106107
# This test isn't testing txn relay/timing, so set whitelist on the
107108
# peers for instant txn relay. This speeds up the test run time 2-3x.
108109
self.extra_args = [["-whitelist=noban@127.0.0.1"]] * self.num_nodes
110+
self.zmq_port_base = p2p_port(self.num_nodes + 1)
109111

110112
def skip_test_if_missing_module(self):
111113
self.skip_if_no_py3_zmq()
@@ -179,7 +181,7 @@ def test_basic(self):
179181
# Invalid zmq arguments don't take down the node, see #17185.
180182
self.restart_node(0, ["-zmqpubrawtx=foo", "-zmqpubhashtx=bar"])
181183

182-
address = 'tcp://127.0.0.1:28332'
184+
address = f"tcp://127.0.0.1:{self.zmq_port_base}"
183185
subs = self.setup_zmq_test([(topic, address) for topic in ["hashblock", "hashtx", "rawblock", "rawtx"]])
184186

185187
hashblock = subs[0]
@@ -246,7 +248,7 @@ def test_basic(self):
246248

247249
def test_reorg(self):
248250

249-
address = 'tcp://127.0.0.1:28333'
251+
address = f"tcp://127.0.0.1:{self.zmq_port_base}"
250252

251253
# Should only notify the tip if a reorg occurs
252254
hashblock, hashtx = self.setup_zmq_test(
@@ -300,7 +302,7 @@ def test_sequence(self):
300302
<32-byte hash>A<8-byte LE uint> : Transactionhash added mempool
301303
"""
302304
self.log.info("Testing 'sequence' publisher")
303-
[seq] = self.setup_zmq_test([("sequence", "tcp://127.0.0.1:28333")])
305+
[seq] = self.setup_zmq_test([("sequence", f"tcp://127.0.0.1:{self.zmq_port_base}")])
304306
self.disconnect_nodes(0, 1)
305307

306308
# Mempool sequence number starts at 1
@@ -444,7 +446,7 @@ def test_mempool_sync(self):
444446
"""
445447

446448
self.log.info("Testing 'mempool sync' usage of sequence notifier")
447-
[seq] = self.setup_zmq_test([("sequence", "tcp://127.0.0.1:28333")])
449+
[seq] = self.setup_zmq_test([("sequence", f"tcp://127.0.0.1:{self.zmq_port_base}")])
448450

449451
# In-memory counter, should always start at 1
450452
next_mempool_seq = self.nodes[0].getrawmempool(mempool_sequence=True)["mempool_sequence"]
@@ -549,8 +551,8 @@ def test_multiple_interfaces(self):
549551
# chain lengths on node0 and node1; for this test we only need node0, so
550552
# we can disable syncing blocks on the setup)
551553
subscribers = self.setup_zmq_test([
552-
("hashblock", "tcp://127.0.0.1:28334"),
553-
("hashblock", "tcp://127.0.0.1:28335"),
554+
("hashblock", f"tcp://127.0.0.1:{self.zmq_port_base + 1}"),
555+
("hashblock", f"tcp://127.0.0.1:{self.zmq_port_base + 2}"),
554556
], sync_blocks=False)
555557

556558
# Generate 1 block in nodes[0] and receive all notifications
@@ -567,7 +569,7 @@ def test_ipv6(self):
567569
self.log.info("Testing IPv6")
568570
# Set up subscriber using IPv6 loopback address
569571
subscribers = self.setup_zmq_test([
570-
("hashblock", "tcp://[::1]:28332")
572+
("hashblock", f"tcp://[::1]:{self.zmq_port_base}")
571573
], ipv6=True)
572574

573575
# Generate 1 block in nodes[0]

0 commit comments

Comments
 (0)