Skip to content
This repository has been archived by the owner on Feb 9, 2024. It is now read-only.

Commit

Permalink
more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Sajjon committed Jan 18, 2024
1 parent a986836 commit 766e698
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions profile/src/wallet/secure_storage/wallet_client_storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,28 @@ impl WalletClientStorage {
let storage = EphemeralSecureStorage::new();
(WalletClientStorage::new(storage.clone()), storage)
}

pub(crate) fn always_fail() -> Self {
WalletClientStorage::new(Arc::new(AlwaysFailStorage {}))
}
}
#[cfg(test)]
#[derive(Debug)]
struct AlwaysFailStorage {}

#[cfg(test)]
impl SecureStorage for AlwaysFailStorage {
fn load_data(&self, _key: SecureStorageKey) -> Result<Option<Vec<u8>>> {
todo!()
}

fn save_data(&self, _key: SecureStorageKey, _data: Vec<u8>) -> Result<()> {
Err(CommonError::Unknown)
}

fn delete_data_for_key(&self, _key: SecureStorageKey) -> Result<()> {
todo!()
}
}

#[cfg(test)]
Expand Down Expand Up @@ -239,4 +261,14 @@ mod tests {
.unwrap()
.contains("zoo"));
}

#[test]
fn save_mnemonic_with_passphrase_failure() {
let sut = WalletClientStorage::always_fail();
let id = FactorSourceIDFromHash::placeholder();
assert_eq!(
sut.save_mnemonic_with_passphrase(&MnemonicWithPassphrase::placeholder(), &id),
Err(CommonError::UnableToSaveMnemonicToSecureStorage(id.clone()))
);
}
}

0 comments on commit 766e698

Please sign in to comment.