mirror of
https://github.com/XRPLF/clio.git
synced 2025-11-29 08:05:50 +00:00
committed by
GitHub
parent
6af86367fd
commit
b5da61931f
@@ -25,8 +25,6 @@
|
|||||||
#include "util/log/Logger.hpp"
|
#include "util/log/Logger.hpp"
|
||||||
#include "web/Resolver.hpp"
|
#include "web/Resolver.hpp"
|
||||||
|
|
||||||
#include <boost/asio/io_context.hpp>
|
|
||||||
#include <boost/asio/ip/tcp.hpp>
|
|
||||||
#include <fmt/core.h>
|
#include <fmt/core.h>
|
||||||
#include <grpcpp/client_context.h>
|
#include <grpcpp/client_context.h>
|
||||||
#include <grpcpp/security/credentials.h>
|
#include <grpcpp/security/credentials.h>
|
||||||
@@ -38,7 +36,7 @@
|
|||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <exception>
|
#include <exception>
|
||||||
#include <sstream>
|
#include <iostream>
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|||||||
@@ -42,7 +42,6 @@
|
|||||||
#include <boost/beast/core/flat_buffer.hpp>
|
#include <boost/beast/core/flat_buffer.hpp>
|
||||||
#include <boost/beast/core/tcp_stream.hpp>
|
#include <boost/beast/core/tcp_stream.hpp>
|
||||||
#include <boost/system/system_error.hpp>
|
#include <boost/system/system_error.hpp>
|
||||||
#include <fmt/compile.h>
|
|
||||||
#include <fmt/core.h>
|
#include <fmt/core.h>
|
||||||
|
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
|
|||||||
@@ -22,7 +22,6 @@
|
|||||||
#include "util/Taggable.hpp"
|
#include "util/Taggable.hpp"
|
||||||
#include "web/SubscriptionContextInterface.hpp"
|
#include "web/SubscriptionContextInterface.hpp"
|
||||||
|
|
||||||
#include <boost/asio/any_io_executor.hpp>
|
|
||||||
#include <boost/asio/buffer.hpp>
|
#include <boost/asio/buffer.hpp>
|
||||||
#include <boost/asio/spawn.hpp>
|
#include <boost/asio/spawn.hpp>
|
||||||
|
|
||||||
|
|||||||
@@ -32,13 +32,9 @@
|
|||||||
#include "web/ng/Response.hpp"
|
#include "web/ng/Response.hpp"
|
||||||
#include "web/ng/SubscriptionContext.hpp"
|
#include "web/ng/SubscriptionContext.hpp"
|
||||||
|
|
||||||
#include <boost/asio/bind_cancellation_slot.hpp>
|
|
||||||
#include <boost/asio/cancellation_signal.hpp>
|
|
||||||
#include <boost/asio/error.hpp>
|
#include <boost/asio/error.hpp>
|
||||||
#include <boost/asio/spawn.hpp>
|
#include <boost/asio/spawn.hpp>
|
||||||
#include <boost/asio/ssl/error.hpp>
|
#include <boost/asio/ssl/error.hpp>
|
||||||
#include <boost/asio/steady_timer.hpp>
|
|
||||||
#include <boost/asio/strand.hpp>
|
|
||||||
#include <boost/beast/http/error.hpp>
|
#include <boost/beast/http/error.hpp>
|
||||||
#include <boost/beast/http/status.hpp>
|
#include <boost/beast/http/status.hpp>
|
||||||
#include <boost/beast/websocket/error.hpp>
|
#include <boost/beast/websocket/error.hpp>
|
||||||
|
|||||||
@@ -29,7 +29,6 @@
|
|||||||
#include <boost/asio/ssl/stream_base.hpp>
|
#include <boost/asio/ssl/stream_base.hpp>
|
||||||
#include <boost/asio/ssl/verify_context.hpp>
|
#include <boost/asio/ssl/verify_context.hpp>
|
||||||
#include <boost/asio/ssl/verify_mode.hpp>
|
#include <boost/asio/ssl/verify_mode.hpp>
|
||||||
#include <boost/beast/core/buffers_to_string.hpp>
|
|
||||||
#include <boost/beast/core/error.hpp>
|
#include <boost/beast/core/error.hpp>
|
||||||
#include <boost/beast/core/flat_buffer.hpp>
|
#include <boost/beast/core/flat_buffer.hpp>
|
||||||
#include <boost/beast/core/stream_traits.hpp>
|
#include <boost/beast/core/stream_traits.hpp>
|
||||||
|
|||||||
@@ -36,7 +36,6 @@
|
|||||||
#include <org/xrpl/rpc/v1/get_ledger_data.pb.h>
|
#include <org/xrpl/rpc/v1/get_ledger_data.pb.h>
|
||||||
#include <xrpl/basics/base_uint.h>
|
#include <xrpl/basics/base_uint.h>
|
||||||
#include <xrpl/basics/strHex.h>
|
#include <xrpl/basics/strHex.h>
|
||||||
#include <xrpl/protocol/AccountID.h>
|
|
||||||
|
|
||||||
#include <atomic>
|
#include <atomic>
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
@@ -91,7 +90,7 @@ struct GrpcSourceNgTests : NoLoggerFixture, tests::util::WithMockXrpLedgerAPISer
|
|||||||
std::optional<std::string>
|
std::optional<std::string>
|
||||||
next(std::string const& marker)
|
next(std::string const& marker)
|
||||||
{
|
{
|
||||||
std::scoped_lock lock(mtx_);
|
std::scoped_lock const lock(mtx_);
|
||||||
|
|
||||||
auto const mapKey = ripple::strHex(marker).substr(0, 2);
|
auto const mapKey = ripple::strHex(marker).substr(0, 2);
|
||||||
auto it = store_.lower_bound(mapKey);
|
auto it = store_.lower_bound(mapKey);
|
||||||
@@ -110,7 +109,7 @@ struct GrpcSourceNgTests : NoLoggerFixture, tests::util::WithMockXrpLedgerAPISer
|
|||||||
std::optional<std::string>
|
std::optional<std::string>
|
||||||
peek(std::string const& marker)
|
peek(std::string const& marker)
|
||||||
{
|
{
|
||||||
std::scoped_lock lock(mtx_);
|
std::scoped_lock const lock(mtx_);
|
||||||
|
|
||||||
auto const mapKey = ripple::strHex(marker).substr(0, 2);
|
auto const mapKey = ripple::strHex(marker).substr(0, 2);
|
||||||
auto it = store_.lower_bound(mapKey);
|
auto it = store_.lower_bound(mapKey);
|
||||||
@@ -264,7 +263,7 @@ TEST_F(GrpcSourceNgLoadInitialLedgerTests, DataTransferredAndObserverCalledCorre
|
|||||||
});
|
});
|
||||||
|
|
||||||
std::atomic_uint total = 0u;
|
std::atomic_uint total = 0u;
|
||||||
[[maybe_unused]] testing::InSequence seqGuard;
|
[[maybe_unused]] testing::InSequence const seqGuard;
|
||||||
|
|
||||||
EXPECT_CALL(observer_, onInitialLoadGotMoreObjects)
|
EXPECT_CALL(observer_, onInitialLoadGotMoreObjects)
|
||||||
.Times(numMarkers_)
|
.Times(numMarkers_)
|
||||||
|
|||||||
@@ -22,9 +22,7 @@
|
|||||||
#include "util/NameGenerator.hpp"
|
#include "util/NameGenerator.hpp"
|
||||||
#include "util/Taggable.hpp"
|
#include "util/Taggable.hpp"
|
||||||
#include "util/config/Config.hpp"
|
#include "util/config/Config.hpp"
|
||||||
#include "web/SubscriptionContextInterface.hpp"
|
|
||||||
#include "web/impl/ErrorHandling.hpp"
|
#include "web/impl/ErrorHandling.hpp"
|
||||||
#include "web/interface/ConnectionBase.hpp"
|
|
||||||
#include "web/interface/ConnectionBaseMock.hpp"
|
#include "web/interface/ConnectionBaseMock.hpp"
|
||||||
|
|
||||||
#include <boost/beast/http/status.hpp>
|
#include <boost/beast/http/status.hpp>
|
||||||
@@ -60,7 +58,7 @@ struct ErrorHandlingComposeErrorTest : ErrorHandlingTests,
|
|||||||
TEST_P(ErrorHandlingComposeErrorTest, composeError)
|
TEST_P(ErrorHandlingComposeErrorTest, composeError)
|
||||||
{
|
{
|
||||||
connection_->upgraded = GetParam().connectionUpgraded;
|
connection_->upgraded = GetParam().connectionUpgraded;
|
||||||
ErrorHelper errorHelper{connection_, GetParam().request};
|
ErrorHelper const errorHelper{connection_, GetParam().request};
|
||||||
auto const result = errorHelper.composeError(rpc::RippledError::rpcNOT_READY);
|
auto const result = errorHelper.composeError(rpc::RippledError::rpcNOT_READY);
|
||||||
EXPECT_EQ(boost::json::serialize(result), boost::json::serialize(GetParam().expectedResult));
|
EXPECT_EQ(boost::json::serialize(result), boost::json::serialize(GetParam().expectedResult));
|
||||||
}
|
}
|
||||||
@@ -134,7 +132,7 @@ struct ErrorHandlingSendErrorTest : ErrorHandlingTests,
|
|||||||
TEST_P(ErrorHandlingSendErrorTest, sendError)
|
TEST_P(ErrorHandlingSendErrorTest, sendError)
|
||||||
{
|
{
|
||||||
connection_->upgraded = GetParam().connectionUpgraded;
|
connection_->upgraded = GetParam().connectionUpgraded;
|
||||||
ErrorHelper errorHelper{connection_};
|
ErrorHelper const errorHelper{connection_};
|
||||||
|
|
||||||
EXPECT_CALL(*connection_, send(std::string{GetParam().expectedMessage}, GetParam().expectedStatus));
|
EXPECT_CALL(*connection_, send(std::string{GetParam().expectedMessage}, GetParam().expectedStatus));
|
||||||
errorHelper.sendError(GetParam().status);
|
errorHelper.sendError(GetParam().status);
|
||||||
@@ -199,7 +197,7 @@ INSTANTIATE_TEST_CASE_P(
|
|||||||
|
|
||||||
TEST_F(ErrorHandlingTests, sendInternalError)
|
TEST_F(ErrorHandlingTests, sendInternalError)
|
||||||
{
|
{
|
||||||
ErrorHelper errorHelper{connection_};
|
ErrorHelper const errorHelper{connection_};
|
||||||
|
|
||||||
EXPECT_CALL(
|
EXPECT_CALL(
|
||||||
*connection_,
|
*connection_,
|
||||||
@@ -215,7 +213,7 @@ TEST_F(ErrorHandlingTests, sendInternalError)
|
|||||||
|
|
||||||
TEST_F(ErrorHandlingTests, sendNotReadyError)
|
TEST_F(ErrorHandlingTests, sendNotReadyError)
|
||||||
{
|
{
|
||||||
ErrorHelper errorHelper{connection_};
|
ErrorHelper const errorHelper{connection_};
|
||||||
EXPECT_CALL(
|
EXPECT_CALL(
|
||||||
*connection_,
|
*connection_,
|
||||||
send(
|
send(
|
||||||
@@ -231,7 +229,7 @@ TEST_F(ErrorHandlingTests, sendNotReadyError)
|
|||||||
TEST_F(ErrorHandlingTests, sendTooBusyError_UpgradedConnection)
|
TEST_F(ErrorHandlingTests, sendTooBusyError_UpgradedConnection)
|
||||||
{
|
{
|
||||||
connection_->upgraded = true;
|
connection_->upgraded = true;
|
||||||
ErrorHelper errorHelper{connection_};
|
ErrorHelper const errorHelper{connection_};
|
||||||
EXPECT_CALL(
|
EXPECT_CALL(
|
||||||
*connection_,
|
*connection_,
|
||||||
send(
|
send(
|
||||||
@@ -247,7 +245,7 @@ TEST_F(ErrorHandlingTests, sendTooBusyError_UpgradedConnection)
|
|||||||
TEST_F(ErrorHandlingTests, sendTooBusyError_NotUpgradedConnection)
|
TEST_F(ErrorHandlingTests, sendTooBusyError_NotUpgradedConnection)
|
||||||
{
|
{
|
||||||
connection_->upgraded = false;
|
connection_->upgraded = false;
|
||||||
ErrorHelper errorHelper{connection_};
|
ErrorHelper const errorHelper{connection_};
|
||||||
EXPECT_CALL(
|
EXPECT_CALL(
|
||||||
*connection_,
|
*connection_,
|
||||||
send(
|
send(
|
||||||
@@ -263,7 +261,7 @@ TEST_F(ErrorHandlingTests, sendTooBusyError_NotUpgradedConnection)
|
|||||||
TEST_F(ErrorHandlingTests, sendJsonParsingError_UpgradedConnection)
|
TEST_F(ErrorHandlingTests, sendJsonParsingError_UpgradedConnection)
|
||||||
{
|
{
|
||||||
connection_->upgraded = true;
|
connection_->upgraded = true;
|
||||||
ErrorHelper errorHelper{connection_};
|
ErrorHelper const errorHelper{connection_};
|
||||||
EXPECT_CALL(
|
EXPECT_CALL(
|
||||||
*connection_,
|
*connection_,
|
||||||
send(
|
send(
|
||||||
@@ -279,7 +277,7 @@ TEST_F(ErrorHandlingTests, sendJsonParsingError_UpgradedConnection)
|
|||||||
TEST_F(ErrorHandlingTests, sendJsonParsingError_NotUpgradedConnection)
|
TEST_F(ErrorHandlingTests, sendJsonParsingError_NotUpgradedConnection)
|
||||||
{
|
{
|
||||||
connection_->upgraded = false;
|
connection_->upgraded = false;
|
||||||
ErrorHelper errorHelper{connection_};
|
ErrorHelper const errorHelper{connection_};
|
||||||
EXPECT_CALL(
|
EXPECT_CALL(
|
||||||
*connection_,
|
*connection_,
|
||||||
send(std::string{"Unable to parse JSON from the request"}, boost::beast::http::status::bad_request)
|
send(std::string{"Unable to parse JSON from the request"}, boost::beast::http::status::bad_request)
|
||||||
|
|||||||
@@ -380,7 +380,7 @@ TEST_F(ng_RPCServerHandlerWsTest, HandleRequest_Successful_WsRequest)
|
|||||||
{
|
{
|
||||||
backend->setRange(0, 1);
|
backend->setRange(0, 1);
|
||||||
runSpawn([&](boost::asio::yield_context yield) {
|
runSpawn([&](boost::asio::yield_context yield) {
|
||||||
Request::HttpHeaders headers;
|
Request::HttpHeaders const headers;
|
||||||
auto const request = Request(R"json({"method":"some_method", "id": 1234, "api_version": 1})json", headers);
|
auto const request = Request(R"json({"method":"some_method", "id": 1234, "api_version": 1})json", headers);
|
||||||
|
|
||||||
EXPECT_CALL(*rpcEngine_, post).WillOnce([&](auto&& fn, auto&&) {
|
EXPECT_CALL(*rpcEngine_, post).WillOnce([&](auto&& fn, auto&&) {
|
||||||
@@ -411,7 +411,7 @@ TEST_F(ng_RPCServerHandlerWsTest, HandleRequest_Successful_WsRequest_HasError)
|
|||||||
{
|
{
|
||||||
backend->setRange(0, 1);
|
backend->setRange(0, 1);
|
||||||
runSpawn([&](boost::asio::yield_context yield) {
|
runSpawn([&](boost::asio::yield_context yield) {
|
||||||
Request::HttpHeaders headers;
|
Request::HttpHeaders const headers;
|
||||||
auto const request = Request(R"json({"method":"some_method", "id": 1234, "api_version": 1})json", headers);
|
auto const request = Request(R"json({"method":"some_method", "id": 1234, "api_version": 1})json", headers);
|
||||||
|
|
||||||
EXPECT_CALL(*rpcEngine_, post).WillOnce([&](auto&& fn, auto&&) {
|
EXPECT_CALL(*rpcEngine_, post).WillOnce([&](auto&& fn, auto&&) {
|
||||||
|
|||||||
@@ -76,7 +76,7 @@ TEST_F(ng_SubscriptionContextTests, SendOrder)
|
|||||||
auto const message1 = std::make_shared<std::string>("message1");
|
auto const message1 = std::make_shared<std::string>("message1");
|
||||||
auto const message2 = std::make_shared<std::string>("message2");
|
auto const message2 = std::make_shared<std::string>("message2");
|
||||||
|
|
||||||
testing::Sequence sequence;
|
testing::Sequence const sequence;
|
||||||
EXPECT_CALL(connection_, sendBuffer)
|
EXPECT_CALL(connection_, sendBuffer)
|
||||||
.InSequence(sequence)
|
.InSequence(sequence)
|
||||||
.WillOnce([&message1](boost::asio::const_buffer buffer, auto, auto) {
|
.WillOnce([&message1](boost::asio::const_buffer buffer, auto, auto) {
|
||||||
|
|||||||
@@ -31,7 +31,6 @@
|
|||||||
#include <boost/json/object.hpp>
|
#include <boost/json/object.hpp>
|
||||||
#include <boost/json/parse.hpp>
|
#include <boost/json/parse.hpp>
|
||||||
#include <boost/json/serialize.hpp>
|
#include <boost/json/serialize.hpp>
|
||||||
#include <gmock/gmock.h>
|
|
||||||
#include <gtest/gtest.h>
|
#include <gtest/gtest.h>
|
||||||
|
|
||||||
#include <optional>
|
#include <optional>
|
||||||
@@ -68,7 +67,7 @@ struct ng_ErrorHandlingMakeErrorTest : ng_ErrorHandlingTests,
|
|||||||
TEST_P(ng_ErrorHandlingMakeErrorTest, MakeError)
|
TEST_P(ng_ErrorHandlingMakeErrorTest, MakeError)
|
||||||
{
|
{
|
||||||
auto const request = makeRequest(GetParam().isHttp);
|
auto const request = makeRequest(GetParam().isHttp);
|
||||||
ErrorHelper errorHelper{request};
|
ErrorHelper const errorHelper{request};
|
||||||
|
|
||||||
auto response = errorHelper.makeError(GetParam().status);
|
auto response = errorHelper.makeError(GetParam().status);
|
||||||
EXPECT_EQ(response.message(), GetParam().expectedMessage);
|
EXPECT_EQ(response.message(), GetParam().expectedMessage);
|
||||||
@@ -158,7 +157,7 @@ TEST_P(ng_ErrorHandlingMakeInternalErrorTest, ComposeError)
|
|||||||
std::optional<boost::json::object> const requestJson = GetParam().request.has_value()
|
std::optional<boost::json::object> const requestJson = GetParam().request.has_value()
|
||||||
? std::make_optional(boost::json::parse(*GetParam().request).as_object())
|
? std::make_optional(boost::json::parse(*GetParam().request).as_object())
|
||||||
: std::nullopt;
|
: std::nullopt;
|
||||||
ErrorHelper errorHelper{request, requestJson};
|
ErrorHelper const errorHelper{request, requestJson};
|
||||||
|
|
||||||
auto response = errorHelper.makeInternalError();
|
auto response = errorHelper.makeInternalError();
|
||||||
|
|
||||||
@@ -314,7 +313,7 @@ struct ng_ErrorHandlingComposeErrorTest : ng_ErrorHandlingTests,
|
|||||||
TEST_P(ng_ErrorHandlingComposeErrorTest, ComposeError)
|
TEST_P(ng_ErrorHandlingComposeErrorTest, ComposeError)
|
||||||
{
|
{
|
||||||
auto const request = makeRequest(GetParam().isHttp);
|
auto const request = makeRequest(GetParam().isHttp);
|
||||||
ErrorHelper errorHelper{request, GetParam().request};
|
ErrorHelper const errorHelper{request, GetParam().request};
|
||||||
auto const response = errorHelper.composeError(rpc::Status{rpc::RippledError::rpcINTERNAL});
|
auto const response = errorHelper.composeError(rpc::Status{rpc::RippledError::rpcINTERNAL});
|
||||||
EXPECT_EQ(boost::json::serialize(response), GetParam().expectedMessage);
|
EXPECT_EQ(boost::json::serialize(response), GetParam().expectedMessage);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,7 +27,6 @@
|
|||||||
#include "web/ng/Response.hpp"
|
#include "web/ng/Response.hpp"
|
||||||
#include "web/ng/impl/HttpConnection.hpp"
|
#include "web/ng/impl/HttpConnection.hpp"
|
||||||
|
|
||||||
#include <boost/asio/error.hpp>
|
|
||||||
#include <boost/asio/ip/tcp.hpp>
|
#include <boost/asio/ip/tcp.hpp>
|
||||||
#include <boost/asio/spawn.hpp>
|
#include <boost/asio/spawn.hpp>
|
||||||
#include <boost/asio/ssl/context.hpp>
|
#include <boost/asio/ssl/context.hpp>
|
||||||
|
|||||||
@@ -23,10 +23,7 @@
|
|||||||
#include "web/ng/impl/ServerSslContext.hpp"
|
#include "web/ng/impl/ServerSslContext.hpp"
|
||||||
|
|
||||||
#include <boost/json/object.hpp>
|
#include <boost/json/object.hpp>
|
||||||
#include <boost/json/parse.hpp>
|
|
||||||
#include <boost/json/value.hpp>
|
#include <boost/json/value.hpp>
|
||||||
#include <fmt/compile.h>
|
|
||||||
#include <fmt/core.h>
|
|
||||||
#include <gmock/gmock.h>
|
#include <gmock/gmock.h>
|
||||||
#include <gtest/gtest.h>
|
#include <gtest/gtest.h>
|
||||||
#include <test_data/SslCert.hpp>
|
#include <test_data/SslCert.hpp>
|
||||||
|
|||||||
Reference in New Issue
Block a user