Skip to content

Commit

Permalink
Tests something for nothing after hardfork #184
Browse files Browse the repository at this point in the history
  • Loading branch information
abitmore committed Feb 14, 2018
1 parent 7c2c1bb commit 1de9270
Showing 1 changed file with 47 additions and 0 deletions.
47 changes: 47 additions & 0 deletions tests/tests/operation_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1155,6 +1155,53 @@ BOOST_AUTO_TEST_CASE( trade_amount_equals_zero )
}
}

/**
* The something-for-nothing bug should be fixed https://github.com/bitshares/bitshares-core/issues/184
*/
BOOST_AUTO_TEST_CASE( trade_amount_equals_zero_after_hf_184 )
{
try {
INVOKE(issue_uia);
generate_blocks( HARDFORK_CORE_184_TIME );
set_expiration( db, trx );

const asset_object& test = get_asset( UIA_TEST_SYMBOL );
const asset_id_type test_id = test.id;
const asset_object& core = get_asset( GRAPHENE_SYMBOL );
const asset_id_type core_id = core.id;
const account_object& core_seller = create_account( "shorter1" );
const account_object& core_buyer = get_account("nathan");

transfer( committee_account(db), core_seller, asset( 100000000 ) );

BOOST_CHECK_EQUAL(get_balance(core_buyer, core), 0);
BOOST_CHECK_EQUAL(get_balance(core_buyer, test), 10000000);
BOOST_CHECK_EQUAL(get_balance(core_seller, test), 0);
BOOST_CHECK_EQUAL(get_balance(core_seller, core), 100000000);

create_sell_order(core_seller, core.amount(1), test.amount(2));
create_sell_order(core_seller, core.amount(1), test.amount(2));
create_sell_order(core_buyer, test.amount(3), core.amount(1));

BOOST_CHECK_EQUAL(get_balance(core_buyer, core), 1);
BOOST_CHECK_EQUAL(get_balance(core_buyer, test), 9999998);
BOOST_CHECK_EQUAL(get_balance(core_seller, core), 99999998);
BOOST_CHECK_EQUAL(get_balance(core_seller, test), 2);

generate_block();

auto result = get_market_order_history(core_id, test_id);
BOOST_CHECK_EQUAL(result.size(), 2);
BOOST_CHECK(result[0].op.pays == core.amount(1));
BOOST_CHECK(result[0].op.receives == test.amount(2));
BOOST_CHECK(result[1].op.pays == test.amount(2));
BOOST_CHECK(result[1].op.receives == core.amount(1));
} catch( const fc::exception& e) {
edump((e.to_detail_string()));
throw;
}
}

/**
* Create an order that cannot be filled immediately and have the
* transaction fail.
Expand Down

0 comments on commit 1de9270

Please sign in to comment.