Skip to content

Commit

Permalink
fix: ensure correct handling of mock endpoints
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
HalosGhost committed Feb 28, 2024
1 parent f9afb23 commit b119956
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 18 deletions.
7 changes: 6 additions & 1 deletion .clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down
47 changes: 30 additions & 17 deletions tests/integration/mock_system.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,29 +31,42 @@ namespace cbdc::test {
const std::unordered_set<mock_system_module>& 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<network::endpoint_t>();
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<network::endpoint_t>();
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);
Expand Down

0 comments on commit b119956

Please sign in to comment.