Skip to content

Commit 2ea7eb6

Browse files
author
MarcoFalke
committed
Merge #13645: [tests] skip rpc_zmq functional test as necessary
a0b604c [tests] skip rpc_zmq functional test when python3 zmq lib is not present (James O'Beirne) Pull request description: As noted in https://github.com/bitcoin/bitcoin/pull/13570/files#r201715904, the `rpc_zmq` functional test should be skipped when the `zmq` python3 package is not installed. This is breaking https://bitcoinperf.com benchmarks at the moment. Tree-SHA512: ab519ae717f4b7a282640cf0389651723fdc108990aeb9852e8b9e96d61fa1ded2461717ae31558b37ff8401a5b1ccc41f4e858e402b8c3d98563d962599767a
2 parents dcb154e + a0b604c commit 2ea7eb6

File tree

3 files changed

+26
-15
lines changed

3 files changed

+26
-15
lines changed

test/functional/interface_zmq.py

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
# Distributed under the MIT software license, see the accompanying
44
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
55
"""Test the ZMQ notification interface."""
6-
import configparser
76
import struct
87

9-
from test_framework.test_framework import BitcoinTestFramework, SkipTest
8+
from test_framework.test_framework import (
9+
BitcoinTestFramework, skip_if_no_bitcoind_zmq, skip_if_no_py3_zmq)
1010
from test_framework.mininode import CTransaction
1111
from test_framework.util import (assert_equal,
1212
bytes_to_hex_str,
@@ -38,18 +38,9 @@ def set_test_params(self):
3838
self.num_nodes = 2
3939

4040
def setup_nodes(self):
41-
# Try to import python3-zmq. Skip this test if the import fails.
42-
try:
43-
import zmq
44-
except ImportError:
45-
raise SkipTest("python3-zmq module not available.")
46-
47-
# Check that bitcoin has been built with ZMQ enabled.
48-
config = configparser.ConfigParser()
49-
config.read_file(open(self.options.configfile))
50-
51-
if not config["components"].getboolean("ENABLE_ZMQ"):
52-
raise SkipTest("bitcoind has not been built with zmq enabled.")
41+
skip_if_no_py3_zmq()
42+
skip_if_no_bitcoind_zmq(self)
43+
import zmq
5344

5445
# Initialize ZMQ context and socket.
5546
# All messages are received in the same socket which means

test/functional/rpc_zmq.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
55
"""Test for the ZMQ RPC methods."""
66

7-
from test_framework.test_framework import BitcoinTestFramework
7+
from test_framework.test_framework import (
8+
BitcoinTestFramework, skip_if_no_py3_zmq, skip_if_no_bitcoind_zmq)
89
from test_framework.util import assert_equal
910

1011

@@ -17,6 +18,8 @@ def set_test_params(self):
1718
self.setup_clean_chain = True
1819

1920
def run_test(self):
21+
skip_if_no_py3_zmq()
22+
skip_if_no_bitcoind_zmq(self)
2023
self._test_getzmqnotifications()
2124

2225
def _test_getzmqnotifications(self):

test/functional/test_framework/test_framework.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -475,3 +475,20 @@ class SkipTest(Exception):
475475
"""This exception is raised to skip a test"""
476476
def __init__(self, message):
477477
self.message = message
478+
479+
480+
def skip_if_no_py3_zmq():
481+
"""Attempt to import the zmq package and skip the test if the import fails."""
482+
try:
483+
import zmq # noqa
484+
except ImportError:
485+
raise SkipTest("python3-zmq module not available.")
486+
487+
488+
def skip_if_no_bitcoind_zmq(test_instance):
489+
"""Skip the running test if bitcoind has not been compiled with zmq support."""
490+
config = configparser.ConfigParser()
491+
config.read_file(open(test_instance.options.configfile))
492+
493+
if not config["components"].getboolean("ENABLE_ZMQ"):
494+
raise SkipTest("bitcoind has not been built with zmq enabled.")

0 commit comments

Comments
 (0)