Skip to content

test(core): add unit tests for TxUpdate methods - #2410

Closed
ravindra-RKB wants to merge 1 commit into
bitcoindevkit:masterfrom
ravindra-RKB:test/core-tx-update
Closed

ravindra-RKB wants to merge 1 commit into
bitcoindevkit:masterfrom
ravindra-RKB:test/core-tx-update

Conversation

@ravindra-RKB

Copy link
Copy Markdown
Contributor

Description

Add unit test coverage for TxUpdate methods in crates/core/tests/test_tx_update.rs.

TxUpdate is the primary interchange data structure used across BDK chain sources to communicate discovered transaction data, but its test target previously only checked default emptiness (test_empty).

This adds test coverage for:

  • test_is_empty_false_when_any_field_populated: verifies that is_empty() returns false when any individual field (txs, txouts, anchors, seen_ats, evicted_ats) is populated.
  • test_extend: verifies extending with an empty update is idempotent, extending an empty update populates all fields, and extending with a populated update properly combines txs, overwrites conflicting txouts with the new output, and unions set fields (anchors, seen_ats, evicted_ats).
  • test_map_anchors: verifies that map_anchors transforms anchor types while preserving all transactions, txouts, seen_ats, and evicted_ats.

Notes to the reviewers

  • All tests pass locally via cargo test -p bdk_core --test test_tx_update.
  • Formatting verified with cargo fmt --all --check and lints verified with cargo clippy -p bdk_core --all-targets -- -D warnings.

Changelog notice

  • Add unit tests for TxUpdate methods in bdk_core.

Checklists

All Submissions:

New Features:

  • I've added tests for the new feature

Add unit tests covering TxUpdate methods in crates/core/tests/test_tx_update.rs:
- test_is_empty_false_when_any_field_populated: verifies that is_empty() returns false when any of txs, txouts, anchors, seen_ats, or evicted_ats is populated.
- test_extend: verifies that extending with an empty update is idempotent, extending an empty update populates all fields, and extending with a populated update properly combines txs, overwrites conflicting txouts, and unions all set fields.
- test_map_anchors: verifies that map_anchors correctly transforms anchor types while preserving all transactions, txouts, seen_ats, and evicted_ats.
@ravindra-RKB
ravindra-RKB requested a review from a team as a code owner October 19, 2026 17:13
@github-project-automation github-project-automation Bot moved this to Triage in BDK Chain Oct 19, 2026
@codecov

codecov Bot commented Oct 19, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 80.24%. Comparing base (0ff6ade) to head (a223eca).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2410      +/-   ##
==========================================
+ Coverage   80.00%   80.24%   +0.24%     
==========================================
  Files          31       31              
  Lines        6187     6187              
  Branches      292      292              
==========================================
+ Hits         4950     4965      +15     
+ Misses       1167     1156      -11     
+ Partials       70       66       -4     
Flag Coverage Δ
rust 80.24% <ø> (+0.24%) ⬆️

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.

@evanlinjin

Copy link
Copy Markdown
Contributor

Thanks for putting this together, @ravindra-RKB. The tests are clear and CI is green.

I'm going to close it, though, for the same reason as #2113 and #2116 (see #2111 (comment)). is_empty, extend and map_anchors just pass each field through, so these tests can't catch the kind of bugs we worry about, and they'd need updating every time TxUpdate gains a field. The lib.rs reformat is already handled by #2405.

If you'd like to keep working on test coverage, these would help a lot more:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants