Skip to content
Snippets Groups Projects
Commit b4a49771 authored by Nicolas Pope's avatar Nicolas Pope
Browse files

Merge branch 'bug/#51' into 'main'

#51 Fix for node details bug

See merge request beyondaka/beyond-protocol!30
parents 52b776cd 155da7ec
No related branches found
No related tags found
No related merge requests found
...@@ -90,8 +90,11 @@ void Node::createStream(const std::string &uri, FrameID id) { ...@@ -90,8 +90,11 @@ void Node::createStream(const std::string &uri, FrameID id) {
} }
nlohmann::json Node::details() { nlohmann::json Node::details() {
const std::string res = peer_->call<std::string>("node_details"); const auto res = peer_->call<std::vector<std::string>>("node_details");
return nlohmann::json::parse(res); if (res.size() > 0) {
return nlohmann::json::parse(res[0]);
}
return {};
} }
int64_t Node::ping() { int64_t Node::ping() {
......
...@@ -173,8 +173,8 @@ void Self::onCreateStream(const std::function<void(const std::string &uri, Frame ...@@ -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) { void Self::onNodeDetails(const std::function<nlohmann::json()> &cb) {
universe_->bind("node_details", [cb]() { universe_->bind("node_details", [cb]() -> std::vector<std::string> {
return cb().dump(); return {cb().dump()};
}); });
} }
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
#include <ftl/protocol/self.hpp> #include <ftl/protocol/self.hpp>
#include <ftl/protocol/node.hpp> #include <ftl/protocol/node.hpp>
#include <ftl/uri.hpp> #include <ftl/uri.hpp>
#include <nlohmann/json.hpp>
// --- Tests ------------------------------------------------------------------- // --- Tests -------------------------------------------------------------------
...@@ -19,6 +20,11 @@ TEST_CASE("Webservice connection", "[net]") { ...@@ -19,6 +20,11 @@ TEST_CASE("Webservice connection", "[net]") {
REQUIRE( p ); REQUIRE( p );
REQUIRE( p->waitConnection(5) ); REQUIRE( p->waitConnection(5) );
auto details = p->details();
REQUIRE(details.contains("id"));
LOG(INFO) << "Details: " << details.dump();
} }
ftl::protocol::reset(); ftl::protocol::reset();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment