feat: ETLng loader basics (#1808)

For #1597
This commit is contained in:
Alex Kremer
2025-01-09 14:47:08 +00:00
committed by GitHub
parent 36a9f40a60
commit 48c8d85d0c
31 changed files with 1093 additions and 36 deletions

View File

@@ -211,7 +211,7 @@ createObject()
.dataRaw = hexStringToBinaryString(kOBJ_BLOB),
.successor = hexStringToBinaryString(kOBJ_SUCC),
.predecessor = hexStringToBinaryString(kOBJ_PRED),
.type = {},
.type = etlng::model::Object::ModType::Created,
};
}

View File

@@ -19,8 +19,10 @@
#pragma once
#include "etlng/AmendmentBlockHandlerInterface.hpp"
#include <gmock/gmock.h>
struct MockAmendmentBlockHandler {
MOCK_METHOD(void, onAmendmentBlock, (), ());
struct MockAmendmentBlockHandler : etlng::AmendmentBlockHandlerInterface {
MOCK_METHOD(void, notifyAmendmentBlocked, (), (override));
};

View File

@@ -20,11 +20,15 @@
#pragma once
#include "util/LoggerFixtures.hpp"
#include "util/MockAmendmentBlockHandler.hpp"
#include "util/MockETLService.hpp"
#include "util/MockLedgerFetcher.hpp"
#include "util/MockLoadBalancer.hpp"
#include <gmock/gmock.h>
#include <memory>
/**
* @brief Fixture with a mock etl service
*/
@@ -63,3 +67,28 @@ struct MockLoadBalancerTest : virtual public NoLoggerFixture {
protected:
std::shared_ptr<MockLoadBalancer> mockLoadBalancerPtr_ = std::make_shared<MockLoadBalancer>();
};
/**
* @brief Fixture with a mock NG etl balancer
*/
struct MockNgLoadBalancerTest : virtual public NoLoggerFixture {
protected:
std::shared_ptr<MockNgLoadBalancer> mockLoadBalancerPtr_ = std::make_shared<MockNgLoadBalancer>();
};
/**
* @brief Fixture with a mock ledger fetcher
*/
struct MockLedgerFetcherTest : virtual public NoLoggerFixture {
protected:
std::shared_ptr<MockNgLedgerFetcher> mockLedgerFetcherPtr_ = std::make_shared<MockNgLedgerFetcher>();
};
/**
* @brief Fixture with a mock ledger fetcher
*/
struct MockAmendmentBlockHandlerTest : virtual public NoLoggerFixture {
protected:
std::shared_ptr<MockAmendmentBlockHandler> mockAmendmentBlockHandlerPtr_ =
std::make_shared<MockAmendmentBlockHandler>();
};

View File

@@ -19,6 +19,7 @@
#pragma once
#include "etl/LedgerFetcherInterface.hpp"
#include "util/FakeFetchResponse.hpp"
#include <gmock/gmock.h>
@@ -30,3 +31,8 @@ struct MockLedgerFetcher {
MOCK_METHOD(std::optional<FakeFetchResponse>, fetchData, (uint32_t), ());
MOCK_METHOD(std::optional<FakeFetchResponse>, fetchDataAndDiff, (uint32_t), ());
};
struct MockNgLedgerFetcher : etl::LedgerFetcherInterface {
MOCK_METHOD(OptionalGetLedgerResponseType, fetchData, (uint32_t), (override));
MOCK_METHOD(OptionalGetLedgerResponseType, fetchDataAndDiff, (uint32_t), (override));
};

View File

@@ -19,6 +19,9 @@
#pragma once
#include "etl/ETLState.hpp"
#include "etlng/InitialLoadObserverInterface.hpp"
#include "etlng/LoadBalancerInterface.hpp"
#include "rpc/Errors.hpp"
#include "util/FakeFetchResponse.hpp"
@@ -28,10 +31,12 @@
#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;
@@ -48,3 +53,36 @@ struct MockLoadBalancer {
(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)
);
};