mirror of
https://github.com/XRPLF/clio.git
synced 2025-11-04 20:05:51 +00:00
89 lines
3.1 KiB
C++
89 lines
3.1 KiB
C++
//------------------------------------------------------------------------------
|
|
/*
|
|
This file is part of clio: https://github.com/XRPLF/clio
|
|
Copyright (c) 2023, 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 "etl/ETLState.hpp"
|
|
#include "etlng/InitialLoadObserverInterface.hpp"
|
|
#include "etlng/LoadBalancerInterface.hpp"
|
|
#include "rpc/Errors.hpp"
|
|
#include "util/FakeFetchResponse.hpp"
|
|
|
|
#include <boost/asio/spawn.hpp>
|
|
#include <boost/json.hpp>
|
|
#include <boost/json/object.hpp>
|
|
#include <boost/json/value.hpp>
|
|
#include <gmock/gmock.h>
|
|
|
|
#include <chrono>
|
|
#include <cstdint>
|
|
#include <expected>
|
|
#include <optional>
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
struct MockLoadBalancer {
|
|
using RawLedgerObjectType = FakeLedgerObject;
|
|
|
|
MOCK_METHOD(void, loadInitialLedger, (std::uint32_t, bool), ());
|
|
MOCK_METHOD(std::optional<FakeFetchResponse>, fetchLedger, (uint32_t, bool, bool), ());
|
|
MOCK_METHOD(boost::json::value, toJson, (), (const));
|
|
|
|
using ForwardToRippledReturnType = std::expected<boost::json::object, rpc::ClioError>;
|
|
MOCK_METHOD(
|
|
ForwardToRippledReturnType,
|
|
forwardToRippled,
|
|
(boost::json::object const&, std::optional<std::string> const&, bool, boost::asio::yield_context),
|
|
(const)
|
|
);
|
|
};
|
|
|
|
struct MockNgLoadBalancer : etlng::LoadBalancerInterface {
|
|
using RawLedgerObjectType = FakeLedgerObject;
|
|
|
|
MOCK_METHOD(
|
|
std::vector<std::string>,
|
|
loadInitialLedger,
|
|
(uint32_t, etlng::InitialLoadObserverInterface&, std::chrono::steady_clock::duration),
|
|
(override)
|
|
);
|
|
MOCK_METHOD(
|
|
std::vector<std::string>,
|
|
loadInitialLedger,
|
|
(uint32_t, std::chrono::steady_clock::duration),
|
|
(override)
|
|
);
|
|
MOCK_METHOD(
|
|
OptionalGetLedgerResponseType,
|
|
fetchLedger,
|
|
(uint32_t, bool, bool, std::chrono::steady_clock::duration),
|
|
(override)
|
|
);
|
|
MOCK_METHOD(boost::json::value, toJson, (), (const, override));
|
|
MOCK_METHOD(std::optional<etl::ETLState>, getETLState, (), (noexcept, override));
|
|
|
|
using ForwardToRippledReturnType = std::expected<boost::json::object, rpc::ClioError>;
|
|
MOCK_METHOD(
|
|
ForwardToRippledReturnType,
|
|
forwardToRippled,
|
|
(boost::json::object const&, std::optional<std::string> const&, bool, boost::asio::yield_context),
|
|
(override)
|
|
);
|
|
};
|