mirror of
https://github.com/XRPLF/clio.git
synced 2025-11-04 20:05:51 +00:00
committed by
GitHub
parent
6065d324b5
commit
a9d685d5c0
7
.github/actions/clang_format/action.yml
vendored
7
.github/actions/clang_format/action.yml
vendored
@@ -18,6 +18,8 @@ runs:
|
|||||||
shell: bash
|
shell: bash
|
||||||
|
|
||||||
- name: Run formatter
|
- name: Run formatter
|
||||||
|
continue-on-error: true
|
||||||
|
id: run_formatter
|
||||||
run: |
|
run: |
|
||||||
./.githooks/pre-commit
|
./.githooks/pre-commit
|
||||||
shell: bash
|
shell: bash
|
||||||
@@ -27,3 +29,8 @@ runs:
|
|||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
git diff --color --exit-code | tee "clang-format.patch"
|
git diff --color --exit-code | tee "clang-format.patch"
|
||||||
|
|
||||||
|
- name: Fail job
|
||||||
|
if: ${{ steps.run_formatter.outcome != 'success' }}
|
||||||
|
shell: bash
|
||||||
|
run: exit 1
|
||||||
|
|||||||
@@ -43,8 +43,8 @@ struct FakeResultOrError {
|
|||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
FakeResult
|
static FakeResult
|
||||||
value() const
|
value()
|
||||||
{
|
{
|
||||||
return FakeResult{};
|
return FakeResult{};
|
||||||
}
|
}
|
||||||
@@ -65,8 +65,8 @@ struct FakeFuture {
|
|||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
FakeMaybeError
|
static FakeMaybeError
|
||||||
await() const
|
await()
|
||||||
{
|
{
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
@@ -103,14 +103,14 @@ struct MockHandle {
|
|||||||
struct FakeRetryPolicy {
|
struct FakeRetryPolicy {
|
||||||
FakeRetryPolicy(boost::asio::io_context&){}; // required by concept
|
FakeRetryPolicy(boost::asio::io_context&){}; // required by concept
|
||||||
|
|
||||||
std::chrono::milliseconds
|
static std::chrono::milliseconds
|
||||||
calculateDelay(uint32_t /* attempt */)
|
calculateDelay(uint32_t /* attempt */)
|
||||||
{
|
{
|
||||||
return std::chrono::milliseconds{1};
|
return std::chrono::milliseconds{1};
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
static bool
|
||||||
shouldRetry(CassandraError) const
|
shouldRetry(CassandraError)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -70,8 +70,8 @@ public:
|
|||||||
using Output = TestOutput;
|
using Output = TestOutput;
|
||||||
using Result = rpc::HandlerReturnType<Output>;
|
using Result = rpc::HandlerReturnType<Output>;
|
||||||
|
|
||||||
rpc::RpcSpecConstRef
|
static rpc::RpcSpecConstRef
|
||||||
spec([[maybe_unused]] uint32_t apiVersion) const
|
spec([[maybe_unused]] uint32_t apiVersion)
|
||||||
{
|
{
|
||||||
using namespace rpc::validation;
|
using namespace rpc::validation;
|
||||||
|
|
||||||
@@ -83,8 +83,8 @@ public:
|
|||||||
return rpcSpec;
|
return rpcSpec;
|
||||||
}
|
}
|
||||||
|
|
||||||
Result
|
static Result
|
||||||
process(Input input, [[maybe_unused]] rpc::Context const& ctx) const
|
process(Input input, [[maybe_unused]] rpc::Context const& ctx)
|
||||||
{
|
{
|
||||||
return Output{input.hello + '_' + std::to_string(input.limit.value_or(0))};
|
return Output{input.hello + '_' + std::to_string(input.limit.value_or(0))};
|
||||||
}
|
}
|
||||||
@@ -95,8 +95,8 @@ public:
|
|||||||
using Output = TestOutput;
|
using Output = TestOutput;
|
||||||
using Result = rpc::HandlerReturnType<Output>;
|
using Result = rpc::HandlerReturnType<Output>;
|
||||||
|
|
||||||
Result
|
static Result
|
||||||
process([[maybe_unused]] rpc::Context const& ctx) const
|
process([[maybe_unused]] rpc::Context const& ctx)
|
||||||
{
|
{
|
||||||
return Output{"test"};
|
return Output{"test"};
|
||||||
}
|
}
|
||||||
@@ -109,8 +109,8 @@ public:
|
|||||||
using Output = TestOutput;
|
using Output = TestOutput;
|
||||||
using Result = rpc::HandlerReturnType<Output>;
|
using Result = rpc::HandlerReturnType<Output>;
|
||||||
|
|
||||||
rpc::RpcSpecConstRef
|
static rpc::RpcSpecConstRef
|
||||||
spec([[maybe_unused]] uint32_t apiVersion) const
|
spec([[maybe_unused]] uint32_t apiVersion)
|
||||||
{
|
{
|
||||||
using namespace rpc::validation;
|
using namespace rpc::validation;
|
||||||
|
|
||||||
@@ -122,8 +122,8 @@ public:
|
|||||||
return rpcSpec;
|
return rpcSpec;
|
||||||
}
|
}
|
||||||
|
|
||||||
Result
|
static Result
|
||||||
process([[maybe_unused]] Input input, [[maybe_unused]] rpc::Context const& ctx) const
|
process([[maybe_unused]] Input input, [[maybe_unused]] rpc::Context const& ctx)
|
||||||
{
|
{
|
||||||
// always fail
|
// always fail
|
||||||
return rpc::Error{rpc::Status{"Very custom error"}};
|
return rpc::Error{rpc::Status{"Very custom error"}};
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ struct FakeAmendmentBlockAction {
|
|||||||
std::reference_wrapper<std::size_t> callCount;
|
std::reference_wrapper<std::size_t> callCount;
|
||||||
|
|
||||||
void
|
void
|
||||||
operator()()
|
operator()() const
|
||||||
{
|
{
|
||||||
++(callCount.get());
|
++(callCount.get());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,6 +21,7 @@
|
|||||||
|
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <utility>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
class FakeBook {
|
class FakeBook {
|
||||||
@@ -135,7 +136,7 @@ class FakeTransactionsList {
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
std::size_t
|
std::size_t
|
||||||
transactions_size()
|
transactions_size() const
|
||||||
{
|
{
|
||||||
return size_;
|
return size_;
|
||||||
}
|
}
|
||||||
@@ -146,7 +147,7 @@ class FakeObjectsList {
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
std::size_t
|
std::size_t
|
||||||
objects_size()
|
objects_size() const
|
||||||
{
|
{
|
||||||
return size_;
|
return size_;
|
||||||
}
|
}
|
||||||
@@ -165,7 +166,7 @@ struct FakeFetchResponse {
|
|||||||
}
|
}
|
||||||
|
|
||||||
FakeFetchResponse(std::string blob, uint32_t id = 0, bool objectNeighborsIncluded = false)
|
FakeFetchResponse(std::string blob, uint32_t id = 0, bool objectNeighborsIncluded = false)
|
||||||
: id{id}, objectNeighborsIncluded{objectNeighborsIncluded}, ledgerHeader{blob}
|
: id{id}, objectNeighborsIncluded{objectNeighborsIncluded}, ledgerHeader{std::move(blob)}
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -175,14 +176,14 @@ struct FakeFetchResponse {
|
|||||||
return other.id == id;
|
return other.id == id;
|
||||||
}
|
}
|
||||||
|
|
||||||
FakeTransactionsList
|
static FakeTransactionsList
|
||||||
transactions_list() const
|
transactions_list()
|
||||||
{
|
{
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
FakeObjectsList
|
static FakeObjectsList
|
||||||
ledger_objects() const
|
ledger_objects()
|
||||||
{
|
{
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,6 +19,7 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include "data/BackendInterface.h"
|
||||||
#include "util/MockBackend.h"
|
#include "util/MockBackend.h"
|
||||||
#include "util/MockCounters.h"
|
#include "util/MockCounters.h"
|
||||||
#include "util/MockETLService.h"
|
#include "util/MockETLService.h"
|
||||||
@@ -26,10 +27,24 @@
|
|||||||
#include "util/MockSubscriptionManager.h"
|
#include "util/MockSubscriptionManager.h"
|
||||||
#include "util/log/Logger.h"
|
#include "util/log/Logger.h"
|
||||||
|
|
||||||
#include <boost/asio.hpp>
|
#include <boost/asio/executor_work_guard.hpp>
|
||||||
|
#include <boost/asio/io_context.hpp>
|
||||||
|
#include <boost/asio/io_service.hpp>
|
||||||
|
#include <boost/asio/spawn.hpp>
|
||||||
|
#include <boost/log/core/core.hpp>
|
||||||
|
#include <boost/log/expressions/predicates/channel_severity_filter.hpp>
|
||||||
|
#include <boost/log/keywords/format.hpp>
|
||||||
|
#include <boost/log/utility/setup/common_attributes.hpp>
|
||||||
|
#include <boost/log/utility/setup/console.hpp>
|
||||||
|
#include <boost/log/utility/setup/formatter_parser.hpp>
|
||||||
#include <gtest/gtest.h>
|
#include <gtest/gtest.h>
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
|
#include <optional>
|
||||||
|
#include <ostream>
|
||||||
|
#include <sstream>
|
||||||
|
#include <string>
|
||||||
#include <thread>
|
#include <thread>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -181,7 +196,7 @@ struct MockBackendTest : virtual public NoLoggerFixture {
|
|||||||
SetUp() override
|
SetUp() override
|
||||||
{
|
{
|
||||||
NoLoggerFixture::SetUp();
|
NoLoggerFixture::SetUp();
|
||||||
util::Config cfg;
|
util::Config const cfg;
|
||||||
mockBackendPtr = std::make_shared<MockBackend>(cfg);
|
mockBackendPtr = std::make_shared<MockBackend>(cfg);
|
||||||
}
|
}
|
||||||
void
|
void
|
||||||
|
|||||||
@@ -28,9 +28,7 @@
|
|||||||
struct MockSubscriptionManager {
|
struct MockSubscriptionManager {
|
||||||
public:
|
public:
|
||||||
using session_ptr = std::shared_ptr<web::ConnectionBase>;
|
using session_ptr = std::shared_ptr<web::ConnectionBase>;
|
||||||
MockSubscriptionManager()
|
MockSubscriptionManager() = default;
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
MOCK_METHOD(boost::json::object, subLedger, (boost::asio::yield_context, session_ptr), ());
|
MOCK_METHOD(boost::json::object, subLedger, (boost::asio::yield_context, session_ptr), ());
|
||||||
|
|
||||||
|
|||||||
@@ -19,8 +19,14 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include "util/Taggable.h"
|
||||||
#include "web/interface/ConnectionBase.h"
|
#include "web/interface/ConnectionBase.h"
|
||||||
|
|
||||||
|
#include <boost/beast/http/status.hpp>
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
struct MockSession : public web::ConnectionBase {
|
struct MockSession : public web::ConnectionBase {
|
||||||
std::string message;
|
std::string message;
|
||||||
void
|
void
|
||||||
@@ -30,6 +36,7 @@ struct MockSession : public web::ConnectionBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
// NOLINTNEXTLINE(cppcoreguidelines-rvalue-reference-param-not-moved)
|
||||||
send(std::string&& msg, boost::beast::http::status = boost::beast::http::status::ok) override
|
send(std::string&& msg, boost::beast::http::status = boost::beast::http::status::ok) override
|
||||||
{
|
{
|
||||||
message += msg;
|
message += msg;
|
||||||
@@ -49,6 +56,7 @@ struct MockDeadSession : public web::ConnectionBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
// NOLINTNEXTLINE(cppcoreguidelines-rvalue-reference-param-not-moved)
|
||||||
send(std::string&&, boost::beast::http::status = boost::beast::http::status::ok) override
|
send(std::string&&, boost::beast::http::status = boost::beast::http::status::ok) override
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,12 +19,36 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <boost/asio.hpp>
|
#include <boost/asio/buffer.hpp>
|
||||||
#include <boost/beast.hpp>
|
#include <boost/asio/io_context.hpp>
|
||||||
|
#include <boost/asio/ip/tcp.hpp>
|
||||||
|
#include <boost/asio/ssl/context.hpp>
|
||||||
|
#include <boost/asio/ssl/error.hpp>
|
||||||
|
#include <boost/asio/ssl/stream_base.hpp>
|
||||||
|
#include <boost/asio/ssl/verify_context.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/flat_buffer.hpp>
|
||||||
|
#include <boost/beast/core/stream_traits.hpp>
|
||||||
|
#include <boost/beast/core/tcp_stream.hpp>
|
||||||
#include <boost/beast/http.hpp>
|
#include <boost/beast/http.hpp>
|
||||||
#include <boost/beast/ssl.hpp>
|
#include <boost/beast/http/field.hpp>
|
||||||
|
#include <boost/beast/http/message.hpp>
|
||||||
|
#include <boost/beast/http/string_body.hpp>
|
||||||
|
#include <boost/beast/http/verb.hpp>
|
||||||
|
#include <boost/beast/ssl/ssl_stream.hpp>
|
||||||
|
#include <boost/beast/version.hpp>
|
||||||
|
#include <boost/beast/websocket/rfc6455.hpp>
|
||||||
|
#include <boost/beast/websocket/stream.hpp>
|
||||||
|
#include <boost/beast/websocket/stream_base.hpp>
|
||||||
|
#include <openssl/err.h>
|
||||||
|
#include <openssl/tls1.h>
|
||||||
|
|
||||||
|
#include <optional>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <utility>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
namespace http = boost::beast::http;
|
namespace http = boost::beast::http;
|
||||||
namespace net = boost::asio;
|
namespace net = boost::asio;
|
||||||
@@ -126,8 +150,8 @@ public:
|
|||||||
ws_.set_option(boost::beast::websocket::stream_base::decorator([additionalHeaders = std::move(additionalHeaders
|
ws_.set_option(boost::beast::websocket::stream_base::decorator([additionalHeaders = std::move(additionalHeaders
|
||||||
)](boost::beast::websocket::request_type& req) {
|
)](boost::beast::websocket::request_type& req) {
|
||||||
req.set(http::field::user_agent, std::string(BOOST_BEAST_VERSION_STRING) + " websocket-client-coro");
|
req.set(http::field::user_agent, std::string(BOOST_BEAST_VERSION_STRING) + " websocket-client-coro");
|
||||||
for (auto& header : additionalHeaders) {
|
for (auto const& header : additionalHeaders) {
|
||||||
req.set(header.name, std::move(header.value));
|
req.set(header.name, header.value);
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
|
|
||||||
@@ -176,7 +200,7 @@ struct HttpsSyncClient {
|
|||||||
if (!SSL_set_tlsext_host_name(stream.native_handle(), host.c_str()))
|
if (!SSL_set_tlsext_host_name(stream.native_handle(), host.c_str()))
|
||||||
#pragma GCC diagnostic pop
|
#pragma GCC diagnostic pop
|
||||||
{
|
{
|
||||||
boost::beast::error_code ec{static_cast<int>(::ERR_get_error()), net::error::get_ssl_category()};
|
boost::beast::error_code const ec{static_cast<int>(::ERR_get_error()), net::error::get_ssl_category()};
|
||||||
throw boost::beast::system_error{ec};
|
throw boost::beast::system_error{ec};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user