mirror of
https://github.com/XRPLF/clio.git
synced 2026-04-29 15:37:53 +00:00
test: Add test for WsConnection for ping response (#1619)
This commit is contained in:
@@ -75,6 +75,14 @@ TestWsConnection::send(std::string const& message, boost::asio::yield_context yi
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
void
|
||||
TestWsConnection::sendPing(boost::beast::websocket::ping_data const& data, boost::asio::yield_context yield)
|
||||
{
|
||||
boost::beast::error_code errorCode;
|
||||
ws_.async_ping(data, yield[errorCode]);
|
||||
[&]() { ASSERT_FALSE(errorCode) << errorCode.message(); }();
|
||||
}
|
||||
|
||||
std::optional<std::string>
|
||||
TestWsConnection::receive(boost::asio::yield_context yield)
|
||||
{
|
||||
@@ -105,6 +113,20 @@ TestWsConnection::headers() const
|
||||
return headers_;
|
||||
}
|
||||
|
||||
void
|
||||
TestWsConnection::setControlFrameCallback(
|
||||
std::function<void(boost::beast::websocket::frame_type, std::string_view)> callback
|
||||
)
|
||||
{
|
||||
ws_.control_callback(std::move(callback));
|
||||
}
|
||||
|
||||
void
|
||||
TestWsConnection::resetControlFrameCallback()
|
||||
{
|
||||
ws_.control_callback();
|
||||
}
|
||||
|
||||
TestWsServer::TestWsServer(asio::io_context& context, std::string const& host) : acceptor_(context)
|
||||
{
|
||||
auto endpoint = asio::ip::tcp::endpoint(boost::asio::ip::make_address(host), 0);
|
||||
|
||||
Reference in New Issue
Block a user