From cc9ee809ad19a63ca284d2fbc327ac1cbcee31e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Barbosa?= Date: Wed, 4 Oct 2017 23:29:34 +0100 Subject: Improve ZMQ functional test --- test/functional/zmq_test.py | 172 ++++++++++++++++++-------------------------- 1 file changed, 70 insertions(+), 102 deletions(-) (limited to 'test/functional') diff --git a/test/functional/zmq_test.py b/test/functional/zmq_test.py index 382ef5bae2..165f9192dd 100755 --- a/test/functional/zmq_test.py +++ b/test/functional/zmq_test.py @@ -2,7 +2,7 @@ # Copyright (c) 2015-2016 The Bitcoin Core developers # Distributed under the MIT software license, see the accompanying # file COPYING or http://www.opensource.org/licenses/mit-license.php. -"""Test the ZMQ API.""" +"""Test the ZMQ notification interface.""" import configparser import os import struct @@ -13,6 +13,25 @@ from test_framework.util import (assert_equal, hash256, ) +class ZMQSubscriber: + def __init__(self, socket, topic): + self.sequence = 0 + self.socket = socket + self.topic = topic + + import zmq + self.socket.setsockopt(zmq.SUBSCRIBE, self.topic) + + def receive(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('