Unverified Commit 67e1dd47 authored by Oleh Nikolaiev's avatar Oleh Nikolaiev Committed by GitHub

Merge pull request #86 from skalenetwork/feature/SKALE-2572-api-call-version

Feature/skale 2572 api call version
parents d1ce9e78 58649813
#define SGXWALLET_VERSION "1.49.4" #define SGXWALLET_VERSION "1.49.5"
...@@ -678,6 +678,15 @@ Json::Value SGXWalletServer::getServerStatusImpl() { ...@@ -678,6 +678,15 @@ Json::Value SGXWalletServer::getServerStatusImpl() {
return result; return result;
} }
Json::Value SGXWalletServer::getServerVersionImpl() {
INIT_RESULT(result)
result["version"] = SGXWALLET_VERSION;
return result;
}
Json::Value SGXWalletServer::generateDKGPoly(const string &_polyName, int _t) { Json::Value SGXWalletServer::generateDKGPoly(const string &_polyName, int _t) {
LOCK(m) LOCK(m)
...@@ -776,6 +785,11 @@ Json::Value SGXWalletServer::getServerStatus() { ...@@ -776,6 +785,11 @@ Json::Value SGXWalletServer::getServerStatus() {
return getServerStatusImpl(); return getServerStatusImpl();
} }
Json::Value SGXWalletServer::getServerVersion() {
LOCK(m)
return getServerVersionImpl();
}
shared_ptr <string> SGXWalletServer::readFromDb(const string &name, const string &prefix) { shared_ptr <string> SGXWalletServer::readFromDb(const string &name, const string &prefix) {
auto dataStr = LevelDB::getLevelDb()->readString(prefix + name); auto dataStr = LevelDB::getLevelDb()->readString(prefix + name);
......
...@@ -86,6 +86,8 @@ public: ...@@ -86,6 +86,8 @@ public:
virtual Json::Value getServerStatus(); virtual Json::Value getServerStatus();
virtual Json::Value getServerVersion();
static shared_ptr<string> readFromDb(const string &name, const string &prefix = ""); static shared_ptr<string> readFromDb(const string &name, const string &prefix = "");
static void writeDataToDB(const string &Name, const string &value); static void writeDataToDB(const string &Name, const string &value);
...@@ -135,6 +137,8 @@ public: ...@@ -135,6 +137,8 @@ public:
static Json::Value getServerStatusImpl(); static Json::Value getServerStatusImpl();
static Json::Value getServerVersionImpl();
static void printDB(); static void printDB();
static int initHttpServer(); static int initHttpServer();
...@@ -142,4 +146,4 @@ public: ...@@ -142,4 +146,4 @@ public:
static int initHttpsServer(bool _checkCerts); static int initHttpsServer(bool _checkCerts);
}; };
#endif //SGXWALLET_SGXWALLETSERVER_HPP #endif //SGXWALLET_SGXWALLETSERVER_HPP
\ No newline at end of file
...@@ -54,7 +54,6 @@ ...@@ -54,7 +54,6 @@
#include "BLSCrypto.h" #include "BLSCrypto.h"
#include "ServerInit.h" #include "ServerInit.h"
#include "SGXWalletServer.hpp" #include "SGXWalletServer.hpp"
#include "SGXWALLET_VERSION"
void initUserSpace() { void initUserSpace() {
libff::init_alt_bn128_params(); libff::init_alt_bn128_params();
......
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
#define SGXWALLET_SERVERINIT_H #define SGXWALLET_SERVERINIT_H
#include "stdint.h" #include "stdint.h"
#include "SGXWALLET_VERSION"
#ifdef __cplusplus #ifdef __cplusplus
#define EXTERNC extern "C" #define EXTERNC extern "C"
......
...@@ -56,6 +56,7 @@ class AbstractStubServer : public jsonrpc::AbstractServer<AbstractStubServer> ...@@ -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("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("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) inline virtual void importBLSKeyShareI(const Json::Value &request, Json::Value &response)
...@@ -133,6 +134,12 @@ class AbstractStubServer : public jsonrpc::AbstractServer<AbstractStubServer> ...@@ -133,6 +134,12 @@ class AbstractStubServer : public jsonrpc::AbstractServer<AbstractStubServer>
response = this->getServerStatus(); 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 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 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; virtual Json::Value importECDSAKey(const std::string& key, const std::string& keyName) = 0;
...@@ -152,6 +159,7 @@ class AbstractStubServer : public jsonrpc::AbstractServer<AbstractStubServer> ...@@ -152,6 +159,7 @@ class AbstractStubServer : public jsonrpc::AbstractServer<AbstractStubServer>
virtual Json::Value isPolyExists(const std::string& polyName) = 0; virtual Json::Value isPolyExists(const std::string& polyName) = 0;
virtual Json::Value getServerStatus() = 0; virtual Json::Value getServerStatus() = 0;
virtual Json::Value getServerVersion() = 0;
}; };
#endif //JSONRPC_CPP_STUB_ABSTRACTSTUBSERVER_H_ #endif //JSONRPC_CPP_STUB_ABSTRACTSTUBSERVER_H_
...@@ -45,6 +45,7 @@ echo "Test run requested" ...@@ -45,6 +45,7 @@ echo "Test run requested"
./testw [dkg-api] ./testw [dkg-api]
./testw [dkg-poly-exists] ./testw [dkg-poly-exists]
./testw [aes-encrypt-decrypt] ./testw [aes-encrypt-decrypt]
./testw [get-server-version]
else else
./sgxwallet $1 $2 $3 $4 ./sgxwallet $1 $2 $3 $4
fi fi
......
...@@ -249,16 +249,26 @@ class StubClient : public jsonrpc::Client ...@@ -249,16 +249,26 @@ class StubClient : public jsonrpc::Client
} }
Json::Value getServerStatus() Json::Value getServerStatus()
{ {
Json::Value p; Json::Value p;
p = Json::nullValue; p = Json::nullValue;
Json::Value result = this->CallMethod("getServerStatus",p); Json::Value result = this->CallMethod("getServerStatus",p);
if (result.isObject()) if (result.isObject())
return result; return result;
else else
throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString()); 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());
}
}; };
......
...@@ -773,6 +773,13 @@ TEST_CASE_METHOD(TestFixture, "Get ServerStatus", "[get-server-status]") { ...@@ -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]") { TEST_CASE_METHOD(TestFixtureHTTPS, "Cert request sign", "[cert-sign]") {
REQUIRE(SGXRegistrationServer::getServer() != nullptr); REQUIRE(SGXRegistrationServer::getServer() != nullptr);
......
...@@ -37,6 +37,7 @@ print("Top directory is:" + topDir) ...@@ -37,6 +37,7 @@ print("Top directory is:" + topDir)
testList = [ "[cert-sign]", testList = [ "[cert-sign]",
"[get-server-status]", "[get-server-status]",
"[get-server-version]",
"[ecdsa-key-gen]", "[ecdsa-key-gen]",
"[ecdsa-key-sig-gen]", "[ecdsa-key-sig-gen]",
"[ecdsa-get-pub-key]", "[ecdsa-get-pub-key]",
......
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