It would be nice if these could stay where they are. How about the following:
0diff --git a/src/test/fuzz/block_index_tree.cpp b/src/test/fuzz/block_index_tree.cpp
1index 037d168e0e..04fbbc5473 100644
2--- a/src/test/fuzz/block_index_tree.cpp
3+++ b/src/test/fuzz/block_index_tree.cpp
4@@ -14,0 +15 @@
5+#include <test/util/validation.h>
6@@ -44 +45 @@ FUZZ_TARGET(block_index_tree, .init = initialize_block_index_tree)
7- ChainstateManager& chainman = *g_setup->m_node.chainman;
8+ auto& chainman = static_cast<TestChainstateManager&>(*g_setup->m_node.chainman);
9@@ -78 +79 @@ FUZZ_TARGET(block_index_tree, .init = initialize_block_index_tree)
10- chainman.ActiveChainstate().InvalidBlockFound(index, state);
11+ chainman.InvalidBlockFound(index, state);
12@@ -97 +98 @@ FUZZ_TARGET(block_index_tree, .init = initialize_block_index_tree)
13- CBlockIndex* best_tip = chainman.ActiveChainstate().FindMostWorkChain();
14+ CBlockIndex* best_tip = chainman.FindMostWorkChain();
15@@ -130 +131 @@ FUZZ_TARGET(block_index_tree, .init = initialize_block_index_tree)
16- chainman.ActiveChainstate().InvalidBlockFound(block, state);
17+ chainman.InvalidBlockFound(block, state);
18diff --git a/src/test/util/validation.cpp b/src/test/util/validation.cpp
19index ce558078a6..b419069b19 100644
20--- a/src/test/util/validation.cpp
21+++ b/src/test/util/validation.cpp
22@@ -33,0 +34,22 @@ void TestChainstateManager::JumpOutOfIbd()
23+void TestChainstateManager::InvalidBlockFound(CBlockIndex* pindex, const BlockValidationState& state)
24+{
25+ struct TestChainstate : public Chainstate {
26+ void CallInvalidBlockFound(CBlockIndex* pindex, const BlockValidationState& state) EXCLUSIVE_LOCKS_REQUIRED(cs_main) {
27+ InvalidBlockFound(pindex, state);
28+ }
29+ };
30+
31+ static_cast<TestChainstate*>(&ActiveChainstate())->CallInvalidBlockFound(pindex, state);
32+}
33+
34+CBlockIndex* TestChainstateManager::FindMostWorkChain()
35+{
36+ struct TestChainstate : public Chainstate {
37+ CBlockIndex* CallFindMostWorkChain() EXCLUSIVE_LOCKS_REQUIRED(cs_main) {
38+ return FindMostWorkChain();
39+ }
40+ };
41+
42+ return static_cast<TestChainstate*>(&ActiveChainstate())->CallFindMostWorkChain();
43+}
44+
45diff --git a/src/test/util/validation.h b/src/test/util/validation.h
46index f9c6a8ac02..ae2e13b826 100644
47--- a/src/test/util/validation.h
48+++ b/src/test/util/validation.h
49@@ -18,0 +19,4 @@ struct TestChainstateManager : public ChainstateManager {
50+
51+ void InvalidBlockFound(CBlockIndex* pindex, const BlockValidationState& state) EXCLUSIVE_LOCKS_REQUIRED(cs_main);
52+
53+ CBlockIndex* FindMostWorkChain() EXCLUSIVE_LOCKS_REQUIRED(cs_main);
54diff --git a/src/validation.h b/src/validation.h
55index 7f284da272..9e58bc9aa7 100644
56--- a/src/validation.h
57+++ b/src/validation.h
58@@ -800,2 +799,0 @@ public:
59- void InvalidBlockFound(CBlockIndex* pindex, const BlockValidationState& state) EXCLUSIVE_LOCKS_REQUIRED(cs_main);
60- CBlockIndex* FindMostWorkChain() EXCLUSIVE_LOCKS_REQUIRED(cs_main);
61@@ -811,0 +810,2 @@ protected:
62+ void InvalidBlockFound(CBlockIndex* pindex, const BlockValidationState& state) EXCLUSIVE_LOCKS_REQUIRED(cs_main);
63+ CBlockIndex* FindMostWorkChain() EXCLUSIVE_LOCKS_REQUIRED(cs_main);
We could also add similar methods for wrapping the block manager and the best invalid entry.