Changeset View
Changeset View
Standalone View
Standalone View
test/functional/interface_zmq.py
#!/usr/bin/env python3 | #!/usr/bin/env python3 | ||||
# Copyright (c) 2015-2016 The Bitcoin Core developers | # Copyright (c) 2015-2016 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 the ZMQ notification interface.""" | """Test the ZMQ notification interface.""" | ||||
import configparser | import configparser | ||||
import os | |||||
import struct | import struct | ||||
from test_framework.test_framework import BitcoinTestFramework, SkipTest | from test_framework.test_framework import BitcoinTestFramework, SkipTest | ||||
from test_framework.util import ( | from test_framework.util import ( | ||||
assert_equal, | assert_equal, | ||||
bytes_to_hex_str, | bytes_to_hex_str, | ||||
hash256, | hash256, | ||||
) | ) | ||||
Show All 26 Lines | def setup_nodes(self): | ||||
# Try to import python3-zmq. Skip this test if the import fails. | # Try to import python3-zmq. Skip this test if the import fails. | ||||
try: | try: | ||||
import zmq | import zmq | ||||
except ImportError: | except ImportError: | ||||
raise SkipTest("python3-zmq module not available.") | raise SkipTest("python3-zmq module not available.") | ||||
# Check that bitcoin has been built with ZMQ enabled. | # Check that bitcoin has been built with ZMQ enabled. | ||||
config = configparser.ConfigParser() | config = configparser.ConfigParser() | ||||
if not self.options.configfile: | |||||
self.options.configfile = os.path.abspath( | |||||
os.path.join(os.path.dirname(__file__), "../config.ini")) | |||||
config.read_file(open(self.options.configfile)) | config.read_file(open(self.options.configfile)) | ||||
if not config["components"].getboolean("ENABLE_ZMQ"): | if not config["components"].getboolean("ENABLE_ZMQ"): | ||||
raise SkipTest("bitcoind has not been built with zmq enabled.") | raise SkipTest("bitcoind has not been built with zmq enabled.") | ||||
# Initialize ZMQ context and socket. | # Initialize ZMQ context and socket. | ||||
# All messages are received in the same socket which means that this | # All messages are received in the same socket which means that this | ||||
# test fails if the publishing order changes. | # test fails if the publishing order changes. | ||||
▲ Show 20 Lines • Show All 69 Lines • Show Last 20 Lines |