From 7827e4de667c58517bb8ae4cfbcd7e9ae41910dc Mon Sep 17 00:00:00 2001 From: imarom Date: Thu, 13 Aug 2015 16:28:21 +0300 Subject: some files added --- src/gtest/rpc_test.cpp | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) (limited to 'src/gtest') diff --git a/src/gtest/rpc_test.cpp b/src/gtest/rpc_test.cpp index f80ebd5d..d8fc5389 100644 --- a/src/gtest/rpc_test.cpp +++ b/src/gtest/rpc_test.cpp @@ -75,28 +75,36 @@ TEST_F(RpcTest, basic_rpc_test) { resp_str = send_msg(req_str); EXPECT_TRUE(reader.parse(resp_str, response, false)); - EXPECT_TRUE(response["jsonrpc"] == "2.0"); - EXPECT_TRUE(response["id"] == Json::Value::null); - EXPECT_TRUE(response["error"]["code"] == -32700); + EXPECT_EQ(response["jsonrpc"], "2.0"); + EXPECT_EQ(response["id"], Json::Value::null); + EXPECT_EQ(response["error"]["code"], -32700); // check bad version req_str = "{\"jsonrpc\": \"1.5\", \"method\": \"foobar\", \"id\": \"1\"}"; resp_str = send_msg(req_str); EXPECT_TRUE(reader.parse(resp_str, response, false)); - EXPECT_TRUE(response["jsonrpc"] == "2.0"); - EXPECT_TRUE(response["id"] == "1"); - EXPECT_TRUE(response["error"]["code"] == -32600); + EXPECT_EQ(response["jsonrpc"], "2.0"); + EXPECT_EQ(response["id"], "1"); + EXPECT_EQ(response["error"]["code"], -32600); // no method name present - req_str = "{\"jsonrpc\": \"1.5\", \"id\": 482}"; + req_str = "{\"jsonrpc\": \"2.0\", \"id\": 482}"; resp_str = send_msg(req_str); EXPECT_TRUE(reader.parse(resp_str, response, false)); - EXPECT_TRUE(response["jsonrpc"] == "2.0"); - EXPECT_TRUE(response["id"] == 482); - EXPECT_TRUE(response["error"]["code"] == -32600); + EXPECT_EQ(response["jsonrpc"], "2.0"); + EXPECT_EQ(response["id"], 482); + EXPECT_EQ(response["error"]["code"], -32600); + /* method does not exist */ + req_str = "{\"jsonrpc\": \"2.0\", \"method\": \"jfgldjlfds\", \"id\": 482}"; + resp_str = send_msg(req_str); + + EXPECT_TRUE(reader.parse(resp_str, response, false)); + EXPECT_EQ(response["jsonrpc"], "2.0"); + EXPECT_EQ(response["id"], 482); + EXPECT_EQ(response["error"]["code"], -32601); } TEST_F(RpcTest, batch_rpc_test) { -- cgit 1.2.3-korg