Review report

bitcoin/bitcoin: PR #36621

1 suggestion

Optional improvements

Link

[suggestion] · Unselected-file assertions accept loss of an availability flag

The batch-pruning unit test accepts an unselected block losing one availability flag because its postconditions only require either flag to remain set.

Location: src/test/blockmanager_tests.cpp:179 (head).

Details and suggested fix

The fixture checks that tip1 initially has both availability flags. After PruneBlockFiles({file0, file2}), however, tip1->nStatus & (BLOCK_HAVE_DATA | BLOCK_HAVE_UNDO) passes with either flag alone. check_unmodified() repeats this check after the rejected calls. A hypothetical regression clearing only BLOCK_HAVE_UNDO on unselected entries outside the selected-file branch could leave the raw positions, file size, and dirty-set membership unchanged, escaping these preservation assertions. Checking raw nUndoPos does not compensate: GetUndoPos() returns a null position without BLOCK_HAVE_UNDO. Save const auto tip1_status{tip1->nStatus}; alongside the saved positions and use BOOST_CHECK_EQUAL(tip1->nStatus, tip1_status) here and in check_unmodified(). The current production implementation preserves unselected entries; this only strengthens the test.


Coverage details