Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unit test + log message related to issue #338 #341

Closed
wants to merge 8 commits into from
2 changes: 2 additions & 0 deletions libraries/chain/db_market.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -530,6 +530,8 @@ bool database::check_call_orders(const asset_object& mia, bool enable_black_swan
order_pays = usd_to_buy;

filled_call = true;
if( filled_limit )
wlog( "Multiple limit match problem (issue 338) occurred at block #${block}", ("block",head_block_num()) );
}

FC_ASSERT( filled_call || filled_limit );
Expand Down
20 changes: 20 additions & 0 deletions tests/common/database_fixture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -709,6 +709,26 @@ const limit_order_object* database_fixture::create_sell_order( const account_obj
return db.find<limit_order_object>( processed.operation_results[0].get<object_id_type>() );
}

//APM --> (for TESTS, adds above1 flag via expiration field in order to indicate if expected order price is trading above or below 1
const limit_order_object* database_fixture::create_sell_order_with_flag( const account_object& user, const asset& amount, const asset& recv, bool above1 )
{
//wdump((amount)(recv));
limit_order_create_operation buy_order;
buy_order.seller = user.id;
buy_order.amount_to_sell = amount;
buy_order.min_to_receive = recv;
if (above1) buy_order.expiration = buy_order.expiration.maximum()-1000; else
buy_order.expiration = buy_order.expiration.maximum()-1001;
trx.operations.push_back(buy_order);
for( auto& op : trx.operations ) db.current_fee_schedule().set_fee(op);
trx.validate();
auto processed = db.push_transaction(trx, ~0);
trx.operations.clear();
verify_asset_supplies(db);
//wdump((processed));
return db.find<limit_order_object>( processed.operation_results[0].get<object_id_type>() );
}

asset database_fixture::cancel_limit_order( const limit_order_object& order )
{
limit_order_cancel_operation cancel_order;
Expand Down
1 change: 1 addition & 0 deletions tests/common/database_fixture.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,7 @@ struct database_fixture {
void sign( signed_transaction& trx, const fc::ecc::private_key& key );
const limit_order_object* create_sell_order( account_id_type user, const asset& amount, const asset& recv );
const limit_order_object* create_sell_order( const account_object& user, const asset& amount, const asset& recv );
const limit_order_object* create_sell_order_with_flag( const account_object& user, const asset& amount, const asset& recv, bool above1 );
asset cancel_limit_order( const limit_order_object& order );
void transfer( account_id_type from, account_id_type to, const asset& amount, const asset& fee = asset() );
void transfer( const account_object& from, const account_object& to, const asset& amount, const asset& fee = asset() );
Expand Down
Loading