Skip to content

test: Add test on skip heights in CBlockIndex#14

Draft
optout21 wants to merge 1 commit into
masterfrom
skip-height-test4
Draft

test: Add test on skip heights in CBlockIndex#14
optout21 wants to merge 1 commit into
masterfrom
skip-height-test4

Conversation

@optout21

@optout21 optout21 commented May 19, 2026

Copy link
Copy Markdown
Owner

Trial for bitcoin#33661

The skip height values computed by the (internal) function GetSkipHeight(), and the CBlockIndex::BuildSkip() method are not tested directly, and the skip logic is not well documented. To improve test coverage, a new test is added, to verify CBlockIndex::BuildSkip() and the skip height bit-manipulation logic.

Note: the original version contained a test for the complexity of the GetAncestor() algorithm, whose performance is greatly determined by the skip height logic. This test was out-scoped.

The motivation is to document the skip value computation through a test. (The issued was noticed while reviewing bitcoin#33515.)

@optout21
optout21 force-pushed the skip-height-test4 branch 2 times, most recently from 1415e29 to 6bd2a1b Compare May 19, 2026 08:00
Add new test that calls `CBlockIndex::BuildSkip()` and verifies skip height values.
It tests that:
- `pprev` field is set (to an earlier block index),
- the skip is to the index as dictated by the `GetSkipHeight()` bit-manipulation logic.
@optout21
optout21 force-pushed the skip-height-test4 branch from 6bd2a1b to 1f13afe Compare May 19, 2026 15:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant