Page MenuHomePhabricator

[avalanche] Fix proof_tests potential failure
ClosedPublic

Authored by Fabien on Sep 8 2022, 14:54.

Details

Reviewers
sdulfari
Group Reviewers
Restricted Project
Commits
rABC0d65ba5572f2: [avalanche] Fix proof_tests potential failure
Summary

It appears that the evaluation order of the left and right parameters of BOOST_CHECK_EQUAL should not be relied upon, and will vary between compilers. This cause the test to fail if the proof has a dust stake because the right part state.GetResult() == ProofValidationResult::NONE is evaluated before state is assigned.

How to reproduce
Edit the proof_tests.cpp:29 line from:

const uint32_t score = InsecureRand32();

to:

const uint32_t score = MIN_VALID_PROOF_SCORE - 1000;

With clang the proof_tests pass as expected, but it fails with gcc as the state is evaluated before it is set.

Test Plan

Edit the line as mentioned above, then with both GCC and Clang:

ninja check-avalanche-proof_tests

The test should succeed with both compilers.

Diff Detail

Repository
rABC Bitcoin ABC
Lint
Lint Not Applicable
Unit
Tests Not Applicable