Skip to content

test(chain): cover TxGraph::insert_anchor highest-height indexing - #2390

Open
evanlinjin wants to merge 1 commit into
bitcoindevkit:masterfrom
evanlinjin:dv/replace-2345
Open

evanlinjin wants to merge 1 commit into
bitcoindevkit:masterfrom
evanlinjin:dv/replace-2345

Conversation

@evanlinjin

Copy link
Copy Markdown
Member

Description

Adds a regression test that TxGraph::insert_anchor keeps exactly one txids_by_descending_anchor_height entry per tx, at its highest anchor height, and that the index is rebuilt the same way from the changesets.

The bug in #2344 (the index used the last anchor in the BTreeSet, which wasn't necessarily the highest one) went away with #2299: Anchor now only has anchor_block(), and its Ord compares the BlockId first, so the last anchor is the highest. This test pins that down, using ConfirmationBlockTimes whose confirmation times aren't in height order, plus a second anchor at the same height.

Unlike #2345, this is test-only: the original's code change is no longer in its diff after the rebase, and its CanonicalTask unit test covers the same ordering through a crate-private API. assert_eq!(recovered, graph) already compares the index (TxGraph derives PartialEq), so the test doesn't need a separate check on recovered.

Replaces #2345
Fixes #2344

Changelog notice

None (test only).

Checklists

All Submissions:

🤖 Generated with Claude Code

@codecov

codecov Bot commented Oct 18, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 79.71%. Comparing base (fbe1aa6) to head (ab40d6b).
⚠️ Report is 18 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2390      +/-   ##
==========================================
+ Coverage   79.11%   79.71%   +0.60%     
==========================================
  Files          31       31              
  Lines        6061     6148      +87     
  Branches      289      291       +2     
==========================================
+ Hits         4795     4901     +106     
+ Misses       1187     1176      -11     
+ Partials       79       71       -8     
Flag Coverage Δ
rust 79.71% <ø> (+0.60%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@evanlinjin
evanlinjin marked this pull request as ready for review October 18, 2026 12:50
@evanlinjin
evanlinjin requested a review from a team as a code owner October 18, 2026 12:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Triage

Development

Successfully merging this pull request may close these issues.

Anchor ordering can produce incorrect confirmation heights

1 participant