From 181474b721f3214444738c2835690945d4bdf2a1 Mon Sep 17 00:00:00 2001 From: Lin Huang Date: Tue, 24 Oct 2023 15:48:57 -0400 Subject: [PATCH 1/2] read_only_trx unit tests improvements * Increase max-transaction-time for setting bios contract * Refactor tests to use common command line arguments --- tests/test_read_only_trx.cpp | 48 +++++++++++++----------------------- 1 file changed, 17 insertions(+), 31 deletions(-) diff --git a/tests/test_read_only_trx.cpp b/tests/test_read_only_trx.cpp index 27a6c6be1e..635f58314c 100644 --- a/tests/test_read_only_trx.cpp +++ b/tests/test_read_only_trx.cpp @@ -106,7 +106,16 @@ void test_trxs_common(std::vector& specific_args, bool test_disable std::thread app_thread( [&]() { try { fc::logger::get(DEFAULT_LOGGER).set_log_level(fc::log_level::debug); - std::vector argv = {"test", "--data-dir", temp_dir_str.c_str(), "--config-dir", temp_dir_str.c_str()}; + std::vector argv = { + "test", // dummy executible name + "-p", "eosio", "-e", // actual arguments follow + "--data-dir", temp_dir_str.c_str(), + "--config-dir", temp_dir_str.c_str(), + "--max-transaction-time=100", + "--abi-serializer-max-time-ms=999", + "--read-only-write-window-time-us=10000", + "--read-only-read-window-time-us=400000" + }; argv.insert(argv.end(), specific_args.begin(), specific_args.end()); app->initialize(argv.size(), (char**)&argv[0]); app->find_plugin()->chain(); @@ -180,62 +189,39 @@ void test_trxs_common(std::vector& specific_args, bool test_disable // test read-only trxs on 1 threads (with --read-only-threads) BOOST_AUTO_TEST_CASE(with_1_read_only_threads) { - std::vector specific_args = { "-p", "eosio", "-e", - "--read-only-threads=1", - "--max-transaction-time=10", - "--abi-serializer-max-time-ms=999", - "--read-only-write-window-time-us=100000", - "--read-only-read-window-time-us=40000" }; + std::vector specific_args = { "--read-only-threads=1" }; test_trxs_common(specific_args); } // test read-only trxs on 3 threads (with --read-only-threads) BOOST_AUTO_TEST_CASE(with_3_read_only_threads) { - std::vector specific_args = { "-p", "eosio", "-e", - "--read-only-threads=3", - "--max-transaction-time=10", - "--abi-serializer-max-time-ms=999", - "--read-only-write-window-time-us=100000", - "--read-only-read-window-time-us=40000" }; + std::vector specific_args = { "--read-only-threads=3" }; test_trxs_common(specific_args); } // test read-only trxs on 3 threads (with --read-only-threads) BOOST_AUTO_TEST_CASE(with_3_read_only_threads_no_tierup) { - std::vector specific_args = { "-p", "eosio", "-e", - "--read-only-threads=3", + std::vector specific_args = { "--read-only-threads=3", #ifdef EOSIO_EOS_VM_OC_RUNTIME_ENABLED "--eos-vm-oc-enable=none", #endif - "--max-transaction-time=10", - "--abi-serializer-max-time-ms=999", - "--read-only-write-window-time-us=100000", - "--read-only-read-window-time-us=40000" }; + }; test_trxs_common(specific_args, true); } // test read-only trxs on 8 separate threads (with --read-only-threads) BOOST_AUTO_TEST_CASE(with_8_read_only_threads) { - std::vector specific_args = { "-p", "eosio", "-e", - "--read-only-threads=8", - "--max-transaction-time=10", - "--abi-serializer-max-time-ms=999", - "--read-only-write-window-time-us=10000", - "--read-only-read-window-time-us=400000" }; + std::vector specific_args = { "--read-only-threads=8" }; test_trxs_common(specific_args); } // test read-only trxs on 8 separate threads (with --read-only-threads) BOOST_AUTO_TEST_CASE(with_8_read_only_threads_no_tierup) { - std::vector specific_args = { "-p", "eosio", "-e", - "--read-only-threads=8", + std::vector specific_args = { "--read-only-threads=8", #ifdef EOSIO_EOS_VM_OC_RUNTIME_ENABLED "--eos-vm-oc-enable=none", #endif - "--max-transaction-time=10", - "--abi-serializer-max-time-ms=999", - "--read-only-write-window-time-us=10000", - "--read-only-read-window-time-us=400000" }; + }; test_trxs_common(specific_args, true); } From f80545a2568e1db4124de6d67e7ccc5cd6cc49b7 Mon Sep 17 00:00:00 2001 From: Lin Huang Date: Wed, 25 Oct 2023 12:20:33 -0400 Subject: [PATCH 2/2] make write-window-time as big as max-transaction-time --- tests/test_read_only_trx.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_read_only_trx.cpp b/tests/test_read_only_trx.cpp index a3429f848a..56b684da86 100644 --- a/tests/test_read_only_trx.cpp +++ b/tests/test_read_only_trx.cpp @@ -113,7 +113,7 @@ void test_trxs_common(std::vector& specific_args, bool test_disable "--config-dir", temp_dir_str.c_str(), "--max-transaction-time=100", "--abi-serializer-max-time-ms=999", - "--read-only-write-window-time-us=10000", + "--read-only-write-window-time-us=100000", "--read-only-read-window-time-us=400000" }; argv.insert(argv.end(), specific_args.begin(), specific_args.end());