preserve vault meta when changing pwd (#4650)
This commit is contained in:
parent
496a6dcfa0
commit
88cdc92ed4
@ -135,6 +135,10 @@ impl VaultKeyDirectory for VaultDiskDirectory {
|
||||
let temp_vault = VaultDiskDirectory::create_temp_vault(self, new_key.clone()).map_err(|err| SetKeyError::NonFatalOld(err))?;
|
||||
let mut source_path = temp_vault.path().expect("temp_vault is instance of DiskDirectory; DiskDirectory always returns path; qed").clone();
|
||||
let mut target_path = self.path().expect("self is instance of DiskDirectory; DiskDirectory always returns path; qed").clone();
|
||||
|
||||
// preserve meta
|
||||
temp_vault.set_meta(&self.meta()).map_err(SetKeyError::NonFatalOld)?;
|
||||
|
||||
// jump to next fs level
|
||||
source_path.push("next");
|
||||
target_path.push("next");
|
||||
|
@ -1015,4 +1015,21 @@ mod tests {
|
||||
// and we can sign with the derived contract
|
||||
assert!(store.sign(&derived, "test", &Default::default()).is_ok(), "Second password should work for second store.");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn should_save_meta_when_setting_before_password() {
|
||||
// given
|
||||
let mut dir = RootDiskDirectoryGuard::new();
|
||||
let store = EthStore::open(dir.key_dir.take().unwrap()).unwrap();
|
||||
let name = "vault"; let password = "password1";
|
||||
let new_password = "password2";
|
||||
|
||||
// when
|
||||
store.create_vault(name, password).unwrap();
|
||||
store.set_vault_meta(name, "OldMeta").unwrap();
|
||||
store.change_vault_password(name, new_password).unwrap();
|
||||
|
||||
// then
|
||||
assert_eq!(store.get_vault_meta(name).unwrap(), "OldMeta".to_owned());
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user