From 9d3652e9eccde397d3f001bf5352a7c2dcf7950a Mon Sep 17 00:00:00 2001 From: theoreticalbts Date: Wed, 28 Oct 2015 13:03:31 -0400 Subject: [PATCH] Fix tests to obey new feed publishing requirement !core_exchange_rate.is_null() --- tests/common/database_fixture.cpp | 2 ++ tests/tests/operation_tests.cpp | 12 ++++++------ tests/tests/operation_tests2.cpp | 7 ++++--- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/tests/common/database_fixture.cpp b/tests/common/database_fixture.cpp index 1fb51ac3..e671aba4 100644 --- a/tests/common/database_fixture.cpp +++ b/tests/common/database_fixture.cpp @@ -733,6 +733,8 @@ void database_fixture::publish_feed( const asset_object& mia, const account_obje op.publisher = by.id; op.asset_id = mia.id; op.feed = f; + if( op.feed.core_exchange_rate.is_null() ) + op.feed.core_exchange_rate = op.feed.settlement_price; trx.operations.emplace_back( std::move(op) ); for( auto& op : trx.operations ) db.current_fee_schedule().set_fee(op); diff --git a/tests/tests/operation_tests.cpp b/tests/tests/operation_tests.cpp index 9c1edef5..001450af 100644 --- a/tests/tests/operation_tests.cpp +++ b/tests/tests/operation_tests.cpp @@ -636,11 +636,11 @@ BOOST_AUTO_TEST_CASE( update_mia ) pop.asset_id = bit_usd.get_id(); pop.publisher = get_account("init0").get_id(); price_feed feed; - feed.settlement_price = price(bit_usd.amount(5), bit_usd.amount(5)); + feed.settlement_price = feed.core_exchange_rate = price(bit_usd.amount(5), bit_usd.amount(5)); REQUIRE_THROW_WITH_VALUE(pop, feed, feed); - feed.settlement_price = ~price(bit_usd.amount(5), asset(5)); + feed.settlement_price = feed.core_exchange_rate = ~price(bit_usd.amount(5), asset(5)); REQUIRE_THROW_WITH_VALUE(pop, feed, feed); - feed.settlement_price = price(bit_usd.amount(5), asset(5)); + feed.settlement_price = feed.core_exchange_rate = price(bit_usd.amount(5), asset(5)); pop.feed = feed; REQUIRE_THROW_WITH_VALUE(pop, feed.maintenance_collateral_ratio, 0); trx.operations.back() = pop; @@ -1144,7 +1144,7 @@ BOOST_AUTO_TEST_CASE( witness_feeds ) asset_publish_feed_operation op; op.publisher = active_witnesses[0]; op.asset_id = bit_usd.get_id(); - op.feed.settlement_price = ~price(asset(GRAPHENE_BLOCKCHAIN_PRECISION),bit_usd.amount(30)); + op.feed.settlement_price = op.feed.core_exchange_rate = ~price(asset(GRAPHENE_BLOCKCHAIN_PRECISION),bit_usd.amount(30)); // Accept defaults for required collateral trx.operations.emplace_back(op); PUSH_TX( db, trx, ~0 ); @@ -1154,7 +1154,7 @@ BOOST_AUTO_TEST_CASE( witness_feeds ) BOOST_CHECK(bitasset.current_feed.maintenance_collateral_ratio == GRAPHENE_DEFAULT_MAINTENANCE_COLLATERAL_RATIO); op.publisher = active_witnesses[1]; - op.feed.settlement_price = ~price(asset(GRAPHENE_BLOCKCHAIN_PRECISION),bit_usd.amount(25)); + op.feed.settlement_price = op.feed.core_exchange_rate = ~price(asset(GRAPHENE_BLOCKCHAIN_PRECISION),bit_usd.amount(25)); trx.operations.back() = op; PUSH_TX( db, trx, ~0 ); @@ -1162,7 +1162,7 @@ BOOST_AUTO_TEST_CASE( witness_feeds ) BOOST_CHECK(bitasset.current_feed.maintenance_collateral_ratio == GRAPHENE_DEFAULT_MAINTENANCE_COLLATERAL_RATIO); op.publisher = active_witnesses[2]; - op.feed.settlement_price = ~price(asset(GRAPHENE_BLOCKCHAIN_PRECISION),bit_usd.amount(40)); + op.feed.settlement_price = op.feed.core_exchange_rate = ~price(asset(GRAPHENE_BLOCKCHAIN_PRECISION),bit_usd.amount(40)); // But this witness is an idiot. op.feed.maintenance_collateral_ratio = 1001; trx.operations.back() = op; diff --git a/tests/tests/operation_tests2.cpp b/tests/tests/operation_tests2.cpp index 5e123e9e..ee05ffd9 100644 --- a/tests/tests/operation_tests2.cpp +++ b/tests/tests/operation_tests2.cpp @@ -348,7 +348,8 @@ BOOST_AUTO_TEST_CASE( mia_feeds ) asset_publish_feed_operation op; op.publisher = vikram_id; op.asset_id = bit_usd_id; - op.feed.settlement_price = ~price(asset(GRAPHENE_BLOCKCHAIN_PRECISION),bit_usd.amount(30)); + op.feed.settlement_price = op.feed.core_exchange_rate = ~price(asset(GRAPHENE_BLOCKCHAIN_PRECISION),bit_usd.amount(30)); + // We'll expire margins after a month // Accept defaults for required collateral trx.operations.emplace_back(op); @@ -359,7 +360,7 @@ BOOST_AUTO_TEST_CASE( mia_feeds ) BOOST_CHECK(bitasset.current_feed.maintenance_collateral_ratio == GRAPHENE_DEFAULT_MAINTENANCE_COLLATERAL_RATIO); op.publisher = ben_id; - op.feed.settlement_price = ~price(asset(GRAPHENE_BLOCKCHAIN_PRECISION),bit_usd.amount(25)); + op.feed.settlement_price = op.feed.core_exchange_rate = ~price(asset(GRAPHENE_BLOCKCHAIN_PRECISION),bit_usd.amount(25)); trx.operations.back() = op; PUSH_TX( db, trx, ~0 ); @@ -367,7 +368,7 @@ BOOST_AUTO_TEST_CASE( mia_feeds ) BOOST_CHECK(bitasset.current_feed.maintenance_collateral_ratio == GRAPHENE_DEFAULT_MAINTENANCE_COLLATERAL_RATIO); op.publisher = dan_id; - op.feed.settlement_price = ~price(asset(GRAPHENE_BLOCKCHAIN_PRECISION),bit_usd.amount(40)); + op.feed.settlement_price = op.feed.core_exchange_rate = ~price(asset(GRAPHENE_BLOCKCHAIN_PRECISION),bit_usd.amount(40)); op.feed.maximum_short_squeeze_ratio = 1001; op.feed.maintenance_collateral_ratio = 1001; trx.operations.back() = op;