diff --git a/libraries/chain/asset_evaluator.cpp b/libraries/chain/asset_evaluator.cpp index 60255490..fcf1c23e 100644 --- a/libraries/chain/asset_evaluator.cpp +++ b/libraries/chain/asset_evaluator.cpp @@ -20,6 +20,7 @@ #include #include #include +#include #include @@ -394,6 +395,8 @@ void_result asset_settle_evaluator::do_evaluate(const asset_settle_evaluator::op FC_ASSERT(asset_to_settle->can_force_settle() || bitasset.has_settlement() ); if( bitasset.is_prediction_market ) FC_ASSERT( bitasset.has_settlement(), "global settlement must occur before force settling a prediction market" ); + else if( bitasset.current_feed.settlement_price.is_null() ) + FC_THROW_EXCEPTION(insufficient_feeds, "Cannot force settle with no price feed."); FC_ASSERT(d.get_balance(d.get(op.account), *asset_to_settle) >= op.amount); return void_result(); diff --git a/libraries/chain/call_order_evaluator.cpp b/libraries/chain/call_order_evaluator.cpp index 379e2287..3db43f42 100644 --- a/libraries/chain/call_order_evaluator.cpp +++ b/libraries/chain/call_order_evaluator.cpp @@ -20,6 +20,7 @@ #include #include #include +#include #include namespace graphene { namespace chain { @@ -43,8 +44,8 @@ void_result call_order_update_evaluator::do_evaluate(const call_order_update_ope if( _bitasset_data->is_prediction_market ) FC_ASSERT( o.delta_collateral.amount == o.delta_debt.amount ); - else - FC_ASSERT( !_bitasset_data->current_feed.settlement_price.is_null() ); + else if( _bitasset_data->current_feed.settlement_price.is_null() ) + FC_THROW_EXCEPTION(insufficient_feeds, "Cannot borrow asset with no price feed."); if( o.delta_debt.amount < 0 ) { diff --git a/libraries/chain/include/graphene/chain/database.hpp b/libraries/chain/include/graphene/chain/database.hpp index 7de14fbd..0f06eb89 100644 --- a/libraries/chain/include/graphene/chain/database.hpp +++ b/libraries/chain/include/graphene/chain/database.hpp @@ -69,7 +69,7 @@ namespace graphene { namespace chain { * @class database * @brief tracks the blockchain state in an extensible manner */ - class database : public object_database + class database : public db::object_database { public: //////////////////// db_management.cpp //////////////////// diff --git a/tests/common/database_fixture.hpp b/tests/common/database_fixture.hpp index 834f9ee0..449f3fd4 100644 --- a/tests/common/database_fixture.hpp +++ b/tests/common/database_fixture.hpp @@ -73,7 +73,7 @@ using namespace graphene::db; #define INVOKE(test) ((struct test*)this)->test_method(); trx.clear() #define PREP_ACTOR(name) \ - fc::ecc::private_key name ## _private_key = generate_private_key(BOOST_PP_STRINGIZE(name)); + fc::ecc::private_key name ## _private_key = generate_private_key(BOOST_PP_STRINGIZE(name)); #define ACTOR(name) \ PREP_ACTOR(name) \ @@ -146,10 +146,20 @@ struct database_fixture { ); void force_global_settle(const asset_object& what, const price& p); + void force_settle(account_id_type who, asset what) + { force_settle(who(db), what); } void force_settle(const account_object& who, asset what); + void update_feed_producers(asset_id_type mia, flat_set producers) + { update_feed_producers(mia(db), producers); } void update_feed_producers(const asset_object& mia, flat_set producers); + void publish_feed(asset_id_type mia, account_id_type by, const price_feed& f) + { publish_feed(mia(db), by(db), f); } void publish_feed(const asset_object& mia, const account_object& by, const price_feed& f); + void borrow(account_id_type who, asset what, asset collateral) + { borrow(who(db), what, collateral); } void borrow(const account_object& who, asset what, asset collateral); + void cover(account_id_type who, asset what, asset collateral_freed) + { cover(who(db), what, collateral_freed); } void cover(const account_object& who, asset what, asset collateral_freed); const asset_object& get_asset( const string& symbol )const; @@ -163,7 +173,7 @@ struct database_fixture { uint16_t market_fee_percent = 100 /*1%*/, uint16_t flags = charge_market_fee); const asset_object& create_user_issued_asset( const string& name ); - const asset_object& create_user_issued_asset( const string& name, + const asset_object& create_user_issued_asset( const string& name, const account_object& issuer, uint16_t flags ); void issue_uia( const account_object& recipient, asset amount );