From 8e42a66de52f4fa30f9977269724596f5df0f611 Mon Sep 17 00:00:00 2001 From: Allen Han Date: Wed, 27 May 2020 17:08:26 -0500 Subject: [PATCH] revert wallet api and change test to nonparallelizable_tests --- .../include/eosio/http_plugin/http_plugin.hpp | 12 --------- .../wallet_api_plugin/wallet_api_plugin.hpp | 12 --------- .../wallet_api_plugin/wallet_api_plugin.cpp | 27 ++++++++++++------- tests/CMakeLists.txt | 4 +-- tests/plugin_http_api_test.py | 10 +++---- 5 files changed, 25 insertions(+), 40 deletions(-) diff --git a/plugins/http_plugin/include/eosio/http_plugin/http_plugin.hpp b/plugins/http_plugin/include/eosio/http_plugin/http_plugin.hpp index d9c315a397..fabe3fea26 100644 --- a/plugins/http_plugin/include/eosio/http_plugin/http_plugin.hpp +++ b/plugins/http_plugin/include/eosio/http_plugin/http_plugin.hpp @@ -190,18 +190,6 @@ namespace eosio { } } EOS_RETHROW_EXCEPTIONS(chain::invalid_http_request, "Unable to parse valid input from POST body"); } - template - struct two_params { - T1 p1; - T2 p2; - }; - - template - struct three_params { - T1 p1; - T2 p2; - T3 p3; - }; } FC_REFLECT(eosio::error_results::error_info::error_detail, (message)(file)(line_number)(method)) diff --git a/plugins/wallet_api_plugin/include/eosio/wallet_api_plugin/wallet_api_plugin.hpp b/plugins/wallet_api_plugin/include/eosio/wallet_api_plugin/wallet_api_plugin.hpp index c3fc5e2a25..e3ba9dbe1b 100644 --- a/plugins/wallet_api_plugin/include/eosio/wallet_api_plugin/wallet_api_plugin.hpp +++ b/plugins/wallet_api_plugin/include/eosio/wallet_api_plugin/wallet_api_plugin.hpp @@ -2,7 +2,6 @@ #include #include -#include #include @@ -29,15 +28,4 @@ class wallet_api_plugin : public plugin { private: }; -typedef two_params two_string_params; -typedef two_params two_params_sign_digest; -typedef three_params three_string_params; -typedef three_params, chain::chain_id_type> three_params_sign_trx; - } - -FC_REFLECT( eosio::two_string_params, (p1)(p2) ) -FC_REFLECT( eosio::two_params_sign_digest, (p1)(p2) ) -FC_REFLECT( eosio::three_string_params, (p1)(p2)(p3) ) -FC_REFLECT( eosio::three_params_sign_trx, (p1)(p2)(p3) ) - diff --git a/plugins/wallet_api_plugin/wallet_api_plugin.cpp b/plugins/wallet_api_plugin/wallet_api_plugin.cpp index 0ac1980495..597509d04b 100644 --- a/plugins/wallet_api_plugin/wallet_api_plugin.cpp +++ b/plugins/wallet_api_plugin/wallet_api_plugin.cpp @@ -36,16 +36,19 @@ using namespace eosio; auto result = api_handle.call_name( std::move(params) ); #define INVOKE_R_R_R(api_handle, call_name, in_param0, in_param1) \ - const auto& params = parse_params, http_params_types::params_required>(body);\ - auto result = api_handle.call_name(params.p1, params.p2); + const auto& params = parse_params(body);\ + if (params.size() != 2) { \ + EOS_THROW(chain::invalid_http_request, "Missing valid input from POST body"); \ + } \ + auto result = api_handle.call_name(params.at(0).as(), params.at(1).as()); // chain_id_type does not have default constructor, keep it unchanged #define INVOKE_R_R_R_R(api_handle, call_name, in_param0, in_param1, in_param2) \ - const auto& vs = parse_params(body);\ - if (vs.size() != 3) { \ + const auto& params = parse_params(body);\ + if (params.size() != 3) { \ EOS_THROW(chain::invalid_http_request, "Missing valid input from POST body"); \ } \ - auto result = api_handle.call_name(vs.at(0).as(), vs.at(1).as(), vs.at(2).as()); + auto result = api_handle.call_name(params.at(0).as(), params.at(1).as(), params.at(2).as()); #define INVOKE_R_V(api_handle, call_name) \ body = parse_params(body); \ @@ -57,13 +60,19 @@ using namespace eosio; eosio::detail::wallet_api_plugin_empty result; #define INVOKE_V_R_R(api_handle, call_name, in_param0, in_param1) \ - const auto& params = parse_params, http_params_types::params_required>(body);\ - api_handle.call_name(params.p1, params.p2); \ + const auto& params = parse_params(body);\ + if (params.size() != 2) { \ + EOS_THROW(chain::invalid_http_request, "Missing valid input from POST body"); \ + } \ + api_handle.call_name(params.at(0).as(), params.at(1).as()); \ eosio::detail::wallet_api_plugin_empty result; #define INVOKE_V_R_R_R(api_handle, call_name, in_param0, in_param1, in_param2) \ - const auto& params = parse_params, http_params_types::params_required>(body);\ - api_handle.call_name(params.p1, params.p2, params.p3); \ + const auto& params = parse_params(body);\ + if (params.size() != 3) { \ + EOS_THROW(chain::invalid_http_request, "Missing valid input from POST body"); \ + } \ + api_handle.call_name(params.at(0).as(), params.at(1).as(), params.at(2).as()); \ eosio::detail::wallet_api_plugin_empty result; #define INVOKE_V_V(api_handle, call_name) \ diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 4ed724045b..1545def7fa 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -164,8 +164,8 @@ set_property(TEST nodeos_repeat_transaction_lr_test PROPERTY LABELS long_running add_test(NAME cli_test COMMAND tests/cli_test.py WORKING_DIRECTORY ${CMAKE_BINARY_DIR}) add_test(NAME plugin_http_api_test COMMAND tests/plugin_http_api_test.py -v --clean-run --dump-error-detail WORKING_DIRECTORY ${CMAKE_BINARY_DIR}) -set_tests_properties(plugin_http_api_test PROPERTIES TIMEOUT 3000) -set_property(TEST plugin_http_api_test PROPERTY LABELS plugin_http_api_tests) +set_tests_properties(plugin_http_api_test PROPERTIES TIMEOUT 40) +set_property(TEST plugin_http_api_test PROPERTY LABELS nonparallelizable_tests) add_subdirectory(se_tests) diff --git a/tests/plugin_http_api_test.py b/tests/plugin_http_api_test.py index 05ee93d049..33d3f6e53e 100755 --- a/tests/plugin_http_api_test.py +++ b/tests/plugin_http_api_test.py @@ -968,7 +968,7 @@ def test_WalletApi(self) : self.assertEqual(ret_json["code"], 400) self.assertEqual(ret_json["error"]["code"], 3200006) # unlock with valid parameter - valid_cmd = default_cmd + self.http_post_str + ("'{\"name\":\"auser\", \"password\":\"nopassword\"}'") + valid_cmd = default_cmd + self.http_post_str + ("'[\"auser\", \"nopassword\"]'") ret_json = Utils.runCmdReturnJson(valid_cmd) self.assertEqual(ret_json["code"], 500) @@ -983,7 +983,7 @@ def test_WalletApi(self) : self.assertEqual(ret_json["code"], 400) self.assertEqual(ret_json["error"]["code"], 3200006) # import_key with valid parameter - valid_cmd = default_cmd + self.http_post_str + ("{'\"name\":\"auser\", \"wif_key\":\"nokey\"'}") + valid_cmd = default_cmd + self.http_post_str + ("'[\"auser\", \"nokey\"]'") ret_json = Utils.runCmdReturnJson(valid_cmd) self.assertEqual(ret_json["code"], 500) @@ -998,7 +998,7 @@ def test_WalletApi(self) : self.assertEqual(ret_json["code"], 400) self.assertEqual(ret_json["error"]["code"], 3200006) # remove_key with valid parameter - valid_cmd = default_cmd + self.http_post_str + ("{'\"name\":\"auser\", \"password\":\"none\", \"key\":\"none\"'}") + valid_cmd = default_cmd + self.http_post_str + ("'[\"auser\", \"none\", \"none\"]'") ret_json = Utils.runCmdReturnJson(valid_cmd) self.assertEqual(ret_json["code"], 500) @@ -1013,7 +1013,7 @@ def test_WalletApi(self) : self.assertEqual(ret_json["code"], 400) self.assertEqual(ret_json["error"]["code"], 3200006) # create_key with valid parameter - valid_cmd = default_cmd + self.http_post_str + ("{'\"name\":\"auser\", \"key_type\":\"none\"'}") + valid_cmd = default_cmd + self.http_post_str + ("'[\"auser\", \"none\", \"none\"]'") ret_json = Utils.runCmdReturnJson(valid_cmd) self.assertEqual(ret_json["code"], 500) @@ -1038,7 +1038,7 @@ def test_WalletApi(self) : self.assertEqual(ret_json["code"], 400) self.assertEqual(ret_json["error"]["code"], 3200006) # list_keys with valid parameter - valid_cmd = default_cmd + self.http_post_str + ("{'\"name\":\"auser\", \"pw\":\"unknownkey\"'}") + valid_cmd = default_cmd + self.http_post_str + ("'[\"auser\", \"unknownkey\"]'") ret_json = Utils.runCmdReturnJson(valid_cmd) self.assertEqual(ret_json["code"], 500)