From b119956173706bb5dca0c88a31b7256d694af917 Mon Sep 17 00:00:00 2001 From: Sam Stuewe Date: Wed, 6 Sep 2023 10:33:28 -0500 Subject: [PATCH] fix: ensure correct handling of mock endpoints This ensures that, regardless of what has been specified for mocking, only modules with endpoints defined in the config will have servers started for them in a mock system test. This also includes removal of some newer clang-format plugins most of which should eventually be reenabled. Signed-off-by: Sam Stuewe --- .clang-tidy | 7 ++++- tests/integration/mock_system.cpp | 47 ++++++++++++++++++++----------- 2 files changed, 36 insertions(+), 18 deletions(-) diff --git a/.clang-tidy b/.clang-tidy index 7efe855e6..b1aebb03c 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -10,7 +10,12 @@ Checks: ' -cppcoreguidelines-pro-bounds-array-to-pointer-decay, readability-*, google-explicit-constructor, - -readability-identifier-length' + -readability-identifier-length, + -cppcoreguidelines-avoid-const-or-ref-data-members, + -bugprone-unchecked-optional-access, + -cppcoreguidelines-avoid-do-while, + -modernize-use-emplace, + -readability-convert-member-functions-to-static' CheckOptions: - {key: cppcoreguidelines-explicit-virtual-functions.AllowOverrideAndFinal, value: true} - {key: modernize-use-override.AllowOverrideAndFinal, value: true} diff --git a/tests/integration/mock_system.cpp b/tests/integration/mock_system.cpp index 1e95eeecf..84b6c578e 100644 --- a/tests/integration/mock_system.cpp +++ b/tests/integration/mock_system.cpp @@ -31,29 +31,42 @@ namespace cbdc::test { const std::unordered_set& disabled_modules, config::options opts) : m_opts(std::move(opts)) { - m_module_endpoints.insert({mock_system_module::watchtower, - m_opts.m_watchtower_internal_endpoints}); + if(!m_opts.m_watchtower_internal_endpoints.empty()) { + m_module_endpoints.emplace(mock_system_module::watchtower, + m_opts.m_watchtower_internal_endpoints); + } + + if(!m_opts.m_atomizer_endpoints.empty()) { + m_module_endpoints.emplace(mock_system_module::atomizer, + m_opts.m_atomizer_endpoints); + } - m_module_endpoints.insert( - {mock_system_module::atomizer, m_opts.m_atomizer_endpoints}); + if(!m_opts.m_coordinator_endpoints.empty()) { + auto coord_eps = std::vector(); + for(const auto& node_eps : m_opts.m_coordinator_endpoints) { + coord_eps.insert(coord_eps.end(), + node_eps.begin(), + node_eps.end()); + } - auto coord_eps = std::vector(); - for(const auto& node_eps : m_opts.m_coordinator_endpoints) { - coord_eps.insert(coord_eps.end(), - node_eps.begin(), - node_eps.end()); + m_module_endpoints.emplace(mock_system_module::coordinator, + coord_eps); } - m_module_endpoints.insert( - {mock_system_module::coordinator, coord_eps}); - m_module_endpoints.insert( - {mock_system_module::archiver, m_opts.m_archiver_endpoints}); + if(!m_opts.m_archiver_endpoints.empty()) { + m_module_endpoints.emplace(mock_system_module::archiver, + m_opts.m_archiver_endpoints); + } - m_module_endpoints.insert( - {mock_system_module::shard, m_opts.m_shard_endpoints}); + if(!m_opts.m_shard_endpoints.empty()) { + m_module_endpoints.emplace(mock_system_module::shard, + m_opts.m_shard_endpoints); + } - m_module_endpoints.insert( - {mock_system_module::sentinel, m_opts.m_sentinel_endpoints}); + if(!m_opts.m_sentinel_endpoints.empty()) { + m_module_endpoints.emplace(mock_system_module::sentinel, + m_opts.m_sentinel_endpoints); + } for(const auto& m : disabled_modules) { m_module_endpoints.erase(m);