Skip to content

feat(persist_test_utils)!: Add async suite to test AsyncWalletPersister - #518

Merged
ValuedMammal merged 2 commits into
bitcoindevkit:masterfrom
bladed-operative:feat/persist-test-utils-async
Jul 27, 2026
Merged

feat(persist_test_utils)!: Add async suite to test AsyncWalletPersister#518
ValuedMammal merged 2 commits into
bitcoindevkit:masterfrom
bladed-operative:feat/persist-test-utils-async

Conversation

@bladed-operative

Copy link
Copy Markdown
Contributor

Description

Picks up the work started on #343 by extending the persist_test_utils module with an async test suite for AsyncWalletPersister.

The public test functions previously took a filename: &str and a path-based closure, managed tempfile::tempdir() internally, and panicked on failure. This redesigns the API so callers supply a FnOnce closure that owns the store directly, and all functions return Result<(), PersistError> instead of panicking. A new PersistError enum exposes failures as structured values with ChangeSetMismatch and Persister variants. persist_single_keychain is removed, and its coverage is absorbed into persist_keychains, which now runs two rounds: external descriptor only, then external plus change descriptor with merge verification. anyhow and tempfile are removed from the test-utils feature's optional dependencies and kept only as dev-dependencies.

Adds async counterparts to every public function in the WalletPersister test suite so implementors of AsyncWalletPersister can exercise the same scenarios: persist_wallet_changeset_async, persist_keychains_async, and persist_network_async. Two private helpers, init_async_wallet_persister and check_changest_is_persisted_async, mirror the sync suite API.

Changelog notice

Added

  • persist-test-utils: Add public functions persist_wallet_changeset_async, persist_keychains_async, and persist_network_async for testing AsyncWalletPersister
  • Added PersistError enum with ChangeSetMismatch and Persister variants

Changed

  • Refactored persist_test_utils public API. callers own store construction; functions now return Result<(), PersistError>
  • deps: Removed optional anyhow and tempfile dependencies from the test-utils feature

Removed

  • Removed persist_single_keychain; persist_keychains now covers the single-keychain case

Before submitting

…e deps

Redesign the API so callers supply a `FnOnce` closure that returns
the persister directly. All functions return
`Result<(), PersistError>` instead of panicking. Add `PersistError`
enum with `Persister` and `ChangeSetMismatch` variants.

Factor common logic into internal helpers `init_wallet_persister` and
`check_changeset_is_persisted` for reuse by each of the public functions.
Remove `persist_single_keychain`. Single-keychain persistence is
covered by `persist_keychains`.

Remove `anyhow` and `tempfile` from the test-utils feature's optional
dependencies.
Add async counterparts to the test suite to exercise implementations
of AsyncWalletPersister. All entry points use the
`F: AsyncFnOnce() -> Result<P, P::Error>` bound, consistent with
the sync API pattern.

`persist_wallet_changeset_async` tests a full changeset round-trip
followed by a second changeset to verify merge semantics.
`persist_keychains_async` runs the two-round descriptor persistence
check. `persist_network_async` verifies the network field round-trips
correctly.

Add private helpers `init_async_wallet_persister` and
`check_changeset_is_persisted_async` to mirror the sync suite.
@codecov

codecov Bot commented Jul 27, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 81.84%. Comparing base (0416409) to head (d138ebb).

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #518      +/-   ##
==========================================
+ Coverage   81.77%   81.84%   +0.06%     
==========================================
  Files          25       25              
  Lines        6487     6487              
  Branches      296      296              
==========================================
+ Hits         5305     5309       +4     
+ Misses       1080     1078       -2     
+ Partials      102      100       -2     
Flag Coverage Δ
rust 81.84% <ø> (+0.06%) ⬆️

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.

@ValuedMammal
ValuedMammal merged commit fc88144 into bitcoindevkit:master Jul 27, 2026
14 checks passed
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