SKALE0-3951 fix proceed requests, add tests

parent 3fb722fd
......@@ -559,7 +559,7 @@ TEST_CASE_METHOD(TestFixture, "Get ServerStatus", "[get-server-status]") {
sleep(3);
}
TEST_CASE_METHOD(TestFixture, "Get ServerStatus", "[get-server-status-zmq]") {
TEST_CASE_METHOD(TestFixture, "Get ServerStatusZmq", "[get-server-status-zmq]") {
auto client = make_shared<ZMQClient>(ZMQ_IP, ZMQ_PORT, true, "./sgx_data/cert_data/rootCA.pem",
"./sgx_data/cert_data/rootCA.key");
REQUIRE_NOTHROW(client->getServerStatus());
......@@ -573,7 +573,7 @@ TEST_CASE_METHOD(TestFixture, "Get ServerVersion", "[get-server-version]") {
sleep(3);
}
TEST_CASE_METHOD(TestFixture, "Get ServerVersion", "[get-server-version-zmq]") {
TEST_CASE_METHOD(TestFixture, "Get ServerVersionZmq", "[get-server-version-zmq]") {
auto client = make_shared<ZMQClient>(ZMQ_IP, ZMQ_PORT, true, "./sgx_data/cert_data/rootCA.pem",
"./sgx_data/cert_data/rootCA.key");
REQUIRE(client->getServerVersion() == SGXWalletServer::getVersion());
......@@ -687,6 +687,20 @@ TEST_CASE_METHOD(TestFixture, "PolyExists test", "[dkg-poly-exists]") {
REQUIRE(!polyDoesNotExist["IsExist"].asBool());
}
TEST_CASE_METHOD(TestFixture, "PolyExistsZmq test", "[dkg-poly-exists-zmq]") {
auto client = make_shared<ZMQClient>(ZMQ_IP, ZMQ_PORT, true, "./sgx_data/cert_data/rootCA.pem",
"./sgx_data/cert_data/rootCA.key");
string polyName = SAMPLE_POLY_NAME;
REQUIRE_NOTHROW(client->generateDKGPoly(polyName, 2));
bool polyExists = client->isPolyExists(polyName);
REQUIRE(polyExists);
bool polyDoesNotExist = client->isPolyExists("Vasya");
REQUIRE(!polyDoesNotExist);
}
TEST_CASE_METHOD(TestFixture, "AES_DKG V2 test", "[aes-dkg-v2]") {
HttpClient client(RPC_ENDPOINT);
StubClient c(client, JSONRPC_CLIENT_V2);
......@@ -936,9 +950,7 @@ TEST_CASE_METHOD(TestFixtureZMQSign, "ZMQ-ecdsa", "[zmq-ecdsa]") {
HttpClient htp(RPC_ENDPOINT);
StubClient c(htp, JSONRPC_CLIENT_V2);
string ip = ZMQ_IP;
auto client = make_shared<ZMQClient>(ip, ZMQ_PORT, true, "./sgx_data/cert_data/rootCA.pem",
auto client = make_shared<ZMQClient>(ZMQ_IP, ZMQ_PORT, true, "./sgx_data/cert_data/rootCA.pem",
"./sgx_data/cert_data/rootCA.key");
string keyName = "";
......
......@@ -59,10 +59,9 @@ testList = [ "[zmq-ecdsa]",
"[dkgzmqbls]",
"[dkg-bls-v2]",
"[dkg-poly-exists]",
# "[dkg-poly-exists-zmq]",
"[dkg-poly-exists-zmq]",
"[dkg-aes-pub-shares]",
"[aes-encrypt-decrypt]",
"[aes-dkg]",
"[aes-dkg-v2]"
]
......
......@@ -353,10 +353,11 @@ string ZMQClient::getECDSAPublicKey(const string& keyName) {
return result->getECDSAPublicKey();
}
void ZMQClient::generateDKGPoly(const string& polyName) {
void ZMQClient::generateDKGPoly(const string& polyName, int t) {
Json::Value p;
p["type"] = ZMQMessage::GENERATE_DKG_POLY_REQ;
p["polyName"] = polyName;
p["t"] = t;
auto result = dynamic_pointer_cast<generateDKGPolyRspMessage>(doRequestReply(p));
CHECK_STATE(result);
CHECK_STATE(result->getStatus() == 0);
......
......@@ -95,7 +95,7 @@ public:
string getECDSAPublicKey(const string& keyName);
void generateDKGPoly(const string& polyName);
void generateDKGPoly(const string& polyName, int t);
Json::Value getVerificationVector(const string& polyName, int t);
......
......@@ -163,7 +163,7 @@ shared_ptr <ZMQMessage> ZMQMessage::parse(const char *_msg,
shared_ptr <ZMQMessage> ZMQMessage::buildRequest(string &_type, shared_ptr <rapidjson::Document> _d) {
Requests r;
try {
int t = requests.at( _type.c_str() );
int t = requests.at( _type );
r = static_cast<Requests>(t);
} catch ( std::out_of_range& ) {
BOOST_THROW_EXCEPTION(SGXException(-301, "Incorrect zmq message type: " + string(_type)));
......@@ -239,7 +239,7 @@ shared_ptr <ZMQMessage> ZMQMessage::buildRequest(string &_type, shared_ptr <rapi
shared_ptr <ZMQMessage> ZMQMessage::buildResponse(string &_type, shared_ptr <rapidjson::Document> _d) {
Responses r;
try {
int t = responses.at( _type.c_str() );
int t = responses.at( _type );
r = static_cast<Responses>(t);
} catch ( std::out_of_range& ) {
BOOST_THROW_EXCEPTION(InvalidStateException("Incorrect zmq message request type: " + string(_type),
......@@ -316,7 +316,7 @@ shared_ptr <ZMQMessage> ZMQMessage::buildResponse(string &_type, shared_ptr <rap
cache::lru_cache<string, pair < EVP_PKEY * , X509 *>> ZMQMessage::verifiedCerts(256);
const std::map<const char *, int> ZMQMessage::responses {
const std::map<string, int> ZMQMessage::requests{
{BLS_SIGN_REQ, 0}, {ECDSA_SIGN_REQ, 1}, {IMPORT_BLS_REQ, 2}, {IMPORT_ECDSA_REQ, 3},
{GENERATE_ECDSA_REQ, 4}, {GET_PUBLIC_ECDSA_REQ, 5}, {GENERATE_DKG_POLY_REQ, 6},
{GET_VV_REQ, 7}, {GET_SECRET_SHARE_REQ, 8}, {DKG_VERIFY_REQ, 9},
......@@ -325,7 +325,7 @@ const std::map<const char *, int> ZMQMessage::responses {
{GET_SERVER_STATUS_REQ, 16}, {GET_SERVER_VERSION_REQ, 17}, {DELETE_BLS_KEY_REQ, 18}
};
const std::map<const char *, int> ZMQMessage::requests {
const std::map<string, int> ZMQMessage::responses {
{BLS_SIGN_RSP, 0}, {ECDSA_SIGN_RSP, 1}, {IMPORT_BLS_RSP, 2}, {IMPORT_ECDSA_RSP, 3},
{GENERATE_ECDSA_RSP, 4}, {GET_PUBLIC_ECDSA_RSP, 5}, {GENERATE_DKG_POLY_RSP, 6},
{GET_VV_RSP, 7}, {GET_SECRET_SHARE_RSP, 8}, {DKG_VERIFY_RSP, 9},
......
......@@ -92,8 +92,8 @@ public:
static constexpr const char *DELETE_BLS_KEY_REQ = "deleteBLSKeyReq";
static constexpr const char *DELETE_BLS_KEY_RSP = "deleteBLSKeyRsp";
static const std::map<const char *, int> requests;
static const std::map<const char *, int> responses;
static const std::map<string, int> requests;
static const std::map<string, int> responses;
enum Requests { ENUM_BLS_SIGN_REQ, ENUM_ECDSA_SIGN_REQ, ENUM_IMPORT_BLS_REQ, ENUM_IMPORT_ECDSA_REQ, ENUM_GENERATE_ECDSA_REQ, ENUM_GET_PUBLIC_ECDSA_REQ,
ENUM_GENERATE_DKG_POLY_REQ, ENUM_GET_VV_REQ, ENUM_GET_SECRET_SHARE_REQ, ENUM_DKG_VERIFY_REQ, ENUM_CREATE_BLS_PRIVATE_REQ,
......
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