mirror of
				https://github.com/XRPLF/clio.git
				synced 2025-11-04 11:55: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
 | 
			
		||||
 | 
			
		||||
    - name: Run formatter
 | 
			
		||||
      continue-on-error: true
 | 
			
		||||
      id: run_formatter
 | 
			
		||||
      run: |
 | 
			
		||||
        ./.githooks/pre-commit
 | 
			
		||||
      shell: bash
 | 
			
		||||
@@ -27,3 +29,8 @@ runs:
 | 
			
		||||
      shell: bash
 | 
			
		||||
      run: |
 | 
			
		||||
        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;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    FakeResult
 | 
			
		||||
    value() const
 | 
			
		||||
    static FakeResult
 | 
			
		||||
    value()
 | 
			
		||||
    {
 | 
			
		||||
        return FakeResult{};
 | 
			
		||||
    }
 | 
			
		||||
@@ -65,8 +65,8 @@ struct FakeFuture {
 | 
			
		||||
        return data;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    FakeMaybeError
 | 
			
		||||
    await() const
 | 
			
		||||
    static FakeMaybeError
 | 
			
		||||
    await()
 | 
			
		||||
    {
 | 
			
		||||
        return {};
 | 
			
		||||
    }
 | 
			
		||||
@@ -103,14 +103,14 @@ struct MockHandle {
 | 
			
		||||
struct FakeRetryPolicy {
 | 
			
		||||
    FakeRetryPolicy(boost::asio::io_context&){};  // required by concept
 | 
			
		||||
 | 
			
		||||
    std::chrono::milliseconds
 | 
			
		||||
    static std::chrono::milliseconds
 | 
			
		||||
    calculateDelay(uint32_t /* attempt */)
 | 
			
		||||
    {
 | 
			
		||||
        return std::chrono::milliseconds{1};
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    bool
 | 
			
		||||
    shouldRetry(CassandraError) const
 | 
			
		||||
    static bool
 | 
			
		||||
    shouldRetry(CassandraError)
 | 
			
		||||
    {
 | 
			
		||||
        return false;
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
@@ -70,8 +70,8 @@ public:
 | 
			
		||||
    using Output = TestOutput;
 | 
			
		||||
    using Result = rpc::HandlerReturnType<Output>;
 | 
			
		||||
 | 
			
		||||
    rpc::RpcSpecConstRef
 | 
			
		||||
    spec([[maybe_unused]] uint32_t apiVersion) const
 | 
			
		||||
    static rpc::RpcSpecConstRef
 | 
			
		||||
    spec([[maybe_unused]] uint32_t apiVersion)
 | 
			
		||||
    {
 | 
			
		||||
        using namespace rpc::validation;
 | 
			
		||||
 | 
			
		||||
@@ -83,8 +83,8 @@ public:
 | 
			
		||||
        return rpcSpec;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    Result
 | 
			
		||||
    process(Input input, [[maybe_unused]] rpc::Context const& ctx) const
 | 
			
		||||
    static Result
 | 
			
		||||
    process(Input input, [[maybe_unused]] rpc::Context const& ctx)
 | 
			
		||||
    {
 | 
			
		||||
        return Output{input.hello + '_' + std::to_string(input.limit.value_or(0))};
 | 
			
		||||
    }
 | 
			
		||||
@@ -95,8 +95,8 @@ public:
 | 
			
		||||
    using Output = TestOutput;
 | 
			
		||||
    using Result = rpc::HandlerReturnType<Output>;
 | 
			
		||||
 | 
			
		||||
    Result
 | 
			
		||||
    process([[maybe_unused]] rpc::Context const& ctx) const
 | 
			
		||||
    static Result
 | 
			
		||||
    process([[maybe_unused]] rpc::Context const& ctx)
 | 
			
		||||
    {
 | 
			
		||||
        return Output{"test"};
 | 
			
		||||
    }
 | 
			
		||||
@@ -109,8 +109,8 @@ public:
 | 
			
		||||
    using Output = TestOutput;
 | 
			
		||||
    using Result = rpc::HandlerReturnType<Output>;
 | 
			
		||||
 | 
			
		||||
    rpc::RpcSpecConstRef
 | 
			
		||||
    spec([[maybe_unused]] uint32_t apiVersion) const
 | 
			
		||||
    static rpc::RpcSpecConstRef
 | 
			
		||||
    spec([[maybe_unused]] uint32_t apiVersion)
 | 
			
		||||
    {
 | 
			
		||||
        using namespace rpc::validation;
 | 
			
		||||
 | 
			
		||||
@@ -122,8 +122,8 @@ public:
 | 
			
		||||
        return rpcSpec;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    Result
 | 
			
		||||
    process([[maybe_unused]] Input input, [[maybe_unused]] rpc::Context const& ctx) const
 | 
			
		||||
    static Result
 | 
			
		||||
    process([[maybe_unused]] Input input, [[maybe_unused]] rpc::Context const& ctx)
 | 
			
		||||
    {
 | 
			
		||||
        // always fail
 | 
			
		||||
        return rpc::Error{rpc::Status{"Very custom error"}};
 | 
			
		||||
 
 | 
			
		||||
@@ -25,7 +25,7 @@ struct FakeAmendmentBlockAction {
 | 
			
		||||
    std::reference_wrapper<std::size_t> callCount;
 | 
			
		||||
 | 
			
		||||
    void
 | 
			
		||||
    operator()()
 | 
			
		||||
    operator()() const
 | 
			
		||||
    {
 | 
			
		||||
        ++(callCount.get());
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
@@ -21,6 +21,7 @@
 | 
			
		||||
 | 
			
		||||
#include <cstddef>
 | 
			
		||||
#include <string>
 | 
			
		||||
#include <utility>
 | 
			
		||||
#include <vector>
 | 
			
		||||
 | 
			
		||||
class FakeBook {
 | 
			
		||||
@@ -135,7 +136,7 @@ class FakeTransactionsList {
 | 
			
		||||
 | 
			
		||||
public:
 | 
			
		||||
    std::size_t
 | 
			
		||||
    transactions_size()
 | 
			
		||||
    transactions_size() const
 | 
			
		||||
    {
 | 
			
		||||
        return size_;
 | 
			
		||||
    }
 | 
			
		||||
@@ -146,7 +147,7 @@ class FakeObjectsList {
 | 
			
		||||
 | 
			
		||||
public:
 | 
			
		||||
    std::size_t
 | 
			
		||||
    objects_size()
 | 
			
		||||
    objects_size() const
 | 
			
		||||
    {
 | 
			
		||||
        return size_;
 | 
			
		||||
    }
 | 
			
		||||
@@ -165,7 +166,7 @@ struct FakeFetchResponse {
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    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;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    FakeTransactionsList
 | 
			
		||||
    transactions_list() const
 | 
			
		||||
    static FakeTransactionsList
 | 
			
		||||
    transactions_list()
 | 
			
		||||
    {
 | 
			
		||||
        return {};
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    FakeObjectsList
 | 
			
		||||
    ledger_objects() const
 | 
			
		||||
    static FakeObjectsList
 | 
			
		||||
    ledger_objects()
 | 
			
		||||
    {
 | 
			
		||||
        return {};
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
@@ -19,6 +19,7 @@
 | 
			
		||||
 | 
			
		||||
#pragma once
 | 
			
		||||
 | 
			
		||||
#include "data/BackendInterface.h"
 | 
			
		||||
#include "util/MockBackend.h"
 | 
			
		||||
#include "util/MockCounters.h"
 | 
			
		||||
#include "util/MockETLService.h"
 | 
			
		||||
@@ -26,10 +27,24 @@
 | 
			
		||||
#include "util/MockSubscriptionManager.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 <memory>
 | 
			
		||||
#include <mutex>
 | 
			
		||||
#include <optional>
 | 
			
		||||
#include <ostream>
 | 
			
		||||
#include <sstream>
 | 
			
		||||
#include <string>
 | 
			
		||||
#include <thread>
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
@@ -181,7 +196,7 @@ struct MockBackendTest : virtual public NoLoggerFixture {
 | 
			
		||||
    SetUp() override
 | 
			
		||||
    {
 | 
			
		||||
        NoLoggerFixture::SetUp();
 | 
			
		||||
        util::Config cfg;
 | 
			
		||||
        util::Config const cfg;
 | 
			
		||||
        mockBackendPtr = std::make_shared<MockBackend>(cfg);
 | 
			
		||||
    }
 | 
			
		||||
    void
 | 
			
		||||
 
 | 
			
		||||
@@ -28,9 +28,7 @@
 | 
			
		||||
struct MockSubscriptionManager {
 | 
			
		||||
public:
 | 
			
		||||
    using session_ptr = std::shared_ptr<web::ConnectionBase>;
 | 
			
		||||
    MockSubscriptionManager()
 | 
			
		||||
    {
 | 
			
		||||
    }
 | 
			
		||||
    MockSubscriptionManager() = default;
 | 
			
		||||
 | 
			
		||||
    MOCK_METHOD(boost::json::object, subLedger, (boost::asio::yield_context, session_ptr), ());
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -19,8 +19,14 @@
 | 
			
		||||
 | 
			
		||||
#pragma once
 | 
			
		||||
 | 
			
		||||
#include "util/Taggable.h"
 | 
			
		||||
#include "web/interface/ConnectionBase.h"
 | 
			
		||||
 | 
			
		||||
#include <boost/beast/http/status.hpp>
 | 
			
		||||
 | 
			
		||||
#include <memory>
 | 
			
		||||
#include <string>
 | 
			
		||||
 | 
			
		||||
struct MockSession : public web::ConnectionBase {
 | 
			
		||||
    std::string message;
 | 
			
		||||
    void
 | 
			
		||||
@@ -30,6 +36,7 @@ struct MockSession : public web::ConnectionBase {
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    void
 | 
			
		||||
    // NOLINTNEXTLINE(cppcoreguidelines-rvalue-reference-param-not-moved)
 | 
			
		||||
    send(std::string&& msg, boost::beast::http::status = boost::beast::http::status::ok) override
 | 
			
		||||
    {
 | 
			
		||||
        message += msg;
 | 
			
		||||
@@ -49,6 +56,7 @@ struct MockDeadSession : public web::ConnectionBase {
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    void
 | 
			
		||||
    // NOLINTNEXTLINE(cppcoreguidelines-rvalue-reference-param-not-moved)
 | 
			
		||||
    send(std::string&&, boost::beast::http::status = boost::beast::http::status::ok) override
 | 
			
		||||
    {
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
@@ -19,12 +19,36 @@
 | 
			
		||||
 | 
			
		||||
#pragma once
 | 
			
		||||
 | 
			
		||||
#include <boost/asio.hpp>
 | 
			
		||||
#include <boost/beast.hpp>
 | 
			
		||||
#include <boost/asio/buffer.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/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 <utility>
 | 
			
		||||
#include <vector>
 | 
			
		||||
 | 
			
		||||
namespace http = boost::beast::http;
 | 
			
		||||
namespace net = boost::asio;
 | 
			
		||||
@@ -126,8 +150,8 @@ public:
 | 
			
		||||
        ws_.set_option(boost::beast::websocket::stream_base::decorator([additionalHeaders = std::move(additionalHeaders
 | 
			
		||||
                                                                        )](boost::beast::websocket::request_type& req) {
 | 
			
		||||
            req.set(http::field::user_agent, std::string(BOOST_BEAST_VERSION_STRING) + " websocket-client-coro");
 | 
			
		||||
            for (auto& header : additionalHeaders) {
 | 
			
		||||
                req.set(header.name, std::move(header.value));
 | 
			
		||||
            for (auto const& header : additionalHeaders) {
 | 
			
		||||
                req.set(header.name, header.value);
 | 
			
		||||
            }
 | 
			
		||||
        }));
 | 
			
		||||
 | 
			
		||||
@@ -176,7 +200,7 @@ struct HttpsSyncClient {
 | 
			
		||||
        if (!SSL_set_tlsext_host_name(stream.native_handle(), host.c_str()))
 | 
			
		||||
#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};
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user