mirror of
https://github.com/XRPLF/clio.git
synced 2026-07-25 16:10:45 +00:00
@@ -17,15 +17,22 @@
|
||||
*/
|
||||
//==============================================================================
|
||||
|
||||
#include "etl/CorruptionDetector.hpp"
|
||||
#include "etl/SystemState.hpp"
|
||||
#include "util/Fixtures.hpp"
|
||||
#include "util/MockPrometheus.hpp"
|
||||
#include "util/TestObject.hpp"
|
||||
|
||||
#include <gmock/gmock.h>
|
||||
#include <gtest/gtest.h>
|
||||
#include <ripple/basics/Blob.h>
|
||||
#include <ripple/basics/XRPAmount.h>
|
||||
#include <ripple/basics/base_uint.h>
|
||||
#include <ripple/protocol/Indexes.h>
|
||||
|
||||
#include <optional>
|
||||
#include <vector>
|
||||
|
||||
using namespace data;
|
||||
using namespace util::prometheus;
|
||||
using namespace testing;
|
||||
@@ -72,3 +79,60 @@ TEST_F(BackendInterfaceTest, FetchFeesLegacySuccessPath)
|
||||
EXPECT_EQ(fees->reserve, XRPAmount(3));
|
||||
});
|
||||
}
|
||||
|
||||
TEST_F(BackendInterfaceTest, FetchLedgerPageSuccessPath)
|
||||
{
|
||||
using namespace ripple;
|
||||
backend->setRange(MINSEQ, MAXSEQ);
|
||||
|
||||
auto state = etl::SystemState{};
|
||||
backend->setCorruptionDetector(etl::CorruptionDetector{state, backend->cache()});
|
||||
|
||||
EXPECT_FALSE(backend->cache().isDisabled());
|
||||
EXPECT_CALL(*backend, doFetchSuccessorKey(_, _, _))
|
||||
.Times(10)
|
||||
.WillRepeatedly(Return(uint256{"1FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF1FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"}));
|
||||
EXPECT_CALL(*backend, doFetchLedgerObjects(_, _, _)).WillOnce(Return(std::vector<Blob>(10, Blob{'s'})));
|
||||
|
||||
runSpawn([this](auto yield) { backend->fetchLedgerPage(std::nullopt, MAXSEQ, 10, false, yield); });
|
||||
EXPECT_FALSE(backend->cache().isDisabled());
|
||||
}
|
||||
|
||||
TEST_F(BackendInterfaceTest, FetchLedgerPageDisablesCacheOnMissingData)
|
||||
{
|
||||
using namespace ripple;
|
||||
backend->setRange(MINSEQ, MAXSEQ);
|
||||
|
||||
auto state = etl::SystemState{};
|
||||
backend->setCorruptionDetector(etl::CorruptionDetector{state, backend->cache()});
|
||||
|
||||
EXPECT_FALSE(backend->cache().isDisabled());
|
||||
EXPECT_CALL(*backend, doFetchSuccessorKey(_, _, _))
|
||||
.Times(10)
|
||||
.WillRepeatedly(Return(uint256{"1FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF1FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"}));
|
||||
EXPECT_CALL(*backend, doFetchLedgerObjects(_, _, _))
|
||||
.WillOnce(Return(std::vector<Blob>{
|
||||
Blob{'s'}, Blob{'s'}, Blob{'s'}, Blob{'s'}, Blob{'s'}, Blob{'s'}, Blob{'s'}, Blob{'s'}, Blob{'s'}, Blob{}
|
||||
}));
|
||||
|
||||
runSpawn([this](auto yield) { backend->fetchLedgerPage(std::nullopt, MAXSEQ, 10, false, yield); });
|
||||
EXPECT_TRUE(backend->cache().isDisabled());
|
||||
}
|
||||
|
||||
TEST_F(BackendInterfaceTest, FetchLedgerPageWithoutCorruptionDetectorDoesNotDisableCacheOnMissingData)
|
||||
{
|
||||
using namespace ripple;
|
||||
backend->setRange(MINSEQ, MAXSEQ);
|
||||
|
||||
EXPECT_FALSE(backend->cache().isDisabled());
|
||||
EXPECT_CALL(*backend, doFetchSuccessorKey(_, _, _))
|
||||
.Times(10)
|
||||
.WillRepeatedly(Return(uint256{"1FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF1FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"}));
|
||||
EXPECT_CALL(*backend, doFetchLedgerObjects(_, _, _))
|
||||
.WillOnce(Return(std::vector<Blob>{
|
||||
Blob{'s'}, Blob{'s'}, Blob{'s'}, Blob{'s'}, Blob{'s'}, Blob{'s'}, Blob{'s'}, Blob{'s'}, Blob{'s'}, Blob{}
|
||||
}));
|
||||
|
||||
runSpawn([this](auto yield) { backend->fetchLedgerPage(std::nullopt, MAXSEQ, 10, false, yield); });
|
||||
EXPECT_FALSE(backend->cache().isDisabled());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user