Implement unit test for #350
This commit is contained in:
parent
9b4be66aca
commit
db84a492b9
1 changed files with 33 additions and 14 deletions
|
|
@ -317,6 +317,7 @@ BOOST_AUTO_TEST_CASE( black_swan_issue_346 )
|
||||||
{
|
{
|
||||||
price_feed feed;
|
price_feed feed;
|
||||||
feed.settlement_price = settlement_price;
|
feed.settlement_price = settlement_price;
|
||||||
|
wdump( (feed.max_short_squeeze_price()) );
|
||||||
publish_feed( bitusd, feeder, feed );
|
publish_feed( bitusd, feeder, feed );
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -332,22 +333,40 @@ BOOST_AUTO_TEST_CASE( black_swan_issue_346 )
|
||||||
BOOST_CHECK( idx.empty() );
|
BOOST_CHECK( idx.empty() );
|
||||||
};
|
};
|
||||||
|
|
||||||
const asset_object& bitusd = setup_asset();
|
{
|
||||||
top_up();
|
const asset_object& bitusd = setup_asset();
|
||||||
set_price( bitusd, bitusd.amount(1) / core.amount(5) ); // $0.20
|
top_up();
|
||||||
borrow(borrower, bitusd.amount(100), asset(1000)); // 2x collat
|
set_price( bitusd, bitusd.amount(1) / core.amount(5) ); // $0.20
|
||||||
transfer( borrower, settler, bitusd.amount(100) );
|
borrow(borrower, bitusd.amount(100), asset(1000)); // 2x collat
|
||||||
|
transfer( borrower, settler, bitusd.amount(100) );
|
||||||
|
|
||||||
// drop to $0.02 and settle
|
// drop to $0.02 and settle
|
||||||
BOOST_CHECK( !bitusd.bitasset_data(db).has_settlement() );
|
BOOST_CHECK( !bitusd.bitasset_data(db).has_settlement() );
|
||||||
set_price( bitusd, bitusd.amount(1) / core.amount(50) );
|
set_price( bitusd, bitusd.amount(1) / core.amount(50) ); // $0.02
|
||||||
BOOST_CHECK( bitusd.bitasset_data(db).has_settlement() );
|
BOOST_CHECK( bitusd.bitasset_data(db).has_settlement() );
|
||||||
GRAPHENE_REQUIRE_THROW( borrow( borrower2, bitusd.amount(100), asset(10000) ), fc::exception );
|
GRAPHENE_REQUIRE_THROW( borrow( borrower2, bitusd.amount(100), asset(10000) ), fc::exception );
|
||||||
force_settle( settler, bitusd.amount(100) );
|
force_settle( settler, bitusd.amount(100) );
|
||||||
|
|
||||||
// wait for forced settlement to execute
|
// wait for forced settlement to execute
|
||||||
// this would throw on Sep.18 testnet, see #346
|
// this would throw on Sep.18 testnet, see #346
|
||||||
wait_for_settlement();
|
wait_for_settlement();
|
||||||
|
}
|
||||||
|
|
||||||
|
// issue 350
|
||||||
|
{
|
||||||
|
// ok, new asset
|
||||||
|
const asset_object& bitusd = setup_asset();
|
||||||
|
top_up();
|
||||||
|
set_price( bitusd, bitusd.amount(40) / core.amount(1000) ); // $0.04
|
||||||
|
borrow( borrower, bitusd.amount(100), asset(5000) ); // 2x collat
|
||||||
|
transfer( borrower, seller, bitusd.amount(100) );
|
||||||
|
limit_order_id_type oid_019 = create_sell_order( seller, bitusd.amount(39), core.amount(2000) )->id; // this order is at $0.019, we should not be able to match against it
|
||||||
|
limit_order_id_type oid_020 = create_sell_order( seller, bitusd.amount(40), core.amount(2000) )->id; // this order is at $0.020, we should be able to match against it
|
||||||
|
set_price( bitusd, bitusd.amount(21) / core.amount(1000) ); // $0.021
|
||||||
|
BOOST_CHECK( !bitusd.bitasset_data(db).has_settlement() );
|
||||||
|
BOOST_CHECK( db.find_object( oid_019 ) != nullptr );
|
||||||
|
BOOST_CHECK( db.find_object( oid_020 ) == nullptr );
|
||||||
|
}
|
||||||
|
|
||||||
} catch( const fc::exception& e) {
|
} catch( const fc::exception& e) {
|
||||||
edump((e.to_detail_string()));
|
edump((e.to_detail_string()));
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue