diff --git a/ethstore/src/dir/vault.rs b/ethstore/src/dir/vault.rs index 2e777360a..f321e3fbb 100755 --- a/ethstore/src/dir/vault.rs +++ b/ethstore/src/dir/vault.rs @@ -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"); diff --git a/ethstore/src/ethstore.rs b/ethstore/src/ethstore.rs index 3cdf0e643..cacb6054f 100755 --- a/ethstore/src/ethstore.rs +++ b/ethstore/src/ethstore.rs @@ -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()); + } }