Skip to content

Commit

Permalink
Add tests for virtual limit_order_cancel op result
Browse files Browse the repository at this point in the history
  • Loading branch information
abitmore committed Mar 19, 2023
1 parent e60d9e1 commit 29d8f9b
Showing 1 changed file with 34 additions and 7 deletions.
41 changes: 34 additions & 7 deletions tests/tests/history_api_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,8 @@ BOOST_AUTO_TEST_CASE(get_account_history) {
}
}

BOOST_AUTO_TEST_CASE(get_account_history_virtual_operation_test) {
try {
BOOST_AUTO_TEST_CASE(get_account_history_virtual_operation_test)
{ try {
graphene::app::history_api hist_api(app);

asset_id_type usd_id = create_user_issued_asset("USD").get_id();
Expand All @@ -164,11 +164,38 @@ BOOST_AUTO_TEST_CASE(get_account_history_virtual_operation_test) {
BOOST_CHECK( histories.front().block_time == db.head_block_time() );
BOOST_CHECK( histories.front().is_virtual );

} catch (fc::exception &e) {
edump((e.to_detail_string()));
throw;
}
}
// Create a limit order that expires in 300 seconds
create_sell_order( dan_id, asset(10, usd_id), asset(10), db.head_block_time() + 300 );

generate_block();
fc::usleep(fc::milliseconds(100));

auto order_create_op_id = operation::tag<limit_order_create_operation>::value;

histories = hist_api.get_account_history("dan", operation_history_id_type(),
100, operation_history_id_type());

BOOST_REQUIRE_GT( histories.size(), 0 );
BOOST_CHECK_EQUAL( histories.front().op.which(), order_create_op_id );
BOOST_CHECK( histories.front().block_time == db.head_block_time() );
BOOST_CHECK( !histories.front().is_virtual );

// Let the limit order expire
generate_blocks( db.head_block_time() + 300 );
generate_block();
fc::usleep(fc::milliseconds(100));

auto order_cancel_op_id = operation::tag<limit_order_cancel_operation>::value;

histories = hist_api.get_account_history("dan", operation_history_id_type(),
100, operation_history_id_type());

BOOST_REQUIRE_GT( histories.size(), 0 );
BOOST_CHECK_EQUAL( histories.front().op.which(), order_cancel_op_id );
BOOST_CHECK( histories.front().is_virtual );
BOOST_CHECK_EQUAL( histories.front().result.which(), operation_result::tag<asset>::value );

} FC_LOG_AND_RETHROW() }

BOOST_AUTO_TEST_CASE(get_account_history_notify_all_on_creation) {
try {
Expand Down

0 comments on commit 29d8f9b

Please sign in to comment.