diff options
author | Sebastian Falbesoner <sebastian.falbesoner@gmail.com> | 2021-01-23 22:19:15 +0100 |
---|---|---|
committer | Sebastian Falbesoner <sebastian.falbesoner@gmail.com> | 2021-02-09 22:54:01 +0100 |
commit | 6014d6e1b5a0dda6e20c2721f0bdb7e6a63ece81 (patch) | |
tree | 992e2ce361835709dd00afdfd35d753069108f50 /test | |
parent | d202054675c91b353d832c9c038247384a39030f (diff) |
zmq test: dedup message reception handling in ZMQSubscriber
Diffstat (limited to 'test')
-rwxr-xr-x | test/functional/interface_zmq.py | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/test/functional/interface_zmq.py b/test/functional/interface_zmq.py index e9f61be4d4..4c23c4d30c 100755 --- a/test/functional/interface_zmq.py +++ b/test/functional/interface_zmq.py @@ -33,7 +33,8 @@ class ZMQSubscriber: self.socket.setsockopt(zmq.SUBSCRIBE, self.topic) - def receive(self): + # Receive message from publisher and verify that topic and sequence match + def _receive_from_publisher_and_check(self): topic, body, seq = self.socket.recv_multipart() # Topic should match the subscriber topic. assert_equal(topic, self.topic) @@ -42,13 +43,11 @@ class ZMQSubscriber: self.sequence += 1 return body + def receive(self): + return self._receive_from_publisher_and_check() + def receive_sequence(self): - topic, body, seq = self.socket.recv_multipart() - # Topic should match the subscriber topic. - assert_equal(topic, self.topic) - # Sequence should be incremental. - assert_equal(struct.unpack('<I', seq)[-1], self.sequence) - self.sequence += 1 + body = self._receive_from_publisher_and_check() hash = body[:32].hex() label = chr(body[32]) mempool_sequence = None if len(body) != 32+1+8 else struct.unpack("<Q", body[32+1:])[0] |