From cd744f5052681bf6f5ce02a406b53836b5e095b3 Mon Sep 17 00:00:00 2001 From: Kevin Heifner Date: Thu, 29 Jun 2023 03:22:48 -0400 Subject: [PATCH] GH-1251 Fix tests to not destroy temp dir before controller which uses it --- .../chain/webassembly/runtimes/eos-vm-oc/code_cache.cpp | 6 ------ plugins/chain_plugin/test/plugin_config_test.cpp | 2 +- plugins/producer_plugin/test/test_read_only_trx.cpp | 4 ++-- plugins/producer_plugin/test/test_trx_full.cpp | 2 +- 4 files changed, 4 insertions(+), 10 deletions(-) diff --git a/libraries/chain/webassembly/runtimes/eos-vm-oc/code_cache.cpp b/libraries/chain/webassembly/runtimes/eos-vm-oc/code_cache.cpp index a43f8ac932..60cac3dc19 100644 --- a/libraries/chain/webassembly/runtimes/eos-vm-oc/code_cache.cpp +++ b/libraries/chain/webassembly/runtimes/eos-vm-oc/code_cache.cpp @@ -306,12 +306,6 @@ code_cache_base::code_cache_base(const std::filesystem::path data_dir, const eos } void code_cache_base::set_on_disk_region_dirty(bool dirty) { - // tests can remove directory before destructor is called - if (!std::filesystem::exists(_cache_file_path)) { - wlog("Unable to sync code cache, cache file does not exist"); - return; - } - bip::file_mapping dirty_mapping(_cache_file_path.generic_string().c_str(), bip::read_write); bip::mapped_region dirty_region(dirty_mapping, bip::read_write); diff --git a/plugins/chain_plugin/test/plugin_config_test.cpp b/plugins/chain_plugin/test/plugin_config_test.cpp index ce308cc2e4..e43b0bfbd3 100644 --- a/plugins/chain_plugin/test/plugin_config_test.cpp +++ b/plugins/chain_plugin/test/plugin_config_test.cpp @@ -5,8 +5,8 @@ #include BOOST_AUTO_TEST_CASE(chain_plugin_default_tests) { - appbase::scoped_app app; fc::temp_directory tmp; + appbase::scoped_app app; auto tmp_path = tmp.path().string(); std::array args = { diff --git a/plugins/producer_plugin/test/test_read_only_trx.cpp b/plugins/producer_plugin/test/test_read_only_trx.cpp index e89dfc2d6a..19c25d0d60 100644 --- a/plugins/producer_plugin/test/test_read_only_trx.cpp +++ b/plugins/producer_plugin/test/test_read_only_trx.cpp @@ -52,8 +52,8 @@ BOOST_AUTO_TEST_SUITE(read_only_trxs) enum class app_init_status { failed, succeeded }; void test_configs_common(std::vector& specific_args, app_init_status expected_status) { - appbase::scoped_app app; fc::temp_directory temp; + appbase::scoped_app app; auto temp_dir_str = temp.path().string(); fc::logger::get(DEFAULT_LOGGER).set_log_level(fc::log_level::debug); @@ -92,8 +92,8 @@ BOOST_AUTO_TEST_CASE(not_check_configs_if_no_read_only_threads) { void test_trxs_common(std::vector& specific_args) { using namespace std::chrono_literals; - appbase::scoped_app app; fc::temp_directory temp; + appbase::scoped_app app; auto temp_dir_str = temp.path().string(); producer_plugin::set_test_mode(true); diff --git a/plugins/producer_plugin/test/test_trx_full.cpp b/plugins/producer_plugin/test/test_trx_full.cpp index b8c313bd29..34ddcc6ea9 100644 --- a/plugins/producer_plugin/test/test_trx_full.cpp +++ b/plugins/producer_plugin/test/test_trx_full.cpp @@ -99,9 +99,9 @@ BOOST_AUTO_TEST_SUITE(ordered_trxs_full) // Test verifies that transactions are processed, reported to caller, and not lost // even when blocks are aborted and some transactions fail. BOOST_AUTO_TEST_CASE(producer) { + fc::temp_directory temp; appbase::scoped_app app; - fc::temp_directory temp; auto temp_dir_str = temp.path().string(); {