@@ -86,7 +86,7 @@ pub(crate) fn generate_unique_signers(
|
||||
bulk_signers: Vec<Option<Box<dyn Signer>>>,
|
||||
matches: &ArgMatches<'_>,
|
||||
default_signer_path: &str,
|
||||
wallet_manager: Option<&Arc<RemoteWalletManager>>,
|
||||
wallet_manager: &mut Option<Arc<RemoteWalletManager>>,
|
||||
) -> Result<CliSignerInfo, Box<dyn error::Error>> {
|
||||
let mut unique_signers = vec![];
|
||||
|
||||
@@ -574,7 +574,7 @@ impl Default for CliConfig<'_> {
|
||||
pub fn parse_command(
|
||||
matches: &ArgMatches<'_>,
|
||||
default_signer_path: &str,
|
||||
wallet_manager: Option<&Arc<RemoteWalletManager>>,
|
||||
wallet_manager: &mut Option<Arc<RemoteWalletManager>>,
|
||||
) -> Result<CliCommandInfo, Box<dyn error::Error>> {
|
||||
let response = match matches.subcommand() {
|
||||
// Cluster Query Commands
|
||||
@@ -1054,7 +1054,7 @@ pub fn return_signers(tx: &Transaction) -> ProcessResult {
|
||||
pub fn parse_create_address_with_seed(
|
||||
matches: &ArgMatches<'_>,
|
||||
default_signer_path: &str,
|
||||
wallet_manager: Option<&Arc<RemoteWalletManager>>,
|
||||
wallet_manager: &mut Option<Arc<RemoteWalletManager>>,
|
||||
) -> Result<CliCommandInfo, CliError> {
|
||||
let from_pubkey = pubkey_of_signer(matches, "from", wallet_manager)?;
|
||||
let signers = if from_pubkey.is_some() {
|
||||
@@ -2633,11 +2633,11 @@ mod tests {
|
||||
write_keypair_file(&default_keypair, &default_keypair_file).unwrap();
|
||||
|
||||
let signer_info =
|
||||
generate_unique_signers(vec![], &matches, &default_keypair_file, None).unwrap();
|
||||
generate_unique_signers(vec![], &matches, &default_keypair_file, &mut None).unwrap();
|
||||
assert_eq!(signer_info.signers.len(), 0);
|
||||
|
||||
let signer_info =
|
||||
generate_unique_signers(vec![None, None], &matches, &default_keypair_file, None)
|
||||
generate_unique_signers(vec![None, None], &matches, &default_keypair_file, &mut None)
|
||||
.unwrap();
|
||||
assert_eq!(signer_info.signers.len(), 1);
|
||||
assert_eq!(signer_info.index_of(None), Some(0));
|
||||
@@ -2649,7 +2649,7 @@ mod tests {
|
||||
let keypair0_clone_pubkey = keypair0.pubkey();
|
||||
let signers = vec![None, Some(keypair0.into()), Some(keypair0_clone.into())];
|
||||
let signer_info =
|
||||
generate_unique_signers(signers, &matches, &default_keypair_file, None).unwrap();
|
||||
generate_unique_signers(signers, &matches, &default_keypair_file, &mut None).unwrap();
|
||||
assert_eq!(signer_info.signers.len(), 2);
|
||||
assert_eq!(signer_info.index_of(None), Some(0));
|
||||
assert_eq!(signer_info.index_of(Some(keypair0_pubkey)), Some(1));
|
||||
@@ -2660,7 +2660,7 @@ mod tests {
|
||||
let keypair0_clone = keypair_from_seed(&[1u8; 32]).unwrap();
|
||||
let signers = vec![Some(keypair0.into()), Some(keypair0_clone.into())];
|
||||
let signer_info =
|
||||
generate_unique_signers(signers, &matches, &default_keypair_file, None).unwrap();
|
||||
generate_unique_signers(signers, &matches, &default_keypair_file, &mut None).unwrap();
|
||||
assert_eq!(signer_info.signers.len(), 1);
|
||||
assert_eq!(signer_info.index_of(Some(keypair0_pubkey)), Some(0));
|
||||
|
||||
@@ -2681,7 +2681,7 @@ mod tests {
|
||||
Some(keypair1.into()),
|
||||
];
|
||||
let signer_info =
|
||||
generate_unique_signers(signers, &matches, &default_keypair_file, None).unwrap();
|
||||
generate_unique_signers(signers, &matches, &default_keypair_file, &mut None).unwrap();
|
||||
assert_eq!(signer_info.signers.len(), 2);
|
||||
assert_eq!(signer_info.index_of(Some(keypair0_pubkey)), Some(0));
|
||||
assert_eq!(signer_info.index_of(Some(keypair1_pubkey)), Some(1));
|
||||
@@ -2707,7 +2707,7 @@ mod tests {
|
||||
.clone()
|
||||
.get_matches_from(vec!["test", "airdrop", "50", &pubkey_string]);
|
||||
assert_eq!(
|
||||
parse_command(&test_airdrop, "", None).unwrap(),
|
||||
parse_command(&test_airdrop, "", &mut None).unwrap(),
|
||||
CliCommandInfo {
|
||||
command: CliCommand::Airdrop {
|
||||
faucet_host: None,
|
||||
@@ -2730,7 +2730,7 @@ mod tests {
|
||||
&keypair.pubkey().to_string(),
|
||||
]);
|
||||
assert_eq!(
|
||||
parse_command(&test_balance, "", None).unwrap(),
|
||||
parse_command(&test_balance, "", &mut None).unwrap(),
|
||||
CliCommandInfo {
|
||||
command: CliCommand::Balance {
|
||||
pubkey: Some(keypair.pubkey()),
|
||||
@@ -2746,7 +2746,7 @@ mod tests {
|
||||
"--lamports",
|
||||
]);
|
||||
assert_eq!(
|
||||
parse_command(&test_balance, "", None).unwrap(),
|
||||
parse_command(&test_balance, "", &mut None).unwrap(),
|
||||
CliCommandInfo {
|
||||
command: CliCommand::Balance {
|
||||
pubkey: Some(keypair.pubkey()),
|
||||
@@ -2760,7 +2760,7 @@ mod tests {
|
||||
.clone()
|
||||
.get_matches_from(vec!["test", "balance", "--lamports"]);
|
||||
assert_eq!(
|
||||
parse_command(&test_balance, &keypair_file, None).unwrap(),
|
||||
parse_command(&test_balance, &keypair_file, &mut None).unwrap(),
|
||||
CliCommandInfo {
|
||||
command: CliCommand::Balance {
|
||||
pubkey: None,
|
||||
@@ -2776,7 +2776,7 @@ mod tests {
|
||||
.clone()
|
||||
.get_matches_from(vec!["test", "cancel", &pubkey_string]);
|
||||
assert_eq!(
|
||||
parse_command(&test_cancel, &keypair_file, None).unwrap(),
|
||||
parse_command(&test_cancel, &keypair_file, &mut None).unwrap(),
|
||||
CliCommandInfo {
|
||||
command: CliCommand::Cancel(pubkey),
|
||||
signers: vec![read_keypair_file(&keypair_file).unwrap().into()],
|
||||
@@ -2791,7 +2791,7 @@ mod tests {
|
||||
.clone()
|
||||
.get_matches_from(vec!["test", "confirm", &signature_string]);
|
||||
assert_eq!(
|
||||
parse_command(&test_confirm, "", None).unwrap(),
|
||||
parse_command(&test_confirm, "", &mut None).unwrap(),
|
||||
CliCommandInfo {
|
||||
command: CliCommand::Confirm(signature),
|
||||
signers: vec![],
|
||||
@@ -2800,7 +2800,7 @@ mod tests {
|
||||
let test_bad_signature = test_commands
|
||||
.clone()
|
||||
.get_matches_from(vec!["test", "confirm", "deadbeef"]);
|
||||
assert!(parse_command(&test_bad_signature, "", None).is_err());
|
||||
assert!(parse_command(&test_bad_signature, "", &mut None).is_err());
|
||||
|
||||
// Test CreateAddressWithSeed
|
||||
let from_pubkey = Some(Pubkey::new_rand());
|
||||
@@ -2820,7 +2820,7 @@ mod tests {
|
||||
&from_str,
|
||||
]);
|
||||
assert_eq!(
|
||||
parse_command(&test_create_address_with_seed, "", None).unwrap(),
|
||||
parse_command(&test_create_address_with_seed, "", &mut None).unwrap(),
|
||||
CliCommandInfo {
|
||||
command: CliCommand::CreateAddressWithSeed {
|
||||
from_pubkey,
|
||||
@@ -2838,7 +2838,7 @@ mod tests {
|
||||
"STAKE",
|
||||
]);
|
||||
assert_eq!(
|
||||
parse_command(&test_create_address_with_seed, &keypair_file, None).unwrap(),
|
||||
parse_command(&test_create_address_with_seed, &keypair_file, &mut None).unwrap(),
|
||||
CliCommandInfo {
|
||||
command: CliCommand::CreateAddressWithSeed {
|
||||
from_pubkey: None,
|
||||
@@ -2855,7 +2855,7 @@ mod tests {
|
||||
.clone()
|
||||
.get_matches_from(vec!["test", "deploy", "/Users/test/program.o"]);
|
||||
assert_eq!(
|
||||
parse_command(&test_deploy, &keypair_file, None).unwrap(),
|
||||
parse_command(&test_deploy, &keypair_file, &mut None).unwrap(),
|
||||
CliCommandInfo {
|
||||
command: CliCommand::Deploy("/Users/test/program.o".to_string()),
|
||||
signers: vec![read_keypair_file(&keypair_file).unwrap().into()],
|
||||
@@ -2868,7 +2868,7 @@ mod tests {
|
||||
.clone()
|
||||
.get_matches_from(vec!["test", "resolve-signer", &keypair_file]);
|
||||
assert_eq!(
|
||||
parse_command(&test_resolve_signer, "", None).unwrap(),
|
||||
parse_command(&test_resolve_signer, "", &mut None).unwrap(),
|
||||
CliCommandInfo {
|
||||
command: CliCommand::ResolveSigner(Some(keypair_file.clone())),
|
||||
signers: vec![],
|
||||
@@ -2880,7 +2880,7 @@ mod tests {
|
||||
.clone()
|
||||
.get_matches_from(vec!["test", "resolve-signer", &pubkey_string]);
|
||||
assert_eq!(
|
||||
parse_command(&test_resolve_signer, "", None).unwrap(),
|
||||
parse_command(&test_resolve_signer, "", &mut None).unwrap(),
|
||||
CliCommandInfo {
|
||||
command: CliCommand::ResolveSigner(Some(pubkey.to_string())),
|
||||
signers: vec![],
|
||||
@@ -2893,7 +2893,7 @@ mod tests {
|
||||
.clone()
|
||||
.get_matches_from(vec!["test", "pay", &pubkey_string, "50"]);
|
||||
assert_eq!(
|
||||
parse_command(&test_pay, &keypair_file, None).unwrap(),
|
||||
parse_command(&test_pay, &keypair_file, &mut None).unwrap(),
|
||||
CliCommandInfo {
|
||||
command: CliCommand::Pay(PayCommand {
|
||||
lamports: 50_000_000_000,
|
||||
@@ -2916,7 +2916,7 @@ mod tests {
|
||||
&witness1_string,
|
||||
]);
|
||||
assert_eq!(
|
||||
parse_command(&test_pay_multiple_witnesses, &keypair_file, None).unwrap(),
|
||||
parse_command(&test_pay_multiple_witnesses, &keypair_file, &mut None).unwrap(),
|
||||
CliCommandInfo {
|
||||
command: CliCommand::Pay(PayCommand {
|
||||
lamports: 50_000_000_000,
|
||||
@@ -2936,7 +2936,7 @@ mod tests {
|
||||
&witness0_string,
|
||||
]);
|
||||
assert_eq!(
|
||||
parse_command(&test_pay_single_witness, &keypair_file, None).unwrap(),
|
||||
parse_command(&test_pay_single_witness, &keypair_file, &mut None).unwrap(),
|
||||
CliCommandInfo {
|
||||
command: CliCommand::Pay(PayCommand {
|
||||
lamports: 50_000_000_000,
|
||||
@@ -2960,7 +2960,7 @@ mod tests {
|
||||
&witness0_string,
|
||||
]);
|
||||
assert_eq!(
|
||||
parse_command(&test_pay_timestamp, &keypair_file, None).unwrap(),
|
||||
parse_command(&test_pay_timestamp, &keypair_file, &mut None).unwrap(),
|
||||
CliCommandInfo {
|
||||
command: CliCommand::Pay(PayCommand {
|
||||
lamports: 50_000_000_000,
|
||||
@@ -2986,7 +2986,7 @@ mod tests {
|
||||
"--sign-only",
|
||||
]);
|
||||
assert_eq!(
|
||||
parse_command(&test_pay, &keypair_file, None).unwrap(),
|
||||
parse_command(&test_pay, &keypair_file, &mut None).unwrap(),
|
||||
CliCommandInfo {
|
||||
command: CliCommand::Pay(PayCommand {
|
||||
lamports: 50_000_000_000,
|
||||
@@ -3009,7 +3009,7 @@ mod tests {
|
||||
&blockhash_string,
|
||||
]);
|
||||
assert_eq!(
|
||||
parse_command(&test_pay, &keypair_file, None).unwrap(),
|
||||
parse_command(&test_pay, &keypair_file, &mut None).unwrap(),
|
||||
CliCommandInfo {
|
||||
command: CliCommand::Pay(PayCommand {
|
||||
lamports: 50_000_000_000,
|
||||
@@ -3038,7 +3038,7 @@ mod tests {
|
||||
&pubkey_string,
|
||||
]);
|
||||
assert_eq!(
|
||||
parse_command(&test_pay, &keypair_file, None).unwrap(),
|
||||
parse_command(&test_pay, &keypair_file, &mut None).unwrap(),
|
||||
CliCommandInfo {
|
||||
command: CliCommand::Pay(PayCommand {
|
||||
lamports: 50_000_000_000,
|
||||
@@ -3071,7 +3071,7 @@ mod tests {
|
||||
&keypair_file,
|
||||
]);
|
||||
assert_eq!(
|
||||
parse_command(&test_pay, &keypair_file, None).unwrap(),
|
||||
parse_command(&test_pay, &keypair_file, &mut None).unwrap(),
|
||||
CliCommandInfo {
|
||||
command: CliCommand::Pay(PayCommand {
|
||||
lamports: 50_000_000_000,
|
||||
@@ -3109,7 +3109,7 @@ mod tests {
|
||||
&signer_arg,
|
||||
]);
|
||||
assert_eq!(
|
||||
parse_command(&test_pay, &keypair_file, None).unwrap(),
|
||||
parse_command(&test_pay, &keypair_file, &mut None).unwrap(),
|
||||
CliCommandInfo {
|
||||
command: CliCommand::Pay(PayCommand {
|
||||
lamports: 50_000_000_000,
|
||||
@@ -3147,7 +3147,7 @@ mod tests {
|
||||
"--signer",
|
||||
&signer_arg,
|
||||
]);
|
||||
assert!(parse_command(&test_pay, &keypair_file, None).is_err());
|
||||
assert!(parse_command(&test_pay, &keypair_file, &mut None).is_err());
|
||||
|
||||
// Test Send-Signature Subcommand
|
||||
let test_send_signature = test_commands.clone().get_matches_from(vec![
|
||||
@@ -3157,7 +3157,7 @@ mod tests {
|
||||
&pubkey_string,
|
||||
]);
|
||||
assert_eq!(
|
||||
parse_command(&test_send_signature, &keypair_file, None).unwrap(),
|
||||
parse_command(&test_send_signature, &keypair_file, &mut None).unwrap(),
|
||||
CliCommandInfo {
|
||||
command: CliCommand::Witness(pubkey, pubkey),
|
||||
signers: vec![read_keypair_file(&keypair_file).unwrap().into()],
|
||||
@@ -3178,7 +3178,7 @@ mod tests {
|
||||
&witness1_string,
|
||||
]);
|
||||
assert_eq!(
|
||||
parse_command(&test_pay_multiple_witnesses, &keypair_file, None).unwrap(),
|
||||
parse_command(&test_pay_multiple_witnesses, &keypair_file, &mut None).unwrap(),
|
||||
CliCommandInfo {
|
||||
command: CliCommand::Pay(PayCommand {
|
||||
lamports: 50_000_000_000,
|
||||
@@ -3202,7 +3202,7 @@ mod tests {
|
||||
"2018-09-19T17:30:59",
|
||||
]);
|
||||
assert_eq!(
|
||||
parse_command(&test_send_timestamp, &keypair_file, None).unwrap(),
|
||||
parse_command(&test_send_timestamp, &keypair_file, &mut None).unwrap(),
|
||||
CliCommandInfo {
|
||||
command: CliCommand::TimeElapsed(pubkey, pubkey, dt),
|
||||
signers: vec![read_keypair_file(&keypair_file).unwrap().into()],
|
||||
@@ -3216,7 +3216,7 @@ mod tests {
|
||||
"--date",
|
||||
"20180919T17:30:59",
|
||||
]);
|
||||
assert!(parse_command(&test_bad_timestamp, &keypair_file, None).is_err());
|
||||
assert!(parse_command(&test_bad_timestamp, &keypair_file, &mut None).is_err());
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -3591,7 +3591,7 @@ mod tests {
|
||||
.clone()
|
||||
.get_matches_from(vec!["test", "transfer", &to_string, "42"]);
|
||||
assert_eq!(
|
||||
parse_command(&test_transfer, &default_keypair_file, None).unwrap(),
|
||||
parse_command(&test_transfer, &default_keypair_file, &mut None).unwrap(),
|
||||
CliCommandInfo {
|
||||
command: CliCommand::Transfer {
|
||||
lamports: 42_000_000_000,
|
||||
@@ -3617,7 +3617,7 @@ mod tests {
|
||||
"42",
|
||||
]);
|
||||
assert_eq!(
|
||||
parse_command(&test_transfer, &default_keypair_file, None).unwrap(),
|
||||
parse_command(&test_transfer, &default_keypair_file, &mut None).unwrap(),
|
||||
CliCommandInfo {
|
||||
command: CliCommand::Transfer {
|
||||
lamports: 42_000_000_000,
|
||||
@@ -3647,7 +3647,7 @@ mod tests {
|
||||
"--sign-only",
|
||||
]);
|
||||
assert_eq!(
|
||||
parse_command(&test_transfer, &default_keypair_file, None).unwrap(),
|
||||
parse_command(&test_transfer, &default_keypair_file, &mut None).unwrap(),
|
||||
CliCommandInfo {
|
||||
command: CliCommand::Transfer {
|
||||
lamports: 42_000_000_000,
|
||||
@@ -3682,7 +3682,7 @@ mod tests {
|
||||
&blockhash_string,
|
||||
]);
|
||||
assert_eq!(
|
||||
parse_command(&test_transfer, &default_keypair_file, None).unwrap(),
|
||||
parse_command(&test_transfer, &default_keypair_file, &mut None).unwrap(),
|
||||
CliCommandInfo {
|
||||
command: CliCommand::Transfer {
|
||||
lamports: 42_000_000_000,
|
||||
@@ -3721,7 +3721,7 @@ mod tests {
|
||||
&nonce_authority_file,
|
||||
]);
|
||||
assert_eq!(
|
||||
parse_command(&test_transfer, &default_keypair_file, None).unwrap(),
|
||||
parse_command(&test_transfer, &default_keypair_file, &mut None).unwrap(),
|
||||
CliCommandInfo {
|
||||
command: CliCommand::Transfer {
|
||||
lamports: 42_000_000_000,
|
||||
|
Reference in New Issue
Block a user