From e0395ac32b24cfb8944973d2a54eb5b13caab3be Mon Sep 17 00:00:00 2001 From: evoskuil Date: Fri, 26 Dec 2025 19:58:03 -0500 Subject: [PATCH 1/7] Remove dead code. --- include/bitcoin/network/messages/http_body.hpp | 8 -------- 1 file changed, 8 deletions(-) diff --git a/include/bitcoin/network/messages/http_body.hpp b/include/bitcoin/network/messages/http_body.hpp index 2274d66ea..4483a1025 100644 --- a/include/bitcoin/network/messages/http_body.hpp +++ b/include/bitcoin/network/messages/http_body.hpp @@ -317,14 +317,6 @@ struct BCT_API body }; }; -} // namespace http -} // namespace network -} // namespace libbitcoin - -namespace libbitcoin { -namespace network { -namespace http { - using request = boost::beast::http::request; using request_cptr = std::shared_ptr; using response = boost::beast::http::response; From cbcdd8b53a2e492111646a5adbf1170e9c9a7c88 Mon Sep 17 00:00:00 2001 From: evoskuil Date: Sat, 27 Dec 2025 16:09:42 -0500 Subject: [PATCH 2/7] Refactor for consistency. --- .../bitcoin/network/channels/channel_http.hpp | 16 +- .../bitcoin/network/channels/channel_rpc.hpp | 59 ++++- .../bitcoin/network/messages/http_body.hpp | 22 +- include/bitcoin/network/messages/rpc/body.hpp | 13 +- include/bitcoin/network/net/proxy.hpp | 32 ++- include/bitcoin/network/net/socket.hpp | 75 +++--- src/channels/channel_http.cpp | 56 ++--- src/channels/channel_rpc.cpp | 142 ++++++++++- src/net/proxy.cpp | 41 ++- src/net/socket.cpp | 235 +++++++++--------- 10 files changed, 450 insertions(+), 241 deletions(-) diff --git a/include/bitcoin/network/channels/channel_http.hpp b/include/bitcoin/network/channels/channel_http.hpp index 17db27f58..e36ec6d93 100644 --- a/include/bitcoin/network/channels/channel_http.hpp +++ b/include/bitcoin/network/channels/channel_http.hpp @@ -42,7 +42,7 @@ class BCT_API channel_http using interface = rpc::interface::http; using dispatcher = rpc::dispatcher; - /// Subscribe to request from client (requires strand). + /// Subscribe to message from client (requires strand). /// Event handler is always invoked on the channel strand. template inline void subscribe(auto&& handler) NOEXCEPT @@ -53,8 +53,7 @@ class BCT_API channel_http } // TODO: network.minimum_buffer is being overloaded here. - /// response_buffer_ is initialized to default size, see set_buffer(). - /// Construct client channel to encapsulate and communicate on the socket. + /// Construct http channel to encapsulate and communicate on the socket. inline channel_http(const logger& log, const socket::ptr& socket, uint64_t identifier, const settings_t& settings, const options_t& options) NOEXCEPT @@ -70,7 +69,7 @@ class BCT_API channel_http /// Must call after successful message handling if no stop. virtual void receive() NOEXCEPT; - /// Serialize and write http response to client (requires strand). + /// Serialize and write http message to client (requires strand). /// Completion handler is always invoked on the channel strand. virtual void send(http::response&& response, result_handler&& handler) NOEXCEPT; @@ -91,12 +90,15 @@ class BCT_API channel_http /// Handlers. virtual void handle_receive(const code& ec, size_t bytes, const http::request_cptr& request) NOEXCEPT; - virtual void handle_send(const code& ec, size_t bytes, http::response_ptr&, + virtual void handle_send(const code& ec, size_t bytes, + const http::response_cptr& response, const result_handler& handler) NOEXCEPT; private: - void log_message(const http::request& request) const NOEXCEPT; - void log_message(const http::response& response) const NOEXCEPT; + void log_message(const http::request& request, + size_t bytes) const NOEXCEPT; + void log_message(const http::response& response, + size_t bytes) const NOEXCEPT; // These are protected by strand. http::flat_buffer_ptr response_buffer_; diff --git a/include/bitcoin/network/channels/channel_rpc.hpp b/include/bitcoin/network/channels/channel_rpc.hpp index 3c8d086af..169fcd29b 100644 --- a/include/bitcoin/network/channels/channel_rpc.hpp +++ b/include/bitcoin/network/channels/channel_rpc.hpp @@ -22,7 +22,9 @@ #include #include #include +#include #include +#include #include namespace libbitcoin { @@ -35,10 +37,27 @@ class BCT_API channel_rpc public: typedef std::shared_ptr ptr; + // TODO: implement in node. + using interface = rpc::interface::http; + using dispatcher = rpc::dispatcher; + + /// Subscribe to request from client (requires strand). + /// Event handler is always invoked on the channel strand. + template + inline void subscribe(Handler&& handler) NOEXCEPT + { + BC_ASSERT(stranded()); + dispatcher_.subscribe(std::forward(handler)); + } + + // TODO: network.minimum_buffer is being overloaded here. + /// Construct rpc channel to encapsulate and communicate on the socket. inline channel_rpc(const logger& log, const socket::ptr& socket, uint64_t identifier, const settings_t& settings, const options_t& options) NOEXCEPT - : channel(log, socket, identifier, settings, options) + : channel(log, socket, identifier, settings, options), + response_buffer_(system::to_shared()), + request_buffer_(settings.minimum_buffer) { } @@ -48,9 +67,43 @@ class BCT_API channel_rpc /// Must call after successful message handling if no stop. virtual void receive() NOEXCEPT; - /// Serialize and write rpc response to client (requires strand). + /// Serialize and write response to client (requires strand). /// Completion handler is always invoked on the channel strand. - virtual void send() NOEXCEPT; + virtual void send(rpc::response_t&& message, size_t size_hint, + result_handler&& handler) NOEXCEPT; + +protected: + /// Stranded handler invoked from stop(). + void stopping(const code& ec) NOEXCEPT override; + + /// Read request buffer (not thread safe). + virtual http::flat_buffer& request_buffer() NOEXCEPT; + + /// Dispatch request to subscribers by requested method. + virtual void dispatch(const rpc::request_cptr& request) NOEXCEPT; + + /// Size and assign response_buffer_ (value type is json-rpc::json). + virtual rpc::response_ptr assign_message(rpc::response_t&& message, + size_t size_hint) NOEXCEPT; + + /// Handlers. + virtual void handle_receive(const code& ec, size_t bytes, + const rpc::request_cptr& request) NOEXCEPT; + virtual void handle_send(const code& ec, size_t bytes, + const rpc::response_cptr& response, + const result_handler& handler) NOEXCEPT; + +private: + void log_message(const rpc::request& request, + size_t bytes) const NOEXCEPT; + void log_message(const rpc::response& response, + size_t bytes) const NOEXCEPT; + + // These are protected by strand. + http::flat_buffer_ptr response_buffer_; + http::flat_buffer request_buffer_; + dispatcher dispatcher_{}; + bool reading_{}; }; } // namespace network diff --git a/include/bitcoin/network/messages/http_body.hpp b/include/bitcoin/network/messages/http_body.hpp index 4483a1025..a66387cc8 100644 --- a/include/bitcoin/network/messages/http_body.hpp +++ b/include/bitcoin/network/messages/http_body.hpp @@ -19,6 +19,7 @@ #ifndef LIBBITCOIN_NETWORK_MESSAGES_HTTP_BODY_HPP #define LIBBITCOIN_NETWORK_MESSAGES_HTTP_BODY_HPP +#include #include #include #include @@ -87,8 +88,8 @@ using body_value = std::variant buffer_value, string_value, json_value, - rpc::in_value, - rpc::out_value + rpc::request, + rpc::response >; /// body template for all known message types. @@ -117,8 +118,8 @@ struct BCT_API body FORWARD_ALTERNATIVE_VARIANT_ASSIGNMENT(value_type, buffer_value, inner_) FORWARD_ALTERNATIVE_VARIANT_ASSIGNMENT(value_type, string_value, inner_) FORWARD_ALTERNATIVE_VARIANT_ASSIGNMENT(value_type, json_value, inner_) - FORWARD_ALTERNATIVE_VARIANT_ASSIGNMENT(value_type, rpc::in_value, inner_) - FORWARD_ALTERNATIVE_VARIANT_ASSIGNMENT(value_type, rpc::out_value, inner_) + FORWARD_ALTERNATIVE_VARIANT_ASSIGNMENT(value_type, rpc::request, inner_) + FORWARD_ALTERNATIVE_VARIANT_ASSIGNMENT(value_type, rpc::response, inner_) inline bool has_value() const NOEXCEPT { @@ -181,7 +182,7 @@ struct BCT_API body if (value_.plain_json) value = json_value{}; else - value = rpc::in_value{}; + value = rpc::request{}; break; case http::media_type::text_plain: value = string_value{}; @@ -202,7 +203,7 @@ struct BCT_API body [&](std::monostate&) NOEXCEPT {}, [&](span_value&) NOEXCEPT {}, [&](buffer_value&) NOEXCEPT {}, - [&](rpc::out_value&) NOEXCEPT {}, + [&](rpc::response&) NOEXCEPT {}, [&](empty_value& value) NOEXCEPT { @@ -225,7 +226,7 @@ struct BCT_API body // json_reader not copy or assignable (by contained parser). reader_.emplace(header, value); }, - [&](rpc::in_value& value) NOEXCEPT + [&](rpc::request& value) NOEXCEPT { // json_reader not copy or assignable (by contained parser). reader_.emplace(header, value); @@ -298,14 +299,14 @@ struct BCT_API body return body_writer{ std::in_place_type, header, value }; }, - [&](rpc::out_value& value) NOEXCEPT + [&](rpc::response& value) NOEXCEPT { // json_writer is not movable (by contained serializer). // So requires in-place construction for variant populate. return body_writer{ std::in_place_type, header, value }; }, - [&](rpc::in_value&) NOEXCEPT + [&](rpc::request&) NOEXCEPT { return body_writer{ std::monostate{} }; } @@ -319,7 +320,10 @@ struct BCT_API body using request = boost::beast::http::request; using request_cptr = std::shared_ptr; +using request_ptr = std::shared_ptr; + using response = boost::beast::http::response; +using response_cptr = std::shared_ptr; using response_ptr = std::shared_ptr; } // namespace http diff --git a/include/bitcoin/network/messages/rpc/body.hpp b/include/bitcoin/network/messages/rpc/body.hpp index 9a227bebf..8199f1133 100644 --- a/include/bitcoin/network/messages/rpc/body.hpp +++ b/include/bitcoin/network/messages/rpc/body.hpp @@ -19,6 +19,7 @@ #ifndef LIBBITCOIN_NETWORK_MESSAGES_RPC_BODY_HPP #define LIBBITCOIN_NETWORK_MESSAGES_RPC_BODY_HPP +#include #include #include #include @@ -98,12 +99,16 @@ struct BCT_API body }; }; -// Only defines that require model.hpp, could move to independent file. using request_body = body; -using response_body = body; -using in_value = request_body::value_type; -using out_value = response_body::value_type; +using request = request_body::value_type; +using request_cptr = std::shared_ptr; +using request_ptr = std::shared_ptr; using reader = request_body::reader; + +using response_body = body; +using response = response_body::value_type; +using response_cptr = std::shared_ptr; +using response_ptr = std::shared_ptr; using writer = response_body::writer; } // namespace rpc diff --git a/include/bitcoin/network/net/proxy.hpp b/include/bitcoin/network/net/proxy.hpp index a02130720..05bb9f1df 100644 --- a/include/bitcoin/network/net/proxy.hpp +++ b/include/bitcoin/network/net/proxy.hpp @@ -132,21 +132,12 @@ class BCT_API proxy /// TCP-RPC (e.g. electrum, stratum_v1). /// ----------------------------------------------------------------------- - /// Read full rpc request from the socket, handler posted to socket strand. - virtual void read(rpc::in_value& out, count_handler&& handler) NOEXCEPT; - - /// Write full rpc response to the socket, handler posted to socket strand. - virtual void write(rpc::out_value&& in, count_handler&& handler) NOEXCEPT; - - /// HTTP (generic). - /// ----------------------------------------------------------------------- - - /// Read full http variant request from the socket, using provided buffer. - virtual void read(http::flat_buffer& buffer, http::request& request, + /// Read rpc request from the socket, using provided buffer. + virtual void read(http::flat_buffer& buffer, rpc::request& request, count_handler&& handler) NOEXCEPT; - /// Write full http variant response to the socket (json buffer in body). - virtual void write(http::response& response, + /// Write rpc response to the socket (json buffer in body). + virtual void write(rpc::response& response, count_handler&& handler) NOEXCEPT; /// WS (generic). @@ -160,6 +151,21 @@ class BCT_API proxy virtual void ws_write(const asio::const_buffer& in, bool binary, count_handler&& handler) NOEXCEPT; + /// WS-RPC (custom). + /// ----------------------------------------------------------------------- + /// TODO. + + /// HTTP (generic). + /// ----------------------------------------------------------------------- + + /// Read http request from the socket, using provided buffer. + virtual void read(http::flat_buffer& buffer, http::request& request, + count_handler&& handler) NOEXCEPT; + + /// Write http response to the socket (json buffer in body). + virtual void write(http::response& response, + count_handler&& handler) NOEXCEPT; + private: typedef std::deque> queue; diff --git a/include/bitcoin/network/net/socket.hpp b/include/bitcoin/network/net/socket.hpp index 8755e5012..4cdac6643 100644 --- a/include/bitcoin/network/net/socket.hpp +++ b/include/bitcoin/network/net/socket.hpp @@ -102,23 +102,12 @@ class BCT_API socket /// TCP-RPC (e.g. electrum, stratum_v1). /// ----------------------------------------------------------------------- - /// Read full rpc request from the socket, handler posted to socket strand. - virtual void rpc_read(rpc::in_value& request, + /// Read rpc request from the socket, handler posted to socket strand. + virtual void rpc_read(http::flat_buffer& buffer, rpc::request& request, count_handler&& handler) NOEXCEPT; - /// Write full rpc response to the socket, handler posted to socket strand. - virtual void rpc_write(rpc::out_value&& response, - count_handler&& handler) NOEXCEPT; - - /// HTTP (generic). - /// ----------------------------------------------------------------------- - - /// Read full http variant request from the socket. - virtual void http_read(http::flat_buffer& buffer, - http::request& request, count_handler&& handler) NOEXCEPT; - - /// Write full http variant response to the socket. - virtual void http_write(http::response& response, + /// Write rpc response to the socket, handler posted to socket strand. + virtual void rpc_write(rpc::response& response, count_handler&& handler) NOEXCEPT; /// WS (generic). @@ -132,6 +121,21 @@ class BCT_API socket virtual void ws_write(const asio::const_buffer& in, bool binary, count_handler&& handler) NOEXCEPT; + /// WS-RPC (custom). + /// ----------------------------------------------------------------------- + /// TODO. + + /// HTTP (generic). + /// ----------------------------------------------------------------------- + + /// Read http request from the socket, handler posted to socket strand. + virtual void http_read(http::flat_buffer& buffer, http::request& request, + count_handler&& handler) NOEXCEPT; + + /// Write http response to the socket, handler posted to socket strand. + virtual void http_write(http::response& response, + count_handler&& handler) NOEXCEPT; + /// Properties. /// ----------------------------------------------------------------------- @@ -166,13 +170,12 @@ class BCT_API socket { typedef std::shared_ptr ptr; - read_rpc(rpc::in_value& request_) NOEXCEPT - : value{}, reader{ value } + read_rpc(rpc::request& request) NOEXCEPT + : value{ request }, reader{ value } { - request_ = value; } - rpc::in_value value; + rpc::request& value; rpc::reader reader; }; @@ -181,12 +184,12 @@ class BCT_API socket typedef std::shared_ptr ptr; using out_buffer = rpc::writer::out_buffer; - write_rpc(rpc::out_value&& response) NOEXCEPT - : value{ std::move(response) }, writer{ value } + write_rpc(rpc::response& response) NOEXCEPT + : value{ response }, writer{ value } { } - rpc::out_value value; + rpc::response& value; rpc::writer writer; }; @@ -221,13 +224,6 @@ class BCT_API socket void do_rpc_write(boost_code ec, size_t total, const write_rpc::ptr& out, const count_handler& handler) NOEXCEPT; - // http (generic) - void do_http_read(std::reference_wrapper buffer, - const std::reference_wrapper& request, - const count_handler& handler) NOEXCEPT; - void do_http_write(const std::reference_wrapper& response, - const count_handler& handler) NOEXCEPT; - // ws (generic) void do_ws_read(std::reference_wrapper out, const count_handler& handler) NOEXCEPT; @@ -236,6 +232,13 @@ class BCT_API socket void do_ws_event(ws::frame_type kind, const std::string_view& data) NOEXCEPT; + // http (generic) + void do_http_read(std::reference_wrapper buffer, + const std::reference_wrapper& request, + const count_handler& handler) NOEXCEPT; + void do_http_write(const std::reference_wrapper& response, + const count_handler& handler) NOEXCEPT; + code set_websocket(const http::request& request) NOEXCEPT; // completion @@ -261,13 +264,6 @@ class BCT_API socket void handle_rpc_write(boost_code ec, size_t size, size_t total, const write_rpc::ptr& out, const count_handler& handler) NOEXCEPT; - // http (generic) - void handle_http_read(const boost_code& ec, size_t size, - const std::reference_wrapper& request, - const count_handler& handler) NOEXCEPT; - void handle_http_write(const boost_code& ec, size_t size, - const count_handler& handler) NOEXCEPT; - // ws (generic) void handle_ws_read(const boost_code& ec, size_t size, const count_handler& handler) NOEXCEPT; @@ -276,6 +272,13 @@ class BCT_API socket void handle_ws_event(ws::frame_type kind, const std::string& data) NOEXCEPT; + // http (generic) + void handle_http_read(const boost_code& ec, size_t size, + const std::reference_wrapper& request, + const count_handler& handler) NOEXCEPT; + void handle_http_write(const boost_code& ec, size_t size, + const count_handler& handler) NOEXCEPT; + protected: // These are thread safe. asio::strand strand_; diff --git a/src/channels/channel_http.cpp b/src/channels/channel_http.cpp index 20e19fc4a..87c334e01 100644 --- a/src/channels/channel_http.cpp +++ b/src/channels/channel_http.cpp @@ -33,12 +33,11 @@ namespace network { #define CASE_REQUEST_TO_MODEL(verb_, request_, model_) \ case verb::verb_: \ model_.method = #verb_; \ - model_.params = { array_t{ any_t{ \ + model_.params = { rpc::array_t{ rpc::any_t{ \ http::method::tag_request(request_) } } }; \ break using namespace system; -using namespace network::rpc; using namespace network::http; using namespace std::placeholders; @@ -86,15 +85,14 @@ void channel_http::receive() NOEXCEPT shared_from_base(), _1, _2, in)); } -// private -void channel_http::handle_receive(const code& ec, size_t, - const request_cptr& request) NOEXCEPT +void channel_http::handle_receive(const code& ec, size_t bytes, + const http::request_cptr& request) NOEXCEPT { BC_ASSERT(stranded()); if (stopped()) { - LOGQ("Request read abort [" << authority() << "]"); + LOGQ("Http read abort [" << authority() << "]"); return; } @@ -103,7 +101,7 @@ void channel_http::handle_receive(const code& ec, size_t, // Don't log common conditions. if (ec != error::end_of_stream && ec != error::operation_canceled) { - LOGF("Request read failure [" << authority() << "] " + LOGF("Http read failure [" << authority() << "] " << ec.message()); } @@ -112,14 +110,14 @@ void channel_http::handle_receive(const code& ec, size_t, } reading_ = false; - log_message(*request); + log_message(*request, bytes); dispatch(request); } // Wrap the http request as a tagged verb request and dispatch by type. void channel_http::dispatch(const request_cptr& request) NOEXCEPT { - request_t model{}; + rpc::request_t model{}; switch (request.get()->method()) { CASE_REQUEST_TO_MODEL(get, request, model); @@ -162,15 +160,16 @@ void channel_http::send(response&& response, result_handler&& handler) NOEXCEPT return; } - log_message(*ptr); - write(*ptr, std::move(complete)); + write(response, std::move(complete)); } -// private -void channel_http::handle_send(const code& ec, size_t, response_ptr&, - const result_handler& handler) NOEXCEPT +void channel_http::handle_send(const code& ec, size_t bytes, + const response_cptr& response, const result_handler& handler) NOEXCEPT { - if (ec) stop(ec); + if (ec) + stop(ec); + + log_message(*response, bytes); handler(ec); } @@ -180,42 +179,39 @@ void channel_http::assign_json_buffer(response& response) NOEXCEPT if (const auto& body = response.body(); body.contains()) { - const auto& value = body.get(); + auto& value = body.get(); response_buffer_->max_size(value.size_hint); - body.get().buffer = response_buffer_; + value.buffer = response_buffer_; } } // log helpers // ---------------------------------------------------------------------------- -// private -void channel_http::log_message(const request& request) const NOEXCEPT +void channel_http::log_message(const request& LOG_ONLY(request), + size_t LOG_ONLY(bytes)) const NOEXCEPT { - LOG_ONLY(const auto size = serialize(request.payload_size() - .has_value() ? request.payload_size().value() : zero);) - LOG_ONLY(const auto version = "http/" + serialize(request.version() / 10) + "." + serialize(request.version() % 10);) - LOGA("Request [" << request.method_string() - << "] " << version << " (" << (request.chunked() ? "c" : size) + LOGA("Http [" << request.method_string() + << "] " << version + << " (" << (request.chunked() ? "c" : serialize(bytes)) << ") " << (request.keep_alive() ? "keep" : "drop") << " [" << authority() << "]" << " {" << (split(request[field::accept], ",").front()) << "...}" << " " << request.target()); } -void channel_http::log_message(const response& response) const NOEXCEPT +void channel_http::log_message(const response& LOG_ONLY(response), + size_t LOG_ONLY(bytes)) const NOEXCEPT { - LOG_ONLY(const auto size = serialize(response.payload_size() - .has_value() ? response.payload_size().value() : zero);) - LOG_ONLY(const auto version = "http/" + serialize(response.version() / 10) + "." + serialize(response.version() % 10);) - LOGA("Response [" << status_string(response.result()) - << "] " << version << " (" << (response.chunked() ? "c" : size) + LOGA("Http [" << status_string(response.result()) + << "] " << version + << " (" << (response.chunked() ? "c" : serialize(bytes)) << ") " << (response.keep_alive() ? "keep" : "drop") << " [" << authority() << "]" << " {" << (response[field::content_type]) << "}"); diff --git a/src/channels/channel_rpc.cpp b/src/channels/channel_rpc.cpp index 01a85c507..e20e78f34 100644 --- a/src/channels/channel_rpc.cpp +++ b/src/channels/channel_rpc.cpp @@ -18,11 +18,35 @@ */ #include +#include +#include +#include #include +#include namespace libbitcoin { namespace network { +using namespace system; +using namespace network::rpc; +using namespace std::placeholders; + +// Shared pointers required in handler parameters so closures control lifetime. +BC_PUSH_WARNING(NO_VALUE_OR_CONST_REF_SHARED_PTR) +BC_PUSH_WARNING(SMART_PTR_NOT_NEEDED) +BC_PUSH_WARNING(NO_THROW_IN_NOEXCEPT) + +// Start/stop/resume (started upon create). +// ---------------------------------------------------------------------------- + +// This should not be called internally, as derived rely on stop() override. +void channel_rpc::stopping(const code& ec) NOEXCEPT +{ + BC_ASSERT(stranded()); + channel::stopping(ec); + dispatcher_.stop(ec); +} + void channel_rpc::resume() NOEXCEPT { BC_ASSERT(stranded()); @@ -30,15 +54,131 @@ void channel_rpc::resume() NOEXCEPT receive(); } +// Read cycle. +// ---------------------------------------------------------------------------- + +// Failure to call after successful message handling causes stalled channel. void channel_rpc::receive() NOEXCEPT { BC_ASSERT(stranded()); + BC_ASSERT_MSG(!reading_, "already reading"); + + if (stopped() || paused() || reading_) + return; + + reading_ = true; + const auto in = to_shared(); + + // Post handle_read to strand upon stop, error, or buffer full. + read(request_buffer(), *in, + std::bind(&channel_rpc::handle_receive, + shared_from_base(), _1, _2, in)); +} + +void channel_rpc::handle_receive(const code& ec, size_t bytes, + const request_cptr& request) NOEXCEPT +{ + BC_ASSERT(stranded()); + + if (stopped()) + { + LOGQ("Rpc read abort [" << authority() << "]"); + return; + } + + if (ec) + { + // Don't log common conditions. + if (ec != error::end_of_stream && ec != error::operation_canceled) + { + LOGF("Rpc read failure [" << authority() << "] " + << ec.message()); + } + + stop(ec); + return; + } + + reading_ = false; + log_message(*request, bytes); + dispatch(request); +} + +void channel_rpc::dispatch(const request_cptr& request) NOEXCEPT +{ + if (const auto code = dispatcher_.notify(request->message)) + stop(code); } -void channel_rpc::send() NOEXCEPT +http::flat_buffer& channel_rpc::request_buffer() NOEXCEPT +{ + return request_buffer_; +} + +// Send. +// ---------------------------------------------------------------------------- + +void channel_rpc::send(response_t&& model, size_t size_hint, + result_handler&& handler) NOEXCEPT { BC_ASSERT(stranded()); + + const auto out = assign_message(std::move(model), size_hint); + count_handler complete = std::bind(&channel_rpc::handle_send, + shared_from_base(), _1, _2, out, std::move(handler)); + + if (!out) + { + complete(error::bad_alloc, {}); + return; + } + + write(*out, std::move(complete)); +} + +void channel_rpc::handle_send(const code& ec, size_t bytes, + const response_cptr& response, const result_handler& handler) NOEXCEPT +{ + if (ec) + stop(ec); + + log_message(*response, bytes); + handler(ec); +} + +// private +response_ptr channel_rpc::assign_message(response_t&& message, + size_t size_hint) NOEXCEPT +{ + response_buffer_->max_size(size_hint); + const auto ptr = to_shared(); + ptr->message = std::move(message); + ptr->buffer = response_buffer_; + return ptr; +} + +// log helpers +// ---------------------------------------------------------------------------- + +void channel_rpc::log_message(const request& LOG_ONLY(request), + size_t LOG_ONLY(bytes)) const NOEXCEPT +{ + LOGA("Rpc request: [" << bytes << "] " + << request.message.method << "(...)."); } +void channel_rpc::log_message(const response& LOG_ONLY(response), + size_t LOG_ONLY(bytes)) const NOEXCEPT +{ + LOG_ONLY(const auto message = response.message.error.has_value() ? + response.message.error.value().message : "success"); + + LOGA("Rpc response: [" << bytes << "], " << message << "."); +} + +BC_POP_WARNING() +BC_POP_WARNING() +BC_POP_WARNING() + } // namespace network } // namespace libbitcoin diff --git a/src/net/proxy.cpp b/src/net/proxy.cpp index 369a77281..f6134cadb 100644 --- a/src/net/proxy.cpp +++ b/src/net/proxy.cpp @@ -204,22 +204,33 @@ void proxy::write(const asio::const_buffer& buffer, // TCP-RPC. // ---------------------------------------------------------------------------- -void proxy::read(rpc::in_value& out, count_handler&& handler) NOEXCEPT +void proxy::read(http::flat_buffer& buffer, rpc::request& request, + count_handler&& handler) NOEXCEPT { boost::asio::dispatch(strand(), std::bind(&proxy::waiting, shared_from_this())); - socket_->rpc_read(out, std::move(handler)); + socket_->rpc_read(buffer, request, std::move(handler)); } -void proxy::write(rpc::out_value&& in, count_handler&& handler) NOEXCEPT +void proxy::write(rpc::response& response, count_handler&& handler) NOEXCEPT { - socket_->rpc_write(std::move(in), std::move(handler)); - // TODO: compose? - ////boost::asio::dispatch(strand(), - //// std::bind(&proxy::do_write, - //// shared_from_this(), std::ref(in), std::move(handler))); + socket_->rpc_write(response, std::move(handler)); +} + +// WS (generic). +// ---------------------------------------------------------------------------- + +void proxy::ws_read(http::flat_buffer& out, count_handler&& handler) NOEXCEPT +{ + socket_->ws_read(out, std::move(handler)); +} + +void proxy::ws_write(const asio::const_buffer& in, bool binary, + count_handler&& handler) NOEXCEPT +{ + socket_->ws_write(in, binary, std::move(handler)); } // HTTP (generic). @@ -242,20 +253,6 @@ void proxy::write(http::response& response, socket_->http_write(response, std::move(handler)); } -// WS (generic). -// ---------------------------------------------------------------------------- - -void proxy::ws_read(http::flat_buffer& out, count_handler&& handler) NOEXCEPT -{ - socket_->ws_read(out, std::move(handler)); -} - -void proxy::ws_write(const asio::const_buffer& in, bool binary, - count_handler&& handler) NOEXCEPT -{ - socket_->ws_write(in, binary, std::move(handler)); -} - // Send cycle (send continues until queue is empty). // ---------------------------------------------------------------------------- // stackoverflow.com/questions/7754695/boost-asio-async-write-how-to-not- diff --git a/src/net/socket.cpp b/src/net/socket.cpp index eec8554b8..3f98e2cdf 100644 --- a/src/net/socket.cpp +++ b/src/net/socket.cpp @@ -279,10 +279,13 @@ void socket::write(const asio::const_buffer& in, /// TCP-RPC. // ---------------------------------------------------------------------------- -void socket::rpc_read(rpc::in_value& request, count_handler&& handler) NOEXCEPT +// Buffer could be passed via request, so this is for interface consistency. +void socket::rpc_read(http::flat_buffer& buffer, rpc::request& request, + count_handler&& handler) NOEXCEPT { boost_code ec{}; const auto in = emplace_shared(request); + in->value.buffer = emplace_shared(buffer); in->reader.init({}, ec); boost::asio::dispatch(strand_, @@ -290,11 +293,11 @@ void socket::rpc_read(rpc::in_value& request, count_handler&& handler) NOEXCEPT shared_from_this(), ec, zero, in, std::move(handler))); } -void socket::rpc_write(rpc::out_value&& response, +void socket::rpc_write(rpc::response& response, count_handler&& handler) NOEXCEPT { boost_code ec{}; - const auto out = emplace_shared(std::move(response)); + const auto out = emplace_shared(response); out->writer.init(ec); // Dispatch success or fail, for handler invoke on strand. @@ -303,42 +306,42 @@ void socket::rpc_write(rpc::out_value&& response, shared_from_this(), ec, zero, out, std::move(handler))); } -// HTTP. +// WS. // ---------------------------------------------------------------------------- -void socket::http_read(http::flat_buffer& buffer, - http::request& request, count_handler&& handler) NOEXCEPT +void socket::ws_read(http::flat_buffer& out, + count_handler&& handler) NOEXCEPT { boost::asio::dispatch(strand_, - std::bind(&socket::do_http_read, shared_from_this(), - std::ref(buffer), std::ref(request), std::move(handler))); + std::bind(&socket::do_ws_read, + shared_from_this(), std::ref(out), std::move(handler))); } -void socket::http_write(http::response& response, +void socket::ws_write(const asio::const_buffer& in, bool binary, count_handler&& handler) NOEXCEPT { boost::asio::dispatch(strand_, - std::bind(&socket::do_http_write, shared_from_this(), - std::ref(response), std::move(handler))); + std::bind(&socket::do_ws_write, + shared_from_this(), in, binary, std::move(handler))); } -// WS. +// HTTP. // ---------------------------------------------------------------------------- -void socket::ws_read(http::flat_buffer& out, - count_handler&& handler) NOEXCEPT +void socket::http_read(http::flat_buffer& buffer, + http::request& request, count_handler&& handler) NOEXCEPT { boost::asio::dispatch(strand_, - std::bind(&socket::do_ws_read, - shared_from_this(), std::ref(out), std::move(handler))); + std::bind(&socket::do_http_read, shared_from_this(), + std::ref(buffer), std::ref(request), std::move(handler))); } -void socket::ws_write(const asio::const_buffer& in, bool binary, +void socket::http_write(http::response& response, count_handler&& handler) NOEXCEPT { boost::asio::dispatch(strand_, - std::bind(&socket::do_ws_write, - shared_from_this(), in, binary, std::move(handler))); + std::bind(&socket::do_http_write, shared_from_this(), + std::ref(response), std::move(handler))); } // connect (private). @@ -457,61 +460,6 @@ void socket::do_rpc_write(boost_code ec, size_t total, shared_from_this(), _1, _2, total, out, handler)); } -// http (generic). -// ---------------------------------------------------------------------------- - -void socket::do_http_read(std::reference_wrapper buffer, - const std::reference_wrapper& request, - const count_handler& handler) NOEXCEPT -{ - BC_ASSERT(stranded()); - - if (websocket()) - { - handler(error::service_stopped, {}); - return; - } - - try - { - // This operation posts handler to the strand. - beast::http::async_read(socket_, buffer.get(), request.get(), - std::bind(&socket::handle_http_read, - shared_from_this(), _1, _2, request, handler)); - } - catch (const std::exception& LOG_ONLY(e)) - { - LOGF("Exception @ do_http_read: " << e.what()); - handler(error::operation_failed, {}); - } -} - -void socket::do_http_write( - const std::reference_wrapper& response, - const count_handler& handler) NOEXCEPT -{ - BC_ASSERT(stranded()); - - if (websocket()) - { - handler(error::service_stopped, {}); - return; - } - - try - { - // This operation posts handler to the strand. - beast::http::async_write(socket_, response.get(), - std::bind(&socket::handle_http_write, - shared_from_this(), _1, _2, handler)); - } - catch (const std::exception& LOG_ONLY(e)) - { - LOGF("Exception @ do_http_write: " << e.what()); - handler(error::operation_failed, {}); - } -} - // ws (generic). // ---------------------------------------------------------------------------- @@ -576,6 +524,61 @@ void socket::do_ws_event(ws::frame_type kind, shared_from_this(), kind, std::string{ data })); } +// http (generic). +// ---------------------------------------------------------------------------- + +void socket::do_http_read(std::reference_wrapper buffer, + const std::reference_wrapper& request, + const count_handler& handler) NOEXCEPT +{ + BC_ASSERT(stranded()); + + if (websocket()) + { + handler(error::service_stopped, {}); + return; + } + + try + { + // This operation posts handler to the strand. + beast::http::async_read(socket_, buffer.get(), request.get(), + std::bind(&socket::handle_http_read, + shared_from_this(), _1, _2, request, handler)); + } + catch (const std::exception& LOG_ONLY(e)) + { + LOGF("Exception @ do_http_read: " << e.what()); + handler(error::operation_failed, {}); + } +} + +void socket::do_http_write( + const std::reference_wrapper& response, + const count_handler& handler) NOEXCEPT +{ + BC_ASSERT(stranded()); + + if (websocket()) + { + handler(error::service_stopped, {}); + return; + } + + try + { + // This operation posts handler to the strand. + beast::http::async_write(socket_, response.get(), + std::bind(&socket::handle_http_write, + shared_from_this(), _1, _2, handler)); + } + catch (const std::exception& LOG_ONLY(e)) + { + LOGF("Exception @ do_http_write: " << e.what()); + handler(error::operation_failed, {}); + } +} + // completion (private). // ---------------------------------------------------------------------------- // These are invoked on strand upon failure, socket cancel, or completion. @@ -703,48 +706,6 @@ void socket::handle_rpc_write(boost_code ec, size_t size, size_t total, do_rpc_write(ec, total, out, handler); } -// http (generic) -// ---------------------------------------------------------------------------- - -void socket::handle_http_read(const boost_code& ec, size_t size, - const std::reference_wrapper& request, - const count_handler& handler) NOEXCEPT -{ - BC_ASSERT(stranded()); - - if (error::asio_is_canceled(ec)) - { - handler(error::channel_stopped, size); - return; - } - - if (!ec && beast::websocket::is_upgrade(request.get())) - { - handler(set_websocket(request.get()), size); - return; - } - - const auto code = error::http_to_error_code(ec); - if (code == error::unknown) logx("http", ec); - handler(code, size); -} - -void socket::handle_http_write(const boost_code& ec, size_t size, - const count_handler& handler) NOEXCEPT -{ - BC_ASSERT(stranded()); - - if (error::asio_is_canceled(ec)) - { - handler(error::channel_stopped, size); - return; - } - - const auto code = error::http_to_error_code(ec); - if (code == error::unknown) logx("http", ec); - handler(code, size); -} - // ws (generic) // ---------------------------------------------------------------------------- @@ -803,6 +764,48 @@ void socket::handle_ws_event(ws::frame_type kind, } } +// http (generic) +// ---------------------------------------------------------------------------- + +void socket::handle_http_read(const boost_code& ec, size_t size, + const std::reference_wrapper& request, + const count_handler& handler) NOEXCEPT +{ + BC_ASSERT(stranded()); + + if (error::asio_is_canceled(ec)) + { + handler(error::channel_stopped, size); + return; + } + + if (!ec && beast::websocket::is_upgrade(request.get())) + { + handler(set_websocket(request.get()), size); + return; + } + + const auto code = error::http_to_error_code(ec); + if (code == error::unknown) logx("http", ec); + handler(code, size); +} + +void socket::handle_http_write(const boost_code& ec, size_t size, + const count_handler& handler) NOEXCEPT +{ + BC_ASSERT(stranded()); + + if (error::asio_is_canceled(ec)) + { + handler(error::channel_stopped, size); + return; + } + + const auto code = error::http_to_error_code(ec); + if (code == error::unknown) logx("http", ec); + handler(code, size); +} + // Properties. // ---------------------------------------------------------------------------- From a0cab205cd87b6543bde59fd71f263f45e75d919 Mon Sep 17 00:00:00 2001 From: evoskuil Date: Sat, 27 Dec 2025 19:40:41 -0500 Subject: [PATCH 3/7] Add ws_to_error_code(). --- include/bitcoin/network/error.hpp | 39 +++++++- src/error.cpp | 160 +++++++++++++++++++++++++----- test/error.cpp | 12 +++ 3 files changed, 183 insertions(+), 28 deletions(-) diff --git a/include/bitcoin/network/error.hpp b/include/bitcoin/network/error.hpp index a0c1e0e6d..3f34be32c 100644 --- a/include/bitcoin/network/error.hpp +++ b/include/bitcoin/network/error.hpp @@ -168,7 +168,7 @@ enum error_t : uint8_t ////not_extended, ////network_authentication_required, - // boost beast error + // boost beast http error end_of_stream, partial_message, need_more, @@ -196,7 +196,41 @@ enum error_t : uint8_t stale_parser, short_read, + // boost beast websocket error + websocket_closed, + websocket_buffer_overflow, + partial_deflate_block, + message_too_big, + bad_http_version, + websocket_bad_method, + no_host, + no_connection, + no_connection_upgrade, + no_upgrade, + no_upgrade_websocket, + no_sec_key, + bad_sec_key, + no_sec_version, + bad_sec_version, + no_sec_accept, + bad_sec_accept, + upgrade_declined, + bad_opcode, + bad_data_frame, + bad_continuation, + bad_reserved_bits, + bad_control_fragment, + bad_control_size, + bad_unmasked_frame, + bad_masked_frame, + bad_size, + bad_frame_payload, + bad_close_code, + bad_close_size, + bad_close_payload, + // rpc error + message_overflow, undefined_type, unexpected_method, unexpected_type, @@ -240,6 +274,9 @@ BCT_API code asio_to_error_code(const boost_code& ec) NOEXCEPT; /// 1:1 mapping of boost::beast:http::error to network (or error::unknown). BCT_API code http_to_error_code(const boost_code& ec) NOEXCEPT; +/// 1:1 mapping of boost::beast:websocket::error to network (or error::unknown). +BCT_API code ws_to_error_code(const boost_code& ec) NOEXCEPT; + } // namespace error } // namespace network } // namespace libbitcoin diff --git a/src/error.cpp b/src/error.cpp index 01d670a23..69d863bd0 100644 --- a/src/error.cpp +++ b/src/error.cpp @@ -171,6 +171,39 @@ DEFINE_ERROR_T_MESSAGE_MAP(error) { stale_parser, "stale parser" }, { short_read, "short read" }, + // boost beast websocket error + { websocket_closed, "websocket closed" }, + { websocket_buffer_overflow, "websocket buffer overflow" }, + { partial_deflate_block, "partial deflate block" }, + { message_too_big, "message too big" }, + { bad_http_version, "bad http version" }, + { bad_method, "bad method" }, + { no_host, "no host" }, + { no_connection, "no connection" }, + { no_connection_upgrade, "no connection upgrade" }, + { no_upgrade, "no upgrade" }, + { no_upgrade_websocket, "no upgrade websocket" }, + { no_sec_key, "no sec key" }, + { bad_sec_key, "bad sec key" }, + { no_sec_version, "no sec version" }, + { bad_sec_version, "bad sec version" }, + { no_sec_accept, "no sec accept" }, + { bad_sec_accept, "bad sec accept" }, + { upgrade_declined, "upgrade declined" }, + { bad_opcode, "bad opcode" }, + { bad_data_frame, "bad data frame" }, + { bad_continuation, "bad continuation" }, + { bad_reserved_bits, "bad reserved bits" }, + { bad_control_fragment, "bad control fragment" }, + { bad_control_size, "bad control size" }, + { bad_unmasked_frame, "bad unmasked frame" }, + { bad_masked_frame, "bad masked frame" }, + { bad_size, "bad size" }, + { bad_frame_payload, "bad frame payload" }, + { bad_close_code, "bad close code" }, + { bad_close_size, "bad close size" }, + { bad_close_payload, "bad close payload" }, + // rpc error { undefined_type, "undefined type" }, { unexpected_method, "unexpected method" }, @@ -318,67 +351,140 @@ code asio_to_error_code(const boost_code& ec) NOEXCEPT code http_to_error_code(const boost_code& ec) NOEXCEPT { - namespace beast = boost::beast::http; + namespace http = boost::beast::http; if (!ec) return {}; - if (ec == beast::error::end_of_stream) + if (ec == http::error::end_of_stream) return error::end_of_stream; - if (ec == beast::error::partial_message) + if (ec == http::error::partial_message) return error::partial_message; - if (ec == beast::error::need_more) + if (ec == http::error::need_more) return error::need_more; - if (ec == beast::error::unexpected_body) + if (ec == http::error::unexpected_body) return error::unexpected_body; - if (ec == beast::error::need_buffer) + if (ec == http::error::need_buffer) return error::need_buffer; - if (ec == beast::error::end_of_chunk) + if (ec == http::error::end_of_chunk) return error::end_of_chunk; - if (ec == beast::error::buffer_overflow) + if (ec == http::error::buffer_overflow) return error::buffer_overflow; - if (ec == beast::error::header_limit) + if (ec == http::error::header_limit) return error::header_limit; - if (ec == beast::error::body_limit) + if (ec == http::error::body_limit) return error::body_limit; - if (ec == beast::error::bad_alloc) + if (ec == http::error::bad_alloc) return error::bad_alloc; - if (ec == beast::error::bad_line_ending) + if (ec == http::error::bad_line_ending) return error::bad_line_ending; - if (ec == beast::error::bad_method) + if (ec == http::error::bad_method) return error::bad_method; - if (ec == beast::error::bad_target) + if (ec == http::error::bad_target) return error::bad_target; - if (ec == beast::error::bad_version) + if (ec == http::error::bad_version) return error::bad_version; - if (ec == beast::error::bad_status) + if (ec == http::error::bad_status) return error::bad_status; - if (ec == beast::error::bad_reason) + if (ec == http::error::bad_reason) return error::bad_reason; - if (ec == beast::error::bad_field) + if (ec == http::error::bad_field) return error::bad_field; - if (ec == beast::error::bad_value) + if (ec == http::error::bad_value) return error::bad_value; - if (ec == beast::error::bad_content_length) + if (ec == http::error::bad_content_length) return error::bad_content_length; - if (ec == beast::error::bad_transfer_encoding) + if (ec == http::error::bad_transfer_encoding) return error::bad_transfer_encoding; - if (ec == beast::error::bad_chunk) + if (ec == http::error::bad_chunk) return error::bad_chunk; - if (ec == beast::error::bad_chunk_extension) + if (ec == http::error::bad_chunk_extension) return error::bad_chunk_extension; - if (ec == beast::error::bad_obs_fold) + if (ec == http::error::bad_obs_fold) return error::bad_obs_fold; - if (ec == beast::error::multiple_content_length) + if (ec == http::error::multiple_content_length) return error::multiple_content_length; - if (ec == beast::error::stale_parser) + if (ec == http::error::stale_parser) return error::stale_parser; - if (ec == beast::error::short_read) + if (ec == http::error::short_read) return error::short_read; return asio_to_error_code(ec); } +code ws_to_error_code(const boost_code& ec) NOEXCEPT +{ + namespace ws = boost::beast::websocket; + + if (!ec) + return {}; + + if (ec == ws::error::closed) + return error::websocket_closed; + if (ec == ws::error::buffer_overflow) + return error::websocket_buffer_overflow; + if (ec == ws::error::partial_deflate_block) + return error::partial_deflate_block; + if (ec == ws::error::message_too_big) + return error::message_too_big; + if (ec == ws::error::bad_http_version) + return error::bad_http_version; + if (ec == ws::error::bad_method) + return error::websocket_bad_method; + if (ec == ws::error::no_host) + return error::no_host; + if (ec == ws::error::no_connection) + return error::no_connection; + if (ec == ws::error::no_connection_upgrade) + return error::no_connection_upgrade; + if (ec == ws::error::no_upgrade) + return error::no_upgrade; + if (ec == ws::error::no_upgrade_websocket) + return error::no_upgrade_websocket; + if (ec == ws::error::no_sec_key) + return error::no_sec_key; + if (ec == ws::error::bad_sec_key) + return error::bad_sec_key; + if (ec == ws::error::no_sec_version) + return error::no_sec_version; + if (ec == ws::error::bad_sec_version) + return error::bad_sec_version; + if (ec == ws::error::no_sec_accept) + return error::no_sec_accept; + if (ec == ws::error::bad_sec_accept) + return error::bad_sec_accept; + if (ec == ws::error::upgrade_declined) + return error::upgrade_declined; + if (ec == ws::error::bad_opcode) + return error::bad_opcode; + if (ec == ws::error::bad_data_frame) + return error::bad_data_frame; + if (ec == ws::error::bad_continuation) + return error::bad_continuation; + if (ec == ws::error::bad_reserved_bits) + return error::bad_reserved_bits; + if (ec == ws::error::bad_control_fragment) + return error::bad_control_fragment; + if (ec == ws::error::bad_control_size) + return error::bad_control_size; + if (ec == ws::error::bad_unmasked_frame) + return error::bad_unmasked_frame; + if (ec == ws::error::bad_masked_frame) + return error::bad_masked_frame; + if (ec == ws::error::bad_size) + return error::bad_size; + if (ec == ws::error::bad_frame_payload) + return error::bad_frame_payload; + if (ec == ws::error::bad_close_code) + return error::bad_close_code; + if (ec == ws::error::bad_close_size) + return error::bad_close_size; + if (ec == ws::error::bad_close_payload) + return error::bad_close_payload; + + return http_to_error_code(ec); +} + } // namespace error } // namespace network } // namespace libbitcoin diff --git a/test/error.cpp b/test/error.cpp index 6dd8065fe..4c404c271 100644 --- a/test/error.cpp +++ b/test/error.cpp @@ -1100,8 +1100,19 @@ BOOST_AUTO_TEST_CASE(error_t__code__short_read__true_exected_message) BOOST_REQUIRE_EQUAL(ec.message(), "short read"); } +// TODO: boost beast websocket error + // rpc error +BOOST_AUTO_TEST_CASE(error_t__code__message_overflow__true_exected_message) +{ + constexpr auto value = error::message_overflow; + const auto ec = code(value); + BOOST_REQUIRE(ec); + BOOST_REQUIRE(ec == value); + BOOST_REQUIRE_EQUAL(ec.message(), "message overflow"); +} + BOOST_AUTO_TEST_CASE(error_t__code__undefined_type__true_exected_message) { constexpr auto value = error::undefined_type; @@ -1110,6 +1121,7 @@ BOOST_AUTO_TEST_CASE(error_t__code__undefined_type__true_exected_message) BOOST_REQUIRE(ec == value); BOOST_REQUIRE_EQUAL(ec.message(), "undefined type"); } + BOOST_AUTO_TEST_CASE(error_t__code__unexpected_method__true_exected_message) { constexpr auto value = error::unexpected_method; From 71cf674857afc58c82aabfab3a967ee0562f9fa2 Mon Sep 17 00:00:00 2001 From: evoskuil Date: Sat, 27 Dec 2025 19:44:26 -0500 Subject: [PATCH 4/7] Use ws_to_error_code(). --- src/net/socket.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/net/socket.cpp b/src/net/socket.cpp index 3f98e2cdf..f6b15ae22 100644 --- a/src/net/socket.cpp +++ b/src/net/socket.cpp @@ -721,7 +721,7 @@ void socket::handle_ws_read(const boost_code& ec, size_t size, return; } - const auto code = error::http_to_error_code(ec); + const auto code = error::ws_to_error_code(ec); if (code == error::unknown) logx("ws-read", ec); handler(code, size /*, websocket_->got_binary() */); } @@ -738,7 +738,7 @@ void socket::handle_ws_write(const boost_code& ec, size_t size, return; } - const auto code = error::http_to_error_code(ec); + const auto code = error::ws_to_error_code(ec); if (code == error::unknown) logx("ws-write", ec); handler(code, size /*, websocket_->got_binary() */); } From 1bfaefef71549baf74ea0c151d5a38952c04e053 Mon Sep 17 00:00:00 2001 From: evoskuil Date: Sat, 27 Dec 2025 19:44:56 -0500 Subject: [PATCH 5/7] Impose client-server client request size limits (DoS). --- include/bitcoin/network/net/socket.hpp | 5 +++- src/net/socket.cpp | 41 ++++++++++++++++++++++---- 2 files changed, 40 insertions(+), 6 deletions(-) diff --git a/include/bitcoin/network/net/socket.hpp b/include/bitcoin/network/net/socket.hpp index 4cdac6643..35b2f7a97 100644 --- a/include/bitcoin/network/net/socket.hpp +++ b/include/bitcoin/network/net/socket.hpp @@ -166,6 +166,9 @@ class BCT_API socket void logx(const std::string& context, const boost_code& ec) const NOEXCEPT; private: + using http_parser = boost::beast::http::request_parser; + using http_parser_ptr = std::shared_ptr; + struct read_rpc { typedef std::shared_ptr ptr; @@ -275,7 +278,7 @@ class BCT_API socket // http (generic) void handle_http_read(const boost_code& ec, size_t size, const std::reference_wrapper& request, - const count_handler& handler) NOEXCEPT; + const http_parser_ptr& parser, const count_handler& handler) NOEXCEPT; void handle_http_write(const boost_code& ec, size_t size, const count_handler& handler) NOEXCEPT; diff --git a/src/net/socket.cpp b/src/net/socket.cpp index f6b15ae22..baa8623b1 100644 --- a/src/net/socket.cpp +++ b/src/net/socket.cpp @@ -34,6 +34,12 @@ using namespace network::rpc; using namespace std::placeholders; namespace beast = boost::beast; +// TODO: move to config. +constexpr size_t client_request_limit = 5u * 1024u * 1024u; + +// Shared pointers required in handler parameters so closures control lifetime. +BC_PUSH_WARNING(NO_VALUE_OR_CONST_REF_SHARED_PTR) +BC_PUSH_WARNING(SMART_PTR_NOT_NEEDED) BC_PUSH_WARNING(NO_THROW_IN_NOEXCEPT) // Boost: "The execution context provides the I/O executor that the socket will @@ -541,10 +547,19 @@ void socket::do_http_read(std::reference_wrapper buffer, try { + // Explicit parser orverride gives access to limits. + auto parser = to_shared(); + + // Causes http::error::body_limit on completion. + parser->body_limit(client_request_limit); + + // Causes http::error::header_limit on completion. + parser->header_limit(client_request_limit); + // This operation posts handler to the strand. - beast::http::async_read(socket_, buffer.get(), request.get(), + beast::http::async_read(socket_, buffer.get(), *parser, std::bind(&socket::handle_http_read, - shared_from_this(), _1, _2, request, handler)); + shared_from_this(), _1, _2, request, parser, handler)); } catch (const std::exception& LOG_ONLY(e)) { @@ -660,6 +675,12 @@ void socket::handle_rpc_read(boost_code ec, size_t size, size_t total, return; } + if (total > client_request_limit) + { + handler(error::message_overflow, total); + return; + } + if (!ec) { in->value.buffer->commit(size); @@ -769,7 +790,7 @@ void socket::handle_ws_event(ws::frame_type kind, void socket::handle_http_read(const boost_code& ec, size_t size, const std::reference_wrapper& request, - const count_handler& handler) NOEXCEPT + const http_parser_ptr& parser, const count_handler& handler) NOEXCEPT { BC_ASSERT(stranded()); @@ -779,12 +800,17 @@ void socket::handle_http_read(const boost_code& ec, size_t size, return; } - if (!ec && beast::websocket::is_upgrade(request.get())) + if (!ec && beast::websocket::is_upgrade(parser->get())) { - handler(set_websocket(request.get()), size); + handler(set_websocket(parser->get()), size); return; } + if (!ec) + { + request.get() = parser->release(); + } + const auto code = error::http_to_error_code(ec); if (code == error::unknown) logx("http", ec); handler(code, size); @@ -866,6 +892,9 @@ code socket::set_websocket(const http::request& request) NOEXCEPT try { websocket_.emplace(std::move(socket_)); + + // Causes websocket::error::message_too_big on completion. + websocket_->read_message_max(client_request_limit); websocket_->set_option(ws::decorator { [](http::fields& header) NOEXCEPT @@ -907,6 +936,8 @@ void socket::logx(const std::string& context, << ec.category().name() << ":" << ec.message()); } +BC_POP_WARNING() +BC_POP_WARNING() BC_POP_WARNING() } // namespace network From 5ff6b1f47cdf4fccfe6b267ea578dea202ce87fd Mon Sep 17 00:00:00 2001 From: evoskuil Date: Sun, 28 Dec 2025 13:24:48 -0500 Subject: [PATCH 6/7] Add missing error::message_overflow error mapping. --- src/error.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/error.cpp b/src/error.cpp index 69d863bd0..285d1cf1d 100644 --- a/src/error.cpp +++ b/src/error.cpp @@ -205,6 +205,7 @@ DEFINE_ERROR_T_MESSAGE_MAP(error) { bad_close_payload, "bad close payload" }, // rpc error + { message_overflow, "message overflow" }, { undefined_type, "undefined type" }, { unexpected_method, "unexpected method" }, { unexpected_type, "unexpected type" }, From f92d51e7ad11b5007fd3d8186fca4575d2443d5f Mon Sep 17 00:00:00 2001 From: evoskuil Date: Sun, 28 Dec 2025 13:30:15 -0500 Subject: [PATCH 7/7] Add websocket error tests, fix test name typo. --- src/error.cpp | 2 +- test/error.cpp | 533 +++++++++++++++++++++++++++++++++++++------------ 2 files changed, 407 insertions(+), 128 deletions(-) diff --git a/src/error.cpp b/src/error.cpp index 285d1cf1d..10e7c5110 100644 --- a/src/error.cpp +++ b/src/error.cpp @@ -177,7 +177,7 @@ DEFINE_ERROR_T_MESSAGE_MAP(error) { partial_deflate_block, "partial deflate block" }, { message_too_big, "message too big" }, { bad_http_version, "bad http version" }, - { bad_method, "bad method" }, + { websocket_bad_method, "websocket bad method" }, { no_host, "no host" }, { no_connection, "no connection" }, { no_connection_upgrade, "no connection upgrade" }, diff --git a/test/error.cpp b/test/error.cpp index 4c404c271..f3757f2cf 100644 --- a/test/error.cpp +++ b/test/error.cpp @@ -23,7 +23,7 @@ BOOST_AUTO_TEST_SUITE(error_tests) // error_t // These test std::error_code equality operator overrides. -BOOST_AUTO_TEST_CASE(error_t__code__success__false_exected_message) +BOOST_AUTO_TEST_CASE(error_t__code__success__false_expected_message) { constexpr auto value = error::success; const auto ec = code(value); @@ -32,7 +32,7 @@ BOOST_AUTO_TEST_CASE(error_t__code__success__false_exected_message) BOOST_REQUIRE_EQUAL(ec.message(), "success"); } -BOOST_AUTO_TEST_CASE(error_t__code__unknown__true_exected_message) +BOOST_AUTO_TEST_CASE(error_t__code__unknown__true_expected_message) { constexpr auto value = error::unknown; const auto ec = code(value); @@ -41,7 +41,7 @@ BOOST_AUTO_TEST_CASE(error_t__code__unknown__true_exected_message) BOOST_REQUIRE_EQUAL(ec.message(), "unknown error"); } -BOOST_AUTO_TEST_CASE(error_t__code__upgraded__true_exected_message) +BOOST_AUTO_TEST_CASE(error_t__code__upgraded__true_expected_message) { constexpr auto value = error::upgraded; const auto ec = code(value); @@ -52,7 +52,7 @@ BOOST_AUTO_TEST_CASE(error_t__code__upgraded__true_exected_message) // addresses -BOOST_AUTO_TEST_CASE(error_t__code__address_invalid__true_exected_message) +BOOST_AUTO_TEST_CASE(error_t__code__address_invalid__true_expected_message) { constexpr auto value = error::address_invalid; const auto ec = code(value); @@ -61,7 +61,7 @@ BOOST_AUTO_TEST_CASE(error_t__code__address_invalid__true_exected_message) BOOST_REQUIRE_EQUAL(ec.message(), "address invalid"); } -BOOST_AUTO_TEST_CASE(error_t__code__address_not_found__true_exected_message) +BOOST_AUTO_TEST_CASE(error_t__code__address_not_found__true_expected_message) { constexpr auto value = error::address_not_found; const auto ec = code(value); @@ -70,7 +70,7 @@ BOOST_AUTO_TEST_CASE(error_t__code__address_not_found__true_exected_message) BOOST_REQUIRE_EQUAL(ec.message(), "address not found"); } -BOOST_AUTO_TEST_CASE(error_t__code__address_disabled__true_exected_message) +BOOST_AUTO_TEST_CASE(error_t__code__address_disabled__true_expected_message) { constexpr auto value = error::address_disabled; const auto ec = code(value); @@ -79,7 +79,7 @@ BOOST_AUTO_TEST_CASE(error_t__code__address_disabled__true_exected_message) BOOST_REQUIRE_EQUAL(ec.message(), "address protocol disabled"); } -BOOST_AUTO_TEST_CASE(error_t__code__address_unsupported__true_exected_message) +BOOST_AUTO_TEST_CASE(error_t__code__address_unsupported__true_expected_message) { constexpr auto value = error::address_unsupported; const auto ec = code(value); @@ -88,7 +88,7 @@ BOOST_AUTO_TEST_CASE(error_t__code__address_unsupported__true_exected_message) BOOST_REQUIRE_EQUAL(ec.message(), "advertised services unsupported"); } -BOOST_AUTO_TEST_CASE(error_t__code__address_insufficient__true_exected_message) +BOOST_AUTO_TEST_CASE(error_t__code__address_insufficient__true_expected_message) { constexpr auto value = error::address_insufficient; const auto ec = code(value); @@ -97,7 +97,7 @@ BOOST_AUTO_TEST_CASE(error_t__code__address_insufficient__true_exected_message) BOOST_REQUIRE_EQUAL(ec.message(), "advertised services insufficient"); } -BOOST_AUTO_TEST_CASE(error_t__code__seeding_unsuccessful__true_exected_message) +BOOST_AUTO_TEST_CASE(error_t__code__seeding_unsuccessful__true_expected_message) { constexpr auto value = error::seeding_unsuccessful; const auto ec = code(value); @@ -106,7 +106,7 @@ BOOST_AUTO_TEST_CASE(error_t__code__seeding_unsuccessful__true_exected_message) BOOST_REQUIRE_EQUAL(ec.message(), "seeding unsuccessful"); } -BOOST_AUTO_TEST_CASE(error_t__code__seeding_complete__true_exected_message) +BOOST_AUTO_TEST_CASE(error_t__code__seeding_complete__true_expected_message) { constexpr auto value = error::seeding_complete; const auto ec = code(value); @@ -117,7 +117,7 @@ BOOST_AUTO_TEST_CASE(error_t__code__seeding_complete__true_exected_message) // file system -BOOST_AUTO_TEST_CASE(error_t__code__file_load__true_exected_message) +BOOST_AUTO_TEST_CASE(error_t__code__file_load__true_expected_message) { constexpr auto value = error::file_load; const auto ec = code(value); @@ -126,7 +126,7 @@ BOOST_AUTO_TEST_CASE(error_t__code__file_load__true_exected_message) BOOST_REQUIRE_EQUAL(ec.message(), "failed to load file"); } -BOOST_AUTO_TEST_CASE(error_t__code__file_save__true_exected_message) +BOOST_AUTO_TEST_CASE(error_t__code__file_save__true_expected_message) { constexpr auto value = error::file_save; const auto ec = code(value); @@ -135,7 +135,7 @@ BOOST_AUTO_TEST_CASE(error_t__code__file_save__true_exected_message) BOOST_REQUIRE_EQUAL(ec.message(), "failed to save file"); } -BOOST_AUTO_TEST_CASE(error_t__code__file_system__true_exected_message) +BOOST_AUTO_TEST_CASE(error_t__code__file_system__true_expected_message) { constexpr auto value = error::file_system; const auto ec = code(value); @@ -144,7 +144,7 @@ BOOST_AUTO_TEST_CASE(error_t__code__file_system__true_exected_message) BOOST_REQUIRE_EQUAL(ec.message(), "file system error"); } -BOOST_AUTO_TEST_CASE(error_t__code__file_exception__true_exected_message) +BOOST_AUTO_TEST_CASE(error_t__code__file_exception__true_expected_message) { constexpr auto value = error::file_exception; const auto ec = code(value); @@ -155,7 +155,7 @@ BOOST_AUTO_TEST_CASE(error_t__code__file_exception__true_exected_message) // general I/O failures -BOOST_AUTO_TEST_CASE(error_t__code__bad_stream__true_exected_message) +BOOST_AUTO_TEST_CASE(error_t__code__bad_stream__true_expected_message) { constexpr auto value = error::bad_stream; const auto ec = code(value); @@ -164,7 +164,7 @@ BOOST_AUTO_TEST_CASE(error_t__code__bad_stream__true_exected_message) BOOST_REQUIRE_EQUAL(ec.message(), "bad data stream"); } -BOOST_AUTO_TEST_CASE(error_t__code__not_allowed__true_exected_message) +BOOST_AUTO_TEST_CASE(error_t__code__not_allowed__true_expected_message) { constexpr auto value = error::not_allowed; const auto ec = code(value); @@ -173,7 +173,7 @@ BOOST_AUTO_TEST_CASE(error_t__code__not_allowed__true_exected_message) BOOST_REQUIRE_EQUAL(ec.message(), "not allowed"); } -BOOST_AUTO_TEST_CASE(error_t__code__peer_disconnect__true_exected_message) +BOOST_AUTO_TEST_CASE(error_t__code__peer_disconnect__true_expected_message) { constexpr auto value = error::peer_disconnect; const auto ec = code(value); @@ -182,7 +182,7 @@ BOOST_AUTO_TEST_CASE(error_t__code__peer_disconnect__true_exected_message) BOOST_REQUIRE_EQUAL(ec.message(), "peer disconnect"); } -BOOST_AUTO_TEST_CASE(error_t__code__peer_unsupported__true_exected_message) +BOOST_AUTO_TEST_CASE(error_t__code__peer_unsupported__true_expected_message) { constexpr auto value = error::peer_unsupported; const auto ec = code(value); @@ -191,7 +191,7 @@ BOOST_AUTO_TEST_CASE(error_t__code__peer_unsupported__true_exected_message) BOOST_REQUIRE_EQUAL(ec.message(), "peer unsupported"); } -BOOST_AUTO_TEST_CASE(error_t__code__peer_insufficient__true_exected_message) +BOOST_AUTO_TEST_CASE(error_t__code__peer_insufficient__true_expected_message) { constexpr auto value = error::peer_insufficient; const auto ec = code(value); @@ -200,7 +200,7 @@ BOOST_AUTO_TEST_CASE(error_t__code__peer_insufficient__true_exected_message) BOOST_REQUIRE_EQUAL(ec.message(), "peer insufficient"); } -BOOST_AUTO_TEST_CASE(error_t__code__peer_timestamp__true_exected_message) +BOOST_AUTO_TEST_CASE(error_t__code__peer_timestamp__true_expected_message) { constexpr auto value = error::peer_timestamp; const auto ec = code(value); @@ -209,7 +209,7 @@ BOOST_AUTO_TEST_CASE(error_t__code__peer_timestamp__true_exected_message) BOOST_REQUIRE_EQUAL(ec.message(), "peer timestamp"); } -BOOST_AUTO_TEST_CASE(error_t__code__protocol_violation__true_exected_message) +BOOST_AUTO_TEST_CASE(error_t__code__protocol_violation__true_expected_message) { constexpr auto value = error::protocol_violation; const auto ec = code(value); @@ -218,7 +218,7 @@ BOOST_AUTO_TEST_CASE(error_t__code__protocol_violation__true_exected_message) BOOST_REQUIRE_EQUAL(ec.message(), "protocol violation"); } -BOOST_AUTO_TEST_CASE(error_t__code__channel_overflow__true_exected_message) +BOOST_AUTO_TEST_CASE(error_t__code__channel_overflow__true_expected_message) { constexpr auto value = error::channel_overflow; const auto ec = code(value); @@ -227,7 +227,7 @@ BOOST_AUTO_TEST_CASE(error_t__code__channel_overflow__true_exected_message) BOOST_REQUIRE_EQUAL(ec.message(), "channel overflow"); } -BOOST_AUTO_TEST_CASE(error_t__code__channel_underflow__true_exected_message) +BOOST_AUTO_TEST_CASE(error_t__code__channel_underflow__true_expected_message) { constexpr auto value = error::channel_underflow; const auto ec = code(value); @@ -238,7 +238,7 @@ BOOST_AUTO_TEST_CASE(error_t__code__channel_underflow__true_exected_message) // incoming connection failures -BOOST_AUTO_TEST_CASE(error_t__code__listen_failed__true_exected_message) +BOOST_AUTO_TEST_CASE(error_t__code__listen_failed__true_expected_message) { constexpr auto value = error::listen_failed; const auto ec = code(value); @@ -247,7 +247,7 @@ BOOST_AUTO_TEST_CASE(error_t__code__listen_failed__true_exected_message) BOOST_REQUIRE_EQUAL(ec.message(), "incoming connection failed"); } -BOOST_AUTO_TEST_CASE(error_t__code__accept_failed__true_exected_message) +BOOST_AUTO_TEST_CASE(error_t__code__accept_failed__true_expected_message) { constexpr auto value = error::accept_failed; const auto ec = code(value); @@ -256,7 +256,7 @@ BOOST_AUTO_TEST_CASE(error_t__code__accept_failed__true_exected_message) BOOST_REQUIRE_EQUAL(ec.message(), "connection to self aborted"); } -BOOST_AUTO_TEST_CASE(error_t__code__oversubscribed__true_exected_message) +BOOST_AUTO_TEST_CASE(error_t__code__oversubscribed__true_expected_message) { constexpr auto value = error::oversubscribed; const auto ec = code(value); @@ -267,7 +267,7 @@ BOOST_AUTO_TEST_CASE(error_t__code__oversubscribed__true_exected_message) // outgoing connection failures -BOOST_AUTO_TEST_CASE(error_t__code__address_blocked__true_exected_message) +BOOST_AUTO_TEST_CASE(error_t__code__address_blocked__true_expected_message) { constexpr auto value = error::address_blocked; const auto ec = code(value); @@ -276,7 +276,7 @@ BOOST_AUTO_TEST_CASE(error_t__code__address_blocked__true_exected_message) BOOST_REQUIRE_EQUAL(ec.message(), "address blocked by policy"); } -BOOST_AUTO_TEST_CASE(error_t__code__address_in_use__true_exected_message) +BOOST_AUTO_TEST_CASE(error_t__code__address_in_use__true_expected_message) { constexpr auto value = error::address_in_use; const auto ec = code(value); @@ -285,7 +285,7 @@ BOOST_AUTO_TEST_CASE(error_t__code__address_in_use__true_exected_message) BOOST_REQUIRE_EQUAL(ec.message(), "address already in use"); } -BOOST_AUTO_TEST_CASE(error_t__code__resolve_failed__true_exected_message) +BOOST_AUTO_TEST_CASE(error_t__code__resolve_failed__true_expected_message) { constexpr auto value = error::resolve_failed; const auto ec = code(value); @@ -294,7 +294,7 @@ BOOST_AUTO_TEST_CASE(error_t__code__resolve_failed__true_exected_message) BOOST_REQUIRE_EQUAL(ec.message(), "resolving hostname failed"); } -BOOST_AUTO_TEST_CASE(error_t__code__connect_failed__true_exected_message) +BOOST_AUTO_TEST_CASE(error_t__code__connect_failed__true_expected_message) { constexpr auto value = error::connect_failed; const auto ec = code(value); @@ -305,7 +305,7 @@ BOOST_AUTO_TEST_CASE(error_t__code__connect_failed__true_exected_message) // heading read failures -BOOST_AUTO_TEST_CASE(error_t__code__invalid_heading__true_exected_message) +BOOST_AUTO_TEST_CASE(error_t__code__invalid_heading__true_expected_message) { constexpr auto value = error::invalid_heading; const auto ec = code(value); @@ -314,7 +314,7 @@ BOOST_AUTO_TEST_CASE(error_t__code__invalid_heading__true_exected_message) BOOST_REQUIRE_EQUAL(ec.message(), "invalid message heading"); } -BOOST_AUTO_TEST_CASE(error_t__code__invalid_magic__true_exected_message) +BOOST_AUTO_TEST_CASE(error_t__code__invalid_magic__true_expected_message) { constexpr auto value = error::invalid_magic; const auto ec = code(value); @@ -325,7 +325,7 @@ BOOST_AUTO_TEST_CASE(error_t__code__invalid_magic__true_exected_message) // payload read failures -BOOST_AUTO_TEST_CASE(error_t__code__oversized_payload__true_exected_message) +BOOST_AUTO_TEST_CASE(error_t__code__oversized_payload__true_expected_message) { constexpr auto value = error::oversized_payload; const auto ec = code(value); @@ -334,7 +334,7 @@ BOOST_AUTO_TEST_CASE(error_t__code__oversized_payload__true_exected_message) BOOST_REQUIRE_EQUAL(ec.message(), "oversize message payload"); } -BOOST_AUTO_TEST_CASE(error_t__code__invalid_checksum__true_exected_message) +BOOST_AUTO_TEST_CASE(error_t__code__invalid_checksum__true_expected_message) { constexpr auto value = error::invalid_checksum; const auto ec = code(value); @@ -343,7 +343,7 @@ BOOST_AUTO_TEST_CASE(error_t__code__invalid_checksum__true_exected_message) BOOST_REQUIRE_EQUAL(ec.message(), "invalid message checksum"); } -BOOST_AUTO_TEST_CASE(error_t__code__invalid_message__true_exected_message) +BOOST_AUTO_TEST_CASE(error_t__code__invalid_message__true_expected_message) { constexpr auto value = error::invalid_message; const auto ec = code(value); @@ -352,7 +352,7 @@ BOOST_AUTO_TEST_CASE(error_t__code__invalid_message__true_exected_message) BOOST_REQUIRE_EQUAL(ec.message(), "message failed to deserialize"); } -BOOST_AUTO_TEST_CASE(error_t__code__unknown_message__true_exected_message) +BOOST_AUTO_TEST_CASE(error_t__code__unknown_message__true_expected_message) { constexpr auto value = error::unknown_message; const auto ec = code(value); @@ -363,7 +363,7 @@ BOOST_AUTO_TEST_CASE(error_t__code__unknown_message__true_exected_message) // general failures -BOOST_AUTO_TEST_CASE(error_t__code__invalid_configuration__true_exected_message) +BOOST_AUTO_TEST_CASE(error_t__code__invalid_configuration__true_expected_message) { constexpr auto value = error::invalid_configuration; const auto ec = code(value); @@ -372,7 +372,7 @@ BOOST_AUTO_TEST_CASE(error_t__code__invalid_configuration__true_exected_message) BOOST_REQUIRE_EQUAL(ec.message(), "invalid configuration"); } -BOOST_AUTO_TEST_CASE(error_t__code__operation_timeout__true_exected_message) +BOOST_AUTO_TEST_CASE(error_t__code__operation_timeout__true_expected_message) { constexpr auto value = error::operation_timeout; const auto ec = code(value); @@ -381,7 +381,7 @@ BOOST_AUTO_TEST_CASE(error_t__code__operation_timeout__true_exected_message) BOOST_REQUIRE_EQUAL(ec.message(), "operation timed out"); } -BOOST_AUTO_TEST_CASE(error_t__code__operation_canceled__true_exected_message) +BOOST_AUTO_TEST_CASE(error_t__code__operation_canceled__true_expected_message) { constexpr auto value = error::operation_canceled; const auto ec = code(value); @@ -390,7 +390,7 @@ BOOST_AUTO_TEST_CASE(error_t__code__operation_canceled__true_exected_message) BOOST_REQUIRE_EQUAL(ec.message(), "operation canceled"); } -BOOST_AUTO_TEST_CASE(error_t__code__operation_failed__true_exected_message) +BOOST_AUTO_TEST_CASE(error_t__code__operation_failed__true_expected_message) { constexpr auto value = error::operation_failed; const auto ec = code(value); @@ -401,7 +401,7 @@ BOOST_AUTO_TEST_CASE(error_t__code__operation_failed__true_exected_message) // termination -BOOST_AUTO_TEST_CASE(error_t__code__channel_timeout__true_exected_message) +BOOST_AUTO_TEST_CASE(error_t__code__channel_timeout__true_expected_message) { constexpr auto value = error::channel_timeout; const auto ec = code(value); @@ -410,7 +410,7 @@ BOOST_AUTO_TEST_CASE(error_t__code__channel_timeout__true_exected_message) BOOST_REQUIRE_EQUAL(ec.message(), "channel timed out"); } -BOOST_AUTO_TEST_CASE(error_t__code__channel_conflict__true_exected_message) +BOOST_AUTO_TEST_CASE(error_t__code__channel_conflict__true_expected_message) { constexpr auto value = error::channel_conflict; const auto ec = code(value); @@ -419,7 +419,7 @@ BOOST_AUTO_TEST_CASE(error_t__code__channel_conflict__true_exected_message) BOOST_REQUIRE_EQUAL(ec.message(), "channel conflict"); } -BOOST_AUTO_TEST_CASE(error_t__code__channel_dropped__true_exected_message) +BOOST_AUTO_TEST_CASE(error_t__code__channel_dropped__true_expected_message) { constexpr auto value = error::channel_dropped; const auto ec = code(value); @@ -428,7 +428,7 @@ BOOST_AUTO_TEST_CASE(error_t__code__channel_dropped__true_exected_message) BOOST_REQUIRE_EQUAL(ec.message(), "channel dropped"); } -BOOST_AUTO_TEST_CASE(error_t__code__channel_expired__true_exected_message) +BOOST_AUTO_TEST_CASE(error_t__code__channel_expired__true_expected_message) { constexpr auto value = error::channel_expired; const auto ec = code(value); @@ -437,7 +437,7 @@ BOOST_AUTO_TEST_CASE(error_t__code__channel_expired__true_exected_message) BOOST_REQUIRE_EQUAL(ec.message(), "channel expired"); } -BOOST_AUTO_TEST_CASE(error_t__code__channel_inactive__true_exected_message) +BOOST_AUTO_TEST_CASE(error_t__code__channel_inactive__true_expected_message) { constexpr auto value = error::channel_inactive; const auto ec = code(value); @@ -446,7 +446,7 @@ BOOST_AUTO_TEST_CASE(error_t__code__channel_inactive__true_exected_message) BOOST_REQUIRE_EQUAL(ec.message(), "channel inactive"); } -BOOST_AUTO_TEST_CASE(error_t__code__channel_stopped__true_exected_message) +BOOST_AUTO_TEST_CASE(error_t__code__channel_stopped__true_expected_message) { constexpr auto value = error::channel_stopped; const auto ec = code(value); @@ -455,7 +455,7 @@ BOOST_AUTO_TEST_CASE(error_t__code__channel_stopped__true_exected_message) BOOST_REQUIRE_EQUAL(ec.message(), "channel stopped"); } -BOOST_AUTO_TEST_CASE(error_t__code__service_stopped__true_exected_message) +BOOST_AUTO_TEST_CASE(error_t__code__service_stopped__true_expected_message) { constexpr auto value = error::service_stopped; const auto ec = code(value); @@ -464,7 +464,7 @@ BOOST_AUTO_TEST_CASE(error_t__code__service_stopped__true_exected_message) BOOST_REQUIRE_EQUAL(ec.message(), "service stopped"); } -BOOST_AUTO_TEST_CASE(error_t__code__service_suspended__true_exected_message) +BOOST_AUTO_TEST_CASE(error_t__code__service_suspended__true_expected_message) { constexpr auto value = error::service_suspended; const auto ec = code(value); @@ -473,7 +473,7 @@ BOOST_AUTO_TEST_CASE(error_t__code__service_suspended__true_exected_message) BOOST_REQUIRE_EQUAL(ec.message(), "service suspended"); } -BOOST_AUTO_TEST_CASE(error_t__code__subscriber_exists__true_exected_message) +BOOST_AUTO_TEST_CASE(error_t__code__subscriber_exists__true_expected_message) { constexpr auto value = error::subscriber_exists; const auto ec = code(value); @@ -482,7 +482,7 @@ BOOST_AUTO_TEST_CASE(error_t__code__subscriber_exists__true_exected_message) BOOST_REQUIRE_EQUAL(ec.message(), "subscriber exists"); } -BOOST_AUTO_TEST_CASE(error_t__code__subscriber_stopped__true_exected_message) +BOOST_AUTO_TEST_CASE(error_t__code__subscriber_stopped__true_expected_message) { constexpr auto value = error::subscriber_stopped; const auto ec = code(value); @@ -491,7 +491,7 @@ BOOST_AUTO_TEST_CASE(error_t__code__subscriber_stopped__true_exected_message) BOOST_REQUIRE_EQUAL(ec.message(), "subscriber stopped"); } -BOOST_AUTO_TEST_CASE(error_t__code__desubscribed__true_exected_message) +BOOST_AUTO_TEST_CASE(error_t__code__desubscribed__true_expected_message) { constexpr auto value = error::desubscribed; const auto ec = code(value); @@ -502,7 +502,7 @@ BOOST_AUTO_TEST_CASE(error_t__code__desubscribed__true_exected_message) // http 4xx client error -BOOST_AUTO_TEST_CASE(error_t__code__bad_request__true_exected_message) +BOOST_AUTO_TEST_CASE(error_t__code__bad_request__true_expected_message) { constexpr auto value = error::bad_request; const auto ec = code(value); @@ -511,7 +511,7 @@ BOOST_AUTO_TEST_CASE(error_t__code__bad_request__true_exected_message) BOOST_REQUIRE_EQUAL(ec.message(), "bad request"); } -////BOOST_AUTO_TEST_CASE(error_t__code__unauthorized__true_exected_message) +////BOOST_AUTO_TEST_CASE(error_t__code__unauthorized__true_expected_message) ////{ //// constexpr auto value = error::unauthorized; //// const auto ec = code(value); @@ -520,7 +520,7 @@ BOOST_AUTO_TEST_CASE(error_t__code__bad_request__true_exected_message) //// BOOST_REQUIRE_EQUAL(ec.message(), "unauthorized"); ////} //// -////BOOST_AUTO_TEST_CASE(error_t__code__payment_required__true_exected_message) +////BOOST_AUTO_TEST_CASE(error_t__code__payment_required__true_expected_message) ////{ //// constexpr auto value = error::payment_required; //// const auto ec = code(value); @@ -529,7 +529,7 @@ BOOST_AUTO_TEST_CASE(error_t__code__bad_request__true_exected_message) //// BOOST_REQUIRE_EQUAL(ec.message(), "payment required"); ////} -BOOST_AUTO_TEST_CASE(error_t__code__forbidden__true_exected_message) +BOOST_AUTO_TEST_CASE(error_t__code__forbidden__true_expected_message) { constexpr auto value = error::forbidden; const auto ec = code(value); @@ -538,7 +538,7 @@ BOOST_AUTO_TEST_CASE(error_t__code__forbidden__true_exected_message) BOOST_REQUIRE_EQUAL(ec.message(), "forbidden"); } -BOOST_AUTO_TEST_CASE(error_t__code__not_found__true_exected_message) +BOOST_AUTO_TEST_CASE(error_t__code__not_found__true_expected_message) { constexpr auto value = error::not_found; const auto ec = code(value); @@ -547,7 +547,7 @@ BOOST_AUTO_TEST_CASE(error_t__code__not_found__true_exected_message) BOOST_REQUIRE_EQUAL(ec.message(), "not found"); } -BOOST_AUTO_TEST_CASE(error_t__code__method_not_allowed__true_exected_message) +BOOST_AUTO_TEST_CASE(error_t__code__method_not_allowed__true_expected_message) { constexpr auto value = error::method_not_allowed; const auto ec = code(value); @@ -556,7 +556,7 @@ BOOST_AUTO_TEST_CASE(error_t__code__method_not_allowed__true_exected_message) BOOST_REQUIRE_EQUAL(ec.message(), "method not allowed"); } -////BOOST_AUTO_TEST_CASE(error_t__code__not_acceptable__true_exected_message) +////BOOST_AUTO_TEST_CASE(error_t__code__not_acceptable__true_expected_message) ////{ //// constexpr auto value = error::not_acceptable; //// const auto ec = code(value); @@ -565,7 +565,7 @@ BOOST_AUTO_TEST_CASE(error_t__code__method_not_allowed__true_exected_message) //// BOOST_REQUIRE_EQUAL(ec.message(), "not acceptable"); ////} //// -////BOOST_AUTO_TEST_CASE(error_t__code__proxy_authentication_required__true_exected_message) +////BOOST_AUTO_TEST_CASE(error_t__code__proxy_authentication_required__true_expected_message) ////{ //// constexpr auto value = error::proxy_authentication_required; //// const auto ec = code(value); @@ -574,7 +574,7 @@ BOOST_AUTO_TEST_CASE(error_t__code__method_not_allowed__true_exected_message) //// BOOST_REQUIRE_EQUAL(ec.message(), "proxy authentication required"); ////} //// -////BOOST_AUTO_TEST_CASE(error_t__code__request_timeout__true_exected_message) +////BOOST_AUTO_TEST_CASE(error_t__code__request_timeout__true_expected_message) ////{ //// constexpr auto value = error::request_timeout; //// const auto ec = code(value); @@ -583,7 +583,7 @@ BOOST_AUTO_TEST_CASE(error_t__code__method_not_allowed__true_exected_message) //// BOOST_REQUIRE_EQUAL(ec.message(), "request timeout"); ////} //// -////BOOST_AUTO_TEST_CASE(error_t__code__conflict__true_exected_message) +////BOOST_AUTO_TEST_CASE(error_t__code__conflict__true_expected_message) ////{ //// constexpr auto value = error::conflict; //// const auto ec = code(value); @@ -592,7 +592,7 @@ BOOST_AUTO_TEST_CASE(error_t__code__method_not_allowed__true_exected_message) //// BOOST_REQUIRE_EQUAL(ec.message(), "conflict"); ////} //// -////BOOST_AUTO_TEST_CASE(error_t__code__gone__true_exected_message) +////BOOST_AUTO_TEST_CASE(error_t__code__gone__true_expected_message) ////{ //// constexpr auto value = error::gone; //// const auto ec = code(value); @@ -601,7 +601,7 @@ BOOST_AUTO_TEST_CASE(error_t__code__method_not_allowed__true_exected_message) //// BOOST_REQUIRE_EQUAL(ec.message(), "gone"); ////} //// -////BOOST_AUTO_TEST_CASE(error_t__code__length_required__true_exected_message) +////BOOST_AUTO_TEST_CASE(error_t__code__length_required__true_expected_message) ////{ //// constexpr auto value = error::length_required; //// const auto ec = code(value); @@ -610,7 +610,7 @@ BOOST_AUTO_TEST_CASE(error_t__code__method_not_allowed__true_exected_message) //// BOOST_REQUIRE_EQUAL(ec.message(), "length required"); ////} //// -////BOOST_AUTO_TEST_CASE(error_t__code__precondition_failed__true_exected_message) +////BOOST_AUTO_TEST_CASE(error_t__code__precondition_failed__true_expected_message) ////{ //// constexpr auto value = error::precondition_failed; //// const auto ec = code(value); @@ -619,7 +619,7 @@ BOOST_AUTO_TEST_CASE(error_t__code__method_not_allowed__true_exected_message) //// BOOST_REQUIRE_EQUAL(ec.message(), "precondition failed"); ////} //// -////BOOST_AUTO_TEST_CASE(error_t__code__payload_too_large__true_exected_message) +////BOOST_AUTO_TEST_CASE(error_t__code__payload_too_large__true_expected_message) ////{ //// constexpr auto value = error::payload_too_large; //// const auto ec = code(value); @@ -628,7 +628,7 @@ BOOST_AUTO_TEST_CASE(error_t__code__method_not_allowed__true_exected_message) //// BOOST_REQUIRE_EQUAL(ec.message(), "payload too large"); ////} //// -////BOOST_AUTO_TEST_CASE(error_t__code__uri_too_long__true_exected_message) +////BOOST_AUTO_TEST_CASE(error_t__code__uri_too_long__true_expected_message) ////{ //// constexpr auto value = error::uri_too_long; //// const auto ec = code(value); @@ -637,7 +637,7 @@ BOOST_AUTO_TEST_CASE(error_t__code__method_not_allowed__true_exected_message) //// BOOST_REQUIRE_EQUAL(ec.message(), "uri too long"); ////} //// -////BOOST_AUTO_TEST_CASE(error_t__code__unsupported_media_type__true_exected_message) +////BOOST_AUTO_TEST_CASE(error_t__code__unsupported_media_type__true_expected_message) ////{ //// constexpr auto value = error::unsupported_media_type; //// const auto ec = code(value); @@ -646,7 +646,7 @@ BOOST_AUTO_TEST_CASE(error_t__code__method_not_allowed__true_exected_message) //// BOOST_REQUIRE_EQUAL(ec.message(), "unsupported media type"); ////} //// -////BOOST_AUTO_TEST_CASE(error_t__code__range_not_satisfiable__true_exected_message) +////BOOST_AUTO_TEST_CASE(error_t__code__range_not_satisfiable__true_expected_message) ////{ //// constexpr auto value = error::range_not_satisfiable; //// const auto ec = code(value); @@ -655,7 +655,7 @@ BOOST_AUTO_TEST_CASE(error_t__code__method_not_allowed__true_exected_message) //// BOOST_REQUIRE_EQUAL(ec.message(), "range not satisfiable"); ////} //// -////BOOST_AUTO_TEST_CASE(error_t__code__expectation_failed__true_exected_message) +////BOOST_AUTO_TEST_CASE(error_t__code__expectation_failed__true_expected_message) ////{ //// constexpr auto value = error::expectation_failed; //// const auto ec = code(value); @@ -664,7 +664,7 @@ BOOST_AUTO_TEST_CASE(error_t__code__method_not_allowed__true_exected_message) //// BOOST_REQUIRE_EQUAL(ec.message(), "expectation failed"); ////} //// -////BOOST_AUTO_TEST_CASE(error_t__code__im_a_teapot__true_exected_message) +////BOOST_AUTO_TEST_CASE(error_t__code__im_a_teapot__true_expected_message) ////{ //// constexpr auto value = error::im_a_teapot; //// const auto ec = code(value); @@ -673,7 +673,7 @@ BOOST_AUTO_TEST_CASE(error_t__code__method_not_allowed__true_exected_message) //// BOOST_REQUIRE_EQUAL(ec.message(), "im a teapot"); ////} //// -////BOOST_AUTO_TEST_CASE(error_t__code__misdirected_request__true_exected_message) +////BOOST_AUTO_TEST_CASE(error_t__code__misdirected_request__true_expected_message) ////{ //// constexpr auto value = error::misdirected_request; //// const auto ec = code(value); @@ -682,7 +682,7 @@ BOOST_AUTO_TEST_CASE(error_t__code__method_not_allowed__true_exected_message) //// BOOST_REQUIRE_EQUAL(ec.message(), "misdirected request"); ////} //// -////BOOST_AUTO_TEST_CASE(error_t__code__unprocessable_entity__true_exected_message) +////BOOST_AUTO_TEST_CASE(error_t__code__unprocessable_entity__true_expected_message) ////{ //// constexpr auto value = error::unprocessable_entity; //// const auto ec = code(value); @@ -691,7 +691,7 @@ BOOST_AUTO_TEST_CASE(error_t__code__method_not_allowed__true_exected_message) //// BOOST_REQUIRE_EQUAL(ec.message(), "unprocessable entity"); ////} //// -////BOOST_AUTO_TEST_CASE(error_t__code__locked__true_exected_message) +////BOOST_AUTO_TEST_CASE(error_t__code__locked__true_expected_message) ////{ //// constexpr auto value = error::locked; //// const auto ec = code(value); @@ -700,7 +700,7 @@ BOOST_AUTO_TEST_CASE(error_t__code__method_not_allowed__true_exected_message) //// BOOST_REQUIRE_EQUAL(ec.message(), "locked"); ////} //// -////BOOST_AUTO_TEST_CASE(error_t__code__failed_dependency__true_exected_message) +////BOOST_AUTO_TEST_CASE(error_t__code__failed_dependency__true_expected_message) ////{ //// constexpr auto value = error::failed_dependency; //// const auto ec = code(value); @@ -709,7 +709,7 @@ BOOST_AUTO_TEST_CASE(error_t__code__method_not_allowed__true_exected_message) //// BOOST_REQUIRE_EQUAL(ec.message(), "failed dependency"); ////} //// -////BOOST_AUTO_TEST_CASE(error_t__code__too_early__true_exected_message) +////BOOST_AUTO_TEST_CASE(error_t__code__too_early__true_expected_message) ////{ //// constexpr auto value = error::too_early; //// const auto ec = code(value); @@ -718,7 +718,7 @@ BOOST_AUTO_TEST_CASE(error_t__code__method_not_allowed__true_exected_message) //// BOOST_REQUIRE_EQUAL(ec.message(), "too early"); ////} //// -////BOOST_AUTO_TEST_CASE(error_t__code__upgrade_required__true_exected_message) +////BOOST_AUTO_TEST_CASE(error_t__code__upgrade_required__true_expected_message) ////{ //// constexpr auto value = error::upgrade_required; //// const auto ec = code(value); @@ -727,7 +727,7 @@ BOOST_AUTO_TEST_CASE(error_t__code__method_not_allowed__true_exected_message) //// BOOST_REQUIRE_EQUAL(ec.message(), "upgrade required"); ////} //// -////BOOST_AUTO_TEST_CASE(error_t__code__precondition_required__true_exected_message) +////BOOST_AUTO_TEST_CASE(error_t__code__precondition_required__true_expected_message) ////{ //// constexpr auto value = error::precondition_required; //// const auto ec = code(value); @@ -736,7 +736,7 @@ BOOST_AUTO_TEST_CASE(error_t__code__method_not_allowed__true_exected_message) //// BOOST_REQUIRE_EQUAL(ec.message(), "precondition required"); ////} //// -////BOOST_AUTO_TEST_CASE(error_t__code__too_many_requests__true_exected_message) +////BOOST_AUTO_TEST_CASE(error_t__code__too_many_requests__true_expected_message) ////{ //// constexpr auto value = error::too_many_requests; //// const auto ec = code(value); @@ -745,7 +745,7 @@ BOOST_AUTO_TEST_CASE(error_t__code__method_not_allowed__true_exected_message) //// BOOST_REQUIRE_EQUAL(ec.message(), "too many requests"); ////} //// -////BOOST_AUTO_TEST_CASE(error_t__code__request_header_fields_too_large__true_exected_message) +////BOOST_AUTO_TEST_CASE(error_t__code__request_header_fields_too_large__true_expected_message) ////{ //// constexpr auto value = error::request_header_fields_too_large; //// const auto ec = code(value); @@ -754,7 +754,7 @@ BOOST_AUTO_TEST_CASE(error_t__code__method_not_allowed__true_exected_message) //// BOOST_REQUIRE_EQUAL(ec.message(), "request header fields too large"); ////} //// -////BOOST_AUTO_TEST_CASE(error_t__code__unavailable_for_legal_reasons__true_exected_message) +////BOOST_AUTO_TEST_CASE(error_t__code__unavailable_for_legal_reasons__true_expected_message) ////{ //// constexpr auto value = error::unavailable_for_legal_reasons; //// const auto ec = code(value); @@ -765,7 +765,7 @@ BOOST_AUTO_TEST_CASE(error_t__code__method_not_allowed__true_exected_message) // http 5xx server error -BOOST_AUTO_TEST_CASE(error_t__code__internal_server_error__true_exected_message) +BOOST_AUTO_TEST_CASE(error_t__code__internal_server_error__true_expected_message) { constexpr auto value = error::internal_server_error; const auto ec = code(value); @@ -774,7 +774,7 @@ BOOST_AUTO_TEST_CASE(error_t__code__internal_server_error__true_exected_message) BOOST_REQUIRE_EQUAL(ec.message(), "internal server error"); } -BOOST_AUTO_TEST_CASE(error_t__code__not_implemented__true_exected_message) +BOOST_AUTO_TEST_CASE(error_t__code__not_implemented__true_expected_message) { constexpr auto value = error::not_implemented; const auto ec = code(value); @@ -783,7 +783,7 @@ BOOST_AUTO_TEST_CASE(error_t__code__not_implemented__true_exected_message) BOOST_REQUIRE_EQUAL(ec.message(), "not implemented"); } -////BOOST_AUTO_TEST_CASE(error_t__code__bad_gateway__true_exected_message) +////BOOST_AUTO_TEST_CASE(error_t__code__bad_gateway__true_expected_message) ////{ //// constexpr auto value = error::bad_gateway; //// const auto ec = code(value); @@ -792,7 +792,7 @@ BOOST_AUTO_TEST_CASE(error_t__code__not_implemented__true_exected_message) //// BOOST_REQUIRE_EQUAL(ec.message(), "bad gateway"); ////} //// -////BOOST_AUTO_TEST_CASE(error_t__code__service_unavailable__true_exected_message) +////BOOST_AUTO_TEST_CASE(error_t__code__service_unavailable__true_expected_message) ////{ //// constexpr auto value = error::service_unavailable; //// const auto ec = code(value); @@ -801,7 +801,7 @@ BOOST_AUTO_TEST_CASE(error_t__code__not_implemented__true_exected_message) //// BOOST_REQUIRE_EQUAL(ec.message(), "service unavailable"); ////} //// -////BOOST_AUTO_TEST_CASE(error_t__code__gateway_timeout__true_exected_message) +////BOOST_AUTO_TEST_CASE(error_t__code__gateway_timeout__true_expected_message) ////{ //// constexpr auto value = error::gateway_timeout; //// const auto ec = code(value); @@ -810,7 +810,7 @@ BOOST_AUTO_TEST_CASE(error_t__code__not_implemented__true_exected_message) //// BOOST_REQUIRE_EQUAL(ec.message(), "gateway timeout"); ////} //// -////BOOST_AUTO_TEST_CASE(error_t__code__http_version_not_supported__true_exected_message) +////BOOST_AUTO_TEST_CASE(error_t__code__http_version_not_supported__true_expected_message) ////{ //// constexpr auto value = error::http_version_not_supported; //// const auto ec = code(value); @@ -819,7 +819,7 @@ BOOST_AUTO_TEST_CASE(error_t__code__not_implemented__true_exected_message) //// BOOST_REQUIRE_EQUAL(ec.message(), "http version not supported"); ////} //// -////BOOST_AUTO_TEST_CASE(error_t__code__variant_also_negotiates__true_exected_message) +////BOOST_AUTO_TEST_CASE(error_t__code__variant_also_negotiates__true_expected_message) ////{ //// constexpr auto value = error::variant_also_negotiates; //// const auto ec = code(value); @@ -828,7 +828,7 @@ BOOST_AUTO_TEST_CASE(error_t__code__not_implemented__true_exected_message) //// BOOST_REQUIRE_EQUAL(ec.message(), "variant also negotiates"); ////} //// -////BOOST_AUTO_TEST_CASE(error_t__code__insufficient_storage__true_exected_message) +////BOOST_AUTO_TEST_CASE(error_t__code__insufficient_storage__true_expected_message) ////{ //// constexpr auto value = error::insufficient_storage; //// const auto ec = code(value); @@ -837,7 +837,7 @@ BOOST_AUTO_TEST_CASE(error_t__code__not_implemented__true_exected_message) //// BOOST_REQUIRE_EQUAL(ec.message(), "insufficient storage"); ////} //// -////BOOST_AUTO_TEST_CASE(error_t__code__loop_detected__true_exected_message) +////BOOST_AUTO_TEST_CASE(error_t__code__loop_detected__true_expected_message) ////{ //// constexpr auto value = error::loop_detected; //// const auto ec = code(value); @@ -846,7 +846,7 @@ BOOST_AUTO_TEST_CASE(error_t__code__not_implemented__true_exected_message) //// BOOST_REQUIRE_EQUAL(ec.message(), "loop detected"); ////} //// -////BOOST_AUTO_TEST_CASE(error_t__code__not_extended__true_exected_message) +////BOOST_AUTO_TEST_CASE(error_t__code__not_extended__true_expected_message) ////{ //// constexpr auto value = error::not_extended; //// const auto ec = code(value); @@ -855,7 +855,7 @@ BOOST_AUTO_TEST_CASE(error_t__code__not_implemented__true_exected_message) //// BOOST_REQUIRE_EQUAL(ec.message(), "not extended"); ////} //// -////BOOST_AUTO_TEST_CASE(error_t__code__network_authentication_required__true_exected_message) +////BOOST_AUTO_TEST_CASE(error_t__code__network_authentication_required__true_expected_message) ////{ //// constexpr auto value = error::network_authentication_required; //// const auto ec = code(value); @@ -866,7 +866,7 @@ BOOST_AUTO_TEST_CASE(error_t__code__not_implemented__true_exected_message) // boost beast error -BOOST_AUTO_TEST_CASE(error_t__code__end_of_stream__true_exected_message) +BOOST_AUTO_TEST_CASE(error_t__code__end_of_stream__true_expected_message) { constexpr auto value = error::end_of_stream; const auto ec = code(value); @@ -875,7 +875,7 @@ BOOST_AUTO_TEST_CASE(error_t__code__end_of_stream__true_exected_message) BOOST_REQUIRE_EQUAL(ec.message(), "end of stream"); } -BOOST_AUTO_TEST_CASE(error_t__code__partial_message__true_exected_message) +BOOST_AUTO_TEST_CASE(error_t__code__partial_message__true_expected_message) { constexpr auto value = error::partial_message; const auto ec = code(value); @@ -884,7 +884,7 @@ BOOST_AUTO_TEST_CASE(error_t__code__partial_message__true_exected_message) BOOST_REQUIRE_EQUAL(ec.message(), "partial message"); } -BOOST_AUTO_TEST_CASE(error_t__code__need_more__true_exected_message) +BOOST_AUTO_TEST_CASE(error_t__code__need_more__true_expected_message) { constexpr auto value = error::need_more; const auto ec = code(value); @@ -893,7 +893,7 @@ BOOST_AUTO_TEST_CASE(error_t__code__need_more__true_exected_message) BOOST_REQUIRE_EQUAL(ec.message(), "need more"); } -BOOST_AUTO_TEST_CASE(error_t__code__unexpected_body__true_exected_message) +BOOST_AUTO_TEST_CASE(error_t__code__unexpected_body__true_expected_message) { constexpr auto value = error::unexpected_body; const auto ec = code(value); @@ -902,7 +902,7 @@ BOOST_AUTO_TEST_CASE(error_t__code__unexpected_body__true_exected_message) BOOST_REQUIRE_EQUAL(ec.message(), "unexpected body"); } -BOOST_AUTO_TEST_CASE(error_t__code__need_buffer__true_exected_message) +BOOST_AUTO_TEST_CASE(error_t__code__need_buffer__true_expected_message) { constexpr auto value = error::need_buffer; const auto ec = code(value); @@ -911,7 +911,7 @@ BOOST_AUTO_TEST_CASE(error_t__code__need_buffer__true_exected_message) BOOST_REQUIRE_EQUAL(ec.message(), "need buffer"); } -BOOST_AUTO_TEST_CASE(error_t__code__end_of_chunk__true_exected_message) +BOOST_AUTO_TEST_CASE(error_t__code__end_of_chunk__true_expected_message) { constexpr auto value = error::end_of_chunk; const auto ec = code(value); @@ -920,7 +920,7 @@ BOOST_AUTO_TEST_CASE(error_t__code__end_of_chunk__true_exected_message) BOOST_REQUIRE_EQUAL(ec.message(), "end of chunk"); } -BOOST_AUTO_TEST_CASE(error_t__code__buffer_overflow__true_exected_message) +BOOST_AUTO_TEST_CASE(error_t__code__buffer_overflow__true_expected_message) { constexpr auto value = error::buffer_overflow; const auto ec = code(value); @@ -929,7 +929,7 @@ BOOST_AUTO_TEST_CASE(error_t__code__buffer_overflow__true_exected_message) BOOST_REQUIRE_EQUAL(ec.message(), "buffer overflow"); } -BOOST_AUTO_TEST_CASE(error_t__code__header_limit__true_exected_message) +BOOST_AUTO_TEST_CASE(error_t__code__header_limit__true_expected_message) { constexpr auto value = error::header_limit; const auto ec = code(value); @@ -938,7 +938,7 @@ BOOST_AUTO_TEST_CASE(error_t__code__header_limit__true_exected_message) BOOST_REQUIRE_EQUAL(ec.message(), "header limit"); } -BOOST_AUTO_TEST_CASE(error_t__code__body_limit__true_exected_message) +BOOST_AUTO_TEST_CASE(error_t__code__body_limit__true_expected_message) { constexpr auto value = error::body_limit; const auto ec = code(value); @@ -947,7 +947,7 @@ BOOST_AUTO_TEST_CASE(error_t__code__body_limit__true_exected_message) BOOST_REQUIRE_EQUAL(ec.message(), "body limit"); } -BOOST_AUTO_TEST_CASE(error_t__code__bad_alloc__true_exected_message) +BOOST_AUTO_TEST_CASE(error_t__code__bad_alloc__true_expected_message) { constexpr auto value = error::bad_alloc; const auto ec = code(value); @@ -956,7 +956,7 @@ BOOST_AUTO_TEST_CASE(error_t__code__bad_alloc__true_exected_message) BOOST_REQUIRE_EQUAL(ec.message(), "bad alloc"); } -BOOST_AUTO_TEST_CASE(error_t__code__bad_line_ending__true_exected_message) +BOOST_AUTO_TEST_CASE(error_t__code__bad_line_ending__true_expected_message) { constexpr auto value = error::bad_line_ending; const auto ec = code(value); @@ -965,7 +965,7 @@ BOOST_AUTO_TEST_CASE(error_t__code__bad_line_ending__true_exected_message) BOOST_REQUIRE_EQUAL(ec.message(), "bad line ending"); } -BOOST_AUTO_TEST_CASE(error_t__code__bad_method__true_exected_message) +BOOST_AUTO_TEST_CASE(error_t__code__bad_method__true_expected_message) { constexpr auto value = error::bad_method; const auto ec = code(value); @@ -974,7 +974,7 @@ BOOST_AUTO_TEST_CASE(error_t__code__bad_method__true_exected_message) BOOST_REQUIRE_EQUAL(ec.message(), "bad method"); } -BOOST_AUTO_TEST_CASE(error_t__code__bad_target__true_exected_message) +BOOST_AUTO_TEST_CASE(error_t__code__bad_target__true_expected_message) { constexpr auto value = error::bad_target; const auto ec = code(value); @@ -983,7 +983,7 @@ BOOST_AUTO_TEST_CASE(error_t__code__bad_target__true_exected_message) BOOST_REQUIRE_EQUAL(ec.message(), "bad target"); } -BOOST_AUTO_TEST_CASE(error_t__code__bad_version__true_exected_message) +BOOST_AUTO_TEST_CASE(error_t__code__bad_version__true_expected_message) { constexpr auto value = error::bad_version; const auto ec = code(value); @@ -992,7 +992,7 @@ BOOST_AUTO_TEST_CASE(error_t__code__bad_version__true_exected_message) BOOST_REQUIRE_EQUAL(ec.message(), "bad version"); } -BOOST_AUTO_TEST_CASE(error_t__code__bad_status__true_exected_message) +BOOST_AUTO_TEST_CASE(error_t__code__bad_status__true_expected_message) { constexpr auto value = error::bad_status; const auto ec = code(value); @@ -1001,7 +1001,7 @@ BOOST_AUTO_TEST_CASE(error_t__code__bad_status__true_exected_message) BOOST_REQUIRE_EQUAL(ec.message(), "bad status"); } -BOOST_AUTO_TEST_CASE(error_t__code__bad_reason__true_exected_message) +BOOST_AUTO_TEST_CASE(error_t__code__bad_reason__true_expected_message) { constexpr auto value = error::bad_reason; const auto ec = code(value); @@ -1010,7 +1010,7 @@ BOOST_AUTO_TEST_CASE(error_t__code__bad_reason__true_exected_message) BOOST_REQUIRE_EQUAL(ec.message(), "bad reason"); } -BOOST_AUTO_TEST_CASE(error_t__code__bad_field__true_exected_message) +BOOST_AUTO_TEST_CASE(error_t__code__bad_field__true_expected_message) { constexpr auto value = error::bad_field; const auto ec = code(value); @@ -1019,7 +1019,7 @@ BOOST_AUTO_TEST_CASE(error_t__code__bad_field__true_exected_message) BOOST_REQUIRE_EQUAL(ec.message(), "bad field"); } -BOOST_AUTO_TEST_CASE(error_t__code__bad_value__true_exected_message) +BOOST_AUTO_TEST_CASE(error_t__code__bad_value__true_expected_message) { constexpr auto value = error::bad_value; const auto ec = code(value); @@ -1028,7 +1028,7 @@ BOOST_AUTO_TEST_CASE(error_t__code__bad_value__true_exected_message) BOOST_REQUIRE_EQUAL(ec.message(), "bad value"); } -BOOST_AUTO_TEST_CASE(error_t__code__bad_content_length__true_exected_message) +BOOST_AUTO_TEST_CASE(error_t__code__bad_content_length__true_expected_message) { constexpr auto value = error::bad_content_length; const auto ec = code(value); @@ -1037,7 +1037,7 @@ BOOST_AUTO_TEST_CASE(error_t__code__bad_content_length__true_exected_message) BOOST_REQUIRE_EQUAL(ec.message(), "bad content length"); } -BOOST_AUTO_TEST_CASE(error_t__code__bad_transfer_encoding__true_exected_message) +BOOST_AUTO_TEST_CASE(error_t__code__bad_transfer_encoding__true_expected_message) { constexpr auto value = error::bad_transfer_encoding; const auto ec = code(value); @@ -1046,7 +1046,7 @@ BOOST_AUTO_TEST_CASE(error_t__code__bad_transfer_encoding__true_exected_message) BOOST_REQUIRE_EQUAL(ec.message(), "bad transfer encoding"); } -BOOST_AUTO_TEST_CASE(error_t__code__bad_chunk__true_exected_message) +BOOST_AUTO_TEST_CASE(error_t__code__bad_chunk__true_expected_message) { constexpr auto value = error::bad_chunk; const auto ec = code(value); @@ -1055,7 +1055,7 @@ BOOST_AUTO_TEST_CASE(error_t__code__bad_chunk__true_exected_message) BOOST_REQUIRE_EQUAL(ec.message(), "bad chunk"); } -BOOST_AUTO_TEST_CASE(error_t__code__bad_chunk_extension__true_exected_message) +BOOST_AUTO_TEST_CASE(error_t__code__bad_chunk_extension__true_expected_message) { constexpr auto value = error::bad_chunk_extension; const auto ec = code(value); @@ -1064,7 +1064,7 @@ BOOST_AUTO_TEST_CASE(error_t__code__bad_chunk_extension__true_exected_message) BOOST_REQUIRE_EQUAL(ec.message(), "bad chunk extension"); } -BOOST_AUTO_TEST_CASE(error_t__code__bad_obs_fold__true_exected_message) +BOOST_AUTO_TEST_CASE(error_t__code__bad_obs_fold__true_expected_message) { constexpr auto value = error::bad_obs_fold; const auto ec = code(value); @@ -1073,7 +1073,7 @@ BOOST_AUTO_TEST_CASE(error_t__code__bad_obs_fold__true_exected_message) BOOST_REQUIRE_EQUAL(ec.message(), "bad obs fold"); } -BOOST_AUTO_TEST_CASE(error_t__code__multiple_content_length__true_exected_message) +BOOST_AUTO_TEST_CASE(error_t__code__multiple_content_length__true_expected_message) { constexpr auto value = error::multiple_content_length; const auto ec = code(value); @@ -1082,7 +1082,7 @@ BOOST_AUTO_TEST_CASE(error_t__code__multiple_content_length__true_exected_messag BOOST_REQUIRE_EQUAL(ec.message(), "multiple content length"); } -BOOST_AUTO_TEST_CASE(error_t__code__stale_parser__true_exected_message) +BOOST_AUTO_TEST_CASE(error_t__code__stale_parser__true_expected_message) { constexpr auto value = error::stale_parser; const auto ec = code(value); @@ -1091,7 +1091,7 @@ BOOST_AUTO_TEST_CASE(error_t__code__stale_parser__true_exected_message) BOOST_REQUIRE_EQUAL(ec.message(), "stale parser"); } -BOOST_AUTO_TEST_CASE(error_t__code__short_read__true_exected_message) +BOOST_AUTO_TEST_CASE(error_t__code__short_read__true_expected_message) { constexpr auto value = error::short_read; const auto ec = code(value); @@ -1100,11 +1100,290 @@ BOOST_AUTO_TEST_CASE(error_t__code__short_read__true_exected_message) BOOST_REQUIRE_EQUAL(ec.message(), "short read"); } -// TODO: boost beast websocket error +// boost beast websocket error + +BOOST_AUTO_TEST_CASE(error_t__code__websocket_closed__true_expected_message) +{ + constexpr auto value = error::websocket_closed; + const auto ec = code(value); + BOOST_REQUIRE(ec); + BOOST_REQUIRE(ec == value); + BOOST_REQUIRE_EQUAL(ec.message(), "websocket closed"); +} + +BOOST_AUTO_TEST_CASE(error_t__code__websocket_buffer_overflow__true_expected_message) +{ + constexpr auto value = error::websocket_buffer_overflow; + const auto ec = code(value); + BOOST_REQUIRE(ec); + BOOST_REQUIRE(ec == value); + BOOST_REQUIRE_EQUAL(ec.message(), "websocket buffer overflow"); +} + +BOOST_AUTO_TEST_CASE(error_t__code__partial_deflate_block__true_expected_message) +{ + constexpr auto value = error::partial_deflate_block; + const auto ec = code(value); + BOOST_REQUIRE(ec); + BOOST_REQUIRE(ec == value); + BOOST_REQUIRE_EQUAL(ec.message(), "partial deflate block"); +} + +BOOST_AUTO_TEST_CASE(error_t__code__message_too_big__true_expected_message) +{ + constexpr auto value = error::message_too_big; + const auto ec = code(value); + BOOST_REQUIRE(ec); + BOOST_REQUIRE(ec == value); + BOOST_REQUIRE_EQUAL(ec.message(), "message too big"); +} + +BOOST_AUTO_TEST_CASE(error_t__code__bad_http_version__true_expected_message) +{ + constexpr auto value = error::bad_http_version; + const auto ec = code(value); + BOOST_REQUIRE(ec); + BOOST_REQUIRE(ec == value); + BOOST_REQUIRE_EQUAL(ec.message(), "bad http version"); +} + +BOOST_AUTO_TEST_CASE(error_t__code__websocket_bad_method__true_expected_message) +{ + constexpr auto value = error::websocket_bad_method; + const auto ec = code(value); + BOOST_REQUIRE(ec); + BOOST_REQUIRE(ec == value); + BOOST_REQUIRE_EQUAL(ec.message(), "websocket bad method"); +} + +BOOST_AUTO_TEST_CASE(error_t__code__no_host__true_expected_message) +{ + constexpr auto value = error::no_host; + const auto ec = code(value); + BOOST_REQUIRE(ec); + BOOST_REQUIRE(ec == value); + BOOST_REQUIRE_EQUAL(ec.message(), "no host"); +} + +BOOST_AUTO_TEST_CASE(error_t__code__no_connection__true_expected_message) +{ + constexpr auto value = error::no_connection; + const auto ec = code(value); + BOOST_REQUIRE(ec); + BOOST_REQUIRE(ec == value); + BOOST_REQUIRE_EQUAL(ec.message(), "no connection"); +} + +BOOST_AUTO_TEST_CASE(error_t__code__no_connection_upgrade__true_expected_message) +{ + constexpr auto value = error::no_connection_upgrade; + const auto ec = code(value); + BOOST_REQUIRE(ec); + BOOST_REQUIRE(ec == value); + BOOST_REQUIRE_EQUAL(ec.message(), "no connection upgrade"); +} + +BOOST_AUTO_TEST_CASE(error_t__code__no_upgrade__true_expected_message) +{ + constexpr auto value = error::no_upgrade; + const auto ec = code(value); + BOOST_REQUIRE(ec); + BOOST_REQUIRE(ec == value); + BOOST_REQUIRE_EQUAL(ec.message(), "no upgrade"); +} + +BOOST_AUTO_TEST_CASE(error_t__code__no_upgrade_websocket__true_expected_message) +{ + constexpr auto value = error::no_upgrade_websocket; + const auto ec = code(value); + BOOST_REQUIRE(ec); + BOOST_REQUIRE(ec == value); + BOOST_REQUIRE_EQUAL(ec.message(), "no upgrade websocket"); +} + +BOOST_AUTO_TEST_CASE(error_t__code__no_sec_key__true_expected_message) +{ + constexpr auto value = error::no_sec_key; + const auto ec = code(value); + BOOST_REQUIRE(ec); + BOOST_REQUIRE(ec == value); + BOOST_REQUIRE_EQUAL(ec.message(), "no sec key"); +} + +BOOST_AUTO_TEST_CASE(error_t__code__bad_sec_key__true_expected_message) +{ + constexpr auto value = error::bad_sec_key; + const auto ec = code(value); + BOOST_REQUIRE(ec); + BOOST_REQUIRE(ec == value); + BOOST_REQUIRE_EQUAL(ec.message(), "bad sec key"); +} + +BOOST_AUTO_TEST_CASE(error_t__code__no_sec_version__true_expected_message) +{ + constexpr auto value = error::no_sec_version; + const auto ec = code(value); + BOOST_REQUIRE(ec); + BOOST_REQUIRE(ec == value); + BOOST_REQUIRE_EQUAL(ec.message(), "no sec version"); +} + +BOOST_AUTO_TEST_CASE(error_t__code__bad_sec_version__true_expected_message) +{ + constexpr auto value = error::bad_sec_version; + const auto ec = code(value); + BOOST_REQUIRE(ec); + BOOST_REQUIRE(ec == value); + BOOST_REQUIRE_EQUAL(ec.message(), "bad sec version"); +} + +BOOST_AUTO_TEST_CASE(error_t__code__no_sec_accept__true_expected_message) +{ + constexpr auto value = error::no_sec_accept; + const auto ec = code(value); + BOOST_REQUIRE(ec); + BOOST_REQUIRE(ec == value); + BOOST_REQUIRE_EQUAL(ec.message(), "no sec accept"); +} + +BOOST_AUTO_TEST_CASE(error_t__code__bad_sec_accept__true_expected_message) +{ + constexpr auto value = error::bad_sec_accept; + const auto ec = code(value); + BOOST_REQUIRE(ec); + BOOST_REQUIRE(ec == value); + BOOST_REQUIRE_EQUAL(ec.message(), "bad sec accept"); +} + +BOOST_AUTO_TEST_CASE(error_t__code__upgrade_declined__true_expected_message) +{ + constexpr auto value = error::upgrade_declined; + const auto ec = code(value); + BOOST_REQUIRE(ec); + BOOST_REQUIRE(ec == value); + BOOST_REQUIRE_EQUAL(ec.message(), "upgrade declined"); +} + +BOOST_AUTO_TEST_CASE(error_t__code__bad_opcode__true_expected_message) +{ + constexpr auto value = error::bad_opcode; + const auto ec = code(value); + BOOST_REQUIRE(ec); + BOOST_REQUIRE(ec == value); + BOOST_REQUIRE_EQUAL(ec.message(), "bad opcode"); +} + +BOOST_AUTO_TEST_CASE(error_t__code__bad_data_frame__true_expected_message) +{ + constexpr auto value = error::bad_data_frame; + const auto ec = code(value); + BOOST_REQUIRE(ec); + BOOST_REQUIRE(ec == value); + BOOST_REQUIRE_EQUAL(ec.message(), "bad data frame"); +} + +BOOST_AUTO_TEST_CASE(error_t__code__bad_continuation__true_expected_message) +{ + constexpr auto value = error::bad_continuation; + const auto ec = code(value); + BOOST_REQUIRE(ec); + BOOST_REQUIRE(ec == value); + BOOST_REQUIRE_EQUAL(ec.message(), "bad continuation"); +} + +BOOST_AUTO_TEST_CASE(error_t__code__bad_reserved_bits__true_expected_message) +{ + constexpr auto value = error::bad_reserved_bits; + const auto ec = code(value); + BOOST_REQUIRE(ec); + BOOST_REQUIRE(ec == value); + BOOST_REQUIRE_EQUAL(ec.message(), "bad reserved bits"); +} + +BOOST_AUTO_TEST_CASE(error_t__code__bad_control_fragment__true_expected_message) +{ + constexpr auto value = error::bad_control_fragment; + const auto ec = code(value); + BOOST_REQUIRE(ec); + BOOST_REQUIRE(ec == value); + BOOST_REQUIRE_EQUAL(ec.message(), "bad control fragment"); +} + +BOOST_AUTO_TEST_CASE(error_t__code__bad_control_size__true_expected_message) +{ + constexpr auto value = error::bad_control_size; + const auto ec = code(value); + BOOST_REQUIRE(ec); + BOOST_REQUIRE(ec == value); + BOOST_REQUIRE_EQUAL(ec.message(), "bad control size"); +} + +BOOST_AUTO_TEST_CASE(error_t__code__bad_unmasked_frame__true_expected_message) +{ + constexpr auto value = error::bad_unmasked_frame; + const auto ec = code(value); + BOOST_REQUIRE(ec); + BOOST_REQUIRE(ec == value); + BOOST_REQUIRE_EQUAL(ec.message(), "bad unmasked frame"); +} + +BOOST_AUTO_TEST_CASE(error_t__code__bad_masked_frame__true_expected_message) +{ + constexpr auto value = error::bad_masked_frame; + const auto ec = code(value); + BOOST_REQUIRE(ec); + BOOST_REQUIRE(ec == value); + BOOST_REQUIRE_EQUAL(ec.message(), "bad masked frame"); +} + +BOOST_AUTO_TEST_CASE(error_t__code__bad_size__true_expected_message) +{ + constexpr auto value = error::bad_size; + const auto ec = code(value); + BOOST_REQUIRE(ec); + BOOST_REQUIRE(ec == value); + BOOST_REQUIRE_EQUAL(ec.message(), "bad size"); +} + +BOOST_AUTO_TEST_CASE(error_t__code__bad_frame_payload__true_expected_message) +{ + constexpr auto value = error::bad_frame_payload; + const auto ec = code(value); + BOOST_REQUIRE(ec); + BOOST_REQUIRE(ec == value); + BOOST_REQUIRE_EQUAL(ec.message(), "bad frame payload"); +} + +BOOST_AUTO_TEST_CASE(error_t__code__bad_close_code__true_expected_message) +{ + constexpr auto value = error::bad_close_code; + const auto ec = code(value); + BOOST_REQUIRE(ec); + BOOST_REQUIRE(ec == value); + BOOST_REQUIRE_EQUAL(ec.message(), "bad close code"); +} + +BOOST_AUTO_TEST_CASE(error_t__code__bad_close_size__true_expected_message) +{ + constexpr auto value = error::bad_close_size; + const auto ec = code(value); + BOOST_REQUIRE(ec); + BOOST_REQUIRE(ec == value); + BOOST_REQUIRE_EQUAL(ec.message(), "bad close size"); +} + +BOOST_AUTO_TEST_CASE(error_t__code__bad_close_payload__true_expected_message) +{ + constexpr auto value = error::bad_close_payload; + const auto ec = code(value); + BOOST_REQUIRE(ec); + BOOST_REQUIRE(ec == value); + BOOST_REQUIRE_EQUAL(ec.message(), "bad close payload"); +} // rpc error -BOOST_AUTO_TEST_CASE(error_t__code__message_overflow__true_exected_message) +BOOST_AUTO_TEST_CASE(error_t__code__message_overflow__true_expected_message) { constexpr auto value = error::message_overflow; const auto ec = code(value); @@ -1113,7 +1392,7 @@ BOOST_AUTO_TEST_CASE(error_t__code__message_overflow__true_exected_message) BOOST_REQUIRE_EQUAL(ec.message(), "message overflow"); } -BOOST_AUTO_TEST_CASE(error_t__code__undefined_type__true_exected_message) +BOOST_AUTO_TEST_CASE(error_t__code__undefined_type__true_expected_message) { constexpr auto value = error::undefined_type; const auto ec = code(value); @@ -1122,7 +1401,7 @@ BOOST_AUTO_TEST_CASE(error_t__code__undefined_type__true_exected_message) BOOST_REQUIRE_EQUAL(ec.message(), "undefined type"); } -BOOST_AUTO_TEST_CASE(error_t__code__unexpected_method__true_exected_message) +BOOST_AUTO_TEST_CASE(error_t__code__unexpected_method__true_expected_message) { constexpr auto value = error::unexpected_method; const auto ec = code(value); @@ -1131,7 +1410,7 @@ BOOST_AUTO_TEST_CASE(error_t__code__unexpected_method__true_exected_message) BOOST_REQUIRE_EQUAL(ec.message(), "unexpected method"); } -BOOST_AUTO_TEST_CASE(error_t__code__unexpected_type__true_exected_message) +BOOST_AUTO_TEST_CASE(error_t__code__unexpected_type__true_expected_message) { constexpr auto value = error::unexpected_type; const auto ec = code(value); @@ -1140,7 +1419,7 @@ BOOST_AUTO_TEST_CASE(error_t__code__unexpected_type__true_exected_message) BOOST_REQUIRE_EQUAL(ec.message(), "unexpected type"); } -BOOST_AUTO_TEST_CASE(error_t__code__extra_positional__true_exected_message) +BOOST_AUTO_TEST_CASE(error_t__code__extra_positional__true_expected_message) { constexpr auto value = error::extra_positional; const auto ec = code(value); @@ -1149,7 +1428,7 @@ BOOST_AUTO_TEST_CASE(error_t__code__extra_positional__true_exected_message) BOOST_REQUIRE_EQUAL(ec.message(), "extra positional"); } -BOOST_AUTO_TEST_CASE(error_t__code__extra_named__true_exected_message) +BOOST_AUTO_TEST_CASE(error_t__code__extra_named__true_expected_message) { constexpr auto value = error::extra_named; const auto ec = code(value); @@ -1158,7 +1437,7 @@ BOOST_AUTO_TEST_CASE(error_t__code__extra_named__true_exected_message) BOOST_REQUIRE_EQUAL(ec.message(), "extra named"); } -BOOST_AUTO_TEST_CASE(error_t__code__missing_array__true_exected_message) +BOOST_AUTO_TEST_CASE(error_t__code__missing_array__true_expected_message) { constexpr auto value = error::missing_array; const auto ec = code(value); @@ -1167,7 +1446,7 @@ BOOST_AUTO_TEST_CASE(error_t__code__missing_array__true_exected_message) BOOST_REQUIRE_EQUAL(ec.message(), "missing array"); } -BOOST_AUTO_TEST_CASE(error_t__code__missing_object__true_exected_message) +BOOST_AUTO_TEST_CASE(error_t__code__missing_object__true_expected_message) { constexpr auto value = error::missing_object; const auto ec = code(value); @@ -1176,7 +1455,7 @@ BOOST_AUTO_TEST_CASE(error_t__code__missing_object__true_exected_message) BOOST_REQUIRE_EQUAL(ec.message(), "missing object"); } -BOOST_AUTO_TEST_CASE(error_t__code__missing_parameter__true_exected_message) +BOOST_AUTO_TEST_CASE(error_t__code__missing_parameter__true_expected_message) { constexpr auto value = error::missing_parameter; const auto ec = code(value);