Skip to content

Commit

Permalink
zmq test: dedup message reception handling in ZMQSubscriber
Browse files Browse the repository at this point in the history
Summary:
PR description:
> Fixes [[bitcoin/bitcoin#20934 | core#20934]] by using the "sync up" method described in [[bitcoin/bitcoin#20538 | core#20538]].
>
> After improving robustness with this approach (commits 1-3), it turned out that there were still some fails, but those were unrelated to zmq: Out of 500 runs, 3 times sync_mempool() or sync_blocks() timed out, which can happen because the trickle relay time has no upper bound -- hence in rare cases, it takes longer than 60s. This is fixed by enabling immediate tx relay on node1 (commit 4), which as a nice side-effect also gives us a rough 2x speedup for the test.
>
> For further details, also see the explanations in the commit messages.

Note that the changes in commit 4, the speedup from 45s to 14s runtime  using `noban` permissions, were already applied in Bitcoin ABC in D10311.

This is a backport of [[bitcoin/bitcoin#21008 | core#21008]] [1/3]
bitcoin/bitcoin@6014d6e

Depends on D10588

Test Plan: `ninja check-functional`

Reviewers: #bitcoin_abc, Fabien

Reviewed By: #bitcoin_abc, Fabien

Differential Revision: https://reviews.bitcoinabc.org/D10589
  • Loading branch information
theStack authored and PiRK committed Nov 30, 2021
1 parent f6f7b13 commit 30b874a
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions test/functional/interface_zmq.py
Expand Up @@ -39,7 +39,8 @@ def __init__(self, socket, topic):

self.socket.setsockopt(zmq.SUBSCRIBE, self.topic)

def receive(self):
# Receive message from publisher and verify that topic and sequence match
def _receive_from_publisher_and_check(self):
topic, body, seq = self.socket.recv_multipart()
# Topic should match the subscriber topic.
assert_equal(topic, self.topic)
Expand All @@ -48,13 +49,11 @@ def receive(self):
self.sequence += 1
return body

def receive(self):
return self._receive_from_publisher_and_check()

def receive_sequence(self):
topic, body, seq = self.socket.recv_multipart()
# Topic should match the subscriber topic.
assert_equal(topic, self.topic)
# Sequence should be incremental.
assert_equal(struct.unpack('<I', seq)[-1], self.sequence)
self.sequence += 1
body = self._receive_from_publisher_and_check()
hash = body[:32].hex()
label = chr(body[32])
mempool_sequence = None if len(
Expand Down

0 comments on commit 30b874a

Please sign in to comment.