Skip to content

Commit 83d0637

Browse files
MarcoFalkePastaPastaPasta
authored andcommitted
Merge bitcoin#10097: Move zmq test skipping logic into individual test case.
6803e09 Move zmq test skipping logic into individual test case. (John Newbery) Tree-SHA512: 9d166b53e9acf386c4dafc860b38e2901b331a7505bba9714a2f4e3bdef68b0316c8b76fddbfb620835ddee549cf32fffb3a96a19b0799ad94f2553f55f19a35 s/bitcoind/dashd/ Signed-off-by: Pasta <pasta@dashboost.org>
1 parent 14cbf54 commit 83d0637

File tree

2 files changed

+23
-23
lines changed

2 files changed

+23
-23
lines changed

test/functional/test_runner.py

Lines changed: 4 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@
6464
'rawtransactions.py',
6565
'reindex.py',
6666
# vv Tests less than 30s vv
67+
"zmq_test.py",
6768
'mempool_resurrect_test.py',
6869
'txn_doublespend.py --mineblock',
6970
'txn_clone.py',
@@ -103,11 +104,6 @@
103104
'p2p-fingerprint.py',
104105
]
105106

106-
ZMQ_SCRIPTS = [
107-
# ZMQ test can only be run if Dash Core was built with zmq-enabled.
108-
# call test_runner.py with -nozmq to explicitly exclude these tests.
109-
'zmq_test.py']
110-
111107
EXTENDED_SCRIPTS = [
112108
# These tests are not run by the travis build process.
113109
# Longest test should go first, to favor running tests in parallel
@@ -140,7 +136,7 @@
140136
]
141137

142138
# Place EXTENDED_SCRIPTS first since it has the 3 longest running tests
143-
ALL_SCRIPTS = EXTENDED_SCRIPTS + BASE_SCRIPTS + ZMQ_SCRIPTS
139+
ALL_SCRIPTS = EXTENDED_SCRIPTS + BASE_SCRIPTS
144140

145141
NON_SCRIPTS = [
146142
# These are python files that live in the functional tests directory, but are not test scripts.
@@ -163,7 +159,6 @@ def main():
163159
parser.add_argument('--force', '-f', action='store_true', help='run tests even on platforms where they are disabled by default (e.g. windows).')
164160
parser.add_argument('--help', '-h', '-?', action='store_true', help='print help text and exit')
165161
parser.add_argument('--jobs', '-j', type=int, default=4, help='how many test scripts to run in parallel. Default=4.')
166-
parser.add_argument('--nozmq', action='store_true', help='do not run the zmq tests')
167162
args, unknown_args = parser.parse_known_args()
168163

169164
# Create a set to store arguments and create the passon string
@@ -177,7 +172,6 @@ def main():
177172
enable_wallet = config["components"].getboolean("ENABLE_WALLET")
178173
enable_utils = config["components"].getboolean("ENABLE_UTILS")
179174
enable_bitcoind = config["components"].getboolean("ENABLE_BITCOIND")
180-
enable_zmq = config["components"].getboolean("ENABLE_ZMQ") and not args.nozmq
181175

182176
if config["environment"]["EXEEXT"] == ".exe" and not args.force:
183177
# https://github.com/bitcoin/bitcoin/commit/d52802551752140cf41f0d9a225a43e84404d3e9
@@ -190,27 +184,16 @@ def main():
190184
print("Rerun `configure` with -enable-wallet, -with-utils and -with-daemon and rerun make")
191185
sys.exit(0)
192186

193-
# python3-zmq may not be installed. Handle this gracefully and with some helpful info
194-
if enable_zmq:
195-
try:
196-
import zmq
197-
except ImportError:
198-
print("ERROR: \"import zmq\" failed. Use -nozmq to run without the ZMQ tests."
199-
"To run zmq tests, see dependency info in /test/README.md.")
200-
raise
201-
202187
# Build list of tests
203188
if tests:
204189
# Individual tests have been specified. Run specified tests that exist
205190
# in the ALL_SCRIPTS list. Accept the name with or without .py extension.
206191
test_list = [t for t in ALL_SCRIPTS if
207192
(t in tests or re.sub(".py$", "", t) in tests)]
208193
else:
209-
# No individual tests have been specified. Run base tests, and
210-
# optionally ZMQ tests and extended tests.
194+
# No individual tests have been specified.
195+
# Run all base tests, and optionally run extended tests.
211196
test_list = BASE_SCRIPTS
212-
if enable_zmq:
213-
test_list += ZMQ_SCRIPTS
214197
if args.extended:
215198
# place the EXTENDED_SCRIPTS first since the three longest ones
216199
# are there and the list is shorter

test/functional/zmq_test.py

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,13 @@
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 API."""
6+
import configparser
7+
import os
8+
import struct
9+
import sys
610

711
from test_framework.test_framework import BitcoinTestFramework
812
from test_framework.util import *
9-
import zmq
10-
import struct
1113

1214
class ZMQTest (BitcoinTestFramework):
1315

@@ -18,6 +20,21 @@ def __init__(self):
1820
port = 28332
1921

2022
def setup_nodes(self):
23+
# Try to import python3-zmq. Skip this test if the import fails.
24+
try:
25+
import zmq
26+
except ImportError:
27+
self.log.warning("python3-zmq module not available. Skipping zmq tests!")
28+
sys.exit(self.TEST_EXIT_SKIPPED)
29+
30+
# Check that bitcoin has been built with ZMQ enabled
31+
config = configparser.ConfigParser()
32+
config.read_file(open(os.path.dirname(__file__) + "/config.ini"))
33+
34+
if not config["components"].getboolean("ENABLE_ZMQ"):
35+
self.log.warning("dashd has not been built with zmq enabled. Skipping zmq tests!")
36+
sys.exit(self.TEST_EXIT_SKIPPED)
37+
2138
self.zmqContext = zmq.Context()
2239
self.zmqSubSocket = self.zmqContext.socket(zmq.SUB)
2340
self.zmqSubSocket.setsockopt(zmq.SUBSCRIBE, b"hashblock")

0 commit comments

Comments
 (0)