Merge #14419: [tests] Remove rpc_zmq.py

42a995ae48 [tests] Remove rpc_zmq.py (John Newbery)

Pull request description:

  rpc_zmq.py is racy and fails intermittently. Remove that test file and
  move the getzmqnotifications RPC test into interface_zmq.py.

Tree-SHA512: 666c8f252f8a392deda1bd531e84fdc04bdae4eab09407657ade2b5fc0aeffa247735e20314236f56e4e3402476673f3b7538d6e09f5af6976021ba2377ce63c
This commit is contained in:
MarcoFalke 2018-10-07 23:49:22 -03:00
commit 02a0242455
No known key found for this signature in database
GPG key ID: D2EA4850E7528B25
3 changed files with 13 additions and 41 deletions

View file

@ -14,6 +14,7 @@ from test_framework.util import (
) )
from io import BytesIO from io import BytesIO
ADDRESS = "tcp://127.0.0.1:28332"
class ZMQSubscriber: class ZMQSubscriber:
def __init__(self, socket, topic): def __init__(self, socket, topic):
@ -51,11 +52,10 @@ class ZMQTest (BitcoinTestFramework):
# that this test fails if the publishing order changes. # that this test fails if the publishing order changes.
# Note that the publishing order is not defined in the documentation and # Note that the publishing order is not defined in the documentation and
# is subject to change. # is subject to change.
address = "tcp://127.0.0.1:28332"
self.zmq_context = zmq.Context() self.zmq_context = zmq.Context()
socket = self.zmq_context.socket(zmq.SUB) socket = self.zmq_context.socket(zmq.SUB)
socket.set(zmq.RCVTIMEO, 60000) socket.set(zmq.RCVTIMEO, 60000)
socket.connect(address) socket.connect(ADDRESS)
# Subscribe to all available topics. # Subscribe to all available topics.
self.hashblock = ZMQSubscriber(socket, b"hashblock") self.hashblock = ZMQSubscriber(socket, b"hashblock")
@ -64,7 +64,7 @@ class ZMQTest (BitcoinTestFramework):
self.rawtx = ZMQSubscriber(socket, b"rawtx") self.rawtx = ZMQSubscriber(socket, b"rawtx")
self.extra_args = [ self.extra_args = [
["-zmqpub%s=%s" % (sub.topic.decode(), address) for sub in [self.hashblock, self.hashtx, self.rawblock, self.rawtx]], ["-zmqpub%s=%s" % (sub.topic.decode(), ADDRESS) for sub in [self.hashblock, self.hashtx, self.rawblock, self.rawtx]],
[], [],
] ]
self.add_nodes(self.num_nodes, self.extra_args) self.add_nodes(self.num_nodes, self.extra_args)
@ -117,5 +117,15 @@ class ZMQTest (BitcoinTestFramework):
hex = self.rawtx.receive() hex = self.rawtx.receive()
assert_equal(payment_txid, bytes_to_hex_str(hash256(hex))) assert_equal(payment_txid, bytes_to_hex_str(hash256(hex)))
self.log.info("Test the getzmqnotifications RPC")
assert_equal(self.nodes[0].getzmqnotifications(), [
{"type": "pubhashblock", "address": ADDRESS},
{"type": "pubhashtx", "address": ADDRESS},
{"type": "pubrawblock", "address": ADDRESS},
{"type": "pubrawtx", "address": ADDRESS},
])
assert_equal(self.nodes[1].getzmqnotifications(), [])
if __name__ == '__main__': if __name__ == '__main__':
ZMQTest().main() ZMQTest().main()

View file

@ -1,37 +0,0 @@
#!/usr/bin/env python3
# Copyright (c) 2018 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 for the ZMQ RPC methods."""
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import assert_equal
class RPCZMQTest(BitcoinTestFramework):
address = "tcp://127.0.0.1:28332"
def set_test_params(self):
self.num_nodes = 1
self.setup_clean_chain = True
def skip_test_if_missing_module(self):
self.skip_if_no_py3_zmq()
self.skip_if_no_bitcoind_zmq()
def run_test(self):
self._test_getzmqnotifications()
def _test_getzmqnotifications(self):
self.restart_node(0, extra_args=[])
assert_equal(self.nodes[0].getzmqnotifications(), [])
self.restart_node(0, extra_args=["-zmqpubhashtx=%s" % self.address])
assert_equal(self.nodes[0].getzmqnotifications(), [
{"type": "pubhashtx", "address": self.address},
])
if __name__ == '__main__':
RPCZMQTest().main()

View file

@ -152,7 +152,6 @@ BASE_SCRIPTS = [
'feature_versionbits_warning.py', 'feature_versionbits_warning.py',
'rpc_preciousblock.py', 'rpc_preciousblock.py',
'wallet_importprunedfunds.py', 'wallet_importprunedfunds.py',
'rpc_zmq.py',
'rpc_signmessage.py', 'rpc_signmessage.py',
'feature_nulldummy.py', 'feature_nulldummy.py',
'mempool_accept.py', 'mempool_accept.py',