1414)
1515from io import BytesIO
1616
17+ ADDRESS = "tcp://127.0.0.1:28332"
1718
1819class ZMQSubscriber :
1920 def __init__ (self , socket , topic ):
@@ -51,11 +52,10 @@ def setup_nodes(self):
5152 # that this test fails if the publishing order changes.
5253 # Note that the publishing order is not defined in the documentation and
5354 # is subject to change.
54- address = "tcp://127.0.0.1:28332"
5555 self .zmq_context = zmq .Context ()
5656 socket = self .zmq_context .socket (zmq .SUB )
5757 socket .set (zmq .RCVTIMEO , 60000 )
58- socket .connect (address )
58+ socket .connect (ADDRESS )
5959
6060 # Subscribe to all available topics.
6161 self .hashblock = ZMQSubscriber (socket , b"hashblock" )
@@ -64,7 +64,7 @@ def setup_nodes(self):
6464 self .rawtx = ZMQSubscriber (socket , b"rawtx" )
6565
6666 self .extra_args = [
67- ["-zmqpub%s=%s" % (sub .topic .decode (), address ) for sub in [self .hashblock , self .hashtx , self .rawblock , self .rawtx ]],
67+ ["-zmqpub%s=%s" % (sub .topic .decode (), ADDRESS ) for sub in [self .hashblock , self .hashtx , self .rawblock , self .rawtx ]],
6868 [],
6969 ]
7070 self .add_nodes (self .num_nodes , self .extra_args )
@@ -117,5 +117,15 @@ def _zmq_test(self):
117117 hex = self .rawtx .receive ()
118118 assert_equal (payment_txid , bytes_to_hex_str (hash256 (hex )))
119119
120+ self .log .info ("Test the getzmqnotifications RPC" )
121+ assert_equal (self .nodes [0 ].getzmqnotifications (), [
122+ {"type" : "pubhashblock" , "address" : ADDRESS },
123+ {"type" : "pubhashtx" , "address" : ADDRESS },
124+ {"type" : "pubrawblock" , "address" : ADDRESS },
125+ {"type" : "pubrawtx" , "address" : ADDRESS },
126+ ])
127+
128+ assert_equal (self .nodes [1 ].getzmqnotifications (), [])
129+
120130if __name__ == '__main__' :
121131 ZMQTest ().main ()
0 commit comments