Review report

bitcoin/bitcoin: PR #36789

1 suggestion

Optional improvements

Link

[suggestion] · FindTx iterator-error propagation lacks regression coverage

The checked-in tests do not distinguish a failed FindTx candidate scan from a healthy miss, so removing the new status check would leave their assertions unchanged.

Location: src/index/txindex.cpp:212 (head).

Details and suggested fix

The txindex tests use healthy databases, and dbwrapper_read_throws_on_db_error asserts only point-read behavior. Add a regression that first retrieves a transaction from an on-disk txindex, then induces an iterator read error during its 'x'-prefix scan and asserts that FindTx() throws dbwrapper_error, with a healthy miss returning nullopt as a control. Target the failure so construction's HasKeyStartingWith probe and salt read succeed, and ensure it comes from the scan rather than a BlockSeqKey point read. Account for cached blocks: fill_cache=false does not bypass existing cache entries. Also cover an error retained while the iterator remains valid: LevelDB can skip an unreadable data block and reach a later entry, which is why this unconditional check must not become conditional on !Valid(). At wrapper level, the existing corruption fixture can check that seeking followed by CheckStatus() throws, and the healthy iterator fixture can check that exhaustion does not throw. Those wrapper assertions alone would not protect the call in FindTx(). If a deterministic FindTx test proves brittle, provide exact manual reproduction steps covering flushing, targeted damage and cache handling, as permitted by doc/developer-notes.md:670-676; the linked external reproducer and brief experiment description do not provide those steps here.


Coverage details