Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add OSO tests for ES #2762

Merged
merged 1 commit into from
Jul 2, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 18 additions & 2 deletions tests/elasticsearch/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,10 @@ BOOST_AUTO_TEST_CASE(elasticsearch_objects) {
// The head block number is 1
BOOST_CHECK_EQUAL( db.head_block_num(), 1u );

generate_blocks( HARDFORK_CORE_2535_TIME ); // For Order-Sends-Take-Profit-Order
generate_block();
set_expiration( db, trx );

// delete all first, this will delete genesis data and data inserted at block 1
auto delete_objects = graphene::utilities::deleteAll(es);
BOOST_REQUIRE(delete_objects); // require successful deletion
Expand Down Expand Up @@ -272,9 +276,13 @@ BOOST_AUTO_TEST_CASE(elasticsearch_objects) {
auto bitasset_object_id = j["hits"]["hits"][size_t(0)]["_source"]["object_id"].as_string();
BOOST_CHECK_EQUAL(bitasset_object_id, bitasset_data_id);

// fee_asset, spread, size, expiration, repeat
create_take_profit_order_action tpa1 { asset_id_type(), 300, 9900, 86400, true };
vector<limit_order_auto_action> on_fill_1 { tpa1 };
// create a limit order that expires at the next maintenance time
create_sell_order( account_id_type(), asset(1), asset(1, usd_id),
db.get_dynamic_global_properties().next_maintenance_time );
db.get_dynamic_global_properties().next_maintenance_time,
price::unit_price(), on_fill_1 );
generate_block();

es.endpoint = es.index_prefix + "limitorder/_count";
Expand Down Expand Up @@ -342,6 +350,10 @@ BOOST_AUTO_TEST_CASE(elasticsearch_history_api) {
es.elasticsearch_url = GRAPHENE_TESTING_ES_URL;
es.index_prefix = es_index_prefix;

generate_blocks( HARDFORK_CORE_2535_TIME ); // For Order-Sends-Take-Profit-Order
generate_block();
set_expiration( db, trx );

auto delete_account_history = graphene::utilities::deleteAll(es);
BOOST_REQUIRE(delete_account_history); // require successful deletion

Expand Down Expand Up @@ -673,8 +685,12 @@ BOOST_AUTO_TEST_CASE(elasticsearch_history_api) {

// Prepare funds
transfer( account_id_type()(db), alice_id(db), asset(100) );
// fee_asset, spread, size, expiration, repeat
create_take_profit_order_action tpa1 { asset_id_type(), 100, 10000, 86400, false };
vector<limit_order_auto_action> on_fill_1 { tpa1 };
// Create a limit order that expires in 300 seconds
create_sell_order( alice_id, asset(1), asset(1, asset_id_type(1)), db.head_block_time() + 300 );
create_sell_order( alice_id, asset(1), asset(1, asset_id_type(1)), db.head_block_time() + 300,
price::unit_price(), on_fill_1 );

generate_block();

Expand Down