feat: Implement and use LedgerCacheInterface (#1955)

For #1200
This commit is contained in:
Alex Kremer
2025-03-12 13:48:33 +00:00
committed by GitHub
parent 26842374de
commit 8ac1ff7699
68 changed files with 369 additions and 177 deletions

View File

@@ -0,0 +1,75 @@
//------------------------------------------------------------------------------
/*
This file is part of clio: https://github.com/XRPLF/clio
Copyright (c) 2025, the clio developers.
Permission to use, copy, modify, and distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
//==============================================================================
#pragma once
#include "data/LedgerCacheInterface.hpp"
#include "data/Types.hpp"
#include <gmock/gmock.h>
#include <xrpl/basics/base_uint.h>
#include <cstddef>
#include <cstdint>
#include <optional>
#include <vector>
struct MockLedgerCache : data::LedgerCacheInterface {
MOCK_METHOD(void, updateImp, (std::vector<data::LedgerObject> const& a, uint32_t b, bool c), ());
void
update(std::vector<data::LedgerObject> const& a, uint32_t b, bool c = false) override
{
updateImp(a, b, c);
}
MOCK_METHOD(std::optional<data::Blob>, get, (ripple::uint256 const& a, uint32_t b), (const, override));
MOCK_METHOD(
std::optional<data::LedgerObject>,
getSuccessor,
(ripple::uint256 const& a, uint32_t b),
(const, override)
);
MOCK_METHOD(
std::optional<data::LedgerObject>,
getPredecessor,
(ripple::uint256 const& a, uint32_t b),
(const, override)
);
MOCK_METHOD(void, setDisabled, (), (override));
MOCK_METHOD(bool, isDisabled, (), (const, override));
MOCK_METHOD(void, setFull, (), (override));
MOCK_METHOD(bool, isFull, (), (const, override));
MOCK_METHOD(uint32_t, latestLedgerSequence, (), (const, override));
MOCK_METHOD(size_t, size, (), (const, override));
MOCK_METHOD(float, getObjectHitRate, (), (const, override));
MOCK_METHOD(float, getSuccessorHitRate, (), (const, override));
MOCK_METHOD(void, waitUntilCacheContainsSeq, (uint32_t), (override));
};