Skip to content

Commit 9840045

Browse files
committed
fix: ensure correct handling of mock endpoints
This ensures that, regardless of what has been specified for mocking, any module with no endpoints defined in the config will have a server started for it in a mock system test. Also includes removal of some newer clang-format plugins most of which should eventually be reenabled. Signed-off-by: Sam Stuewe <[email protected]>
1 parent 211bbc9 commit 9840045

File tree

2 files changed

+36
-18
lines changed

2 files changed

+36
-18
lines changed

.clang-tidy

+6-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,12 @@ Checks: '
1010
-cppcoreguidelines-pro-bounds-array-to-pointer-decay,
1111
readability-*,
1212
google-explicit-constructor,
13-
-readability-identifier-length'
13+
-readability-identifier-length,
14+
-cppcoreguidelines-avoid-const-or-ref-data-members,
15+
-bugprone-unchecked-optional-access,
16+
-cppcoreguidelines-avoid-do-while,
17+
-modernize-use-emplace,
18+
-readability-convert-member-functions-to-static'
1419
CheckOptions:
1520
- {key: cppcoreguidelines-explicit-virtual-functions.AllowOverrideAndFinal, value: true}
1621
- {key: modernize-use-override.AllowOverrideAndFinal, value: true}

tests/integration/mock_system.cpp

+30-17
Original file line numberDiff line numberDiff line change
@@ -31,29 +31,42 @@ namespace cbdc::test {
3131
const std::unordered_set<mock_system_module>& disabled_modules,
3232
config::options opts)
3333
: m_opts(std::move(opts)) {
34-
m_module_endpoints.insert({mock_system_module::watchtower,
35-
m_opts.m_watchtower_internal_endpoints});
34+
if(!m_opts.m_watchtower_internal_endpoints.empty()) {
35+
m_module_endpoints.emplace(mock_system_module::watchtower,
36+
m_opts.m_watchtower_internal_endpoints);
37+
}
38+
39+
if(!m_opts.m_atomizer_endpoints.empty()) {
40+
m_module_endpoints.emplace(mock_system_module::atomizer,
41+
m_opts.m_atomizer_endpoints);
42+
}
3643

37-
m_module_endpoints.insert(
38-
{mock_system_module::atomizer, m_opts.m_atomizer_endpoints});
44+
if(!m_opts.m_coordinator_endpoints.empty()) {
45+
auto coord_eps = std::vector<network::endpoint_t>();
46+
for(const auto& node_eps : m_opts.m_coordinator_endpoints) {
47+
coord_eps.insert(coord_eps.end(),
48+
node_eps.begin(),
49+
node_eps.end());
50+
}
3951

40-
auto coord_eps = std::vector<network::endpoint_t>();
41-
for(const auto& node_eps : m_opts.m_coordinator_endpoints) {
42-
coord_eps.insert(coord_eps.end(),
43-
node_eps.begin(),
44-
node_eps.end());
52+
m_module_endpoints.emplace(mock_system_module::coordinator,
53+
coord_eps);
4554
}
46-
m_module_endpoints.insert(
47-
{mock_system_module::coordinator, coord_eps});
4855

49-
m_module_endpoints.insert(
50-
{mock_system_module::archiver, m_opts.m_archiver_endpoints});
56+
if(!m_opts.m_archiver_endpoints.empty()) {
57+
m_module_endpoints.emplace(mock_system_module::archiver,
58+
m_opts.m_archiver_endpoints);
59+
}
5160

52-
m_module_endpoints.insert(
53-
{mock_system_module::shard, m_opts.m_shard_endpoints});
61+
if(!m_opts.m_shard_endpoints.empty()) {
62+
m_module_endpoints.emplace(mock_system_module::shard,
63+
m_opts.m_shard_endpoints);
64+
}
5465

55-
m_module_endpoints.insert(
56-
{mock_system_module::sentinel, m_opts.m_sentinel_endpoints});
66+
if(!m_opts.m_sentinel_endpoints.empty()) {
67+
m_module_endpoints.emplace(mock_system_module::sentinel,
68+
m_opts.m_sentinel_endpoints);
69+
}
5770

5871
for(const auto& m : disabled_modules) {
5972
m_module_endpoints.erase(m);

0 commit comments

Comments
 (0)