Skip to content

Commit

Permalink
Cleanup tests
Browse files Browse the repository at this point in the history
  • Loading branch information
elizabethengelman committed Dec 2, 2024
1 parent a6756f1 commit 072a3af
Showing 1 changed file with 15 additions and 16 deletions.
31 changes: 15 additions & 16 deletions cmd/soroban-cli/src/config/secret.rs
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ mod tests {
}

#[test]
fn test_from_str_for_seed_phrase() {
fn test_secret_from_seed_phrase() {
let secret = Secret::from_str(TEST_SEED_PHRASE).unwrap();
let public_key = secret.public_key(None).unwrap();
let private_key = secret.private_key(None).unwrap();
Expand All @@ -232,32 +232,31 @@ mod tests {
}

#[test]
fn test_from_str_for_ledger_secret() {
fn test_secret_from_ledger() {
let secret = Secret::from_str("ledger").unwrap();

assert!(matches!(secret, Secret::Ledger));
}

#[test]
#[should_panic]
fn test_ledger_secret_will_not_reveal_private_key() {
let secret = Secret::from_str("ledger").unwrap();
secret.private_key(None).unwrap();
let private_key_result = secret.private_key(None);
assert!(private_key_result.is_err());
assert!(matches!(
private_key_result.unwrap_err(),
Error::LedgerDoesNotRevealSecretKey
));
}

#[test]
fn test_from_str_for_secure_store_secret() {
fn test_secret_from_secure_store() {
//todo: add assertion for getting public key - will need to mock the keychain and add the keypair to the keychain
let secret = Secret::from_str("secure_store:org.stellar.cli-alice").unwrap();

assert!(matches!(secret, Secret::SecureStore { .. }));
}

#[test]
#[should_panic]
fn test_secure_store_will_not_reveal_private_key() {
let secret = Secret::from_str("secure_store").unwrap();
secret.private_key(None).unwrap();
let private_key_result = secret.private_key(None);
assert!(private_key_result.is_err());
assert!(matches!(
private_key_result.unwrap_err(),
Error::SecureStoreDoesNotRevealSecretKey
));
}

#[test]
Expand Down

0 comments on commit 072a3af

Please sign in to comment.