Skip to content

Commit 6e56261

Browse files
committed
Add tests for es_plugin::get_operation_by_id()
1 parent 6a6ba4a commit 6e56261

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

tests/elasticsearch/main.cpp

+11-1
Original file line numberDiff line numberDiff line change
@@ -357,8 +357,8 @@ BOOST_AUTO_TEST_CASE(elasticsearch_history_api) {
357357

358358
generate_block();
359359

360+
// Test history APIs
360361
graphene::app::history_api hist_api(app);
361-
app.enable_plugin("elasticsearch");
362362

363363
// f(A, 0, 4, 9) = { 5, 3, 1, 0 }
364364
auto histories = hist_api.get_account_history(
@@ -652,6 +652,16 @@ BOOST_AUTO_TEST_CASE(elasticsearch_history_api) {
652652
BOOST_CHECK_EQUAL(histories[2].id.instance(), 3u);
653653
BOOST_CHECK_EQUAL(histories[3].id.instance(), 1u);
654654
BOOST_CHECK_EQUAL(histories[4].id.instance(), 0u);
655+
656+
// Ugly test to cover elasticsearch_plugin::get_operation_by_id()
657+
if( !app.elasticsearch_thread )
658+
app.elasticsearch_thread = std::make_shared<fc::thread>("elasticsearch");
659+
auto es_plugin = app.get_plugin< graphene::elasticsearch::elasticsearch_plugin >("elasticsearch");
660+
auto his_obj7 = app.elasticsearch_thread->async([&es_plugin]() {
661+
return es_plugin->get_operation_by_id( operation_history_id_type(7) );
662+
}, "thread invoke for method " BOOST_PP_STRINGIZE(method_name)).wait();
663+
BOOST_REQUIRE( his_obj7.op.is_type<account_create_operation>() );
664+
BOOST_CHECK_EQUAL( his_obj7.op.get<account_create_operation>().name, "alice" );
655665
}
656666
}
657667
catch (fc::exception &e) {

0 commit comments

Comments
 (0)