Changeset View
Changeset View
Standalone View
Standalone View
test/functional/rpc_zmq.py
#!/usr/bin/env python3 | #!/usr/bin/env python3 | ||||
# Copyright (c) 2018 The Bitcoin Core developers | # Copyright (c) 2018 The Bitcoin Core developers | ||||
# Distributed under the MIT software license, see the accompanying | # Distributed under the MIT software license, see the accompanying | ||||
# file COPYING or http://www.opensource.org/licenses/mit-license.php. | # file COPYING or http://www.opensource.org/licenses/mit-license.php. | ||||
"""Test for the ZMQ RPC methods.""" | """Test for the ZMQ RPC methods.""" | ||||
from test_framework.test_framework import ( | from test_framework.test_framework import BitcoinTestFramework | ||||
BitcoinTestFramework, | |||||
skip_if_no_bitcoind_zmq, | |||||
skip_if_no_py3_zmq, | |||||
) | |||||
from test_framework.util import assert_equal | from test_framework.util import assert_equal | ||||
class RPCZMQTest(BitcoinTestFramework): | class RPCZMQTest(BitcoinTestFramework): | ||||
address = "tcp://127.0.0.1:28332" | address = "tcp://127.0.0.1:28332" | ||||
def set_test_params(self): | def set_test_params(self): | ||||
self.num_nodes = 1 | self.num_nodes = 1 | ||||
self.setup_clean_chain = True | 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): | def run_test(self): | ||||
skip_if_no_py3_zmq() | |||||
skip_if_no_bitcoind_zmq(self) | |||||
self._test_getzmqnotifications() | self._test_getzmqnotifications() | ||||
def _test_getzmqnotifications(self): | def _test_getzmqnotifications(self): | ||||
self.restart_node(0, extra_args=[]) | self.restart_node(0, extra_args=[]) | ||||
assert_equal(self.nodes[0].getzmqnotifications(), []) | assert_equal(self.nodes[0].getzmqnotifications(), []) | ||||
self.restart_node( | self.restart_node( | ||||
0, extra_args=["-zmqpubhashtx={}".format(self.address)]) | 0, extra_args=["-zmqpubhashtx={}".format(self.address)]) | ||||
assert_equal(self.nodes[0].getzmqnotifications(), [ | assert_equal(self.nodes[0].getzmqnotifications(), [ | ||||
{"type": "pubhashtx", "address": self.address}, | {"type": "pubhashtx", "address": self.address}, | ||||
]) | ]) | ||||
if __name__ == '__main__': | if __name__ == '__main__': | ||||
RPCZMQTest().main() | RPCZMQTest().main() |