21
21
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22
22
* THE SOFTWARE.
23
23
*/
24
+ #include < boost/test/unit_test.hpp>
24
25
#include < boost/program_options.hpp>
25
26
#include < boost/range.hpp>
26
27
#include < boost/tuple/tuple.hpp>
27
28
28
29
#include < fc/optional.hpp>
29
30
30
31
#include < graphene/voting_stat/voting_stat_plugin.hpp>
31
- #include < graphene/es_objects/es_objects.hpp>
32
- #include < graphene/utilities/elasticsearch.hpp>
32
+ // #include <graphene/es_objects/es_objects.hpp>
33
+ // #include <graphene/utilities/elasticsearch.hpp>
33
34
34
35
#include < graphene/app/api.hpp>
35
36
36
37
#include < graphene/protocol/account.hpp>
37
38
38
- #include < graphene/chain /voting_statistics_object.hpp>
39
- #include < graphene/chain /voteable_statistics_object.hpp>
39
+ #include < graphene/voting_stat /voting_statistics_object.hpp>
40
+ #include < graphene/voting_stat /voteable_statistics_object.hpp>
40
41
41
42
#include " ../common/database_fixture.hpp"
42
43
43
- #define BOOST_TEST_MODULE Voting Statistics Plugin Test
44
- #include < boost/test/included/unit_test.hpp>
45
-
46
44
using namespace fc ;
47
45
using namespace graphene ::app;
48
46
using namespace graphene ::chain;
49
47
using namespace graphene ::chain::test;
50
48
using namespace graphene ::voting_stat;
51
- using namespace graphene ::es_objects;
49
+ // using namespace graphene::es_objects;
52
50
using namespace graphene ::utilities;
53
51
namespace bpo = boost::program_options;
54
52
55
53
struct voting_stat_fixture : public database_fixture
56
54
{
57
55
vote_id_type default_vote_id;
58
- CURL *_curl;
59
- ES _es;
56
+ // CURL *_curl;
57
+ // ES _es;
60
58
61
59
voting_stat_fixture ()
62
60
{
63
61
try
64
62
{
65
- _curl = curl_easy_init ();
66
- _es.curl = _curl;
67
- _es.elasticsearch_url = " http://localhost:9200/" ;
68
- _es.index_prefix = " objects-" ;
63
+ // _curl = curl_easy_init();
64
+ // _es.curl = _curl;
65
+ // _es.elasticsearch_url = "http://localhost:9200/";
66
+ // _es.index_prefix = "objects-";
69
67
70
68
app.register_plugin <voting_stat_plugin>( true );
71
- app.register_plugin <es_objects_plugin>( true );
69
+ // app.register_plugin<es_objects_plugin>( true );
72
70
}
73
71
catch (fc::exception &e)
74
72
{
@@ -181,8 +179,8 @@ BOOST_AUTO_TEST_CASE( test_voting_statistics_with_proxy_delete_after_interval )
181
179
auto voting_stat = app.get_plugin <voting_stat_plugin>(" voting_stat" );
182
180
voting_stat->plugin_set_program_options ( cli_vs, cfg );
183
181
184
- auto es_objects = app.get_plugin <es_objects_plugin>(" es_objects" );
185
- es_objects->plugin_set_program_options ( cli_es, cfg );
182
+ // auto es_objects = app.get_plugin<es_objects_plugin>("es_objects");
183
+ // es_objects->plugin_set_program_options( cli_es, cfg );
186
184
187
185
const char * const plugin_argv[]{ " voting_stat" ,
188
186
" --voting-stat-track-every-x-maint" , " 1" ,
@@ -191,24 +189,24 @@ BOOST_AUTO_TEST_CASE( test_voting_statistics_with_proxy_delete_after_interval )
191
189
" --voting-stat-track-committee-votes" , " false" ,
192
190
" --voting-stat-track-worker-votes" , " false" ,
193
191
194
- " --es-objects-bulk-replay" , " 1" ,
195
- " --es-objects-proposals" , " false" ,
196
- " --es-objects-accounts" , " false" ,
197
- " --es-objects-assets" , " false" ,
198
- " --es-objects-balances" , " false" ,
199
- " --es-objects-limit-orders" , " false" ,
200
- " --es-objects-asset-bitasset" , " false" ,
201
- " --es-objects-keep-only-current" , " true" ,
192
+ // "--es-objects-bulk-replay", "1",
193
+ // "--es-objects-proposals", "false",
194
+ // "--es-objects-accounts", "false",
195
+ // "--es-objects-assets", "false",
196
+ // "--es-objects-balances", "false",
197
+ // "--es-objects-limit-orders", "false",
198
+ // "--es-objects-asset-bitasset", "false",
199
+ // "--es-objects-keep-only-current", "true",
202
200
};
203
201
int plugin_argc = sizeof (plugin_argv)/sizeof (char *);
204
202
205
203
bpo::variables_map var_map;
206
204
bpo::store ( bpo::parse_command_line ( plugin_argc, plugin_argv, cfg ), var_map );
207
205
app.initialize_plugins ( var_map );
208
206
209
- auto objects_deleted = graphene::utilities::deleteAll (_es);
210
- if ( !objects_deleted )
211
- BOOST_FAIL ( " elastic search DB could not be deleted" );
207
+ // auto objects_deleted = graphene::utilities::deleteAll(_es);
208
+ // if( !objects_deleted )
209
+ // BOOST_FAIL( "elastic search DB could not be deleted" );
212
210
213
211
214
212
ACTORS ( (alice)(bob)(charlie) );
@@ -313,13 +311,13 @@ BOOST_AUTO_TEST_CASE( test_voting_statistics_with_proxy_delete_after_interval )
313
311
BOOST_CHECK ( charlie_stat.get_total_voting_stake () == 222 );
314
312
}
315
313
316
- fc::usleep (fc::milliseconds (2000 ));
317
- string query = " { \" query\" : { \" bool\" : { \" must\" : [{\" match_all\" : {}}] } } }" ;
318
- _es.endpoint = _es.index_prefix + " */data/_count" ;
319
- _es.query = query;
320
- auto res = graphene::utilities::simpleQuery (_es);
321
- variant j = fc::json::from_string (res);
322
- BOOST_CHECK ( j[" count" ].as_int64 () == 12 );
314
+ // fc::usleep(fc::milliseconds(2000));
315
+ // string query = "{ \"query\" : { \"bool\" : { \"must\" : [{\"match_all\": {}}] } } }";
316
+ // _es.endpoint = _es.index_prefix + "*/data/_count";
317
+ // _es.query = query;
318
+ // auto res = graphene::utilities::simpleQuery(_es);
319
+ // variant j = fc::json::from_string(res);
320
+ // BOOST_CHECK( j["count"].as_int64() == 12 );
323
321
324
322
} FC_LOG_AND_RETHROW () }
325
323
@@ -335,8 +333,8 @@ BOOST_AUTO_TEST_CASE( test_voting_statistics_with_proxy_keep_after_interval )
335
333
auto voting_stat = app.get_plugin <voting_stat_plugin>(" voting_stat" );
336
334
voting_stat->plugin_set_program_options ( cli_vs, cfg );
337
335
338
- auto es_objects = app.get_plugin <es_objects_plugin>(" es_objects" );
339
- es_objects->plugin_set_program_options ( cli_es, cfg );
336
+ // auto es_objects = app.get_plugin<es_objects_plugin>("es_objects");
337
+ // es_objects->plugin_set_program_options( cli_es, cfg );
340
338
341
339
const char * const plugin_argv[]{ " voting_stat" ,
342
340
" --voting-stat-track-every-x-maint" , " 1" ,
@@ -345,24 +343,24 @@ BOOST_AUTO_TEST_CASE( test_voting_statistics_with_proxy_keep_after_interval )
345
343
" --voting-stat-track-committee-votes" , " false" ,
346
344
" --voting-stat-track-worker-votes" , " false" ,
347
345
348
- " --es-objects-bulk-replay" , " 1" ,
349
- " --es-objects-proposals" , " false" ,
350
- " --es-objects-accounts" , " false" ,
351
- " --es-objects-assets" , " false" ,
352
- " --es-objects-balances" , " false" ,
353
- " --es-objects-limit-orders" , " false" ,
354
- " --es-objects-asset-bitasset" , " false" ,
355
- " --es-objects-keep-only-current" , " true" ,
346
+ // "--es-objects-bulk-replay", "1",
347
+ // "--es-objects-proposals", "false",
348
+ // "--es-objects-accounts", "false",
349
+ // "--es-objects-assets", "false",
350
+ // "--es-objects-balances", "false",
351
+ // "--es-objects-limit-orders", "false",
352
+ // "--es-objects-asset-bitasset", "false",
353
+ // "--es-objects-keep-only-current", "true",
356
354
};
357
355
int plugin_argc = sizeof (plugin_argv)/sizeof (char *);
358
356
359
357
bpo::variables_map var_map;
360
358
bpo::store ( bpo::parse_command_line ( plugin_argc, plugin_argv, cfg ), var_map );
361
359
app.initialize_plugins ( var_map );
362
360
363
- auto objects_deleted = graphene::utilities::deleteAll (_es);
364
- if ( !objects_deleted )
365
- BOOST_FAIL ( " elastic search DB could not be deleted" );
361
+ // auto objects_deleted = graphene::utilities::deleteAll(_es);
362
+ // if( !objects_deleted )
363
+ // BOOST_FAIL( "elastic search DB could not be deleted" );
366
364
367
365
368
366
ACTORS ( (alice)(bob)(charlie) );
@@ -467,13 +465,13 @@ BOOST_AUTO_TEST_CASE( test_voting_statistics_with_proxy_keep_after_interval )
467
465
BOOST_CHECK ( charlie_stat.get_total_voting_stake () == 222 );
468
466
}
469
467
470
- fc::usleep (fc::milliseconds (2000 ));
471
- string query = " { \" query\" : { \" bool\" : { \" must\" : [{\" match_all\" : {}}] } } }" ;
472
- _es.endpoint = _es.index_prefix + " */data/_count" ;
473
- _es.query = query;
474
- auto res = graphene::utilities::simpleQuery (_es);
475
- variant j = fc::json::from_string (res);
476
- BOOST_CHECK ( j[" count" ].as_int64 () == 12 );
468
+ // fc::usleep(fc::milliseconds(2000));
469
+ // string query = "{ \"query\" : { \"bool\" : { \"must\" : [{\"match_all\": {}}] } } }";
470
+ // _es.endpoint = _es.index_prefix + "*/data/_count";
471
+ // _es.query = query;
472
+ // auto res = graphene::utilities::simpleQuery(_es);
473
+ // variant j = fc::json::from_string(res);
474
+ // BOOST_CHECK( j["count"].as_int64() == 12 );
477
475
478
476
} FC_LOG_AND_RETHROW () }
479
477
@@ -487,8 +485,8 @@ BOOST_AUTO_TEST_CASE( test_voteable_objects_tracking_with_es )
487
485
auto voting_stat = app.get_plugin <voting_stat_plugin>(" voting_stat" );
488
486
voting_stat->plugin_set_program_options ( cli_vs, cfg );
489
487
490
- auto es_objects = app.get_plugin <es_objects_plugin>(" es_objects" );
491
- es_objects->plugin_set_program_options ( cli_es, cfg );
488
+ // auto es_objects = app.get_plugin<es_objects_plugin>("es_objects");
489
+ // es_objects->plugin_set_program_options( cli_es, cfg );
492
490
493
491
const char * const plugin_argv[]{ " voting_stat" ,
494
492
" --voting-stat-track-every-x-maint" , " 1" ,
@@ -497,28 +495,28 @@ BOOST_AUTO_TEST_CASE( test_voteable_objects_tracking_with_es )
497
495
" --voting-stat-track-witness-votes" , " true" ,
498
496
" --voting-stat-track-committee-votes" , " true" ,
499
497
500
- " --es-objects-voting-statistics" , " true" ,
501
- " --es-objects-voteable-statistics" , " true" ,
502
- " --es-objects-statistics-delete-allowed" , " false" ,
503
-
504
- " --es-objects-bulk-replay" , " 1" ,
505
- " --es-objects-proposals" , " false" ,
506
- " --es-objects-accounts" , " false" ,
507
- " --es-objects-assets" , " false" ,
508
- " --es-objects-balances" , " false" ,
509
- " --es-objects-limit-orders" , " false" ,
510
- " --es-objects-asset-bitasset" , " false" ,
511
- " --es-objects-keep-only-current" , " true" ,
498
+ // "--es-objects-voting-statistics", "true",
499
+ // "--es-objects-voteable-statistics", "true",
500
+ // "--es-objects-statistics-delete-allowed", "false",
501
+
502
+ // "--es-objects-bulk-replay", "1",
503
+ // "--es-objects-proposals", "false",
504
+ // "--es-objects-accounts", "false",
505
+ // "--es-objects-assets", "false",
506
+ // "--es-objects-balances", "false",
507
+ // "--es-objects-limit-orders", "false",
508
+ // "--es-objects-asset-bitasset", "false",
509
+ // "--es-objects-keep-only-current", "true",
512
510
};
513
511
int plugin_argc = sizeof (plugin_argv)/sizeof (char *);
514
512
515
513
bpo::variables_map var_map;
516
514
bpo::store ( bpo::parse_command_line ( plugin_argc, plugin_argv, cfg ), var_map );
517
515
app.initialize_plugins ( var_map );
518
516
519
- auto objects_deleted = graphene::utilities::deleteAll (_es);
520
- if ( !objects_deleted )
521
- BOOST_FAIL ( " elastic search DB could not be deleted" );
517
+ // auto objects_deleted = graphene::utilities::deleteAll(_es);
518
+ // if( !objects_deleted )
519
+ // BOOST_FAIL( "elastic search DB could not be deleted" );
522
520
523
521
524
522
ACTOR ( alice );
@@ -553,16 +551,16 @@ BOOST_AUTO_TEST_CASE( test_voteable_objects_tracking_with_es )
553
551
BOOST_CHECK ( voteable_idx.size () == expected_voteables );
554
552
555
553
556
- auto expected_objs_in_es = 2 *(expected_voteables + 1 );
554
+ // auto expected_objs_in_es = 2*(expected_voteables + 1);
557
555
558
- fc::usleep (fc::milliseconds (2000 ));
559
- string query = " { \" query\" : { \" bool\" : { \" must\" : [{\" match_all\" : {}}] } } }" ;
560
- _es.endpoint = _es.index_prefix + " */data/_count" ;
561
- _es.query = query;
562
- auto res = graphene::utilities::simpleQuery (_es);
563
- variant j = fc::json::from_string (res);
564
- uint64_t obj_count = j[" count" ].as_uint64 ();
565
- BOOST_CHECK ( obj_count == expected_objs_in_es );
556
+ // fc::usleep(fc::milliseconds(2000));
557
+ // string query = "{ \"query\" : { \"bool\" : { \"must\" : [{\"match_all\": {}}] } } }";
558
+ // _es.endpoint = _es.index_prefix + "*/data/_count";
559
+ // _es.query = query;
560
+ // auto res = graphene::utilities::simpleQuery(_es);
561
+ // variant j = fc::json::from_string(res);
562
+ // uint64_t obj_count = j["count"].as_uint64();
563
+ // BOOST_CHECK( obj_count == expected_objs_in_es );
566
564
567
565
} FC_LOG_AND_RETHROW () }
568
566
@@ -621,35 +619,35 @@ BOOST_AUTO_TEST_CASE( test_delete_after_interval_and_pushed_to_es )
621
619
auto voting_stat = app.get_plugin <voting_stat_plugin>(" voting_stat" );
622
620
voting_stat->plugin_set_program_options ( cli_vs, cfg );
623
621
624
- auto es_objects = app.get_plugin <es_objects_plugin>(" es_objects" );
625
- es_objects->plugin_set_program_options ( cli_es, cfg );
622
+ // auto es_objects = app.get_plugin<es_objects_plugin>("es_objects");
623
+ // es_objects->plugin_set_program_options( cli_es, cfg );
626
624
627
625
const char * const plugin_argv[]{ " voting_stat" ,
628
626
" --voting-stat-track-every-x-maint" , " 1" ,
629
627
" --voting-stat-keep-objects-in-db" , " false" ,
630
628
631
- " --es-objects-voting-statistics" , " true" ,
632
- " --es-objects-voteable-statistics" , " false" ,
633
- " --es-objects-statistics-delete-allowed" , " false" ,
634
-
635
- " --es-objects-bulk-replay" , " 1" ,
636
- " --es-objects-proposals" , " false" ,
637
- " --es-objects-accounts" , " false" ,
638
- " --es-objects-assets" , " false" ,
639
- " --es-objects-balances" , " false" ,
640
- " --es-objects-limit-orders" , " false" ,
641
- " --es-objects-asset-bitasset" , " false" ,
642
- " --es-objects-keep-only-current" , " true" ,
629
+ // "--es-objects-voting-statistics", "true",
630
+ // "--es-objects-voteable-statistics", "false",
631
+ // "--es-objects-statistics-delete-allowed", "false",
632
+
633
+ // "--es-objects-bulk-replay", "1",
634
+ // "--es-objects-proposals", "false",
635
+ // "--es-objects-accounts", "false",
636
+ // "--es-objects-assets", "false",
637
+ // "--es-objects-balances", "false",
638
+ // "--es-objects-limit-orders", "false",
639
+ // "--es-objects-asset-bitasset", "false",
640
+ // "--es-objects-keep-only-current", "true",
643
641
};
644
642
int plugin_argc = sizeof (plugin_argv)/sizeof (char *);
645
643
646
644
bpo::variables_map var_map;
647
645
bpo::store ( bpo::parse_command_line ( plugin_argc, plugin_argv, cfg ), var_map );
648
646
app.initialize_plugins ( var_map );
649
647
650
- auto objects_deleted = graphene::utilities::deleteAll (_es);
651
- if ( !objects_deleted )
652
- BOOST_FAIL ( " elastic search DB could not be deleted" );
648
+ // auto objects_deleted = graphene::utilities::deleteAll(_es);
649
+ // if( !objects_deleted )
650
+ // BOOST_FAIL( "elastic search DB could not be deleted" );
653
651
654
652
655
653
const auto & idx = db.get_index_type <voting_statistics_index>().indices ().get <by_block_number>();
@@ -672,14 +670,14 @@ BOOST_AUTO_TEST_CASE( test_delete_after_interval_and_pushed_to_es )
672
670
BOOST_CHECK ( idx.size () == 1 );
673
671
674
672
675
- fc::usleep (fc::milliseconds (2000 ));
676
- string query = " { \" query\" : { \" bool\" : { \" must\" : [{\" match_all\" : {}}] } } }" ;
677
- _es.endpoint = _es.index_prefix + " */data/_count" ;
678
- _es.query = query;
679
- auto res = graphene::utilities::simpleQuery (_es);
680
- variant j = fc::json::from_string (res);
681
- int64_t obj_count = j[" count" ].as_int64 ();
682
- BOOST_CHECK ( obj_count == 3 );
673
+ // fc::usleep(fc::milliseconds(2000));
674
+ // string query = "{ \"query\" : { \"bool\" : { \"must\" : [{\"match_all\": {}}] } } }";
675
+ // _es.endpoint = _es.index_prefix + "*/data/_count";
676
+ // _es.query = query;
677
+ // auto res = graphene::utilities::simpleQuery(_es);
678
+ // variant j = fc::json::from_string(res);
679
+ // int64_t obj_count = j["count"].as_int64();
680
+ // BOOST_CHECK( obj_count == 3 );
683
681
684
682
} FC_LOG_AND_RETHROW () }
685
683
0 commit comments