refactor(test): Only specify TestChain100Setup in test cases
What changed, and why it matters
This is a test-only code cleanup. It moves the setup of a shared test fixture from the entire test suite down to individual test cases, so future tests added to these files won't automatically inherit an expensive 100-block chain setup unless they actually need it. There is no change to production Bitcoin Core code, no bug fix, and no security vulnerability.
No security action required. Treat as normal test refactoring.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The commit refactors three test files to use BOOST_AUTO_TEST_SUITE instead of BOOST_FIXTURE_TEST_SUITE with TestChain100Setup/TestingSetup, then adds BOOST_FIXTURE_TEST_CASE to the specific test cases that require the fixture. This is purely a test-code maintainability change intended to prevent accidental costly fixture use in future tests. It does not alter runtime behavior of existing tests or any production code paths.
Changed components
src/test/disconnected_transactions.cppsrc/test/interfaces_tests.cppsrc/test/txdownload_tests.cppInspect captured patch +10 / −10
diff --git a/src/test/disconnected_transactions.cpp b/src/test/disconnected_transactions.cpp
index a363fe81..076d81cf 100644
--- a/src/test/disconnected_transactions.cpp
+++ b/src/test/disconnected_transactions.cpp
@@ -7,10 +7,10 @@
#include <kernel/disconnected_transactions.h>
#include <test/util/setup_common.h>
-BOOST_FIXTURE_TEST_SUITE(disconnected_transactions, TestChain100Setup)
+BOOST_AUTO_TEST_SUITE(disconnected_transactions)
//! Tests that DisconnectedBlockTransactions limits its own memory properly
-BOOST_AUTO_TEST_CASE(disconnectpool_memory_limits)
+BOOST_FIXTURE_TEST_CASE(disconnectpool_memory_limits, TestChain100Setup)
{
// Use the coinbase transactions from TestChain100Setup. It doesn't matter whether these
// transactions would realistically be in a block together, they just need distinct txids and
diff --git a/src/test/interfaces_tests.cpp b/src/test/interfaces_tests.cpp
index 1a98256c..584a5cef 100644
--- a/src/test/interfaces_tests.cpp
+++ b/src/test/interfaces_tests.cpp
@@ -14,9 +14,9 @@
using interfaces::FoundBlock;
-BOOST_FIXTURE_TEST_SUITE(interfaces_tests, TestChain100Setup)
+BOOST_AUTO_TEST_SUITE(interfaces_tests)
-BOOST_AUTO_TEST_CASE(findBlock)
+BOOST_FIXTURE_TEST_CASE(findBlock, TestChain100Setup)
{
LOCK(Assert(m_node.chainman)->GetMutex());
auto& chain = m_node.chain;
@@ -61,7 +61,7 @@ BOOST_AUTO_TEST_CASE(findBlock)
BOOST_CHECK(!chain->findBlock({}, FoundBlock()));
}
-BOOST_AUTO_TEST_CASE(findFirstBlockWithTimeAndHeight)
+BOOST_FIXTURE_TEST_CASE(findFirstBlockWithTimeAndHeight, TestChain100Setup)
{
LOCK(Assert(m_node.chainman)->GetMutex());
auto& chain = m_node.chain;
@@ -74,7 +74,7 @@ BOOST_AUTO_TEST_CASE(findFirstBlockWithTimeAndHeight)
BOOST_CHECK(!chain->findFirstBlockWithTimeAndHeight(/* min_time= */ active.Tip()->GetBlockTimeMax() + 1, /* min_height= */ 0));
}
-BOOST_AUTO_TEST_CASE(findAncestorByHeight)
+BOOST_FIXTURE_TEST_CASE(findAncestorByHeight, TestChain100Setup)
{
LOCK(Assert(m_node.chainman)->GetMutex());
auto& chain = m_node.chain;
@@ -85,7 +85,7 @@ BOOST_AUTO_TEST_CASE(findAncestorByHeight)
BOOST_CHECK(!chain->findAncestorByHeight(active[10]->GetBlockHash(), 20));
}
-BOOST_AUTO_TEST_CASE(findAncestorByHash)
+BOOST_FIXTURE_TEST_CASE(findAncestorByHash, TestChain100Setup)
{
LOCK(Assert(m_node.chainman)->GetMutex());
auto& chain = m_node.chain;
@@ -96,7 +96,7 @@ BOOST_AUTO_TEST_CASE(findAncestorByHash)
BOOST_CHECK(!chain->findAncestorByHash(active[10]->GetBlockHash(), active[20]->GetBlockHash()));
}
-BOOST_AUTO_TEST_CASE(findCommonAncestor)
+BOOST_FIXTURE_TEST_CASE(findCommonAncestor, TestChain100Setup)
{
auto& chain = m_node.chain;
const CChain& active{*WITH_LOCK(Assert(m_node.chainman)->GetMutex(), return &Assert(m_node.chainman)->ActiveChain())};
@@ -126,7 +126,7 @@ BOOST_AUTO_TEST_CASE(findCommonAncestor)
BOOST_CHECK_EQUAL(orig_hash, orig_tip->GetBlockHash());
}
-BOOST_AUTO_TEST_CASE(hasBlocks)
+BOOST_FIXTURE_TEST_CASE(hasBlocks, TestChain100Setup)
{
LOCK(::cs_main);
auto& chain = m_node.chain;
diff --git a/src/test/txdownload_tests.cpp b/src/test/txdownload_tests.cpp
index d7ddef90..296daf5f 100644
--- a/src/test/txdownload_tests.cpp
+++ b/src/test/txdownload_tests.cpp
@@ -17,7 +17,7 @@
#include <boost/test/unit_test.hpp>
-BOOST_FIXTURE_TEST_SUITE(txdownload_tests, TestingSetup)
+BOOST_AUTO_TEST_SUITE(txdownload_tests)
struct Behaviors {
bool m_txid_in_rejects;
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.