Skip to content
Draft
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
9 changes: 8 additions & 1 deletion src/test/llmq_commitment_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include <boost/test/unit_test.hpp>

#include <algorithm>
#include <optional>

using namespace llmq;
using namespace llmq::testutils;
Expand Down Expand Up @@ -124,7 +125,7 @@ BOOST_FIXTURE_TEST_CASE(commitment_check_undersized_bitset_debug_log_test, RegTe
};

std::vector<std::string> log_lines;
LogCaptureGuard guard{log_lines};
std::optional<LogCaptureGuard> guard{std::in_place, log_lines};
BOOST_REQUIRE(LogAcceptDebug(BCLog::LLMQ));

CFinalCommitmentTxPayload payload;
Expand Down Expand Up @@ -168,6 +169,12 @@ BOOST_FIXTURE_TEST_CASE(commitment_check_undersized_bitset_debug_log_test, RegTe
BOOST_CHECK(state.IsInvalid());
BOOST_CHECK_EQUAL(state.GetRejectReason(), "bad-qc-height");

// Remove the callback before reading log_lines: callbacks run under the
// logger mutex from whichever thread logs, and RegTestingSetup has
// background threads that log concurrently. DeleteCallback takes the same
// mutex, so after this reset no thread can still be mutating log_lines.
guard.reset();

// Locate the validMembers debug line emitted by CheckLLMQCommitment and
// assert the loop was clamped: with an empty bitset the rendered list must
// be empty. Old code emitted "v[0]=..." here even though the bitset had no
Expand Down
Loading