diff --git a/test/functional/test_runner.py b/test/functional/test_runner.py --- a/test/functional/test_runner.py +++ b/test/functional/test_runner.py @@ -20,6 +20,7 @@ import os import time import shutil +import signal import sys import subprocess import tempfile @@ -333,6 +334,10 @@ time.sleep(.5) for j in self.jobs: (name, time0, proc, log_out, log_err) = j + if os.getenv('TRAVIS') == 'true' and int(time.time() - time0) > 20 * 60: + # In travis, timeout individual tests after 20 minutes (to stop tests hanging and not + # providing useful output. + proc.send_signal(signal.SIGINT) if proc.poll() is not None: log_out.seek(0), log_err.seek(0) [stdout, stderr] = [l.read().decode('utf-8') diff --git a/test/functional/zmq_test.py b/test/functional/zmq_test.py --- a/test/functional/zmq_test.py +++ b/test/functional/zmq_test.py @@ -11,7 +11,11 @@ import sys from test_framework.test_framework import BitcoinTestFramework -from test_framework.util import * +from test_framework.util import ( + assert_equal, + bytes_to_hex_str, + start_nodes, +) class ZMQTest (BitcoinTestFramework): @@ -48,8 +52,8 @@ self.zmqSubSocket.setsockopt(zmq.SUBSCRIBE, b"hashtx") ip_address = "tcp://127.0.0.1:28332" self.zmqSubSocket.connect(ip_address) - extra_args = [ - ['-zmqpubhashtx=%s' % ip_address, '-zmqpubhashblock=%s' % ip_address], []] + extra_args = [['-zmqpubhashtx=%s' % + ip_address, '-zmqpubhashblock=%s' % ip_address], []] self.nodes = start_nodes( self.num_nodes, self.options.tmpdir, extra_args) @@ -65,7 +69,7 @@ genhashes = self.nodes[0].generate(1) self.sync_all() - self.log.info("listen...") + self.log.info("Wait for tx") msg = self.zmqSubSocket.recv_multipart() topic = msg[0] assert_equal(topic, b"hashtx") @@ -74,10 +78,12 @@ # Must be sequence 0 on hashtx assert_equal(msgSequence, 0) + self.log.info("Wait for block") msg = self.zmqSubSocket.recv_multipart() topic = msg[0] body = msg[1] msgSequence = struct.unpack('