Skip to content

Commit

Permalink
Add tests for storing budget records in ES
Browse files Browse the repository at this point in the history
  • Loading branch information
abitmore committed Jan 3, 2022
1 parent 827340a commit 6f4e491
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion tests/elasticsearch/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -259,11 +259,31 @@ BOOST_AUTO_TEST_CASE(elasticsearch_objects) {

auto bitasset_data_id = j["hits"]["hits"][size_t(0)]["_source"]["bitasset_data_id"].as_string();
es.endpoint = es.index_prefix + "bitasset/_doc/_search";
es.query = "{ \"query\" : { \"bool\": { \"must\" : [{ \"term\": { \"object_id\": \""+bitasset_data_id+"\"}}] } } }";
es.query = "{ \"query\" : { \"bool\": { \"must\" : [{ \"term\": { \"object_id\": \""
+ bitasset_data_id + "\"}}] } } }";
res = graphene::utilities::simpleQuery(es);
j = fc::json::from_string(res);
auto bitasset_object_id = j["hits"]["hits"][size_t(0)]["_source"]["object_id"].as_string();
BOOST_CHECK_EQUAL(bitasset_object_id, bitasset_data_id);

// maintenance, for budget records
generate_blocks( db.get_dynamic_global_properties().next_maintenance_time );
generate_block();

es.endpoint = es.index_prefix + "budget/_doc/_count";
es.query = "";
fc::wait_for( ES_WAIT_TIME, [&]() {
res = graphene::utilities::getEndPoint(es);
j = fc::json::from_string(res);
if( !j.is_object() )
return false;
const auto& obj = j.get_object();
if( obj.find("count") == obj.end() )
return false;
total = obj["count"].as_string();
return (total == "2"); // the first from block one, the second from the first maintenance block
});

}
}
catch (fc::exception &e) {
Expand Down

0 comments on commit 6f4e491

Please sign in to comment.