14
14
)
15
15
from io import BytesIO
16
16
17
+ ADDRESS = "tcp://127.0.0.1:28332"
17
18
18
19
class ZMQSubscriber :
19
20
def __init__ (self , socket , topic ):
@@ -51,11 +52,10 @@ def setup_nodes(self):
51
52
# that this test fails if the publishing order changes.
52
53
# Note that the publishing order is not defined in the documentation and
53
54
# is subject to change.
54
- address = "tcp://127.0.0.1:28332"
55
55
self .zmq_context = zmq .Context ()
56
56
socket = self .zmq_context .socket (zmq .SUB )
57
57
socket .set (zmq .RCVTIMEO , 60000 )
58
- socket .connect (address )
58
+ socket .connect (ADDRESS )
59
59
60
60
# Subscribe to all available topics.
61
61
self .hashblock = ZMQSubscriber (socket , b"hashblock" )
@@ -64,7 +64,7 @@ def setup_nodes(self):
64
64
self .rawtx = ZMQSubscriber (socket , b"rawtx" )
65
65
66
66
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 ]],
68
68
[],
69
69
]
70
70
self .add_nodes (self .num_nodes , self .extra_args )
@@ -117,5 +117,15 @@ def _zmq_test(self):
117
117
hex = self .rawtx .receive ()
118
118
assert_equal (payment_txid , bytes_to_hex_str (hash256 (hex )))
119
119
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
+
120
130
if __name__ == '__main__' :
121
131
ZMQTest ().main ()
0 commit comments