From 2f0dfee908e4ce02120568e67ec7d7c0dc0e3fce Mon Sep 17 00:00:00 2001 From: abitmore Date: Sun, 8 Jan 2023 09:51:46 +0000 Subject: [PATCH] Add tests for es_plugin::get_operation_by_id() --- tests/elasticsearch/main.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/tests/elasticsearch/main.cpp b/tests/elasticsearch/main.cpp index e5a7bc34b..bba0ce188 100644 --- a/tests/elasticsearch/main.cpp +++ b/tests/elasticsearch/main.cpp @@ -357,8 +357,8 @@ BOOST_AUTO_TEST_CASE(elasticsearch_history_api) { generate_block(); + // Test history APIs graphene::app::history_api hist_api(app); - app.enable_plugin("elasticsearch"); // f(A, 0, 4, 9) = { 5, 3, 1, 0 } auto histories = hist_api.get_account_history( @@ -652,6 +652,16 @@ BOOST_AUTO_TEST_CASE(elasticsearch_history_api) { BOOST_CHECK_EQUAL(histories[2].id.instance(), 3u); BOOST_CHECK_EQUAL(histories[3].id.instance(), 1u); BOOST_CHECK_EQUAL(histories[4].id.instance(), 0u); + + // Ugly test to cover elasticsearch_plugin::get_operation_by_id() + if( !app.elasticsearch_thread ) + app.elasticsearch_thread = std::make_shared("elasticsearch"); + auto es_plugin = app.get_plugin< graphene::elasticsearch::elasticsearch_plugin >("elasticsearch"); + auto his_obj7 = app.elasticsearch_thread->async([&es_plugin]() { + return es_plugin->get_operation_by_id( operation_history_id_type(7) ); + }, "thread invoke for method " BOOST_PP_STRINGIZE(method_name)).wait(); + BOOST_REQUIRE( his_obj7.op.is_type() ); + BOOST_CHECK_EQUAL( his_obj7.op.get().name, "alice" ); } } catch (fc::exception &e) {