fix: Address AmendmentBlockHandler flakiness in old ETL tests (#2694)

Co-authored-by: Ayaz Salikhov <mathbunnyru@users.noreply.github.com>
This commit is contained in:
Alex Kremer
2025-10-15 17:15:12 +01:00
committed by GitHub
parent b361e3a108
commit b4e40558c9

View File

@@ -36,6 +36,9 @@ struct AmendmentBlockHandlerTest : util::prometheus::WithPrometheus, SyncAsioCon
etl::SystemState state; etl::SystemState state;
}; };
// Note: This test can be flaky due to the way it was written (depends on time)
// Since the old ETL is going to be replaced by ETLng all tests including this one will be deleted anyway so the fix for
// flakiness is to increase the context runtime to 50ms until then (to not waste time).
TEST_F(AmendmentBlockHandlerTest, CallToNotifyAmendmentBlockedSetsStateAndRepeatedlyCallsAction) TEST_F(AmendmentBlockHandlerTest, CallToNotifyAmendmentBlockedSetsStateAndRepeatedlyCallsAction)
{ {
AmendmentBlockHandler handler{ctx_, state, std::chrono::nanoseconds{1}, actionMock.AsStdFunction()}; AmendmentBlockHandler handler{ctx_, state, std::chrono::nanoseconds{1}, actionMock.AsStdFunction()};
@@ -45,12 +48,7 @@ TEST_F(AmendmentBlockHandlerTest, CallToNotifyAmendmentBlockedSetsStateAndRepeat
handler.notifyAmendmentBlocked(); handler.notifyAmendmentBlocked();
EXPECT_TRUE(state.isAmendmentBlocked); EXPECT_TRUE(state.isAmendmentBlocked);
// Code runs significantly slower when assertions are enabled runContextFor(std::chrono::milliseconds{50});
#ifdef _GLIBCXX_ASSERTIONS
runContextFor(std::chrono::milliseconds{10});
#else
runContextFor(std::chrono::milliseconds{1});
#endif
} }
struct DefaultAmendmentBlockActionTest : LoggerFixture {}; struct DefaultAmendmentBlockActionTest : LoggerFixture {};