It would be nice if these could stay where they are. How about the following:
<details>
<summary>Protected Method Wrapper</summary>
diff --git a/src/test/fuzz/block_index_tree.cpp b/src/test/fuzz/block_index_tree.cpp
index 037d168e0e..04fbbc5473 100644
--- a/src/test/fuzz/block_index_tree.cpp
+++ b/src/test/fuzz/block_index_tree.cpp
@@ -14,0 +15 @@
+#include <test/util/validation.h>
@@ -44 +45 @@ FUZZ_TARGET(block_index_tree, .init = initialize_block_index_tree)
- ChainstateManager& chainman = *g_setup->m_node.chainman;
+ auto& chainman = static_cast<TestChainstateManager&>(*g_setup->m_node.chainman);
@@ -78 +79 @@ FUZZ_TARGET(block_index_tree, .init = initialize_block_index_tree)
- chainman.ActiveChainstate().InvalidBlockFound(index, state);
+ chainman.InvalidBlockFound(index, state);
@@ -97 +98 @@ FUZZ_TARGET(block_index_tree, .init = initialize_block_index_tree)
- CBlockIndex* best_tip = chainman.ActiveChainstate().FindMostWorkChain();
+ CBlockIndex* best_tip = chainman.FindMostWorkChain();
@@ -130 +131 @@ FUZZ_TARGET(block_index_tree, .init = initialize_block_index_tree)
- chainman.ActiveChainstate().InvalidBlockFound(block, state);
+ chainman.InvalidBlockFound(block, state);
diff --git a/src/test/util/validation.cpp b/src/test/util/validation.cpp
index ce558078a6..b419069b19 100644
--- a/src/test/util/validation.cpp
+++ b/src/test/util/validation.cpp
@@ -33,0 +34,22 @@ void TestChainstateManager::JumpOutOfIbd()
+void TestChainstateManager::InvalidBlockFound(CBlockIndex* pindex, const BlockValidationState& state)
+{
+ struct TestChainstate : public Chainstate {
+ void CallInvalidBlockFound(CBlockIndex* pindex, const BlockValidationState& state) EXCLUSIVE_LOCKS_REQUIRED(cs_main) {
+ InvalidBlockFound(pindex, state);
+ }
+ };
+
+ static_cast<TestChainstate*>(&ActiveChainstate())->CallInvalidBlockFound(pindex, state);
+}
+
+CBlockIndex* TestChainstateManager::FindMostWorkChain()
+{
+ struct TestChainstate : public Chainstate {
+ CBlockIndex* CallFindMostWorkChain() EXCLUSIVE_LOCKS_REQUIRED(cs_main) {
+ return FindMostWorkChain();
+ }
+ };
+
+ return static_cast<TestChainstate*>(&ActiveChainstate())->CallFindMostWorkChain();
+}
+
diff --git a/src/test/util/validation.h b/src/test/util/validation.h
index f9c6a8ac02..ae2e13b826 100644
--- a/src/test/util/validation.h
+++ b/src/test/util/validation.h
@@ -18,0 +19,4 @@ struct TestChainstateManager : public ChainstateManager {
+
+ void InvalidBlockFound(CBlockIndex* pindex, const BlockValidationState& state) EXCLUSIVE_LOCKS_REQUIRED(cs_main);
+
+ CBlockIndex* FindMostWorkChain() EXCLUSIVE_LOCKS_REQUIRED(cs_main);
diff --git a/src/validation.h b/src/validation.h
index 7f284da272..9e58bc9aa7 100644
--- a/src/validation.h
+++ b/src/validation.h
@@ -800,2 +799,0 @@ public:
- void InvalidBlockFound(CBlockIndex* pindex, const BlockValidationState& state) EXCLUSIVE_LOCKS_REQUIRED(cs_main);
- CBlockIndex* FindMostWorkChain() EXCLUSIVE_LOCKS_REQUIRED(cs_main);
@@ -811,0 +810,2 @@ protected:
+ void InvalidBlockFound(CBlockIndex* pindex, const BlockValidationState& state) EXCLUSIVE_LOCKS_REQUIRED(cs_main);
+ CBlockIndex* FindMostWorkChain() EXCLUSIVE_LOCKS_REQUIRED(cs_main);
</details>
We could also add similar methods for wrapping the block manager and the best invalid entry.