Skip to content

Commit

Permalink
Fix after merging feat/os_keychain
Browse files Browse the repository at this point in the history
  • Loading branch information
elizabethengelman committed Jan 8, 2025
1 parent 4c2491b commit 3cd96bc
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
2 changes: 1 addition & 1 deletion cmd/soroban-cli/src/config/locator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ impl Args {
let identity = self.read_identity(name)?;
if let Secret::SecureStore { entry_name } = identity {
let entry = StellarEntry::new(&entry_name)?;
match entry.delete_password() {
match entry.delete_seed_phrase() {
Ok(()) => {}
Err(e) => match e {
signer::keyring::Error::Keyring(keyring::Error::NoEntry) => {
Expand Down
21 changes: 12 additions & 9 deletions cmd/soroban-cli/src/signer/keyring.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ impl StellarEntry {
Ok(self.keyring.get_password()?.parse()?)
}

pub fn delete_password(&self) -> Result<(), Error> {
pub fn delete_seed_phrase(&self) -> Result<(), Error> {
Ok(self.keyring.delete_credential()?)
}

Expand Down Expand Up @@ -150,23 +150,26 @@ mod test {
}

#[test]
fn test_delete_password() {
fn test_delete_seed_phrase() {
set_default_credential_builder(mock::default_credential_builder());

// add a keyring entry
//create a seed phrase
let seed_phrase = crate::config::secret::seed_phrase_from_seed(None).unwrap();

// create a keyring entry and set the seed_phrase
let entry = StellarEntry::new("test").unwrap();
entry.set_password("test password".as_bytes()).unwrap();
entry.set_seed_phrase(seed_phrase).unwrap();

// assert it is there
let get_password_result = entry.get_password();
assert!(get_password_result.is_ok());
let get_seed_phrase_result = entry.get_seed_phrase();
assert!(get_seed_phrase_result.is_ok());

// delete the password
let delete_password_result = entry.delete_password();
assert!(delete_password_result.is_ok());
let delete_seed_phrase_result = entry.delete_seed_phrase();
assert!(delete_seed_phrase_result.is_ok());

// confirm the entry is gone
let get_password_result = entry.get_password();
let get_password_result = entry.get_seed_phrase();
assert!(get_password_result.is_err());
assert!(matches!(
get_password_result.unwrap_err(),
Expand Down

0 comments on commit 3cd96bc

Please sign in to comment.