From e960ce8376966517d4754806b33ac0ac1ca15844 Mon Sep 17 00:00:00 2001 From: fikumikudev Date: Sat, 29 Jan 2022 19:55:19 +0000 Subject: [PATCH] Fix `ipc_client::async_resolve` when given invalid endpoint --- nano/core_test/ipc.cpp | 16 ++++++++++++++++ nano/lib/ipc_client.cpp | 2 +- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/nano/core_test/ipc.cpp b/nano/core_test/ipc.cpp index a12ce3e7..fc24f0be 100644 --- a/nano/core_test/ipc.cpp +++ b/nano/core_test/ipc.cpp @@ -189,3 +189,19 @@ TEST (ipc, permissions_default_user_order) nano::ipc::access access; ASSERT_TRUE (access.deserialize_toml (toml)); } + +TEST (ipc, invalid_endpoint) +{ + nano::system system (1); + system.nodes[0]->config.ipc_config.transport_tcp.enabled = true; + system.nodes[0]->config.ipc_config.transport_tcp.port = 24077; + nano::node_rpc_config node_rpc_config; + nano::ipc::ipc_client client (system.nodes[0]->io_ctx); + + std::atomic call_completed{ false }; + client.async_connect ("::-1", 24077, [&client, &call_completed] (nano::error err) { + ASSERT_IS_ERROR (static_cast (err)); + call_completed = true; + }); + ASSERT_TIMELY (5s, call_completed); +} \ No newline at end of file diff --git a/nano/lib/ipc_client.cpp b/nano/lib/ipc_client.cpp index b2eea05b..31c6aac7 100644 --- a/nano/lib/ipc_client.cpp +++ b/nano/lib/ipc_client.cpp @@ -64,7 +64,7 @@ public: } else { - callback (ec, *end); + callback (ec, boost::asio::ip::tcp::endpoint ()); } }); }