Commit Graph

8 Commits

Author SHA1 Message Date
Lőrinc
7ea36e985a test: preserve index crash test state
Flush the chainstate at the current tip and drain its notification before registering any index.
This lets each end-of-sync `Commit()` persist the pre-crash height and keeps the setup callback out of the simulated crash window.

Replace the TODO-marked `0` expectation with the captured tip height.
The check runs before background sync, so rebuilding cannot hide a missing checkpoint.
2026-08-22 20:30:50 -07:00
Lőrinc
5aa15df60c test: expose missing index crash checkpoint
`index_unclean_shutdown` previously checked only that each index could reopen and start background sync after the simulated crash.
An empty index at height 0 satisfies both checks, so the test could pass without preserving any pre-crash checkpoint.

Assert the current reopened height before background sync to make the false positive explicit.
2026-08-22 20:28:39 -07:00
Martin Zumsande
34c03075a5 test: run generic baseindex tests against every index type
This adds a factory that returns each index type and runs the test
in a loop against all indexes.

index_reorg_crash is left as a single test since it uses a bespoke index.
2026-07-30 15:43:32 +02:00
Martin Zumsande
11b3e251c4 test: make baseindex flush test chain-length agnostic
This is in preparation for the following commit, where the
baseindex tests are executed for multiple indexes.
Since each run increases the chain, make no absolute assumptions.
2026-07-30 15:43:32 +02:00
Martin Zumsande
8b959f4c6a test: move unclean_shutdown test to baseindex_tests
It tests generic functionality, nothing specific to the
coinststatsindex.
Mostly move-only, can be reviewed with
--color-moved=dimmed-zebra --color-moved-ws=ignore-all-space
2026-07-30 15:43:32 +02:00
Martin Zumsande
2232d6afbe test: move index_reorg_crash to baseindex_tests
It tests generic functionality, nothing specific to the
blockfilterindex.

Mostly move-only, can be reviewed with
--color-moved=dimmed-zebra --color-moved-ws=ignore-all-space
2026-07-30 15:43:32 +02:00
Martin Zumsande
3679f1ecf5 index: Don't commit ahead of the flushed chainstate
Otherwise, if the node has an unclean restart,
indexes with state (coinstatsindex) couldn't reorg to the
last flushed tip and would be corrupted.

Also updates documentation of Commit() -
the locator functionality isn't used, so the previous text was wrong:
We must have the best block in our block index after a restart.

Co-authored-by: Fabian Jahr <fjahr@protonmail.com>
2026-07-09 16:21:28 +02:00
Martin Zumsande
13c02b5466 test: add test for index commits ahead of the last flushed block
Co-authored-by: Ryan Ofsky <ryan@ofsky.org>
2026-07-09 15:20:20 +02:00