@@ -75,6 +75,7 @@ def run_test(self):
75
75
self .test_sequence ()
76
76
self .test_mempool_sync ()
77
77
self .test_reorg ()
78
+ self .test_multiple_interfaces ()
78
79
finally :
79
80
# Destroy the ZMQ context.
80
81
self .log .debug ("Destroying ZMQ context" )
@@ -506,5 +507,28 @@ def test_mempool_sync(self):
506
507
507
508
self .nodes [0 ].generatetoaddress (1 , ADDRESS_BCRT1_UNSPENDABLE )
508
509
510
+ def test_multiple_interfaces (self ):
511
+ # Set up two subscribers with different addresses
512
+ subscribers = []
513
+ for i in range (2 ):
514
+ address = 'tcp://127.0.0.1:%d' % (28334 + i )
515
+ socket = self .ctx .socket (zmq .SUB )
516
+ socket .set (zmq .RCVTIMEO , 60000 )
517
+ hashblock = ZMQSubscriber (socket , b"hashblock" )
518
+ socket .connect (address )
519
+ subscribers .append ({'address' : address , 'hashblock' : hashblock })
520
+
521
+ self .restart_node (0 , ['-zmqpub%s=%s' % (subscriber ['hashblock' ].topic .decode (), subscriber ['address' ]) for subscriber in subscribers ])
522
+
523
+ # Relax so that the subscriber is ready before publishing zmq messages
524
+ sleep (0.2 )
525
+
526
+ # Generate 1 block in nodes[0] and receive all notifications
527
+ self .nodes [0 ].generatetoaddress (1 , ADDRESS_BCRT1_UNSPENDABLE )
528
+
529
+ # Should receive the same block hash on both subscribers
530
+ assert_equal (self .nodes [0 ].getbestblockhash (), subscribers [0 ]['hashblock' ].receive ().hex ())
531
+ assert_equal (self .nodes [0 ].getbestblockhash (), subscribers [1 ]['hashblock' ].receive ().hex ())
532
+
509
533
if __name__ == '__main__' :
510
534
ZMQTest ().main ()
0 commit comments