aboutsummaryrefslogtreecommitdiff
path: root/test/functional/interface_zmq.py
diff options
context:
space:
mode:
authornthumann <me@n-thumann.de>2020-03-11 19:09:05 +0100
committernthumann <me@n-thumann.de>2020-10-01 00:33:38 +0200
commit241803da211265444e65f254f24dd184f2457fa9 (patch)
tree21d9541a12e493cb30932c051a06ecad7c0c0a99 /test/functional/interface_zmq.py
parenta0b2e5cb6aa8db0563fac7d67a949b9baefe3a25 (diff)
downloadbitcoin-241803da211265444e65f254f24dd184f2457fa9.tar.xz
test: Add zmq test to support multiple interfaces
Diffstat (limited to 'test/functional/interface_zmq.py')
-rwxr-xr-xtest/functional/interface_zmq.py24
1 files changed, 24 insertions, 0 deletions
diff --git a/test/functional/interface_zmq.py b/test/functional/interface_zmq.py
index 17032a3b83..a0bc937f75 100755
--- a/test/functional/interface_zmq.py
+++ b/test/functional/interface_zmq.py
@@ -75,6 +75,7 @@ class ZMQTest (BitcoinTestFramework):
self.test_sequence()
self.test_mempool_sync()
self.test_reorg()
+ self.test_multiple_interfaces()
finally:
# Destroy the ZMQ context.
self.log.debug("Destroying ZMQ context")
@@ -506,5 +507,28 @@ class ZMQTest (BitcoinTestFramework):
self.nodes[0].generatetoaddress(1, ADDRESS_BCRT1_UNSPENDABLE)
+ def test_multiple_interfaces(self):
+ # Set up two subscribers with different addresses
+ subscribers = []
+ for i in range(2):
+ address = 'tcp://127.0.0.1:%d' % (28334 + i)
+ socket = self.ctx.socket(zmq.SUB)
+ socket.set(zmq.RCVTIMEO, 60000)
+ hashblock = ZMQSubscriber(socket, b"hashblock")
+ socket.connect(address)
+ subscribers.append({'address': address, 'hashblock': hashblock})
+
+ self.restart_node(0, ['-zmqpub%s=%s' % (subscriber['hashblock'].topic.decode(), subscriber['address']) for subscriber in subscribers])
+
+ # Relax so that the subscriber is ready before publishing zmq messages
+ sleep(0.2)
+
+ # Generate 1 block in nodes[0] and receive all notifications
+ self.nodes[0].generatetoaddress(1, ADDRESS_BCRT1_UNSPENDABLE)
+
+ # Should receive the same block hash on both subscribers
+ assert_equal(self.nodes[0].getbestblockhash(), subscribers[0]['hashblock'].receive().hex())
+ assert_equal(self.nodes[0].getbestblockhash(), subscribers[1]['hashblock'].receive().hex())
+
if __name__ == '__main__':
ZMQTest().main()