feat: add inactive and expired keysets to fake wallet test mint ( #1596 ) #1681

Closed
Forte11Cuba wants to merge 2 commits from feat/inactive-expired-keysets-fake-wallet into main
Forte11Cuba commented 2026-02-26 07:21:06 +00:00 (Migrated from github.com)

Description

Add inactive and expired keysets to the fake wallet test mint so downstream wallet tests can exercise keyset filtering logic (closes #1596 ).

The fake mint now performs two keyset rotations at startup, producing:

  • Sat V1 (active) — current working keyset
  • Sat V0 (inactive, final_expiry in the past) — expired keyset scenario
  • Sat V1 (inactive, no final_expiry) — rotation-deactivated scenario
  • USD V1 (active) — non-sat keyset (unchanged)
  • Auth V1 (active) — auth keyset (unchanged)

To enable this, run_mintd_with_shutdown was decomposed into build_mint_from_settings + start_mint_services, allowing callers to interact with
the mint between build and service start.

A bug where final_expiry was hardcoded to None in DbSignatory::rotate_keyset was also fixed as part of this work.


Notes to the reviewers

  • The Mint::rotate_keyset() signature gained a final_expiry: Option<u64> parameter. All existing callers pass None so behavior is unchanged.
  • MintdInstance uses a manual Debug impl because DynMintAuthDatabase doesn't implement Debug.
  • The new build_mint_from_settings / start_mint_services public API is only used by start_fake_mint.rs for now, but could be useful for other test binaries or custom mint setups.

Suggested CHANGELOG Updates

CHANGED

  • Mint::rotate_keyset() now takes an additional final_expiry: Option<u64> parameter

ADDED

  • build_mint_from_settings() and start_mint_services() public API in cdk-mintd for composable mint setup
  • MintdInstance struct exposing the built mint before services start
  • Inactive and expired test keysets in the fake wallet mint binary
  • test_rotate_keyset_with_expiry integration test

REMOVED

FIXED

  • final_expiry passthrough in DbSignatory — was hardcoded to None, now correctly uses the value from RotateKeyArguments

Checklist

### Description Add inactive and expired keysets to the fake wallet test mint so downstream wallet tests can exercise keyset filtering logic (closes #1596 ). The fake mint now performs two keyset rotations at startup, producing: - **Sat V1 (active)** — current working keyset - **Sat V0 (inactive, `final_expiry` in the past)** — expired keyset scenario - **Sat V1 (inactive, no `final_expiry`)** — rotation-deactivated scenario - **USD V1 (active)** — non-sat keyset (unchanged) - **Auth V1 (active)** — auth keyset (unchanged) To enable this, `run_mintd_with_shutdown` was decomposed into `build_mint_from_settings` + `start_mint_services`, allowing callers to interact with the mint between build and service start. A bug where `final_expiry` was hardcoded to `None` in `DbSignatory::rotate_keyset` was also fixed as part of this work. ----- ### Notes to the reviewers - The `Mint::rotate_keyset()` signature gained a `final_expiry: Option<u64>` parameter. All existing callers pass `None` so behavior is unchanged. - `MintdInstance` uses a manual `Debug` impl because `DynMintAuthDatabase` doesn't implement `Debug`. - The new `build_mint_from_settings` / `start_mint_services` public API is only used by `start_fake_mint.rs` for now, but could be useful for other test binaries or custom mint setups. ----- ### Suggested [CHANGELOG](https://github.com/cashubtc/cdk/blob/main/CHANGELOG.md) Updates <!-- Please do not edit the actual changelog but note what you changed here. --> #### CHANGED - `Mint::rotate_keyset()` now takes an additional `final_expiry: Option<u64>` parameter #### ADDED - `build_mint_from_settings()` and `start_mint_services()` public API in `cdk-mintd` for composable mint setup - `MintdInstance` struct exposing the built mint before services start - Inactive and expired test keysets in the fake wallet mint binary - `test_rotate_keyset_with_expiry` integration test #### REMOVED #### FIXED - `final_expiry` passthrough in `DbSignatory` — was hardcoded to `None`, now correctly uses the value from `RotateKeyArguments` ---- ### Checklist * [x] I followed the [code style guidelines](https://github.com/cashubtc/cdk/blob/main/CODE_STYLE.md) * [ ] I ran `just final-check` before committing
thesimplekid (Migrated from github.com) reviewed 2026-02-26 10:32:53 +00:00
thesimplekid (Migrated from github.com) left a comment

Thanks for picking this up.

Could we separate the fix of the hard coding the final expiry into its own pr as we can get that in first.

For the issue @robwoodgate opened we need to expose the ability to set these keysets in mintd and specifically in the env that docker uses since that is what cashu-ts uses to test. I believe this pr only exposes it within cdk though that is useful for our testing.

Thanks for picking this up. Could we separate the fix of the hard coding the final expiry into its own pr as we can get that in first. For the issue @robwoodgate opened we need to expose the ability to set these keysets in mintd and specifically in the env that docker uses since that is what cashu-ts uses to test. I believe this pr only exposes it within cdk though that is useful for our testing.
@ -1344,0 +1360,4 @@
.field(
"auth_localstore",
&self.auth_localstore.as_ref().map(|_| "<auth_db>"),
)
thesimplekid (Migrated from github.com) commented 2026-02-26 10:31:52 +00:00

I think it maybe better to modify the mint_builder with a fn that adds the keysets in the configuration we want rather then using the rotate_keyset.

I think it maybe better to modify the mint_builder with a fn that adds the keysets in the configuration we want rather then using the rotate_keyset.
@ -1344,0 +1362,4 @@
&self.auth_localstore.as_ref().map(|_| "<auth_db>"),
)
.finish()
}
thesimplekid (Migrated from github.com) commented 2026-02-26 10:27:13 +00:00

Why is it required to split this? Can't the rotate just be called on the Mint?

Why is it required to split this? Can't the rotate just be called on the `Mint`?
Forte11Cuba commented 2026-02-27 02:29:11 +00:00 (Migrated from github.com)

Thanks for the review!

I've separated the final_expiry fix into its own PR: #1686

Regarding the MintBuilder approach that makes sense. I'll rework this PR to add keyset configuration directly in the MintBuilder instead of splitting run_mintd_with_shutdown. Will also look into exposing it via mintd settings/env for Docker.

Thanks for the review! I've separated the final_expiry fix into its own PR: #1686 Regarding the MintBuilder approach that makes sense. I'll rework this PR to add keyset configuration directly in the MintBuilder instead of splitting run_mintd_with_shutdown. Will also look into exposing it via mintd settings/env for Docker.
Forte11Cuba commented 2026-02-27 04:27:16 +00:00 (Migrated from github.com)

Closing in favor of #1687, which implements this via MintBuilder as suggested in the review.

Closing in favor of #1687, which implements this via `MintBuilder` as suggested in the review.

Pull request closed

Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
cashubtc/cdk!1681
No description provided.