mirror of
https://github.com/XRPLF/clio.git
synced 2025-12-06 17:27:58 +00:00
@@ -50,8 +50,10 @@ struct CacheLoaderTest : public MockBackendTest
|
||||
{
|
||||
work.reset();
|
||||
for (auto& optThread : optThreads)
|
||||
{
|
||||
if (optThread.joinable())
|
||||
optThread.join();
|
||||
}
|
||||
ctx.stop();
|
||||
MockBackendTest::TearDown();
|
||||
}
|
||||
@@ -88,7 +90,7 @@ getLatestDiff()
|
||||
|
||||
TEST_F(CacheLoaderTest, FromCache)
|
||||
{
|
||||
MockBackend* rawBackendPtr = static_cast<MockBackend*>(mockBackendPtr.get());
|
||||
MockBackend* rawBackendPtr = dynamic_cast<MockBackend*>(mockBackendPtr.get());
|
||||
CacheLoader loader{cfg, ctx, mockBackendPtr, cache};
|
||||
|
||||
auto const diffs = getLatestDiff();
|
||||
@@ -104,22 +106,19 @@ TEST_F(CacheLoaderTest, FromCache)
|
||||
.WillByDefault(Invoke([&]() -> std::optional<ripple::uint256> {
|
||||
// mock the result from doFetchSuccessorKey, be aware this function will be called from multiple threads
|
||||
// for each thread, the last 2 items must be end flag and nullopt, otherwise it will loop forever
|
||||
std::lock_guard<std::mutex> guard(keysMutex);
|
||||
std::lock_guard<std::mutex> const guard(keysMutex);
|
||||
threadKeysMap[std::this_thread::get_id()]++;
|
||||
|
||||
if (threadKeysMap[std::this_thread::get_id()] == keysSize - 1)
|
||||
{
|
||||
return lastKey;
|
||||
}
|
||||
else if (threadKeysMap[std::this_thread::get_id()] == keysSize)
|
||||
if (threadKeysMap[std::this_thread::get_id()] == keysSize)
|
||||
{
|
||||
threadKeysMap[std::this_thread::get_id()] = 0;
|
||||
return std::nullopt;
|
||||
}
|
||||
else
|
||||
{
|
||||
return ripple::uint256{INDEX1};
|
||||
}
|
||||
return ripple::uint256{INDEX1};
|
||||
}));
|
||||
EXPECT_CALL(*rawBackendPtr, doFetchSuccessorKey).Times(keysSize * loops);
|
||||
|
||||
@@ -135,7 +134,7 @@ TEST_F(CacheLoaderTest, FromCache)
|
||||
bool cacheReady = false;
|
||||
ON_CALL(cache, setFull).WillByDefault(Invoke([&]() {
|
||||
{
|
||||
std::lock_guard lk(m);
|
||||
std::lock_guard const lk(m);
|
||||
cacheReady = true;
|
||||
}
|
||||
cv.notify_one();
|
||||
|
||||
@@ -94,7 +94,8 @@ TEST_F(ETLTransformerTest, StopsOnWriteConflict)
|
||||
|
||||
TEST_F(ETLTransformerTest, StopsOnEmptyFetchResponse)
|
||||
{
|
||||
MockBackend* rawBackendPtr = static_cast<MockBackend*>(mockBackendPtr.get());
|
||||
MockBackend* rawBackendPtr = dynamic_cast<MockBackend*>(mockBackendPtr.get());
|
||||
ASSERT_NE(rawBackendPtr, nullptr);
|
||||
mockBackendPtr->cache().setFull(); // to avoid throwing exception in updateCache
|
||||
|
||||
auto const blob = hexStringToBinaryString(RAW_HEADER);
|
||||
@@ -103,7 +104,7 @@ TEST_F(ETLTransformerTest, StopsOnEmptyFetchResponse)
|
||||
ON_CALL(dataPipe_, popNext).WillByDefault([this, &response](auto) -> std::optional<FakeFetchResponse> {
|
||||
if (state_.isStopping)
|
||||
return std::nullopt;
|
||||
return response;
|
||||
return response; // NOLINT (performance-no-automatic-move)
|
||||
});
|
||||
ON_CALL(*rawBackendPtr, doFinishWrites).WillByDefault(Return(true));
|
||||
|
||||
@@ -129,7 +130,8 @@ TEST_F(ETLTransformerTest, StopsOnEmptyFetchResponse)
|
||||
|
||||
TEST_F(ETLTransformerTest, DoesNotPublishIfCanNotBuildNextLedger)
|
||||
{
|
||||
MockBackend* rawBackendPtr = static_cast<MockBackend*>(mockBackendPtr.get());
|
||||
MockBackend* rawBackendPtr = dynamic_cast<MockBackend*>(mockBackendPtr.get());
|
||||
ASSERT_NE(rawBackendPtr, nullptr);
|
||||
mockBackendPtr->cache().setFull(); // to avoid throwing exception in updateCache
|
||||
|
||||
auto const blob = hexStringToBinaryString(RAW_HEADER);
|
||||
|
||||
Reference in New Issue
Block a user