From f41d574204093098f87101d837af47712c05004f Mon Sep 17 00:00:00 2001 From: Alex Kremer Date: Thu, 23 Oct 2025 16:33:58 +0100 Subject: [PATCH] fix: Flaky DeadlineIsHandledCorrectly (#2716) --- tests/unit/etlng/GrpcSourceTests.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/tests/unit/etlng/GrpcSourceTests.cpp b/tests/unit/etlng/GrpcSourceTests.cpp index 945d6233..1bc6ad90 100644 --- a/tests/unit/etlng/GrpcSourceTests.cpp +++ b/tests/unit/etlng/GrpcSourceTests.cpp @@ -374,10 +374,12 @@ TEST_F(GrpcSourceNgTests, DeadlineIsHandledCorrectly) auto grpcSource = std::make_unique("localhost", std::to_string(getXRPLMockPort()), kDEADLINE); + // Note: this may not be called at all if gRPC cancels before it gets a chance to call the stub EXPECT_CALL(mockXrpLedgerAPIService, GetLedger) - .WillOnce([&](grpc::ServerContext*, - org::xrpl::rpc::v1::GetLedgerRequest const*, - org::xrpl::rpc::v1::GetLedgerResponse*) { + .Times(testing::AtMost(1)) + .WillRepeatedly([&](grpc::ServerContext*, + org::xrpl::rpc::v1::GetLedgerRequest const*, + org::xrpl::rpc::v1::GetLedgerResponse*) { // wait for main thread to discard us and fail the test if unsuccessful within expected timeframe [&] { ASSERT_TRUE(sem.try_acquire_for(std::chrono::milliseconds{50})); }(); return grpc::Status{};