commit 63d5214db3e256e75d1c1d5d25e9ab6eab6203a7
parent 5b125f343f1b55436954db44cea73e2050d96915
Author: triesap <tyson@radroots.org>
Date: Sun, 29 Mar 2026 02:43:47 +0000
remote-signer: align typed pending poll app coverage
Diffstat:
3 files changed, 28 insertions(+), 30 deletions(-)
diff --git a/crates/remote-signer/src/custody.rs b/crates/remote-signer/src/custody.rs
@@ -529,14 +529,16 @@ mod tests {
let path = temp.path().join("sessions.json");
std::fs::write(path.as_path(), "{invalid").expect("write invalid");
let manager = RadrootsNostrAccountsManager::new_in_memory();
+ let alice_client_account_id = fixture_public(&FIXTURE_ALICE).id;
+ let bob_client_account_id = fixture_public(&FIXTURE_BOB).id;
let public = fixture_public(&FIXTURE_CAROL);
manager
.upsert_public_identity(public, Some(REMOTE_SIGNER_LABEL.to_owned()), true)
.expect("upsert");
let vault = RadrootsNostrSecretVaultMemory::new();
- secret_store_secret(&vault, FIXTURE_ALICE.id, "pending");
- secret_store_secret(&vault, FIXTURE_BOB.id, "active");
+ secret_store_secret(&vault, alice_client_account_id.as_str(), "pending");
+ secret_store_secret(&vault, bob_client_account_id.as_str(), "active");
radroots_app_remote_signer_reconcile_startup(
&manager,
@@ -546,20 +548,23 @@ mod tests {
secret_remover(vault.clone()),
secret_namespace_purger(
vault.clone(),
- vec![FIXTURE_ALICE.id.to_owned(), FIXTURE_BOB.id.to_owned()],
+ vec![
+ alice_client_account_id.to_string(),
+ bob_client_account_id.to_string(),
+ ],
),
)
.expect("reconcile after quarantine");
assert!(
vault
- .load_secret_hex(&fixture_account_id(FIXTURE_ALICE.id))
+ .load_secret_hex(&fixture_account_id(alice_client_account_id.as_str()))
.expect("pending removed by namespace purge")
.is_none()
);
assert!(
vault
- .load_secret_hex(&fixture_account_id(FIXTURE_BOB.id))
+ .load_secret_hex(&fixture_account_id(bob_client_account_id.as_str()))
.expect("active removed by namespace purge")
.is_none()
);
@@ -573,9 +578,10 @@ mod tests {
.save(path.as_path())
.expect("save empty");
let manager = RadrootsNostrAccountsManager::new_in_memory();
+ let alice_client_account_id = fixture_public(&FIXTURE_ALICE).id;
let vault = RadrootsNostrSecretVaultMemory::new();
- secret_store_secret(&vault, FIXTURE_ALICE.id, "pending");
+ secret_store_secret(&vault, alice_client_account_id.as_str(), "pending");
radroots_app_remote_signer_reconcile_startup(
&manager,
@@ -583,13 +589,13 @@ mod tests {
REMOTE_SIGNER_LABEL,
secret_loader(vault.clone()),
secret_remover(vault.clone()),
- secret_namespace_purger(vault.clone(), vec![FIXTURE_ALICE.id.to_owned()]),
+ secret_namespace_purger(vault.clone(), vec![alice_client_account_id.to_string()]),
)
.expect("reconcile empty store");
assert!(
vault
- .load_secret_hex(&fixture_account_id(FIXTURE_ALICE.id))
+ .load_secret_hex(&fixture_account_id(alice_client_account_id.as_str()))
.expect("pending removed by empty-store namespace purge")
.is_none()
);
diff --git a/crates/remote-signer/src/protocol.rs b/crates/remote-signer/src/protocol.rs
@@ -348,17 +348,14 @@ mod tests {
}
#[test]
- fn pending_error_response_is_classified_as_pending_approval() {
- let outcome = classify_pending_poll_response(RadrootsNostrConnectResponse::Error {
- result: None,
- error: radroots_nostr_connect::prelude::RADROOTS_NOSTR_CONNECT_PENDING_CONNECTION_ERROR
- .to_owned(),
- });
+ fn pending_connection_response_is_classified_as_pending_approval() {
+ let outcome =
+ classify_pending_poll_response(RadrootsNostrConnectResponse::PendingConnection);
- assert_eq!(
+ assert!(matches!(
outcome,
RadrootsAppRemoteSignerPendingPollOutcome::PendingApproval
- );
+ ));
}
#[test]
@@ -368,12 +365,11 @@ mod tests {
error: "unauthorized".to_owned(),
});
- assert_eq!(
+ assert!(matches!(
outcome,
- RadrootsAppRemoteSignerPendingPollOutcome::Rejected {
- message: "unauthorized".to_owned(),
- }
- );
+ RadrootsAppRemoteSignerPendingPollOutcome::Rejected { message }
+ if message == "unauthorized"
+ ));
}
#[test]
@@ -395,12 +391,11 @@ mod tests {
method: RadrootsNostrConnectMethod::GetPublicKey,
});
- assert_eq!(
+ assert!(matches!(
outcome,
- RadrootsAppRemoteSignerPendingPollOutcome::TransportFailure {
- message: "remote signer did not respond yet".to_owned(),
- }
- );
+ RadrootsAppRemoteSignerPendingPollOutcome::TransportFailure { message }
+ if message == "remote signer did not respond yet"
+ ));
}
#[test]
diff --git a/crates/remote-signer/src/session.rs b/crates/remote-signer/src/session.rs
@@ -220,10 +220,7 @@ impl RadrootsAppRemoteSignerSessionStoreState {
}
};
- let state: Self = serde_json::from_str(&contents)
- .map_err(|error| RadrootsAppRemoteSignerError::InvalidSessionStore(error.to_string()));
-
- let state = match state {
+ let state = match serde_json::from_str::<Self>(&contents) {
Ok(state) => state,
Err(error) => {
quarantine_invalid_store(path)?;