Skip to content

Commit

Permalink
need unsafe-dont-encrypt arg for testing
Browse files Browse the repository at this point in the history
  • Loading branch information
brentstone committed Dec 1, 2023
1 parent 4cabebc commit bff9734
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 1 deletion.
7 changes: 7 additions & 0 deletions apps/src/lib/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5175,6 +5175,7 @@ pub mod args {
consensus_key: self
.consensus_key
.map(|x| chain_ctx.get_cached(&x)),
unsafe_dont_encrypt: self.unsafe_dont_encrypt,
tx_code_path: self.tx_code_path.to_path_buf(),
}
}
Expand All @@ -5185,11 +5186,13 @@ pub mod args {
let tx = Tx::parse(matches);
let validator = VALIDATOR.parse(matches);
let consensus_key = VALIDATOR_CONSENSUS_KEY.parse(matches);
let unsafe_dont_encrypt = UNSAFE_DONT_ENCRYPT.parse(matches);
let tx_code_path = PathBuf::from(TX_CHANGE_CONSENSUS_KEY_WASM);
Self {
tx,
validator,
consensus_key,
unsafe_dont_encrypt,
tx_code_path,
}
}
Expand All @@ -5203,6 +5206,10 @@ pub mod args {
"The desired new consensus key. A new one will be \
generated if none given. Note this key must be ed25519.",
))
.arg(UNSAFE_DONT_ENCRYPT.def().help(
"UNSAFE: Do not encrypt the generated keypairs. Do not \
use this for keys used in a live network.",
))
}
}

Expand Down
4 changes: 3 additions & 1 deletion apps/src/lib/client/tx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,7 @@ pub async fn submit_change_consensus_key<'a>(
tx: tx_args,
validator,
consensus_key,
unsafe_dont_encrypt,
tx_code_path: _,
}: args::ConsensusKeyChange,
) -> Result<(), error::Error> {
Expand Down Expand Up @@ -392,7 +393,8 @@ pub async fn submit_change_consensus_key<'a>(
})
.unwrap_or_else(|| {
display_line!(namada.io(), "Generating new consensus key...");
let password = read_and_confirm_encryption_password(false);
let password =
read_and_confirm_encryption_password(unsafe_dont_encrypt);
wallet
.gen_store_secret_key(
// Note that TM only allows ed25519 for consensus key
Expand Down
2 changes: 2 additions & 0 deletions sdk/src/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1363,6 +1363,8 @@ pub struct ConsensusKeyChange<C: NamadaTypes = SdkTypes> {
pub validator: C::Address,
/// New consensus key
pub consensus_key: Option<C::Keypair>,
/// Don't encrypt the keypair
pub unsafe_dont_encrypt: bool,
/// Path to the TX WASM code file
pub tx_code_path: PathBuf,
}
Expand Down
1 change: 1 addition & 0 deletions sdk/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,7 @@ pub trait Namada<'a>: Sized {
validator,
consensus_key: None,
tx_code_path: PathBuf::from(TX_CHANGE_CONSENSUS_KEY_WASM),
unsafe_dont_encrypt: false,
tx: self.tx_builder(),
}
}
Expand Down
3 changes: 3 additions & 0 deletions tests/src/e2e/ledger_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3738,8 +3738,11 @@ fn change_consensus_key() -> Result<()> {
"change-consensus-key",
"--validator",
"validator-0",
"--signing-keys",
"validator-0-validator-key",
"--node",
&validator_0_rpc,
"--unsafe-dont-encrypt",
];
let mut client =
run_as!(test, Who::Validator(0), Bin::Client, tx_args, Some(40))?;
Expand Down

0 comments on commit bff9734

Please sign in to comment.