HomePhabricator

[avalanche] Fix a race condition in a unit test where proof registration time…

Description

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

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

Reviewers: #bitcoin_abc, Fabien

Reviewed By: #bitcoin_abc, Fabien

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

Details

Provenance
sdulfariAuthored on Jul 21 2022, 17:21
sdulfariPushed on Jul 22 2022, 05:22
Reviewer
Restricted Project
Differential Revision
D11786: [avalanche] Fix a race condition in a unit test where proof registration time could be off by one
Parents
rABC3186cbec3ca4: Remove obsolete --runbarelyexpensive parameter
Branches
Unknown
Tags
Unknown