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:
- Generate a block on the node
- Try to receive a notification on all subscribers
- 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
Reviewers: #bitcoin_abc, Fabien
Reviewed By: #bitcoin_abc, Fabien
Differential Revision: https://reviews.bitcoinabc.org/D10591