From 60267992fd97bc2f8f86fe1475b9111b53c218f2 Mon Sep 17 00:00:00 2001 From: Michael Vandeberg Date: Fri, 3 Jun 2016 09:48:17 -0400 Subject: [PATCH] Finish testing of plugin objects. API needs testing for correctness #69 --- .gitignore | 1 + .../market_history/market_history_plugin.hpp | 12 +- .../market_history/market_history_plugin.cpp | 21 +- tests/CMakeLists.txt | 6 +- tests/plugin_tests/main.cpp | 40 ++ tests/plugin_tests/market_history.cpp | 353 ++++++++++++++++++ tests/tests/operation_time_tests.cpp | 5 - 7 files changed, 408 insertions(+), 30 deletions(-) create mode 100644 tests/plugin_tests/main.cpp create mode 100644 tests/plugin_tests/market_history.cpp diff --git a/.gitignore b/.gitignore index 5490abcece..935b72bfae 100644 --- a/.gitignore +++ b/.gitignore @@ -31,6 +31,7 @@ programs/util/inflation_model tests/app_test tests/chain_bench tests/chain_test +tests/plugin_test tests/intense_test tests/performance_test diff --git a/libraries/plugins/market_history/include/steemit/market_history/market_history_plugin.hpp b/libraries/plugins/market_history/include/steemit/market_history/market_history_plugin.hpp index 2c9d50ecc0..cf485c4754 100644 --- a/libraries/plugins/market_history/include/steemit/market_history/market_history_plugin.hpp +++ b/libraries/plugins/market_history/include/steemit/market_history/market_history_plugin.hpp @@ -59,8 +59,8 @@ struct bucket_object : public abstract_object< bucket_object > static const uint8_t space_id = MARKET_HISTORY_SPACE_ID; static const uint8_t type_id = 1; - price high()const { return asset( high_steem, STEEM_SYMBOL ) / asset( high_sbd, SBD_SYMBOL ); } - price low()const { return asset( low_steem, STEEM_SYMBOL ) / asset( high_sbd, SBD_SYMBOL ); } + price high()const { return asset( high_sbd, SBD_SYMBOL ) / asset( high_steem, STEEM_SYMBOL ); } + price low()const { return asset( low_sbd, SBD_SYMBOL ) / asset( low_steem, STEEM_SYMBOL ); } fc::time_point_sec open; uint32_t seconds = 0; @@ -78,12 +78,11 @@ struct bucket_object : public abstract_object< bucket_object > struct order_history_object : public abstract_object< order_history_object > { - uint64_t sequence; fc::time_point_sec time; fill_order_operation op; }; -struct by_id; +//struct by_id; struct by_bucket; typedef multi_index_container< bucket_object, @@ -99,14 +98,12 @@ typedef multi_index_container< > > bucket_object_multi_index_type; -struct by_sequence; struct by_time; typedef multi_index_container< order_history_object, indexed_by< hashed_unique< tag< by_id >, member< object, object_id_type, &object::id > >, - ordered_unique< tag< by_sequence >, member< order_history_object, uint64_t, &order_history_object::sequence > >, - ordered_unique< tag< by_time >, member< order_history_object, time_point_sec, &order_history_object::time > > + ordered_non_unique< tag< by_time >, member< order_history_object, time_point_sec, &order_history_object::time > > > > order_history_multi_index_type; @@ -124,6 +121,5 @@ FC_REFLECT_DERIVED( steemit::market_history::bucket_object, (graphene::db::objec (steem_volume)(sbd_volume) ) FC_REFLECT_DERIVED( steemit::market_history::order_history_object, (graphene::db::object), - (sequence) (time) (op) ) diff --git a/libraries/plugins/market_history/market_history_plugin.cpp b/libraries/plugins/market_history/market_history_plugin.cpp index fc1b9bc0ac..578c9dce8c 100644 --- a/libraries/plugins/market_history/market_history_plugin.cpp +++ b/libraries/plugins/market_history/market_history_plugin.cpp @@ -21,32 +21,23 @@ class market_history_plugin_impl void update_market_histories( const operation_object& b ); market_history_plugin& _self; - flat_set _tracked_buckets = { 15, 50, 300, 3600, 86400 }; + flat_set _tracked_buckets = { 15, 60, 300, 3600, 86400 }; int32_t _maximum_history_per_bucket_size = 1000; }; void market_history_plugin_impl::update_market_histories( const operation_object& o ) { - try + if( o.op.which() == operation::tag< fill_order_operation >::value ) { fill_order_operation op = o.op.get< fill_order_operation >(); auto& db = _self.database(); const auto& bucket_idx = db.get_index_type< bucket_index >().indices().get< by_bucket >(); - const auto& history_idx = db.get_index_type< order_history_index >().indices().get< by_sequence >(); - - uint64_t history_seq = std::numeric_limits< uint64_t >::max(); - auto hist_itr = history_idx.upper_bound( history_seq ); - - if ( hist_itr != history_idx.end() ) - history_seq = hist_itr->sequence + 1; - else - history_seq = 0; + uint64_t history_seq = std::numeric_limits< uint64_t >::min(); db.create< order_history_object >( [&]( order_history_object& ho ) { - ho.sequence = history_seq; ho.time = db.head_block_time(); ho.op = op; }); @@ -79,7 +70,6 @@ void market_history_plugin_impl::update_market_histories( const operation_object b.close_sbd = op.receives.amount; b.steem_volume = op.pays.amount; b.sbd_volume = op.receives.amount; - }); } else @@ -90,13 +80,13 @@ void market_history_plugin_impl::update_market_histories( const operation_object b.close_steem = op.pays.amount; b.close_sbd = op.receives.amount; - if( b.high() < price( op.pays, op.receives ) ) + if( b.high() < price( op.receives, op.pays ) ) { b.high_steem = op.pays.amount; b.high_sbd = op.receives.amount; } - if( b.low() > price( op.pays, op.receives ) ) + if( b.low() > price( op.receives, op.pays ) ) { b.low_steem = op.pays.amount; b.low_sbd = op.receives.amount; @@ -118,7 +108,6 @@ void market_history_plugin_impl::update_market_histories( const operation_object } } } - catch ( fc::assert_exception ) { return; } } } // detail diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index da778a47b5..51eb4f0a8b 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -8,7 +8,11 @@ endif() file(GLOB UNIT_TESTS "tests/*.cpp") add_executable( chain_test ${UNIT_TESTS} ${COMMON_SOURCES} ) -target_link_libraries( chain_test steemit_chain steemit_app steemit_account_history fc ${PLATFORM_SPECIFIC_LIBS} ) +target_link_libraries( chain_test steemit_chain steemit_app steemit_account_history steemit_market_history fc ${PLATFORM_SPECIFIC_LIBS} ) + +file(GLOB PLUGIN_TESTS "plugin_tests/*.cpp") +add_executable( plugin_test ${PLUGIN_TESTS} ${COMMON_SOURCES} ) +target_link_libraries( plugin_test steemit_chain steemit_app steemit_account_history steemit_market_history fc ${PLATFORM_SPECIFIC_LIBS} ) if(MSVC) set_source_files_properties( tests/serialization_tests.cpp PROPERTIES COMPILE_FLAGS "/bigobj" ) diff --git a/tests/plugin_tests/main.cpp b/tests/plugin_tests/main.cpp new file mode 100644 index 0000000000..7b54d55e50 --- /dev/null +++ b/tests/plugin_tests/main.cpp @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2015 Cryptonomex, Inc., and contributors. + * + * The MIT License + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +#include +#include +#include + +extern uint32_t STEEMIT_TESTING_GENESIS_TIMESTAMP; + +boost::unit_test::test_suite* init_unit_test_suite(int argc, char* argv[]) { + std::srand(time(NULL)); + std::cout << "Random number generator seeded to " << time(NULL) << std::endl; + const char* genesis_timestamp_str = getenv("STEEMIT_TESTING_GENESIS_TIMESTAMP"); + if( genesis_timestamp_str != nullptr ) + { + STEEMIT_TESTING_GENESIS_TIMESTAMP = std::stoul( genesis_timestamp_str ); + } + std::cout << "STEEMIT_TESTING_GENESIS_TIMESTAMP is " << STEEMIT_TESTING_GENESIS_TIMESTAMP << std::endl; + return nullptr; +} diff --git a/tests/plugin_tests/market_history.cpp b/tests/plugin_tests/market_history.cpp new file mode 100644 index 0000000000..bbafea8b5c --- /dev/null +++ b/tests/plugin_tests/market_history.cpp @@ -0,0 +1,353 @@ +#ifdef IS_TEST_NET +#include + +#include +#include +#include + +#include + +#include "../common/database_fixture.hpp" + +using namespace steemit::chain; +using namespace steemit::chain::test; + +BOOST_FIXTURE_TEST_SUITE( market_history, clean_database_fixture ) + +BOOST_AUTO_TEST_CASE( mh_test ) +{ + using namespace steemit::market_history; + + try + { + auto mh_plugin = app.register_plugin< market_history_plugin >(); + boost::program_options::variables_map options; + mh_plugin->plugin_set_app( &app ); + mh_plugin->plugin_initialize( options ); + + ACTORS( (alice)(bob)(sam) ); + fund( "alice", 1000000 ); + fund( "bob", 1000000 ); + fund( "sam", 1000000 ); + + set_price_feed( price( ASSET( "0.500 TESTS" ), ASSET( "1.000 TBD" ) ) ); + + signed_transaction tx; + comment_operation comment; + comment.author = "alice"; + comment.permlink = "test"; + comment.parent_permlink = "test"; + comment.title = "foo"; + comment.body = "bar"; + tx.operations.push_back( comment ); + + vote_operation vote; + vote.voter = "alice"; + vote.weight = STEEMIT_100_PERCENT; + vote.author = "alice"; + vote.permlink = "test"; + tx.operations.push_back( vote ); + + tx.set_expiration( db.head_block_time() + STEEMIT_MAX_TIME_UNTIL_EXPIRATION ); + tx.sign( alice_private_key, db.get_chain_id() ); + db.push_transaction( tx, 0 ); + + generate_blocks( db.get_comment( "alice", "test" ).cashout_time ); + + const auto& bucket_idx = db.get_index_type< bucket_index >().indices().get< by_bucket >(); + const auto& order_hist_idx = db.get_index_type< order_history_index >().indices().get< by_id >(); + + BOOST_REQUIRE( bucket_idx.begin() == bucket_idx.end() ); + BOOST_REQUIRE( order_hist_idx.begin() == order_hist_idx.end() ); + validate_database(); + + tx.operations.clear(); + tx.signatures.clear(); + + auto fill_order_a_time = db.head_block_time(); + auto time_a = fc::time_point_sec( ( fill_order_a_time.sec_since_epoch() / 15 ) * 15 ); + + limit_order_create_operation op; + op.owner = "alice"; + op.amount_to_sell = ASSET( "1.000 TBD" ); + op.min_to_receive = ASSET( "2.000 TESTS" ); + tx.operations.push_back( op ); + tx.set_expiration( db.head_block_time() + STEEMIT_MAX_TIME_UNTIL_EXPIRATION ); + tx.sign( alice_private_key, db.get_chain_id() ); + db.push_transaction( tx, 0 ); + + tx.operations.clear(); + tx.signatures.clear(); + + op.owner = "bob"; + op.amount_to_sell = ASSET( "1.500 TESTS" ); + op.min_to_receive = ASSET( "0.750 TBD" ); + tx.operations.push_back( op ); + tx.sign( bob_private_key, db.get_chain_id() ); + db.push_transaction( tx, 0 ); + + generate_blocks( db.head_block_time() + ( 60 * 90 ) ); + + auto fill_order_b_time = db.head_block_time(); + + tx.operations.clear(); + tx.signatures.clear(); + + op.owner = "sam"; + op.amount_to_sell = ASSET( "1.000 TESTS" ); + op.min_to_receive = ASSET( "0.500 TBD" ); + tx.operations.push_back( op ); + tx.set_expiration( db.head_block_time() + STEEMIT_MAX_TIME_UNTIL_EXPIRATION ); + tx.sign( sam_private_key, db.get_chain_id() ); + db.push_transaction( tx, 0 ); + + generate_blocks( db.head_block_time() + 60 ); + + auto fill_order_c_time = db.head_block_time(); + + tx.operations.clear(); + tx.signatures.clear(); + + op.owner = "alice"; + op.amount_to_sell = ASSET( "0.500 TBD" ); + op.min_to_receive = ASSET( "0.900 TESTS" ); + tx.operations.push_back( op ); + tx.set_expiration( db.head_block_time() + STEEMIT_MAX_TIME_UNTIL_EXPIRATION ); + tx.sign( alice_private_key, db.get_chain_id() ); + db.push_transaction( tx, 0 ); + + tx.operations.clear(); + tx.signatures.clear(); + + op.owner = "bob"; + op.amount_to_sell = ASSET( "0.450 TESTS" ); + op.min_to_receive = ASSET( "0.250 TBD" ); + tx.operations.push_back( op ); + tx.set_expiration( db.head_block_time() + STEEMIT_MAX_TIME_UNTIL_EXPIRATION ); + tx.sign( bob_private_key, db.get_chain_id() ); + db.push_transaction( tx, 0 ); + validate_database(); + + auto bucket = bucket_idx.begin(); + + BOOST_REQUIRE( bucket->seconds == 15 ); + BOOST_REQUIRE( bucket->open == time_a ); + BOOST_REQUIRE( bucket->high_steem == ASSET( "1.500 TESTS " ).amount ); + BOOST_REQUIRE( bucket->high_sbd == ASSET( "0.750 TBD" ).amount ); + BOOST_REQUIRE( bucket->low_steem == ASSET( "1.500 TESTS" ).amount ); + BOOST_REQUIRE( bucket->low_sbd == ASSET( "0.750 TBD" ).amount ); + BOOST_REQUIRE( bucket->open_steem == ASSET( "1.500 TESTS" ).amount ); + BOOST_REQUIRE( bucket->open_sbd == ASSET( "0.750 TBD" ).amount ); + BOOST_REQUIRE( bucket->close_steem == ASSET( "1.500 TESTS").amount ); + BOOST_REQUIRE( bucket->close_sbd == ASSET( "0.750 TBD" ).amount ); + BOOST_REQUIRE( bucket->steem_volume == ASSET( "1.500 TESTS" ).amount ); + BOOST_REQUIRE( bucket->sbd_volume == ASSET( "0.750 TBD" ).amount ); + bucket++; + + BOOST_REQUIRE( bucket->seconds == 15 ); + BOOST_REQUIRE( bucket->open == time_a + ( 60 * 90 ) ); + BOOST_REQUIRE( bucket->high_steem == ASSET( "0.500 TESTS " ).amount ); + BOOST_REQUIRE( bucket->high_sbd == ASSET( "0.250 TBD" ).amount ); + BOOST_REQUIRE( bucket->low_steem == ASSET( "0.500 TESTS" ).amount ); + BOOST_REQUIRE( bucket->low_sbd == ASSET( "0.250 TBD" ).amount ); + BOOST_REQUIRE( bucket->open_steem == ASSET( "0.500 TESTS" ).amount ); + BOOST_REQUIRE( bucket->open_sbd == ASSET( "0.250 TBD" ).amount ); + BOOST_REQUIRE( bucket->close_steem == ASSET( "0.500 TESTS").amount ); + BOOST_REQUIRE( bucket->close_sbd == ASSET( "0.250 TBD" ).amount ); + BOOST_REQUIRE( bucket->steem_volume == ASSET( "0.500 TESTS" ).amount ); + BOOST_REQUIRE( bucket->sbd_volume == ASSET( "0.250 TBD" ).amount ); + bucket++; + + BOOST_REQUIRE( bucket->seconds == 15 ); + BOOST_REQUIRE( bucket->open == time_a + ( 60 * 90 ) + 60 ); + BOOST_REQUIRE( bucket->high_steem == ASSET( "0.450 TESTS " ).amount ); + BOOST_REQUIRE( bucket->high_sbd == ASSET( "0.250 TBD" ).amount ); + BOOST_REQUIRE( bucket->low_steem == ASSET( "0.500 TESTS" ).amount ); + BOOST_REQUIRE( bucket->low_sbd == ASSET( "0.250 TBD" ).amount ); + BOOST_REQUIRE( bucket->open_steem == ASSET( "0.500 TESTS" ).amount ); + BOOST_REQUIRE( bucket->open_sbd == ASSET( "0.250 TBD" ).amount ); + BOOST_REQUIRE( bucket->close_steem == ASSET( "0.450 TESTS").amount ); + BOOST_REQUIRE( bucket->close_sbd == ASSET( "0.250 TBD" ).amount ); + BOOST_REQUIRE( bucket->steem_volume == ASSET( "0.950 TESTS" ).amount ); + BOOST_REQUIRE( bucket->sbd_volume == ASSET( "0.500 TBD" ).amount ); + bucket++; + + BOOST_REQUIRE( bucket->seconds == 60 ); + BOOST_REQUIRE( bucket->open == time_a ); + BOOST_REQUIRE( bucket->high_steem == ASSET( "1.500 TESTS " ).amount ); + BOOST_REQUIRE( bucket->high_sbd == ASSET( "0.750 TBD" ).amount ); + BOOST_REQUIRE( bucket->low_steem == ASSET( "1.500 TESTS" ).amount ); + BOOST_REQUIRE( bucket->low_sbd == ASSET( "0.750 TBD" ).amount ); + BOOST_REQUIRE( bucket->open_steem == ASSET( "1.500 TESTS" ).amount ); + BOOST_REQUIRE( bucket->open_sbd == ASSET( "0.750 TBD" ).amount ); + BOOST_REQUIRE( bucket->close_steem == ASSET( "1.500 TESTS").amount ); + BOOST_REQUIRE( bucket->close_sbd == ASSET( "0.750 TBD" ).amount ); + BOOST_REQUIRE( bucket->steem_volume == ASSET( "1.500 TESTS" ).amount ); + BOOST_REQUIRE( bucket->sbd_volume == ASSET( "0.750 TBD" ).amount ); + bucket++; + + BOOST_REQUIRE( bucket->seconds == 60 ); + BOOST_REQUIRE( bucket->open == time_a + ( 60 * 90 ) ); + BOOST_REQUIRE( bucket->high_steem == ASSET( "0.500 TESTS " ).amount ); + BOOST_REQUIRE( bucket->high_sbd == ASSET( "0.250 TBD" ).amount ); + BOOST_REQUIRE( bucket->low_steem == ASSET( "0.500 TESTS" ).amount ); + BOOST_REQUIRE( bucket->low_sbd == ASSET( "0.250 TBD" ).amount ); + BOOST_REQUIRE( bucket->open_steem == ASSET( "0.500 TESTS" ).amount ); + BOOST_REQUIRE( bucket->open_sbd == ASSET( "0.250 TBD" ).amount ); + BOOST_REQUIRE( bucket->close_steem == ASSET( "0.500 TESTS").amount ); + BOOST_REQUIRE( bucket->close_sbd == ASSET( "0.250 TBD" ).amount ); + BOOST_REQUIRE( bucket->steem_volume == ASSET( "0.500 TESTS" ).amount ); + BOOST_REQUIRE( bucket->sbd_volume == ASSET( "0.250 TBD" ).amount ); + bucket++; + + BOOST_REQUIRE( bucket->seconds == 60 ); + BOOST_REQUIRE( bucket->open == time_a + ( 60 * 90 ) + 60 ); + BOOST_REQUIRE( bucket->high_steem == ASSET( "0.450 TESTS " ).amount ); + BOOST_REQUIRE( bucket->high_sbd == ASSET( "0.250 TBD" ).amount ); + BOOST_REQUIRE( bucket->low_steem == ASSET( "0.500 TESTS" ).amount ); + BOOST_REQUIRE( bucket->low_sbd == ASSET( "0.250 TBD" ).amount ); + BOOST_REQUIRE( bucket->open_steem == ASSET( "0.500 TESTS" ).amount ); + BOOST_REQUIRE( bucket->open_sbd == ASSET( "0.250 TBD" ).amount ); + BOOST_REQUIRE( bucket->close_steem == ASSET( "0.450 TESTS").amount ); + BOOST_REQUIRE( bucket->close_sbd == ASSET( "0.250 TBD" ).amount ); + BOOST_REQUIRE( bucket->steem_volume == ASSET( "0.950 TESTS" ).amount ); + BOOST_REQUIRE( bucket->sbd_volume == ASSET( "0.500 TBD" ).amount ); + bucket++; + + BOOST_REQUIRE( bucket->seconds == 300 ); + BOOST_REQUIRE( bucket->open == time_a ); + BOOST_REQUIRE( bucket->high_steem == ASSET( "1.500 TESTS " ).amount ); + BOOST_REQUIRE( bucket->high_sbd == ASSET( "0.750 TBD" ).amount ); + BOOST_REQUIRE( bucket->low_steem == ASSET( "1.500 TESTS" ).amount ); + BOOST_REQUIRE( bucket->low_sbd == ASSET( "0.750 TBD" ).amount ); + BOOST_REQUIRE( bucket->open_steem == ASSET( "1.500 TESTS" ).amount ); + BOOST_REQUIRE( bucket->open_sbd == ASSET( "0.750 TBD" ).amount ); + BOOST_REQUIRE( bucket->close_steem == ASSET( "1.500 TESTS").amount ); + BOOST_REQUIRE( bucket->close_sbd == ASSET( "0.750 TBD" ).amount ); + BOOST_REQUIRE( bucket->steem_volume == ASSET( "1.500 TESTS" ).amount ); + BOOST_REQUIRE( bucket->sbd_volume == ASSET( "0.750 TBD" ).amount ); + bucket++; + + BOOST_REQUIRE( bucket->seconds == 300 ); + BOOST_REQUIRE( bucket->open == time_a + ( 60 * 90 ) ); + BOOST_REQUIRE( bucket->high_steem == ASSET( "0.450 TESTS " ).amount ); + BOOST_REQUIRE( bucket->high_sbd == ASSET( "0.250 TBD" ).amount ); + BOOST_REQUIRE( bucket->low_steem == ASSET( "0.500 TESTS" ).amount ); + BOOST_REQUIRE( bucket->low_sbd == ASSET( "0.250 TBD" ).amount ); + BOOST_REQUIRE( bucket->open_steem == ASSET( "0.500 TESTS" ).amount ); + BOOST_REQUIRE( bucket->open_sbd == ASSET( "0.250 TBD" ).amount ); + BOOST_REQUIRE( bucket->close_steem == ASSET( "0.450 TESTS").amount ); + BOOST_REQUIRE( bucket->close_sbd == ASSET( "0.250 TBD" ).amount ); + BOOST_REQUIRE( bucket->steem_volume == ASSET( "1.450 TESTS" ).amount ); + BOOST_REQUIRE( bucket->sbd_volume == ASSET( "0.750 TBD" ).amount ); + bucket++; + + BOOST_REQUIRE( bucket->seconds == 3600 ); + BOOST_REQUIRE( bucket->open == time_a ); + BOOST_REQUIRE( bucket->high_steem == ASSET( "1.500 TESTS " ).amount ); + BOOST_REQUIRE( bucket->high_sbd == ASSET( "0.750 TBD" ).amount ); + BOOST_REQUIRE( bucket->low_steem == ASSET( "1.500 TESTS" ).amount ); + BOOST_REQUIRE( bucket->low_sbd == ASSET( "0.750 TBD" ).amount ); + BOOST_REQUIRE( bucket->open_steem == ASSET( "1.500 TESTS" ).amount ); + BOOST_REQUIRE( bucket->open_sbd == ASSET( "0.750 TBD" ).amount ); + BOOST_REQUIRE( bucket->close_steem == ASSET( "1.500 TESTS").amount ); + BOOST_REQUIRE( bucket->close_sbd == ASSET( "0.750 TBD" ).amount ); + BOOST_REQUIRE( bucket->steem_volume == ASSET( "1.500 TESTS" ).amount ); + BOOST_REQUIRE( bucket->sbd_volume == ASSET( "0.750 TBD" ).amount ); + bucket++; + + BOOST_REQUIRE( bucket->seconds == 3600 ); + BOOST_REQUIRE( bucket->open == time_a + ( 60 * 60 ) ); + BOOST_REQUIRE( bucket->high_steem == ASSET( "0.450 TESTS " ).amount ); + BOOST_REQUIRE( bucket->high_sbd == ASSET( "0.250 TBD" ).amount ); + BOOST_REQUIRE( bucket->low_steem == ASSET( "0.500 TESTS" ).amount ); + BOOST_REQUIRE( bucket->low_sbd == ASSET( "0.250 TBD" ).amount ); + BOOST_REQUIRE( bucket->open_steem == ASSET( "0.500 TESTS" ).amount ); + BOOST_REQUIRE( bucket->open_sbd == ASSET( "0.250 TBD" ).amount ); + BOOST_REQUIRE( bucket->close_steem == ASSET( "0.450 TESTS").amount ); + BOOST_REQUIRE( bucket->close_sbd == ASSET( "0.250 TBD" ).amount ); + BOOST_REQUIRE( bucket->steem_volume == ASSET( "1.450 TESTS" ).amount ); + BOOST_REQUIRE( bucket->sbd_volume == ASSET( "0.750 TBD" ).amount ); + bucket++; + + BOOST_REQUIRE( bucket->seconds == 86400 ); + BOOST_REQUIRE( bucket->open == STEEMIT_GENESIS_TIME ); + BOOST_REQUIRE( bucket->high_steem == ASSET( "0.450 TESTS " ).amount ); + BOOST_REQUIRE( bucket->high_sbd == ASSET( "0.250 TBD" ).amount ); + BOOST_REQUIRE( bucket->low_steem == ASSET( "1.500 TESTS" ).amount ); + BOOST_REQUIRE( bucket->low_sbd == ASSET( "0.750 TBD" ).amount ); + BOOST_REQUIRE( bucket->open_steem == ASSET( "1.500 TESTS" ).amount ); + BOOST_REQUIRE( bucket->open_sbd == ASSET( "0.750 TBD" ).amount ); + BOOST_REQUIRE( bucket->close_steem == ASSET( "0.450 TESTS").amount ); + BOOST_REQUIRE( bucket->close_sbd == ASSET( "0.250 TBD" ).amount ); + BOOST_REQUIRE( bucket->steem_volume == ASSET( "2.950 TESTS" ).amount ); + BOOST_REQUIRE( bucket->sbd_volume == ASSET( "1.500 TBD" ).amount ); + bucket++; + + BOOST_REQUIRE( bucket == bucket_idx.end() ); + + auto order = order_hist_idx.begin(); + + BOOST_REQUIRE( order->time == fill_order_a_time ); + BOOST_REQUIRE( order->op.owner == "bob" ); + BOOST_REQUIRE( order->op.orderid == 0 ); + BOOST_REQUIRE( order->op.pays == ASSET( "1.500 TESTS" ) ); + BOOST_REQUIRE( order->op.receives == ASSET( "0.750 TBD" ) ); + order++; + + BOOST_REQUIRE( order->time == fill_order_a_time ); + BOOST_REQUIRE( order->op.owner == "alice" ); + BOOST_REQUIRE( order->op.orderid == 0 ); + BOOST_REQUIRE( order->op.pays == ASSET( "0.750 TBD" ) ); + BOOST_REQUIRE( order->op.receives == ASSET( "1.500 TESTS" ) ); + order++; + + BOOST_REQUIRE( order->time == fill_order_b_time ); + BOOST_REQUIRE( order->op.owner == "sam" ); + BOOST_REQUIRE( order->op.orderid == 0 ); + BOOST_REQUIRE( order->op.pays == ASSET( "0.500 TESTS" ) ); + BOOST_REQUIRE( order->op.receives == ASSET( "0.250 TBD" ) ); + order++; + + BOOST_REQUIRE( order->time == fill_order_b_time ); + BOOST_REQUIRE( order->op.owner == "alice" ); + BOOST_REQUIRE( order->op.orderid == 0 ); + BOOST_REQUIRE( order->op.pays == ASSET( "0.250 TBD" ) ); + BOOST_REQUIRE( order->op.receives == ASSET( "0.500 TESTS" ) ); + order++; + + BOOST_REQUIRE( order->time == fill_order_c_time ); + BOOST_REQUIRE( order->op.owner == "alice" ); + BOOST_REQUIRE( order->op.orderid == 0 ); + BOOST_REQUIRE( order->op.pays == ASSET( "0.250 TBD" ) ); + BOOST_REQUIRE( order->op.receives == ASSET( "0.500 TESTS" ) ); + order++; + + BOOST_REQUIRE( order->time == fill_order_c_time ); + BOOST_REQUIRE( order->op.owner == "sam" ); + BOOST_REQUIRE( order->op.orderid == 0 ); + BOOST_REQUIRE( order->op.pays == ASSET( "0.500 TESTS" ) ); + BOOST_REQUIRE( order->op.receives == ASSET( "0.250 TBD" ) ); + order++; + + BOOST_REQUIRE( order->time == fill_order_c_time ); + BOOST_REQUIRE( order->op.owner == "bob" ); + BOOST_REQUIRE( order->op.orderid == 0 ); + BOOST_REQUIRE( order->op.pays == ASSET( "0.450 TESTS" ) ); + BOOST_REQUIRE( order->op.receives == ASSET( "0.250 TBD" ) ); + order++; + + BOOST_REQUIRE( order->time == fill_order_c_time ); + BOOST_REQUIRE( order->op.owner == "alice" ); + BOOST_REQUIRE( order->op.orderid == 0 ); + BOOST_REQUIRE( order->op.pays == ASSET( "0.250 TBD" ) ); + BOOST_REQUIRE( order->op.receives == ASSET( "0.450 TESTS" ) ); + order++; + + BOOST_REQUIRE( order == order_hist_idx.end() ); + } + FC_LOG_AND_RETHROW() +} + +BOOST_AUTO_TEST_SUITE_END() +#endif \ No newline at end of file diff --git a/tests/tests/operation_time_tests.cpp b/tests/tests/operation_time_tests.cpp index f0ab209fdc..8ea494b078 100644 --- a/tests/tests/operation_time_tests.cpp +++ b/tests/tests/operation_time_tests.cpp @@ -1237,11 +1237,6 @@ BOOST_AUTO_TEST_CASE( liquidity_rewards ) { ACTORS( (alice)(bob)(sam)(dave) ) - auto mh_plugin = app.register_plugin< steemit::market_history::market_history_plugin >(); - boost::program_options::variables_map options; - mh_plugin->plugin_set_app( &app ); - mh_plugin->plugin_initialize( options ); - BOOST_TEST_MESSAGE( "Rewarding Bob with TESTS" ); auto exchange_rate = price( ASSET( "1.250 TESTS" ), ASSET( "1.000 TBD" ) );