SKALE-2572 add api call for sgx version

parent e86abd44
......@@ -678,6 +678,15 @@ Json::Value SGXWalletServer::getServerStatusImpl() {
return result;
}
Json::Value SGXWalletServer::getServerVersionImpl() {
INIT_RESULT(result)
result["version"] = SGXWALLET_VERSION;
return result;
}
Json::Value SGXWalletServer::generateDKGPoly(const string &_polyName, int _t) {
LOCK(m)
......@@ -776,6 +785,11 @@ Json::Value SGXWalletServer::getServerStatus() {
return getServerStatusImpl();
}
Json::Value SGXWalletServer::getServerVersion() {
LOCK(m)
return getServerVersionImpl();
}
shared_ptr <string> SGXWalletServer::readFromDb(const string &name, const string &prefix) {
auto dataStr = LevelDB::getLevelDb()->readString(prefix + name);
......
......@@ -86,6 +86,8 @@ public:
virtual Json::Value getServerStatus();
virtual Json::Value getServerVersion();
static shared_ptr<string> readFromDb(const string &name, const string &prefix = "");
static void writeDataToDB(const string &Name, const string &value);
......@@ -135,6 +137,8 @@ public:
static Json::Value getServerStatusImpl();
static Json::Value getServerVersionImpl();
static void printDB();
static int initHttpServer();
......
......@@ -54,7 +54,6 @@
#include "BLSCrypto.h"
#include "ServerInit.h"
#include "SGXWalletServer.hpp"
#include "SGXWALLET_VERSION"
void initUserSpace() {
libff::init_alt_bn128_params();
......
......@@ -25,6 +25,7 @@
#define SGXWALLET_SERVERINIT_H
#include "stdint.h"
#include "SGXWALLET_VERSION"
#ifdef __cplusplus
#define EXTERNC extern "C"
......
......@@ -56,6 +56,7 @@ class AbstractStubServer : public jsonrpc::AbstractServer<AbstractStubServer>
this->bindAndAddMethod(jsonrpc::Procedure("isPolyExists", jsonrpc::PARAMS_BY_NAME, jsonrpc::JSON_OBJECT, "polyName",jsonrpc::JSON_STRING, NULL), &AbstractStubServer::isPolyExistsI);
this->bindAndAddMethod(jsonrpc::Procedure("getServerStatus", jsonrpc::PARAMS_BY_NAME, jsonrpc::JSON_OBJECT, NULL), &AbstractStubServer::getServerStatusI);
this->bindAndAddMethod(jsonrpc::Procedure("getServerVersion", jsonrpc::PARAMS_BY_NAME, jsonrpc::JSON_OBJECT, NULL), &AbstractStubServer::getServerVersionI);
}
inline virtual void importBLSKeyShareI(const Json::Value &request, Json::Value &response)
......@@ -133,6 +134,12 @@ class AbstractStubServer : public jsonrpc::AbstractServer<AbstractStubServer>
response = this->getServerStatus();
}
inline virtual void getServerVersionI(const Json::Value &request, Json::Value &response)
{
(void)request;
response = this->getServerVersion();
}
virtual Json::Value importBLSKeyShare(const std::string& keyShare, const std::string& keyShareName, int t, int n, int index) = 0;
virtual Json::Value blsSignMessageHash(const std::string& keyShareName, const std::string& messageHash, int t, int n, int signerIndex ) = 0;
virtual Json::Value importECDSAKey(const std::string& key, const std::string& keyName) = 0;
......@@ -152,6 +159,7 @@ class AbstractStubServer : public jsonrpc::AbstractServer<AbstractStubServer>
virtual Json::Value isPolyExists(const std::string& polyName) = 0;
virtual Json::Value getServerStatus() = 0;
virtual Json::Value getServerVersion() = 0;
};
#endif //JSONRPC_CPP_STUB_ABSTRACTSTUBSERVER_H_
......@@ -260,6 +260,16 @@ class StubClient : public jsonrpc::Client
throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
}
Json::Value getServerVersion() {
Json::Value p;
p = Json::nullValue;
Json::Value result = this->CallMethod("getServerVersion",p);
if (result.isObject())
return result;
else
throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
}
};
#endif //JSONRPC_CPP_STUB_STUBCLIENT_H_
......@@ -773,6 +773,13 @@ TEST_CASE_METHOD(TestFixture, "Get ServerStatus", "[get-server-status]") {
}
TEST_CASE_METHOD(TestFixture, "Get ServerVersion", "[get-server-version]") {
HttpClient client(RPC_ENDPOINT);
StubClient c(client, JSONRPC_CLIENT_V2);
REQUIRE(c.getServerVersion()["version"] == SGXWALLET_VERSION);
}
TEST_CASE_METHOD(TestFixtureHTTPS, "Cert request sign", "[cert-sign]") {
REQUIRE(SGXRegistrationServer::getServer() != nullptr);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment