SKALE-2835 add check

parent 810e33aa
......@@ -669,6 +669,12 @@ Json::Value SGXWalletServer::deleteBlsKeyImpl(const std::string& name) {
if (!checkName(name, "BLS_KEY")) {
throw SGXException(INVALID_BLS_NAME, "Invalid BLSKey name");
}
std::shared_ptr <std::string> bls_ptr = LevelDB::getLevelDb()->readString(name);
if (bls_ptr != nullptr) {
result["deleted"] = true;
return result;
}
LevelDB::getLevelDb()->deleteKey(name);
} HANDLE_SGX_EXCEPTION(result)
return result;
......
......@@ -220,6 +220,18 @@ class StubClient : public jsonrpc::Client
throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
}
Json::Value deleteBlsKey(const std::string & polyName)
{
Json::Value p;
p["blsKeyName"] = polyName;
Json::Value result = this->CallMethod("deleteBlsKey",p);
if (result.isObject())
return result;
else
throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
}
////CSRManagerServer
......
......@@ -574,8 +574,11 @@ TEST_CASE_METHOD(TestFixture, "DKG_BLS test", "[dkg-bls]") {
TestUtils::doDKG(c, 16, 5, ecdsaKeyNames, blsKeyNames, schainID, dkgID);
}
for (const auto& name : blsKeyNames) {
REQUIRE(c.deleteBlsKey(name)["deleted"] == true);
}
}
TEST_CASE_METHOD(TestFixture, "Get ServerStatus", "[get-server-status]") {
HttpClient client(RPC_ENDPOINT);
......
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