Skip to content
This repository has been archived by the owner on Aug 2, 2022. It is now read-only.

Commit

Permalink
Cleaned up test code. GH #4973
Browse files Browse the repository at this point in the history
  • Loading branch information
brianjohnson5972 committed Sep 10, 2018
1 parent 2590ea9 commit 1a0eba2
Showing 1 changed file with 1 addition and 32 deletions.
33 changes: 1 addition & 32 deletions plugins/test_control_api_plugin/test_control_api_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ struct async_result_visitor : public fc::visitor<std::string> {
#define CALL(api_name, api_handle, api_namespace, call_name, http_response_code) \
{std::string("/v1/" #api_name "/" #call_name), \
[this, api_handle](string, string body, url_response_callback cb) mutable { \
wlog("test_control_api_plugin CALL"); \
try { \
if (body.empty()) body = "{}"; \
auto result = api_handle.call_name(fc::json::from_string(body).as<api_namespace::call_name ## _params>()); \
Expand All @@ -50,42 +49,12 @@ struct async_result_visitor : public fc::visitor<std::string> {

#define TEST_CONTROL_RW_CALL(call_name, http_response_code) CALL(test_control, rw_api, test_control_apis::read_write, call_name, http_response_code)

/*
#define CALL(api_name, api_handle, api_namespace, call_name, http_response_code) \
{std::string("/v1/" #api_name "/" #call_name), \
[this, api_handle](string, string body, url_response_callback cb) mutable { \
try { \
wlog("test_control_api_plugin CALL"); \
wlog("test_control_api_plugin CALL body=${body}",("body",body)); \
if (body.empty()) body = "{}"; \
auto result = api_handle.call_name(fc::json::from_string(body).as<api_namespace::call_name ## _params>()); \
cb(http_response_code, fc::json::to_string(result)); \
} catch (...) { \
http_plugin::handle_exception(#api_name, #call_name, body, cb); \
} \
}}
#define TEST_CONTROL_RW_CALL(call_name, http_response_code) CALL(test_control, rw_api, test_control_apis::read_write, call_name, http_response_code)
*/
void test_control_api_plugin::plugin_startup() {
ilog( "starting test_control_api_plugin" );
// auto& chain = app().get_plugin<chain_plugin>().chain();
my.reset(new test_control_api_plugin_impl(app().get_plugin<chain_plugin>().chain()));
auto rw_api = app().get_plugin<test_control_plugin>().get_read_write_api();

app().get_plugin<http_plugin>().add_api({
// TEST_CONTROL_RW_CALL(kill_node_on_producer, 202)
{std::string("/v1/test_control/kill_node_on_producer"),
[this, rw_api](string, string body, url_response_callback cb) mutable {
wlog("test_control_api_plugin CALL");
try {
if (body.empty()) body = "{}";
auto result = rw_api.kill_node_on_producer(fc::json::from_string(body).as<test_control_apis::read_write::kill_node_on_producer_params>());
cb(202, fc::json::to_string(result));
} catch (...) {
http_plugin::handle_exception("rw_api", "kill_node_on_producer", body, cb);
}
}}
TEST_CONTROL_RW_CALL(kill_node_on_producer, 202)
});
}

Expand Down

0 comments on commit 1a0eba2

Please sign in to comment.