Unverified Commit 8ca3a0ca authored by Stan Kladko's avatar Stan Kladko Committed by GitHub

Merge pull request #21 from skalenetwork/enhancement/SKALE-1955-add-healthcheck

Enhancement/skale 1955 add healthcheck
parents 42227253 199cd7e9
......@@ -653,6 +653,14 @@ Json::Value MultG2Impl(const std::string& x){
return result;
}
Json::Value getServerStatusImpl() {
Json::Value result;
result["status"] = 0;
result["errorMessage"] = "";
return result;
}
Json::Value SGXWalletServer::generateDKGPoly(const std::string& polyName, int t){
std::cerr << "entered generateDKGPoly" << std::endl;
......@@ -739,6 +747,10 @@ Json::Value SGXWalletServer::MultG2(const std::string& x){
return MultG2Impl(x);
}
Json::Value SGXWalletServer::getServerStatus() {
lock_guard<recursive_mutex> lock(m);
return getServerStatusImpl();
}
shared_ptr<string> readFromDb(const string & name, const string & prefix) {
......
......@@ -60,6 +60,7 @@ public:
virtual Json::Value GetBLSPublicKeyShare(const std::string & BLSKeyName);
virtual Json::Value ComplaintResponse(const std::string& polyName, int ind);
virtual Json::Value MultG2(const std::string & x);
virtual Json::Value getServerStatus();
};
......@@ -86,5 +87,6 @@ Json::Value CreateBLSPrivateKeyImpl(const std::string & BLSKeyName, const std::s
Json::Value GetBLSPublicKeyShareImpl(const std::string & BLSKeyName);
Json::Value ComplaintResponseImpl(const std::string& polyName, int ind);
Json::Value MultG2Impl(const std::string & x);
Json::Value getServerStatusImpl();
#endif //SGXWALLET_SGXWALLETSERVER_HPP
\ No newline at end of file
......@@ -30,6 +30,7 @@ class AbstractStubServer : public jsonrpc::AbstractServer<AbstractStubServer>
this->bindAndAddMethod(jsonrpc::Procedure("ComplaintResponse", jsonrpc::PARAMS_BY_NAME, jsonrpc::JSON_OBJECT, "polyName",jsonrpc::JSON_STRING,"ind",jsonrpc::JSON_INTEGER, NULL), &AbstractStubServer::ComplaintResponseI);
this->bindAndAddMethod(jsonrpc::Procedure("MultG2", jsonrpc::PARAMS_BY_NAME, jsonrpc::JSON_OBJECT, "x",jsonrpc::JSON_STRING, NULL), &AbstractStubServer::MultG2I);
this->bindAndAddMethod(jsonrpc::Procedure("getServerStatus", jsonrpc::PARAMS_BY_NAME, jsonrpc::JSON_OBJECT, NULL), &AbstractStubServer::getServerStatusI);
}
inline virtual void importBLSKeyShareI(const Json::Value &request, Json::Value &response)
......@@ -93,6 +94,11 @@ class AbstractStubServer : public jsonrpc::AbstractServer<AbstractStubServer>
{
response = this->MultG2(request["x"].asString());
}
inline virtual void getServerStatusI(const Json::Value &request, Json::Value &response)
{
(void)request;
response = this->getServerStatus();
}
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;
......@@ -110,6 +116,8 @@ class AbstractStubServer : public jsonrpc::AbstractServer<AbstractStubServer>
virtual Json::Value GetBLSPublicKeyShare(const std::string & BLSKeyName) = 0;
virtual Json::Value ComplaintResponse(const std::string& polyName, int ind) = 0;
virtual Json::Value MultG2(const std::string & x) = 0;
virtual Json::Value getServerStatus() = 0;
};
#endif //JSONRPC_CPP_STUB_ABSTRACTSTUBSERVER_H_
......@@ -141,14 +141,14 @@ assert subprocess.call(["cp", "sgx_tgmp.h", TGMP_BUILD_DIR + "/include/sgx_tgmp.
os.chdir(SSL_DIR);
print "===>>> Downloading vanilla openssl source package"
print("===>>> Downloading vanilla openssl source package")
os.chdir(SSL_SOURCE_DIR);
assert subprocess.call(["wget", "https://www.openssl.org/source/openssl-1.1.1b.tar.gz"]) == 0
print "===>>> Making SSL project"
print("===>>> Making SSL project")
os.chdir(SSL_MAKE_DIR);
......
......@@ -26,6 +26,7 @@ class StubClient : public jsonrpc::Client
else
throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
}
Json::Value blsSignMessageHash(const std::string& keyShareName, const std::string& messageHash, int t, int n, int signerIndex) throw (jsonrpc::JsonRpcException)
{
Json::Value p;
......@@ -40,6 +41,7 @@ class StubClient : public jsonrpc::Client
else
throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
}
Json::Value importECDSAKey(const std::string& key, const std::string& keyName) throw (jsonrpc::JsonRpcException)
{
Json::Value p;
......@@ -51,6 +53,7 @@ class StubClient : public jsonrpc::Client
else
throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
}
Json::Value generateECDSAKey() throw (jsonrpc::JsonRpcException)
{
Json::Value p;
......@@ -61,6 +64,7 @@ class StubClient : public jsonrpc::Client
else
throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
}
Json::Value renameECDSAKey(const std::string& KeyName, const std::string& tempKeyName) throw (jsonrpc::JsonRpcException)
{
Json::Value p;
......@@ -72,6 +76,7 @@ class StubClient : public jsonrpc::Client
else
throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
}
Json::Value getPublicECDSAKey(const std::string& keyName) throw (jsonrpc::JsonRpcException)
{
Json::Value p;
......@@ -82,6 +87,7 @@ class StubClient : public jsonrpc::Client
else
throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
}
Json::Value ecdsaSignMessageHash(int base, const std::string& keyName, const std::string& messageHash) throw (jsonrpc::JsonRpcException)
{
Json::Value p;
......@@ -94,6 +100,7 @@ class StubClient : public jsonrpc::Client
else
throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
}
Json::Value generateDKGPoly(const std::string& polyName, int t) throw (jsonrpc::JsonRpcException)
{
Json::Value p;
......@@ -105,6 +112,7 @@ class StubClient : public jsonrpc::Client
else
throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
}
Json::Value getVerificationVector(const std::string& polyName, int t, int n) throw (jsonrpc::JsonRpcException)
{
Json::Value p;
......@@ -117,6 +125,7 @@ class StubClient : public jsonrpc::Client
else
throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
}
Json::Value getSecretShare(const std::string& polyName, const Json::Value& publicKeys, int t, int n) throw (jsonrpc::JsonRpcException)
{
Json::Value p;
......@@ -130,6 +139,7 @@ class StubClient : public jsonrpc::Client
else
throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
}
Json::Value DKGVerification(const std::string& publicShares, const std::string& EthKeyName, const std::string& SecretShare, int t, int n, int index) throw (jsonrpc::JsonRpcException)
{
Json::Value p;
......@@ -145,6 +155,7 @@ class StubClient : public jsonrpc::Client
else
throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
}
Json::Value CreateBLSPrivateKey(const std::string & BLSKeyName, const std::string& EthKeyName, const std::string& polyName, const std::string& SecretShare, int t, int n) throw (jsonrpc::JsonRpcException)
{
Json::Value p;
......@@ -197,6 +208,16 @@ class StubClient : public jsonrpc::Client
throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
}
Json::Value getServerStatus() throw (jsonrpc::JsonRpcException)
{
Json::Value p;
p = Json::nullValue;
Json::Value result = this->CallMethod("getServerStatus",p);
if (result.isObject())
return result;
else
throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
}
};
#endif //JSONRPC_CPP_STUB_STUBCLIENT_H_
......@@ -955,4 +955,11 @@ TEST_CASE("API test", "[api_test]") {
sgx_destroy_enclave(eid);
}
TEST_CASE("getServerStatus test", "[getServerStatus_test]") {
init_all();
HttpClient client("http://localhost:1028");
StubClient c(client, JSONRPC_CLIENT_V2);
REQUIRE(c.getServerStatus()["status"] == 0);
sgx_destroy_enclave(eid);
}
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