HomePhabricator

Fix sporadic policyestimator_tests failure due to unspecified operand…
779785eada81Unpublished

Unpublished Commit · Learn More

Repository Importing: This repository is still importing.

Description

Fix sporadic policyestimator_tests failure due to unspecified operand evaluation order

Summary:
This code was a little buggy, which caused some sporadic failures of this unit test.

The first bug was in evaluation of this expression

mpool.estimateSmartFee(i, &answerFound).GetFeePerK() > origFeeEst[answerFound - 1] - deltaFee

The result incorrectly depends on prior evaluation of answerFound in LHS which is not guaranteed to happen before evaluation of RHS. (http://en.cppreference.com/w/cpp/language/eval_order)

The second bug was that due to the first, the use of answerFound could occur before it has even been initialized (on entry to the loop).

The fix here ensures that answerFound is properly initialized before further use (provided estimateSmartFee returns it with value > 0) , and the result of the comparison becomes determinate.

Test Plan: make check

Reviewers: #bitcoin_abc, deadalnix, schancel

Reviewed By: #bitcoin_abc, deadalnix

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

Details

Provenance
freetraderAuthored on Oct 20 2017, 14:29
schancelPushed on Jan 5 2018, 21:58
schancelPushed on Jan 5 2018, 21:39
schancelPushed on Jan 5 2018, 21:17
Reviewer
Restricted Project
Differential Revision
D621: Fix sporadic policyestimator_tests failure due to unspecified operand evaluation order
Parents
rSTAGING25fbcf451e5f: Refactor GetDifficulty from RPC
Branches
Unknown
Tags
Unknown