Skip to content

Commit

Permalink
Added test case for settlement bug described in cryptonomex#216
Browse files Browse the repository at this point in the history
  • Loading branch information
pmconrad committed Jul 27, 2017
1 parent 74c650d commit 5c5424d
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion tests/tests/operation_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,7 @@ BOOST_AUTO_TEST_CASE( black_swan )
ACTORS((buyer)(seller)(borrower)(borrower2)(feedproducer));

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

int64_t init_balance(1000000);
Expand Down Expand Up @@ -272,8 +273,15 @@ BOOST_AUTO_TEST_CASE( black_swan )

force_settle(borrower, bitusd.amount(100));

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

FC_ASSERT( bitusd_id(db).bitasset_data(db).current_feed.settlement_price.is_null() );
force_settle(borrower_id(db), asset(100, bitusd_id));

BOOST_TEST_MESSAGE( "Verify that we cannot borrow after black swan" );
GRAPHENE_REQUIRE_THROW( borrow(borrower, bitusd.amount(1000), asset(2000)), fc::exception );
GRAPHENE_REQUIRE_THROW( borrow(borrower_id(db), asset(1000, bitusd_id), asset(2000)), fc::exception );
} catch( const fc::exception& e) {
edump((e.to_detail_string()));
throw;
Expand Down

0 comments on commit 5c5424d

Please sign in to comment.