Fix tests to obey new feed publishing requirement !core_exchange_rate.is_null()

This commit is contained in:
theoreticalbts 2015-10-28 13:03:31 -04:00
parent 2adbe53714
commit 9d3652e9ec
3 changed files with 12 additions and 9 deletions

View file

@ -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);

View file

@ -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;

View file

@ -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;