From 3b8913b7ceb777179bd7fd30ace4fdd302d5e0ec Mon Sep 17 00:00:00 2001 From: Abit Date: Sun, 19 Mar 2023 02:44:55 +0100 Subject: [PATCH 1/5] Save the result of virtual limit_order_cancel op --- libraries/chain/db_market.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/libraries/chain/db_market.cpp b/libraries/chain/db_market.cpp index 05c78c0b54..397312cd90 100644 --- a/libraries/chain/db_market.cpp +++ b/libraries/chain/db_market.cpp @@ -593,7 +593,10 @@ void database::cancel_limit_order( const limit_order_object& order, bool create_ } if( create_virtual_op ) - push_applied_operation( vop ); + { + auto op_id = push_applied_operation( vop ); + set_applied_operation_result( op_id, refunded ); + } remove(order); } From e60d9e1910e0b9b7449adf389d41b6b2551bf571 Mon Sep 17 00:00:00 2001 From: Abit Date: Sun, 19 Mar 2023 12:47:12 +0100 Subject: [PATCH 2/5] Bump DB_VERSION --- libraries/chain/include/graphene/chain/config.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/chain/include/graphene/chain/config.hpp b/libraries/chain/include/graphene/chain/config.hpp index 5390eb2270..e905050d7c 100644 --- a/libraries/chain/include/graphene/chain/config.hpp +++ b/libraries/chain/include/graphene/chain/config.hpp @@ -32,7 +32,7 @@ #define GRAPHENE_MAX_NESTED_OBJECTS (200) -const std::string GRAPHENE_CURRENT_DB_VERSION = "20220930"; +const std::string GRAPHENE_CURRENT_DB_VERSION = "20230319"; #define GRAPHENE_RECENTLY_MISSED_COUNT_INCREMENT 4 #define GRAPHENE_RECENTLY_MISSED_COUNT_DECREMENT 3 From 637a414815a404effc09eba8d7e0a63776da8436 Mon Sep 17 00:00:00 2001 From: Abit Date: Sun, 19 Mar 2023 17:12:24 +0100 Subject: [PATCH 3/5] Update license year to 2023 --- LICENSE.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/LICENSE.txt b/LICENSE.txt index dab0004a09..0b8ebaf47b 100644 --- a/LICENSE.txt +++ b/LICENSE.txt @@ -1,4 +1,4 @@ -Copyright (c) 2015-2022 Cryptonomex Inc. and +Copyright (c) 2015-2023 Cryptonomex Inc. and contributors (see CONTRIBUTORS.txt) The MIT License From 40be62a0b0bafcfa9596a267f8c7db47400f3088 Mon Sep 17 00:00:00 2001 From: Abit Date: Sun, 19 Mar 2023 15:47:12 +0100 Subject: [PATCH 4/5] Add tests for virtual limit_order_cancel op result --- tests/tests/history_api_tests.cpp | 41 +++++++++++++++++++++++++------ 1 file changed, 34 insertions(+), 7 deletions(-) diff --git a/tests/tests/history_api_tests.cpp b/tests/tests/history_api_tests.cpp index c1a5f31a75..4608e4b3a1 100644 --- a/tests/tests/history_api_tests.cpp +++ b/tests/tests/history_api_tests.cpp @@ -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(); @@ -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::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::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( histories.front().result.is_type() ); + +} FC_LOG_AND_RETHROW() } BOOST_AUTO_TEST_CASE(get_account_history_notify_all_on_creation) { try { From c3a1e40bafba4e3f7f3f6add361e57474733e0ba Mon Sep 17 00:00:00 2001 From: abitmore Date: Sun, 19 Mar 2023 18:26:10 +0000 Subject: [PATCH 5/5] Set a timeout for running unit tests in Github CI --- .github/workflows/build-and-test.mac.yml | 1 + .github/workflows/build-and-test.ubuntu-debug.yml | 1 + .github/workflows/build-and-test.ubuntu-release.yml | 1 + .github/workflows/sonar-scan.yml | 1 + 4 files changed, 4 insertions(+) diff --git a/.github/workflows/build-and-test.mac.yml b/.github/workflows/build-and-test.mac.yml index de5dcd5e8a..bf43b5baae 100644 --- a/.github/workflows/build-and-test.mac.yml +++ b/.github/workflows/build-and-test.mac.yml @@ -45,6 +45,7 @@ jobs: make -j 3 -C _build witness_node cli_wallet app_test cli_test chain_test df -h - name: Unit-Tests + timeout-minutes: 15 run: | _build/tests/app_test -l test_suite libraries/fc/tests/run-parallel-tests.sh _build/tests/chain_test -l test_suite diff --git a/.github/workflows/build-and-test.ubuntu-debug.yml b/.github/workflows/build-and-test.ubuntu-debug.yml index 8946b3e036..35a506108c 100644 --- a/.github/workflows/build-and-test.ubuntu-debug.yml +++ b/.github/workflows/build-and-test.ubuntu-debug.yml @@ -110,6 +110,7 @@ jobs: du -hs _build/* du -hs /_build/* - name: Unit-Tests + timeout-minutes: 15 run: | _build/tests/app_test -l test_suite df -h diff --git a/.github/workflows/build-and-test.ubuntu-release.yml b/.github/workflows/build-and-test.ubuntu-release.yml index c149e28901..d85aed7b6b 100644 --- a/.github/workflows/build-and-test.ubuntu-release.yml +++ b/.github/workflows/build-and-test.ubuntu-release.yml @@ -87,6 +87,7 @@ jobs: make -j 2 -C _build df -h - name: Unit-Tests + timeout-minutes: 15 run: | _build/tests/app_test -l test_suite _build/tests/es_test -l test_suite diff --git a/.github/workflows/sonar-scan.yml b/.github/workflows/sonar-scan.yml index c83b9857a4..8356303fda 100644 --- a/.github/workflows/sonar-scan.yml +++ b/.github/workflows/sonar-scan.yml @@ -164,6 +164,7 @@ jobs: rm -rf _build/programs/genesis_util/get_dev_key df -h - name: Unit-Tests + timeout-minutes: 15 run: | _build/tests/app_test -l test_suite df -h