aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcoFalke <falke.marco@gmail.com>2019-08-28 13:30:55 -0400
committerMarcoFalke <falke.marco@gmail.com>2019-08-28 13:30:59 -0400
commit119e97ae2d805fc29ef3744fff401ef289a19f8e (patch)
tree90c2fedce688cdae89fd13a52302c1451a479663
parent2d38950e5dbd05c0ffd8cc3fbb1fc00f6ddf8dd9 (diff)
parent403e372407db1d020eedede4d322ee79d4a85dfc (diff)
Merge #16740: qa: Relax so that the subscriber is ready before publishing zmq messages
403e372407db1d020eedede4d322ee79d4a85dfc qa: Relax so that the subscriber is ready before publishing zmq messages (João Barbosa) Pull request description: Prevents the syndrome "slow joiner" - see http://zguide.zeromq.org/py:all#sockets-and-patterns - by relaxing before publishing messages. ACKs for top commit: MarcoFalke: unsigned ACK 403e372407db1d020eedede4d322ee79d4a85dfc Tree-SHA512: 0e856accbc450a9b09160bdce5112b2103dc9436cc317d31fb1c9634ebd76823a300a2e727818057fb4d0a615271772ff23e80553a13e9aa1935500de5eeec5f
-rwxr-xr-xtest/functional/interface_zmq.py9
1 files changed, 7 insertions, 2 deletions
diff --git a/test/functional/interface_zmq.py b/test/functional/interface_zmq.py
index 912b667b0c..5aea10fbce 100755
--- a/test/functional/interface_zmq.py
+++ b/test/functional/interface_zmq.py
@@ -10,6 +10,7 @@ from test_framework.test_framework import BitcoinTestFramework
from test_framework.messages import CTransaction, hash256
from test_framework.util import assert_equal, connect_nodes
from io import BytesIO
+from time import sleep
def hash256_reversed(byte_str):
return hash256(byte_str)[::-1]
@@ -61,7 +62,6 @@ class ZMQTest (BitcoinTestFramework):
address = 'tcp://127.0.0.1:28332'
socket = self.ctx.socket(zmq.SUB)
socket.set(zmq.RCVTIMEO, 60000)
- socket.connect(address)
# Subscribe to all available topics.
hashblock = ZMQSubscriber(socket, b"hashblock")
@@ -71,6 +71,9 @@ class ZMQTest (BitcoinTestFramework):
self.restart_node(0, ["-zmqpub%s=%s" % (sub.topic.decode(), address) for sub in [hashblock, hashtx, rawblock, rawtx]])
connect_nodes(self.nodes[0], 1)
+ socket.connect(address)
+ # Relax so that the subscriber is ready before publishing zmq messages
+ sleep(0.2)
num_blocks = 5
self.log.info("Generate %(n)d blocks (and %(n)d coinbase txes)" % {"n": num_blocks})
@@ -128,11 +131,13 @@ class ZMQTest (BitcoinTestFramework):
address = 'tcp://127.0.0.1:28333'
socket = self.ctx.socket(zmq.SUB)
socket.set(zmq.RCVTIMEO, 60000)
- socket.connect(address)
hashblock = ZMQSubscriber(socket, b'hashblock')
# Should only notify the tip if a reorg occurs
self.restart_node(0, ['-zmqpub%s=%s' % (hashblock.topic.decode(), address)])
+ socket.connect(address)
+ # Relax so that the subscriber is ready before publishing zmq messages
+ sleep(0.2)
# Generate 1 block in nodes[0] and receive all notifications
self.nodes[0].generatetoaddress(1, ADDRESS_BCRT1_UNSPENDABLE)