Skip to content

Commit

Permalink
Remove cull_small_test for easier merging
Browse files Browse the repository at this point in the history
  • Loading branch information
abitmore committed Apr 7, 2018
1 parent 145b0ad commit c049b53
Showing 1 changed file with 0 additions and 73 deletions.
73 changes: 0 additions & 73 deletions tests/tests/market_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -229,78 +229,5 @@ BOOST_AUTO_TEST_CASE(issue_338_etc)

} FC_LOG_AND_RETHROW() }

/***
* reproduce check_call_orders cull_small issue
*/
BOOST_AUTO_TEST_CASE( check_call_order_cull_small_test )
{ try { // matching a limit order with call order
generate_block();

set_expiration( db, trx );

ACTORS((buyer)(seller)(borrower)(borrower2)(borrower3)(borrower4)(feedproducer));

const auto& bitusd = create_bitasset("USDBIT", feedproducer_id);
const auto& core = asset_id_type()(db);
asset_id_type usd_id = bitusd.id;
asset_id_type core_id = core.id;

int64_t init_balance(1000000);

transfer(committee_account, buyer_id, asset(init_balance));
transfer(committee_account, borrower_id, asset(init_balance));
transfer(committee_account, borrower2_id, asset(init_balance));
transfer(committee_account, borrower3_id, asset(init_balance));
transfer(committee_account, borrower4_id, asset(init_balance));
update_feed_producers( bitusd, {feedproducer.id} );

price_feed current_feed;
current_feed.maintenance_collateral_ratio = 1750;
current_feed.maximum_short_squeeze_ratio = 1100;
current_feed.settlement_price = bitusd.amount( 100 ) / core.amount( 5 );
publish_feed( bitusd, feedproducer, current_feed );
// start out with 200% collateral, call price is 10/175 CORE/USD = 40/700
const call_order_object& call = *borrow( borrower, bitusd.amount(10), asset(1));
call_order_id_type call_id = call.id;
// create another position with 310% collateral, call price is 15.5/175 CORE/USD = 62/700
const call_order_object& call2 = *borrow( borrower2, bitusd.amount(100000), asset(15500));
call_order_id_type call2_id = call2.id;
// create yet another position with 350% collateral, call price is 17.5/175 CORE/USD = 77/700
const call_order_object& call3 = *borrow( borrower3, bitusd.amount(100000), asset(17500));
call_order_id_type call3_id = call3.id;
transfer(borrower, seller, bitusd.amount(10));
transfer(borrower2, seller, bitusd.amount(100000));
transfer(borrower3, seller, bitusd.amount(100000));

BOOST_CHECK_EQUAL( 10, call.debt.value );
BOOST_CHECK_EQUAL( 1, call.collateral.value );
BOOST_CHECK_EQUAL( 100000, call2.debt.value );
BOOST_CHECK_EQUAL( 15500, call2.collateral.value );
BOOST_CHECK_EQUAL( 100000, call3.debt.value );
BOOST_CHECK_EQUAL( 17500, call3.collateral.value );

BOOST_CHECK_EQUAL( 200010, get_balance(seller, bitusd) );
BOOST_CHECK_EQUAL( 0, get_balance(seller, core) );
BOOST_CHECK_EQUAL( 0, get_balance(borrower, bitusd) );
BOOST_CHECK_EQUAL( init_balance-1, get_balance(borrower, core) );

// adjust price feed to get call_order into margin call territory
current_feed.settlement_price = bitusd.amount( 120 ) / core.amount(10);
publish_feed( bitusd, feedproducer, current_feed );
// settlement price = 120 USD / 10 CORE, mssp = 120/11 USD/CORE

// This would match with call at price 11 USD / 1 CORE, but call only owes 10 USD,
// so the seller will pay 10 USD but get nothing.
// The remaining 1 USD is too little to get any CORE, so the limit order will be cancelled
BOOST_CHECK( !create_sell_order(seller, bitusd.amount(11), core.amount(1)) );
BOOST_CHECK( !db.find<call_order_object>( call_id ) ); // the first call order get filled
BOOST_CHECK_EQUAL( 200000, get_balance(seller, bitusd) ); // the seller paid 10 USD
BOOST_CHECK_EQUAL( 0, get_balance(seller, core) ); // the seller got nothing
BOOST_CHECK_EQUAL( 0, get_balance(borrower, bitusd) );
BOOST_CHECK_EQUAL( init_balance, get_balance(borrower, core) );

generate_block();

} FC_LOG_AND_RETHROW() }

BOOST_AUTO_TEST_SUITE_END()

0 comments on commit c049b53

Please sign in to comment.