Page MenuHomePhabricator

zmq test: fix flakiness by using more robust sync method
ClosedPublic

Authored by PiRK on Nov 29 2021, 15:26.

Details

Reviewers
Fabien
Group Reviewers
Restricted Project
Commits
rABCb98d91efd3cb: zmq test: fix flakiness by using more robust sync method
Summary

After connecting the subscriber sockets to the node, there is no
guarantee that the node's zmq publisher interfaces are ready yet, which
means that potentially the first expected notification messages could
get lost and the test fails. Currently this is handled by just waiting
for a short period of time (200ms), which works most of the time but is
still problematic, as in some rare cases the setup time takes much
longer, even in the range of multiple seconds.

The solution in this commit approaches the problem by using a more
robust method of syncing up, originally proposed by instagibbs:

  1. Generate a block on the node
  2. Try to receive a notification on all subscribers
  3. If all subscribers get a message within the timeout (1 second), we are done, otherwise repeat starting from step 1

This is a backport of core#21008 [3/3]
https://github.com/bitcoin/bitcoin/pull/21008/commits/5c6546362dce8b468268578e345c37ed515a1855

Depends on D10590

Test Plan

ninja check-functional