Page MenuHomePhabricator

[avalanche] Fix a race condition in a unit test where proof registration time could be off by one
ClosedPublic

Authored by sdulfari on Jul 21 2022, 17:49.

Details

Summary

util/time.* uses multiple clocks depending on circumstances like if mock time is set or if templated
GetTime<>() is called. This can result in unexpected behavior where registerProof() uses a different
clock than when SetMockTime(GetTime()...) is called in unit tests.

Example failure: https://build.bitcoinabc.org/viewLog.html?buildId=416835&buildTypeId=BitcoinABC_BitcoinAbcStaging&tab=buildLog&_focus=1325

This patch makes this specific unit test predictable by setting mock time before any proofs are registered.

The root cause may be fixed with additional backports to util/time.* that make the clock selection more
consistent (see backport core#24871 and core#21110).

Test Plan
ninja check-avalanche

Diff Detail

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