Progress #8: Test shorts and force settles
This commit is contained in:
parent
8f25a3fee9
commit
3d60449c6e
4 changed files with 19 additions and 5 deletions
|
|
@ -20,6 +20,7 @@
|
|||
#include <graphene/chain/account_object.hpp>
|
||||
#include <graphene/chain/call_order_object.hpp>
|
||||
#include <graphene/chain/database.hpp>
|
||||
#include <graphene/chain/exceptions.hpp>
|
||||
|
||||
#include <functional>
|
||||
|
||||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@
|
|||
#include <graphene/chain/account_object.hpp>
|
||||
#include <graphene/chain/call_order_object.hpp>
|
||||
#include <graphene/chain/limit_order_object.hpp>
|
||||
#include <graphene/chain/exceptions.hpp>
|
||||
#include <fc/uint128.hpp>
|
||||
|
||||
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 )
|
||||
{
|
||||
|
|
|
|||
|
|
@ -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 ////////////////////
|
||||
|
|
|
|||
|
|
@ -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<account_id_type> producers)
|
||||
{ update_feed_producers(mia(db), producers); }
|
||||
void update_feed_producers(const asset_object& mia, flat_set<account_id_type> 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 );
|
||||
|
|
|
|||
Loading…
Reference in a new issue