diff --git a/tests/tests/block_tests.cpp b/tests/tests/block_tests.cpp index 2c9bbecb83..a39caffbee 100644 --- a/tests/tests/block_tests.cpp +++ b/tests/tests/block_tests.cpp @@ -710,138 +710,6 @@ BOOST_FIXTURE_TEST_CASE( change_block_interval, database_fixture ) BOOST_CHECK_EQUAL(db.head_block_time().sec_since_epoch() - past_time, 2); } FC_LOG_AND_RETHROW() } -BOOST_AUTO_TEST_CASE_EXPECTED_FAILURES( unimp_force_settlement, 1 ) -BOOST_FIXTURE_TEST_CASE( unimp_force_settlement, database_fixture ) -{ - BOOST_FAIL( "TODO" ); - /* - try { - auto private_key = init_account_priv_key; - auto private_key = generate_private_key("committee"); ->>>>>>> short_refactor - account_id_type nathan_id = create_account("nathan").get_id(); - account_id_type shorter1_id = create_account("shorter1").get_id(); - account_id_type shorter2_id = create_account("shorter2").get_id(); - account_id_type shorter3_id = create_account("shorter3").get_id(); - transfer(account_id_type()(db), nathan_id(db), asset(100000000)); - transfer(account_id_type()(db), shorter1_id(db), asset(100000000)); - transfer(account_id_type()(db), shorter2_id(db), asset(100000000)); - transfer(account_id_type()(db), shorter3_id(db), asset(100000000)); - asset_id_type bit_usd = create_bitasset("BITUSD", GRAPHENE_TEMP_ACCOUNT, 0).get_id(); - { - asset_update_bitasset_operation op; - op.asset_to_update = bit_usd; - op.issuer = bit_usd(db).issuer; - op.new_options = bit_usd(db).bitasset_data(db).options; - op.new_options.maximum_force_settlement_volume = 9000; - trx.clear(); - trx.operations.push_back(op); - PUSH_TX( db, trx, ~0 ); - trx.clear(); - } - generate_block(); - - create_short(shorter1_id(db), asset(1000, bit_usd), asset(1000)); - create_sell_order(nathan_id(db), asset(1000), asset(1000, bit_usd)); - create_short(shorter2_id(db), asset(2000, bit_usd), asset(1999)); - create_sell_order(nathan_id(db), asset(1999), asset(2000, bit_usd)); - create_short(shorter3_id(db), asset(3000, bit_usd), asset(2990)); - create_sell_order(nathan_id(db), asset(2990), asset(3000, bit_usd)); - BOOST_CHECK_EQUAL(get_balance(nathan_id, bit_usd), 6000); - - transfer(nathan_id(db), account_id_type()(db), db.get_balance(nathan_id, asset_id_type())); - - { - asset_update_bitasset_operation uop; - uop.issuer = bit_usd(db).issuer; - uop.asset_to_update = bit_usd; - uop.new_options = bit_usd(db).bitasset_data(db).options; - uop.new_options.force_settlement_delay_sec = 100; - uop.new_options.force_settlement_offset_percent = 100; - trx.operations.push_back(uop); - } { - asset_update_feed_producers_operation uop; - uop.asset_to_update = bit_usd; - uop.issuer = bit_usd(db).issuer; - uop.new_feed_producers = {nathan_id}; - trx.operations.push_back(uop); - } { - asset_publish_feed_operation pop; - pop.asset_id = bit_usd; - pop.publisher = nathan_id; - price_feed feed; - feed.settlement_price = price(asset(1),asset(1, bit_usd)); - feed.call_limit = price::min(0, bit_usd); - feed.short_limit = price::min(bit_usd, 0); - pop.feed = feed; - trx.operations.push_back(pop); - } - trx.sign(key_id_type(),private_key); - PUSH_TX( db, trx ); - trx.clear(); - - asset_settle_operation sop; - sop.account = nathan_id; - sop.amount = asset(50, bit_usd); - trx.operations.push_back(sop); - REQUIRE_THROW_WITH_VALUE(sop, amount, asset(999999, bit_usd)); - trx.operations.back() = sop; - trx.sign(key_id_type(),private_key); - - //Partially settle a call - force_settlement_id_type settle_id = PUSH_TX( db, trx ).operation_results.front().get(); - trx.clear(); - call_order_id_type call_id = db.get_index_type().indices().get().begin()->id; - BOOST_CHECK_EQUAL(settle_id(db).balance.amount.value, 50); - BOOST_CHECK_EQUAL(call_id(db).debt.value, 3000); - BOOST_CHECK(settle_id(db).owner == nathan_id); - - generate_blocks(settle_id(db).settlement_date); - BOOST_CHECK(db.find(settle_id) == nullptr); - BOOST_CHECK_EQUAL(get_balance(nathan_id, asset_id_type()), 49); - BOOST_CHECK_EQUAL(call_id(db).debt.value, 2950); - - //Exactly settle a call - call_id = db.get_index_type().indices().get().begin()->id; - sop.amount.amount = 2000; - trx.operations.push_back(sop); - trx.sign(key_id_type(),private_key); - //Trx has expired by now. Make sure it throws. - GRAPHENE_CHECK_THROW(settle_id = PUSH_TX( db, trx ).operation_results.front().get(), fc::exception); - trx.set_expiration(db.head_block_time() + fc::minutes(1)); - trx.sign(key_id_type(),private_key); - settle_id = PUSH_TX( db, trx ).operation_results.front().get(); - trx.clear(); - - generate_blocks(settle_id(db).settlement_date); - BOOST_CHECK(db.find(settle_id) == nullptr); - BOOST_CHECK_EQUAL(get_balance(nathan_id, asset_id_type()), 2029); - BOOST_CHECK(db.find(call_id) == nullptr); - trx.set_expiration(db.head_block_time() + fc::minutes(1)); - - //Attempt to settle all existing asset - sop.amount = db.get_balance(nathan_id, bit_usd); - trx.operations.push_back(sop); - trx.sign(key_id_type(),private_key); - settle_id = PUSH_TX( db, trx ).operation_results.front().get(); - trx.clear(); - - generate_blocks(settle_id(db).settlement_date); - //We've hit the max force settlement. Can't settle more now. - BOOST_CHECK(db.find(settle_id)); - BOOST_CHECK_EQUAL(get_balance(nathan_id, asset_id_type()), 5344); - BOOST_CHECK(!db.get_index_type().indices().empty()); - - generate_blocks(db.get_dynamic_global_properties().next_maintenance_time); - //Now it's been another maintenance interval, so we should have some more settlement. - //I can't force settle all existing asset, but with a 90% limit, I get pretty close. - BOOST_CHECK(db.find(settle_id)); - BOOST_CHECK_EQUAL(get_balance(nathan_id, asset_id_type()), 5878); - BOOST_CHECK(!db.get_index_type().indices().empty()); -} FC_LOG_AND_RETHROW() -*/ -} - BOOST_FIXTURE_TEST_CASE( pop_block_twice, database_fixture ) { try