Skip to content

Commit b1bac1c

Browse files
committed
[tests] in zmq test, timeout if message not received
1 parent 5ebd5f9 commit b1bac1c

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

test/functional/zmq_test.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ def setup_nodes(self):
3636

3737
self.zmqContext = zmq.Context()
3838
self.zmqSubSocket = self.zmqContext.socket(zmq.SUB)
39+
self.zmqSubSocket.set(zmq.RCVTIMEO, 60000)
3940
self.zmqSubSocket.setsockopt(zmq.SUBSCRIBE, b"hashblock")
4041
self.zmqSubSocket.setsockopt(zmq.SUBSCRIBE, b"hashtx")
4142
ip_address = "tcp://127.0.0.1:28332"
@@ -94,11 +95,10 @@ def run_test(self):
9495
msg = self.zmqSubSocket.recv_multipart()
9596
topic = msg[0]
9697
body = msg[1]
97-
hashZMQ = ""
98-
if topic == b"hashtx":
99-
hashZMQ = bytes_to_hex_str(body)
100-
msgSequence = struct.unpack('<I', msg[-1])[-1]
101-
assert_equal(msgSequence, blockcount + 1)
98+
assert_equal(topic, b"hashtx")
99+
hashZMQ = bytes_to_hex_str(body)
100+
msgSequence = struct.unpack('<I', msg[-1])[-1]
101+
assert_equal(msgSequence, blockcount + 1)
102102

103103
assert_equal(hashRPC, hashZMQ) # txid from sendtoaddress must be equal to the hash received over zmq
104104

0 commit comments

Comments
 (0)