Skip to content

Commit

Permalink
Fixed settlement bug cryptonomex#216
Browse files Browse the repository at this point in the history
  • Loading branch information
pmconrad committed Jul 27, 2017
1 parent 5c5424d commit 894d5b6
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
4 changes: 3 additions & 1 deletion libraries/chain/asset_evaluator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,9 @@ 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() )
else if( bitasset.current_feed.settlement_price.is_null()
&& ( d.head_block_time() <= HARDFORK_CORE_216_TIME
|| !bitasset.has_settlement() ) )
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);

Expand Down
4 changes: 4 additions & 0 deletions libraries/chain/hardfork.d/CORE_216.hf
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// bitshares-core #216 Process to reset a Smartcoin after a Black Swan
#ifndef HARDFORK_CORE_216_TIME
#define HARDFORK_CORE_216_TIME (fc::time_point_sec( 1498762800 ))
#endif
1 change: 1 addition & 0 deletions tests/tests/operation_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,7 @@ BOOST_AUTO_TEST_CASE( black_swan )

// make sure pricefeeds expire
generate_blocks(db.head_block_time() + GRAPHENE_DEFAULT_PRICE_FEED_LIFETIME);
generate_blocks( HARDFORK_CORE_216_TIME );
generate_blocks(2);

FC_ASSERT( bitusd_id(db).bitasset_data(db).current_feed.settlement_price.is_null() );
Expand Down

0 comments on commit 894d5b6

Please sign in to comment.