@@ -39,6 +39,7 @@ void initialize_block_index_tree()
39
39
FUZZ_TARGET (block_index_tree, .init = initialize_block_index_tree)
40
40
{
41
41
FuzzedDataProvider fuzzed_data_provider (buffer.data (), buffer.size ());
42
+ SetMockTime (ConsumeTime (fuzzed_data_provider));
42
43
ChainstateManager& chainman = *g_setup->m_node .chainman ;
43
44
auto & blockman = chainman.m_blockman ;
44
45
CBlockIndex* genesis = chainman.ActiveChainstate ().m_chain [0 ];
@@ -54,18 +55,19 @@ FUZZ_TARGET(block_index_tree, .init = initialize_block_index_tree)
54
55
// Receive a header building on an existing one. This assumes headers are valid, so PoW is not relevant here.
55
56
LOCK (cs_main);
56
57
CBlockIndex* prev_block = PickValue (fuzzed_data_provider, blocks);
57
- if (!(prev_block->nStatus & BLOCK_FAILED_MASK )) {
58
+ if (!(prev_block->nStatus & BLOCK_FAILED_VALID )) {
58
59
CBlockHeader header = ConsumeBlockHeader (fuzzed_data_provider, prev_block->GetBlockHash (), nonce_counter);
59
60
CBlockIndex* index = blockman.AddToBlockIndex (header, chainman.m_best_header );
60
61
assert (index ->nStatus & BLOCK_VALID_TREE);
62
+ blocks.push_back (index );
61
63
}
62
64
},
63
65
[&] {
64
66
// Receive a full block (valid or invalid) for an existing header, but don't attempt to connect it yet
65
67
LOCK (cs_main);
66
68
CBlockIndex* index = PickValue (fuzzed_data_provider, blocks);
67
69
// Must be new to us and not known to be invalid (e.g. because of an invalid ancestor).
68
- if (index ->nTx == 0 && !(index ->nStatus & BLOCK_FAILED_MASK )) {
70
+ if (index ->nTx == 0 && !(index ->nStatus & BLOCK_FAILED_VALID )) {
69
71
if (fuzzed_data_provider.ConsumeBool ()) { // Invalid
70
72
BlockValidationState state;
71
73
state.Invalid (BlockValidationResult::BLOCK_CONSENSUS, " consensus-invalid" );
@@ -118,7 +120,7 @@ FUZZ_TARGET(block_index_tree, .init = initialize_block_index_tree)
118
120
}
119
121
// Connect blocks, possibly fail
120
122
for (CBlockIndex* block : to_connect | std::views::reverse) {
121
- assert (!(block->nStatus & BLOCK_FAILED_MASK ));
123
+ assert (!(block->nStatus & BLOCK_FAILED_VALID ));
122
124
assert (block->nStatus & BLOCK_HAVE_DATA);
123
125
if (!block->IsValid (BLOCK_VALID_SCRIPTS)) {
124
126
if (fuzzed_data_provider.ConsumeBool ()) { // Invalid
0 commit comments