HomePhabricator

Fix race condition in avalanche test

Description

Fix race condition in avalanche test

Summary:
As it turns out, self.last_message and the call to on_mesage is not an atomic operation (it cannot be) and it is possible to bail out of the wait-for function before they are called.

By checking the result of the on_messages function instead, this is not possible. It also makes the code simpler, because we don't need to check for the None case anymore, nor do we need to ping.

Test Plan: Ran the test 100 time in a row in regular and debug mode.

Reviewers: #bitcoin_abc, Fabien

Reviewed By: #bitcoin_abc, Fabien

Differential Revision: https://reviews.bitcoinabc.org/D5703

Details

Provenance
deadalnixAuthored on Apr 12 2020, 15:46
deadalnixPushed on Apr 13 2020, 12:51
Reviewer
Restricted Project
Differential Revision
D5703: Fix race condition in avalanche test
Parents
rSTAGING98c75b84874e: nits: use const for loop iterrators in avalanche code
Branches
Unknown
Tags
Unknown
References
tag: phabricator/base/18778, tag: phabricator/base/18761, tag: phabricator/base/18757