From 155da7ec9a11c5d32fb5cc0e49f08d67cc240093 Mon Sep 17 00:00:00 2001 From: Nicolas Pope <nicolas.pope@utu.fi> Date: Mon, 13 Jun 2022 05:18:51 +0000 Subject: [PATCH] #51 Fix for node details bug --- src/node.cpp | 7 +++++-- src/self.cpp | 4 ++-- test/webservice_e2e.cpp | 6 ++++++ 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/node.cpp b/src/node.cpp index 00ed176..2869314 100644 --- a/src/node.cpp +++ b/src/node.cpp @@ -90,8 +90,11 @@ void Node::createStream(const std::string &uri, FrameID id) { } nlohmann::json Node::details() { - const std::string res = peer_->call<std::string>("node_details"); - return nlohmann::json::parse(res); + const auto res = peer_->call<std::vector<std::string>>("node_details"); + if (res.size() > 0) { + return nlohmann::json::parse(res[0]); + } + return {}; } int64_t Node::ping() { diff --git a/src/self.cpp b/src/self.cpp index bbf49bc..84671b0 100644 --- a/src/self.cpp +++ b/src/self.cpp @@ -173,8 +173,8 @@ void Self::onCreateStream(const std::function<void(const std::string &uri, Frame } void Self::onNodeDetails(const std::function<nlohmann::json()> &cb) { - universe_->bind("node_details", [cb]() { - return cb().dump(); + universe_->bind("node_details", [cb]() -> std::vector<std::string> { + return {cb().dump()}; }); } diff --git a/test/webservice_e2e.cpp b/test/webservice_e2e.cpp index 722b281..a18abd0 100644 --- a/test/webservice_e2e.cpp +++ b/test/webservice_e2e.cpp @@ -3,6 +3,7 @@ #include <ftl/protocol/self.hpp> #include <ftl/protocol/node.hpp> #include <ftl/uri.hpp> +#include <nlohmann/json.hpp> // --- Tests ------------------------------------------------------------------- @@ -19,6 +20,11 @@ TEST_CASE("Webservice connection", "[net]") { REQUIRE( p ); REQUIRE( p->waitConnection(5) ); + + auto details = p->details(); + REQUIRE(details.contains("id")); + + LOG(INFO) << "Details: " << details.dump(); } ftl::protocol::reset(); -- GitLab