Skip to content

Commit 22b1757

Browse files
committed
validation: Proper validation state set for "out of order" check in CheckBlock.
1 parent 9606474 commit 22b1757

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

src/test/validation_block_tests.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -143,10 +143,10 @@ BOOST_AUTO_TEST_CASE(processnewblock_signals_ordering)
143143
if (block->vtx.size() == 1) {
144144
bool processed = ProcessNewBlock(state, block, nullptr);
145145
// Future to do: "prevblk-not-found" here is the only valid reason to not check processed flag.
146-
if (state.GetRejectReason() == "duplicate" ||
147-
state.GetRejectReason() == "prevblk-not-found" ||
148-
state.GetRejectReason() == "bad-prevblk") continue;
149-
ASSERT_WITH_MSG(!processed, ("Error: " + state.GetRejectReason()).c_str());
146+
std::string stateReason = state.GetRejectReason();
147+
if (stateReason == "duplicate" || stateReason == "prevblk-not-found" ||
148+
stateReason == "bad-prevblk" || stateReason == "blk-out-of-order") continue;
149+
ASSERT_WITH_MSG(processed, ("Error: " + state.GetRejectReason()).c_str());
150150
}
151151
}
152152
});

src/validation.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2759,7 +2759,7 @@ bool CheckBlock(const CBlock& block, CValidationState& state, bool fCheckPOW, bo
27592759
//out of order
27602760
auto mi = mapBlockIndex.find(block.hashPrevBlock);
27612761
if (mi == mapBlockIndex.end()) {
2762-
return false;
2762+
return state.Error("blk-out-of-order");
27632763
}
27642764
pindexPrev = mi->second;
27652765
}

0 commit comments

Comments
 (0)