Fix broken delegate_feeds test

This commit is contained in:
Nathan Hourt 2015-06-19 13:43:39 -04:00
parent 6bc2d06833
commit a90e3f0155
3 changed files with 24 additions and 23 deletions

View file

@ -78,14 +78,15 @@ database_fixture::database_fixture()
database_fixture::~database_fixture()
{
// If we're unwinding due to an exception, don't do any more checks.
// This way, boost test's last checkpoint tells us approximately where the error was.
if( !std::uncaught_exception() )
{
verify_asset_supplies();
verify_account_history_plugin_index();
BOOST_CHECK( db.get_node_properties().skip_flags == database::skip_nothing );
}
BOOST_CHECK( db.get_node_properties().skip_flags == database::skip_nothing );
if( data_dir )
db.close();
return;

View file

@ -62,6 +62,20 @@ BOOST_AUTO_TEST_CASE( price_test )
BOOST_CHECK( ~price::min(0,1) == price::max(1,0) );
BOOST_CHECK( ~price::max(0,1) < ~price::min(0,1) );
BOOST_CHECK( ~price::max(0,1) <= ~price::min(0,1) );
price a(asset(1), asset(2,1));
price b(asset(2), asset(2,1));
price c(asset(1), asset(2,1));
BOOST_CHECK(a < b);
BOOST_CHECK(b > a);
BOOST_CHECK(a == c);
BOOST_CHECK(!(b == c));
price_feed dummy;
dummy.maintenance_collateral_ratio = 1002;
dummy.maximum_short_squeeze_ratio = 1234;
dummy.settlement_price = price(asset(1000), asset(2000, 1));
price_feed dummy2 = dummy;
BOOST_CHECK(dummy == dummy2);
}
BOOST_AUTO_TEST_CASE( serialization_tests )

View file

@ -933,7 +933,6 @@ BOOST_AUTO_TEST_CASE( cancel_limit_order_test )
}
}
BOOST_AUTO_TEST_CASE_EXPECTED_FAILURES( delegate_feeds, 1 )
BOOST_AUTO_TEST_CASE( delegate_feeds )
{
using namespace graphene::chain;
@ -955,44 +954,31 @@ BOOST_AUTO_TEST_CASE( delegate_feeds )
asset_publish_feed_operation op({asset(), 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 = ~price(asset(GRAPHENE_BLOCKCHAIN_PRECISION),bit_usd.amount(30));
// Accept defaults for required collateral
trx.operations.emplace_back(op);
PUSH_TX( db, trx, ~0 );
{
//Dumb sanity check of some operators. Only here to improve code coverage. :D
price_feed dummy = op.feed;
BOOST_CHECK(op.feed == dummy);
price a(asset(1), bit_usd.amount(2));
price b(asset(2), bit_usd.amount(2));
price c(asset(1), bit_usd.amount(2));
BOOST_CHECK(a < b);
BOOST_CHECK(b > a);
BOOST_CHECK(a == c);
BOOST_CHECK(!(b == c));
}
const asset_bitasset_data_object& bitasset = bit_usd.bitasset_data(db);
BOOST_CHECK(bitasset.current_feed.settlement_price.to_real() == GRAPHENE_BLOCKCHAIN_PRECISION / 30.0);
BOOST_CHECK(bitasset.current_feed.settlement_price.to_real() == 30.0 / GRAPHENE_BLOCKCHAIN_PRECISION);
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 = ~price(asset(GRAPHENE_BLOCKCHAIN_PRECISION),bit_usd.amount(25));
trx.operations.back() = op;
PUSH_TX( db, trx, ~0 );
BOOST_CHECK_EQUAL(bitasset.current_feed.settlement_price.to_real(), GRAPHENE_BLOCKCHAIN_PRECISION / 25.0);
BOOST_CHECK_EQUAL(bitasset.current_feed.settlement_price.to_real(), 30.0 / GRAPHENE_BLOCKCHAIN_PRECISION);
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 = ~price(asset(GRAPHENE_BLOCKCHAIN_PRECISION),bit_usd.amount(40));
// But this delegate is an idiot.
op.feed.maintenance_collateral_ratio = 1000;
op.feed.maintenance_collateral_ratio = 1001;
trx.operations.back() = op;
PUSH_TX( db, trx, ~0 );
BOOST_CHECK_EQUAL(bitasset.current_feed.settlement_price.to_real(), GRAPHENE_BLOCKCHAIN_PRECISION / 30.0);
BOOST_CHECK_EQUAL(bitasset.current_feed.settlement_price.to_real(), 30.0 / GRAPHENE_BLOCKCHAIN_PRECISION);
BOOST_CHECK(bitasset.current_feed.maintenance_collateral_ratio == GRAPHENE_DEFAULT_MAINTENANCE_COLLATERAL_RATIO);
} catch (const fc::exception& e) {
edump((e.to_detail_string()));