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