feat: add backup restore workflow
This commit is contained in:
parent
0d588fb3d9
commit
619e8eee62
7 changed files with 498 additions and 6 deletions
|
|
@ -149,6 +149,64 @@ fn geth_init_in_temp_home() {
|
|||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn backup_create_and_restore_use_separate_home_without_private_identity_keys() {
|
||||
let home = tempfile::tempdir().expect("tempdir");
|
||||
let backup = tempfile::tempdir().expect("backup");
|
||||
let restore = tempfile::tempdir().expect("restore");
|
||||
let restore_home = restore.path().join("restored-home");
|
||||
|
||||
let init = run_geth(home.path(), &["init"]);
|
||||
assert!(
|
||||
init.status.success(),
|
||||
"stderr: {}",
|
||||
String::from_utf8_lossy(&init.stderr)
|
||||
);
|
||||
let create = run_geth(
|
||||
home.path(),
|
||||
&[
|
||||
"--json",
|
||||
"backup",
|
||||
"create",
|
||||
"--out",
|
||||
backup.path().to_str().expect("backup path"),
|
||||
],
|
||||
);
|
||||
let create_json = command_json(&create);
|
||||
assert_eq!(create_json["type"], "backup-created");
|
||||
assert!(backup.path().join("manifest.json").exists());
|
||||
assert!(backup.path().join("home/config.toml").exists());
|
||||
assert!(backup.path().join("home/geth.sqlite").exists());
|
||||
assert!(!backup.path().join("home/identity/agent.ed25519").exists());
|
||||
assert!(
|
||||
create_json["manifest"]["excludes"]
|
||||
.as_array()
|
||||
.expect("excludes")
|
||||
.iter()
|
||||
.any(|entry| entry
|
||||
.as_str()
|
||||
.expect("exclude")
|
||||
.contains("private SSH admin keys"))
|
||||
);
|
||||
|
||||
let restore_output = run_geth(
|
||||
home.path(),
|
||||
&[
|
||||
"--json",
|
||||
"backup",
|
||||
"restore",
|
||||
backup.path().to_str().expect("backup path"),
|
||||
"--target-home",
|
||||
restore_home.to_str().expect("restore path"),
|
||||
],
|
||||
);
|
||||
let restore_json = command_json(&restore_output);
|
||||
assert_eq!(restore_json["type"], "backup-restored");
|
||||
assert!(restore_home.join("config.toml").exists());
|
||||
assert!(restore_home.join("geth.sqlite").exists());
|
||||
assert!(!restore_home.join("identity/agent.ed25519").exists());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn cli_help_documents_owner_init_keys() {
|
||||
let home = tempfile::tempdir().expect("tempdir");
|
||||
|
|
|
|||
Loading…
Reference in a new issue