Fix `solana-keygen new --force ...` (#7064)

automerge
This commit is contained in:
Michael Vines 2019-11-20 13:46:16 -07:00 committed by Grimes
parent 9f6a2e51b2
commit 1fef74b00c
1 changed files with 9 additions and 2 deletions

View File

@ -168,7 +168,7 @@ pub fn write_keypair_file(
}
}
.write(true)
.create_new(true)
.create(true)
.open(outfile)?;
write_keypair(keypair, &mut f)
@ -200,7 +200,7 @@ mod tests {
#[test]
fn test_write_keypair_file() {
let outfile = tmp_file_path("test_gen_keypair_file.json");
let outfile = tmp_file_path("test_write_keypair_file.json");
let serialized_keypair = write_keypair_file(&Keypair::new(), &outfile).unwrap();
let keypair_vec: Vec<u8> = serde_json::from_str(&serialized_keypair).unwrap();
assert!(Path::new(&outfile).exists());
@ -232,6 +232,13 @@ mod tests {
assert!(!Path::new(&outfile).exists());
}
#[test]
fn test_write_keypair_file_overwrite_ok() {
let outfile = tmp_file_path("test_write_keypair_file_overwrite_ok.json");
write_keypair_file(&Keypair::new(), &outfile).unwrap();
write_keypair_file(&Keypair::new(), &outfile).unwrap();
}
#[test]
fn test_keypair_from_seed() {
let good_seed = vec![0; 32];