Skip to content

Commit 8666033

Browse files
committed
zmq test: accept arbitrary sequence start number in ZMQSubscriber
The ZMQSubscriber reception methods currently assert that the first received publisher message has a sequence number of zero. In order to fix the current test flakiness via "syncing up" to nodes in the setup phase, we have to cope with the situation that messages get lost and the first actual received message has a sequence number larger than zero.
1 parent 6014d6e commit 8666033

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

test/functional/interface_zmq.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ def hash256_reversed(byte_str):
2727

2828
class ZMQSubscriber:
2929
def __init__(self, socket, topic):
30-
self.sequence = 0
30+
self.sequence = None # no sequence number received yet
3131
self.socket = socket
3232
self.topic = topic
3333

@@ -39,7 +39,11 @@ def _receive_from_publisher_and_check(self):
3939
# Topic should match the subscriber topic.
4040
assert_equal(topic, self.topic)
4141
# Sequence should be incremental.
42-
assert_equal(struct.unpack('<I', seq)[-1], self.sequence)
42+
received_seq = struct.unpack('<I', seq)[-1]
43+
if self.sequence is None:
44+
self.sequence = received_seq
45+
else:
46+
assert_equal(received_seq, self.sequence)
4347
self.sequence += 1
4448
return body
4549

0 commit comments

Comments
 (0)