mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-06-03 09:43:55 +02:00
Move zmq test skipping logic into individual test case.
This commit uses the new skip test funcationality added in
232b6665bc to skip the zmq tests if the
python zmq module is not available or if bitcoind has been built without
zmq support.
This removes the zmq-specific logic from test_runner.py. In general it's
better if test_runner.py has no knowledge of special cases for
individual tests and is a general purpose test runner.
This commit is contained in:
@@ -3,11 +3,13 @@
|
||||
# Distributed under the MIT software license, see the accompanying
|
||||
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
"""Test the ZMQ API."""
|
||||
import configparser
|
||||
import os
|
||||
import struct
|
||||
import sys
|
||||
|
||||
from test_framework.test_framework import BitcoinTestFramework
|
||||
from test_framework.util import *
|
||||
import zmq
|
||||
import struct
|
||||
|
||||
class ZMQTest (BitcoinTestFramework):
|
||||
|
||||
@@ -18,6 +20,21 @@ class ZMQTest (BitcoinTestFramework):
|
||||
port = 28332
|
||||
|
||||
def setup_nodes(self):
|
||||
# Try to import python3-zmq. Skip this test if the import fails.
|
||||
try:
|
||||
import zmq
|
||||
except ImportError:
|
||||
self.log.warning("python3-zmq module not available. Skipping zmq tests!")
|
||||
sys.exit(self.TEST_EXIT_SKIPPED)
|
||||
|
||||
# Check that bitcoin has been built with ZMQ enabled
|
||||
config = configparser.ConfigParser()
|
||||
config.read_file(open(os.path.dirname(__file__) + "/config.ini"))
|
||||
|
||||
if not config["components"].getboolean("ENABLE_ZMQ"):
|
||||
self.log.warning("bitcoind has not been built with zmq enabled. Skipping zmq tests!")
|
||||
sys.exit(self.TEST_EXIT_SKIPPED)
|
||||
|
||||
self.zmqContext = zmq.Context()
|
||||
self.zmqSubSocket = self.zmqContext.socket(zmq.SUB)
|
||||
self.zmqSubSocket.setsockopt(zmq.SUBSCRIBE, b"hashblock")
|
||||
|
||||
Reference in New Issue
Block a user