Fix undeterministic call to shouldPoll() in Avalanche tests
Summary:
These tests pass consistently with make check but fail ninja check consistently with the following setup:
gcc 8.1.0 clang 7.0.1 boost 1.58.0
The failure occurs at step i = 9, where registerPoll() is called, setting inflight to 10
and then immediately after, the call to shouldPoll() returns false.
Based on reading of the test, it seems clear that shouldPoll() should be evaluated before registerPoll() is called, but apparently compiler differences evaluate the BOOST_CHECK_EQUAL macro differently.
Before writing this diff, I attempted to write the test in such a way as to evaluate registerPoll() and shouldPoll(), in that order, in intermediate variables, as this is the expected order of evaluation when reading the BOOST_CHECK_EQUAL call. This test fails for ninja and make as expected:
- BOOST_CHECK_EQUAL(vrinflight.registerPoll(), vrinflight.shouldPoll()); + bool rp = vrinflight.registerPoll(); + bool sp = vrinflight.shouldPoll(); + BOOST_CHECK_EQUAL(rp, sp);
Test Plan:
make check ninja check
Reviewers: deadalnix, Fabien, #bitcoin_abc
Reviewed By: deadalnix, #bitcoin_abc
Subscribers: teamcity, schancel
Differential Revision: https://reviews.bitcoinabc.org/D2504