From 9ee77701ddb44c661da753f330bc09078138b2d4 Mon Sep 17 00:00:00 2001 From: Hodlinator <172445034+hodlinator@users.noreply.github.com> Date: Tue, 7 Apr 2026 21:45:17 +0200 Subject: [PATCH] refactor(test): Only specify TestChain100Setup in test cases Reduces risk for accidental use of costly TestChain100Setup in later added test cases. --- src/test/disconnected_transactions.cpp | 4 ++-- src/test/interfaces_tests.cpp | 14 +++++++------- src/test/txdownload_tests.cpp | 2 +- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/test/disconnected_transactions.cpp b/src/test/disconnected_transactions.cpp index a363fe8197d..076d81cfb35 100644 --- a/src/test/disconnected_transactions.cpp +++ b/src/test/disconnected_transactions.cpp @@ -7,10 +7,10 @@ #include #include -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 1a98256ce2e..584a5cef2f6 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 d7ddef905b0..296daf5fcfd 100644 --- a/src/test/txdownload_tests.cpp +++ b/src/test/txdownload_tests.cpp @@ -17,7 +17,7 @@ #include -BOOST_FIXTURE_TEST_SUITE(txdownload_tests, TestingSetup) +BOOST_AUTO_TEST_SUITE(txdownload_tests) struct Behaviors { bool m_txid_in_rejects;