Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions cmake/common.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ function(add_unit_test name)
enable_coverage(${name})
target_link_libraries(${name} PRIVATE ccfcrypto -pthread)
add_san(${name})
add_warning_checks(${name})

add_test(NAME ${name} COMMAND ${name})
set_property(TEST ${name} APPEND PROPERTY LABELS unit)
Expand Down
4 changes: 2 additions & 2 deletions include/ccf/ds/contiguous_set.h
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ namespace ccf::ds
auto next_it = std::next(it);
if (next_it != ranges.end())
{
if (it->first + it->second + 1 == next_it->first)
if (it->first + static_cast<T>(it->second) + 1 == next_it->first)
{
it->second = it->second + 1 + next_it->second;
ranges.erase(next_it);
Expand Down Expand Up @@ -463,7 +463,7 @@ namespace ccf::ds
{
for (auto n = from; n <= from + additional; ++n)
{
const auto b = insert(n);
insert(n);
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/consensus/aft/test/committable_suffix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -646,7 +646,7 @@ DOCTEST_TEST_CASE_TEMPLATE("Multi-term divergence", T, WorstCase, RandomCase)
channels_primary->messages.clear();
};

const auto num_terms = rand() % 30 + 5;
const size_t num_terms = rand() % 30 + 5;
if constexpr (is_worst_case)
{
std::cout << fmt::format("Worst case construction with {} terms", num_terms)
Expand Down
8 changes: 6 additions & 2 deletions src/consensus/aft/test/logging_stub.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ namespace aft

LedgerStubProxy(const ccf::NodeId& id) : _id(id) {}

virtual ~LedgerStubProxy() = default;

virtual void init(Index, Index) {}

virtual void put_entry(
Expand All @@ -45,7 +47,7 @@ namespace aft
// (to mirror the deserialisation in LoggingStubStore::ExecutionWrapper).
// We also size-prefix, so in a buffer of multiple of these messages we
// can extract each with get_entry
const size_t idx = ledger.size() + 1;
[[maybe_unused]] const size_t idx = ledger.size() + 1;
assert(idx == index);
auto additional_size =
sizeof(size_t) /* size-prefix */ + ADDITIONAL_METADATA_SIZE;
Expand Down Expand Up @@ -341,6 +343,8 @@ namespace aft
public:
LoggingStubStore(ccf::NodeId id) : _id(id) {}

virtual ~LoggingStubStore() = default;

virtual void set_set_retired_committed_hook(
RCHook set_retired_committed_hook_)
{
Expand Down Expand Up @@ -523,7 +527,7 @@ namespace aft
// Read wrapping term and version
auto data_ = data.data();
auto size = data.size();
const auto committable = serialized::read<bool>(data_, size);
serialized::read<bool>(data_, size);
serialized::read<aft::Term>(data_, size);
auto version = serialized::read<ccf::kv::Version>(data_, size);
ReplicatedData r = nlohmann::json::parse(std::span{data_, size});
Expand Down
15 changes: 5 additions & 10 deletions src/consensus/aft/test/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,6 @@ DOCTEST_TEST_CASE("Single node commit" * doctest::test_suite("single"))
entry->push_back(2);
entry->push_back(3);

auto hooks = std::make_shared<ccf::kv::ConsensusHookPtrs>();

r0.replicate(ccf::kv::BatchVector{{i, entry, true, hooks}}, 1);
DOCTEST_REQUIRE(r0.get_last_idx() == i);
DOCTEST_REQUIRE(r0.get_committed_seqno() == i);
Expand Down Expand Up @@ -430,7 +428,6 @@ DOCTEST_TEST_CASE(
DOCTEST_INFO("Try to replicate on a follower, and fail");
std::vector<uint8_t> entry = {1, 2, 3};
auto data = std::make_shared<std::vector<uint8_t>>(entry);
auto hooks = std::make_shared<ccf::kv::ConsensusHookPtrs>();
DOCTEST_REQUIRE_FALSE(
r1.replicate(ccf::kv::BatchVector{{1, data, true, hooks}}, 1));

Expand Down Expand Up @@ -551,7 +548,6 @@ DOCTEST_TEST_CASE("Multiple nodes late join" * doctest::test_suite("multiple"))

std::vector<uint8_t> first_entry = {1, 2, 3};
auto data = std::make_shared<std::vector<uint8_t>>(first_entry);
auto hooks = std::make_shared<ccf::kv::ConsensusHookPtrs>();
DOCTEST_REQUIRE(
r0.replicate(ccf::kv::BatchVector{{1, data, true, hooks}}, 1));
r0.periodic(request_timeout);
Expand Down Expand Up @@ -625,7 +621,6 @@ DOCTEST_TEST_CASE("Recv append entries logic" * doctest::test_suite("multiple"))
std::make_shared<aft::ChannelStubProxy>(),
std::make_shared<aft::State>(node_id1),
nullptr);
auto hooks = std::make_shared<ccf::kv::ConsensusHookPtrs>();

aft::Configuration::Nodes config0;
config0[node_id0] = {};
Expand Down Expand Up @@ -939,14 +934,13 @@ DOCTEST_TEST_CASE("Exceed append entries limit")
// send_append_entries() triggered or not
bool expected_ae = false;

for (size_t i = 1; i <= num_big_entries; ++i)
for (size_t i = 1; i <= static_cast<size_t>(num_big_entries); ++i)
{
auto hooks = std::make_shared<ccf::kv::ConsensusHookPtrs>();
DOCTEST_REQUIRE(
r0.replicate(ccf::kv::BatchVector{{i, data, true, hooks}}, 1));
const auto received_ae =
dispatch_all_and_DOCTEST_CHECK<aft::AppendEntries>(
nodes, node_id0, r0c->messages, [&i](const auto& msg) {
nodes, node_id0, r0c->messages, [](const auto& msg) {
DOCTEST_REQUIRE(msg.term == 1);
}) > 0;
DOCTEST_REQUIRE(received_ae == expected_ae);
Expand All @@ -957,9 +951,10 @@ DOCTEST_TEST_CASE("Exceed append entries limit")
(individual_entries - num_big_entries);
auto smaller_data = std::make_shared<std::vector<uint8_t>>(data_size, 1);

for (size_t i = num_big_entries + 1; i <= individual_entries; ++i)
for (size_t i = num_big_entries + 1;
i <= static_cast<size_t>(individual_entries);
++i)
{
auto hooks = std::make_shared<ccf::kv::ConsensusHookPtrs>();
DOCTEST_REQUIRE(
r0.replicate(ccf::kv::BatchVector{{i, smaller_data, true, hooks}}, 1));
dispatch_all(nodes, node_id0, r0c->messages);
Expand Down
Loading