From b468d9f17cae3806ee5e58f16fcc7d19dc0db231 Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Sun, 26 Jan 2020 00:13:06 -0800 Subject: [PATCH] CLI: Deterministic dummy keypair generation for SigningAuthority::Offline (#7971) (#7978) automerge --- cli/src/cli.rs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/cli/src/cli.rs b/cli/src/cli.rs index 71e414e465..9cf7d8bb62 100644 --- a/cli/src/cli.rs +++ b/cli/src/cli.rs @@ -31,7 +31,7 @@ use solana_sdk::{ message::Message, native_token::lamports_to_sol, pubkey::Pubkey, - signature::{Keypair, KeypairUtil, Signature}, + signature::{keypair_from_seed, Keypair, KeypairUtil, Signature}, system_instruction::{create_address_with_seed, SystemError, MAX_ADDRESS_SEED_LEN}, system_transaction, transaction::{Transaction, TransactionError}, @@ -125,7 +125,7 @@ impl From for SigningAuthority { impl From for SigningAuthority { fn from(pubkey: Pubkey) -> Self { - SigningAuthority::Offline(pubkey, Keypair::new()) + SigningAuthority::Offline(pubkey, keypair_from_seed(pubkey.as_ref()).unwrap()) } } @@ -2092,6 +2092,7 @@ mod tests { use solana_sdk::{ account::Account, nonce_state::{Meta as NonceMeta, NonceState}, + pubkey::Pubkey, signature::{read_keypair_file, write_keypair_file}, system_program, transaction::TransactionError, @@ -2112,6 +2113,13 @@ mod tests { path } + #[test] + fn test_signing_authority_dummy_keypairs() { + let signing_authority: SigningAuthority = Pubkey::new(&[1u8; 32]).into(); + assert_eq!(signing_authority, Pubkey::new(&[1u8; 32]).into()); + assert_ne!(signing_authority, Pubkey::new(&[2u8; 32]).into()); + } + #[test] fn test_cli_parse_command() { let test_commands = app("test", "desc", "version");