Cli: Remove units from various subcommands (#8301) (#8306)

automerge
This commit is contained in:
mergify[bot]
2020-02-15 12:45:02 -08:00
committed by GitHub
parent 897e1fc5d6
commit 8d59bef561
16 changed files with 491 additions and 401 deletions

View File

@@ -408,7 +408,6 @@ pub enum CliCommand {
faucet_host: Option<IpAddr>,
faucet_port: u16,
lamports: u64,
use_lamports_unit: bool,
},
Balance {
pubkey: Option<Pubkey>,
@@ -640,14 +639,12 @@ pub fn parse_command(matches: &ArgMatches<'_>) -> Result<CliCommandInfo, Box<dyn
} else {
None
};
let lamports = required_lamports_from(matches, "amount", "unit")?;
let use_lamports_unit = matches.value_of("unit") == Some("lamports");
let lamports = lamports_of_sol(matches, "amount").unwrap();
Ok(CliCommandInfo {
command: CliCommand::Airdrop {
faucet_host,
faucet_port,
lamports,
use_lamports_unit,
},
require_keypair: true,
})
@@ -680,7 +677,7 @@ pub fn parse_command(matches: &ArgMatches<'_>) -> Result<CliCommandInfo, Box<dyn
}
},
("pay", Some(matches)) => {
let lamports = required_lamports_from(matches, "amount", "unit")?;
let lamports = lamports_of_sol(matches, "amount").unwrap();
let to = pubkey_of(&matches, "to").unwrap();
let timestamp = if matches.is_present("timestamp") {
// Parse input for serde_json
@@ -764,7 +761,7 @@ pub fn parse_command(matches: &ArgMatches<'_>) -> Result<CliCommandInfo, Box<dyn
})
}
("transfer", Some(matches)) => {
let lamports = required_lamports_from(matches, "amount", "unit")?;
let lamports = lamports_of_sol(matches, "amount").unwrap();
let to = pubkey_of(&matches, "to").unwrap();
let sign_only = matches.is_present(SIGN_ONLY_ARG.name);
let signers = pubkeys_sigs_of(&matches, SIGNER_ARG.name);
@@ -943,12 +940,11 @@ fn process_airdrop(
config: &CliConfig,
faucet_addr: &SocketAddr,
lamports: u64,
use_lamports_unit: bool,
) -> ProcessResult {
let pubkey = config.pubkey()?;
println!(
"Requesting airdrop of {} from {}",
build_balance_message(lamports, use_lamports_unit, true),
build_balance_message(lamports, false, true),
faucet_addr
);
let previous_balance = match rpc_client.retry_get_balance(&pubkey, 5)? {
@@ -967,11 +963,7 @@ fn process_airdrop(
.retry_get_balance(&pubkey, 5)?
.unwrap_or(previous_balance);
Ok(build_balance_message(
current_balance,
use_lamports_unit,
true,
))
Ok(build_balance_message(current_balance, false, true))
}
fn process_balance(
@@ -1853,7 +1845,6 @@ pub fn process_command(config: &CliConfig) -> ProcessResult {
faucet_host,
faucet_port,
lamports,
use_lamports_unit,
} => {
let faucet_addr = SocketAddr::new(
faucet_host.unwrap_or_else(|| {
@@ -1869,13 +1860,7 @@ pub fn process_command(config: &CliConfig) -> ProcessResult {
*faucet_port,
);
process_airdrop(
&rpc_client,
config,
&faucet_addr,
*lamports,
*use_lamports_unit,
)
process_airdrop(&rpc_client, config, &faucet_addr, *lamports)
}
// Check client balance
CliCommand::Balance {
@@ -2044,22 +2029,6 @@ where
}
}
// If clap arg `name` is_required, and specifies an amount of either lamports or SOL, the only way
// `amount_of()` can return None is if `name` is an f64 and `unit`== "lamports". This method
// catches that case and converts it to an Error.
pub(crate) fn required_lamports_from(
matches: &ArgMatches<'_>,
name: &str,
unit: &str,
) -> Result<u64, CliError> {
amount_of(matches, name, unit).ok_or_else(|| {
CliError::BadParameter(format!(
"Lamports cannot be fractional: {}",
matches.value_of("amount").unwrap()
))
})
}
pub(crate) fn build_balance_message(
lamports: u64,
use_lamports_unit: bool,
@@ -2117,15 +2086,7 @@ pub fn app<'ab, 'v>(name: &str, about: &'ab str, version: &'v str) -> App<'ab, '
.takes_value(true)
.validator(is_amount)
.required(true)
.help("The airdrop amount to request (default unit SOL)"),
)
.arg(
Arg::with_name("unit")
.index(2)
.value_name("UNIT")
.takes_value(true)
.possible_values(&["SOL", "lamports"])
.help("Specify unit to use for request and balance display"),
.help("The airdrop amount to request, in SOL"),
),
)
.subcommand(
@@ -2234,15 +2195,7 @@ pub fn app<'ab, 'v>(name: &str, about: &'ab str, version: &'v str) -> App<'ab, '
.takes_value(true)
.validator(is_amount)
.required(true)
.help("The amount to send (default unit SOL)"),
)
.arg(
Arg::with_name("unit")
.index(3)
.value_name("UNIT")
.takes_value(true)
.possible_values(&["SOL", "lamports"])
.help("Specify unit to use for request"),
.help("The amount to send, in SOL"),
)
.arg(
Arg::with_name("timestamp")
@@ -2347,15 +2300,7 @@ pub fn app<'ab, 'v>(name: &str, about: &'ab str, version: &'v str) -> App<'ab, '
.takes_value(true)
.validator(is_amount)
.required(true)
.help("The amount to send (default unit SOL)"),
)
.arg(
Arg::with_name("unit")
.index(3)
.value_name("UNIT")
.takes_value(true)
.possible_values(&["SOL", "lamports"])
.help("Specify unit to use for request"),
.help("The amount to send, in SOL"),
)
.arg(
Arg::with_name("from")
@@ -2457,15 +2402,14 @@ mod tests {
// Test Airdrop Subcommand
let test_airdrop = test_commands
.clone()
.get_matches_from(vec!["test", "airdrop", "50", "lamports"]);
.get_matches_from(vec!["test", "airdrop", "50"]);
assert_eq!(
parse_command(&test_airdrop).unwrap(),
CliCommandInfo {
command: CliCommand::Airdrop {
faucet_host: None,
faucet_port: solana_faucet::faucet::FAUCET_PORT,
lamports: 50,
use_lamports_unit: true,
lamports: 50_000_000_000,
},
require_keypair: true,
}
@@ -2613,18 +2557,15 @@ mod tests {
);
// Test Simple Pay Subcommand
let test_pay = test_commands.clone().get_matches_from(vec![
"test",
"pay",
&pubkey_string,
"50",
"lamports",
]);
let test_pay =
test_commands
.clone()
.get_matches_from(vec!["test", "pay", &pubkey_string, "50"]);
assert_eq!(
parse_command(&test_pay).unwrap(),
CliCommandInfo {
command: CliCommand::Pay(PayCommand {
lamports: 50,
lamports: 50_000_000_000,
to: pubkey,
..PayCommand::default()
}),
@@ -2638,7 +2579,6 @@ mod tests {
"pay",
&pubkey_string,
"50",
"lamports",
"--require-signature-from",
&witness0_string,
"--require-signature-from",
@@ -2648,7 +2588,7 @@ mod tests {
parse_command(&test_pay_multiple_witnesses).unwrap(),
CliCommandInfo {
command: CliCommand::Pay(PayCommand {
lamports: 50,
lamports: 50_000_000_000,
to: pubkey,
witnesses: Some(vec![witness0, witness1]),
..PayCommand::default()
@@ -2661,7 +2601,6 @@ mod tests {
"pay",
&pubkey_string,
"50",
"lamports",
"--require-signature-from",
&witness0_string,
]);
@@ -2669,7 +2608,7 @@ mod tests {
parse_command(&test_pay_single_witness).unwrap(),
CliCommandInfo {
command: CliCommand::Pay(PayCommand {
lamports: 50,
lamports: 50_000_000_000,
to: pubkey,
witnesses: Some(vec![witness0]),
..PayCommand::default()
@@ -2684,7 +2623,6 @@ mod tests {
"pay",
&pubkey_string,
"50",
"lamports",
"--after",
"2018-09-19T17:30:59",
"--require-timestamp-from",
@@ -2694,7 +2632,7 @@ mod tests {
parse_command(&test_pay_timestamp).unwrap(),
CliCommandInfo {
command: CliCommand::Pay(PayCommand {
lamports: 50,
lamports: 50_000_000_000,
to: pubkey,
timestamp: Some(dt),
timestamp_pubkey: Some(witness0),
@@ -2712,7 +2650,6 @@ mod tests {
"pay",
&pubkey_string,
"50",
"lamports",
"--blockhash",
&blockhash_string,
"--sign-only",
@@ -2721,7 +2658,7 @@ mod tests {
parse_command(&test_pay).unwrap(),
CliCommandInfo {
command: CliCommand::Pay(PayCommand {
lamports: 50,
lamports: 50_000_000_000,
to: pubkey,
blockhash_query: BlockhashQuery::None(blockhash, FeeCalculator::default()),
sign_only: true,
@@ -2740,7 +2677,6 @@ mod tests {
"pay",
&pubkey_string,
"50",
"lamports",
"--blockhash",
&blockhash_string,
"--signer",
@@ -2750,7 +2686,7 @@ mod tests {
parse_command(&test_pay).unwrap(),
CliCommandInfo {
command: CliCommand::Pay(PayCommand {
lamports: 50,
lamports: 50_000_000_000,
to: pubkey,
blockhash_query: BlockhashQuery::FeeCalculator(blockhash),
signers: Some(vec![(key1, sig1)]),
@@ -2769,7 +2705,6 @@ mod tests {
"pay",
&pubkey_string,
"50",
"lamports",
"--blockhash",
&blockhash_string,
"--signer",
@@ -2781,7 +2716,7 @@ mod tests {
parse_command(&test_pay).unwrap(),
CliCommandInfo {
command: CliCommand::Pay(PayCommand {
lamports: 50,
lamports: 50_000_000_000,
to: pubkey,
blockhash_query: BlockhashQuery::FeeCalculator(blockhash),
signers: Some(vec![(key1, sig1), (key2, sig2)]),
@@ -2797,7 +2732,6 @@ mod tests {
"pay",
&pubkey_string,
"50",
"lamports",
"--blockhash",
&blockhash_string,
]);
@@ -2805,7 +2739,7 @@ mod tests {
parse_command(&test_pay).unwrap(),
CliCommandInfo {
command: CliCommand::Pay(PayCommand {
lamports: 50,
lamports: 50_000_000_000,
to: pubkey,
blockhash_query: BlockhashQuery::FeeCalculator(blockhash),
..PayCommand::default()
@@ -2822,7 +2756,6 @@ mod tests {
"pay",
&pubkey_string,
"50",
"lamports",
"--blockhash",
&blockhash_string,
"--nonce",
@@ -2832,7 +2765,7 @@ mod tests {
parse_command(&test_pay).unwrap(),
CliCommandInfo {
command: CliCommand::Pay(PayCommand {
lamports: 50,
lamports: 50_000_000_000,
to: pubkey,
blockhash_query: BlockhashQuery::FeeCalculator(blockhash),
nonce_account: Some(pubkey),
@@ -2851,7 +2784,6 @@ mod tests {
"pay",
&pubkey_string,
"50",
"lamports",
"--blockhash",
&blockhash_string,
"--nonce",
@@ -2863,7 +2795,7 @@ mod tests {
parse_command(&test_pay).unwrap(),
CliCommandInfo {
command: CliCommand::Pay(PayCommand {
lamports: 50,
lamports: 50_000_000_000,
to: pubkey,
blockhash_query: BlockhashQuery::FeeCalculator(blockhash),
nonce_account: Some(pubkey),
@@ -2885,7 +2817,6 @@ mod tests {
"pay",
&pubkey_string,
"50",
"lamports",
"--blockhash",
&blockhash_string,
"--nonce",
@@ -2899,7 +2830,7 @@ mod tests {
parse_command(&test_pay).unwrap(),
CliCommandInfo {
command: CliCommand::Pay(PayCommand {
lamports: 50,
lamports: 50_000_000_000,
to: pubkey,
blockhash_query: BlockhashQuery::FeeCalculator(blockhash),
nonce_account: Some(pubkey),
@@ -2923,7 +2854,6 @@ mod tests {
"pay",
&pubkey_string,
"50",
"lamports",
"--blockhash",
&blockhash_string,
"--nonce",
@@ -2954,7 +2884,6 @@ mod tests {
"pay",
&pubkey_string,
"50",
"lamports",
"--after",
"2018-09-19T17:30:59",
"--require-signature-from",
@@ -2968,7 +2897,7 @@ mod tests {
parse_command(&test_pay_multiple_witnesses).unwrap(),
CliCommandInfo {
command: CliCommand::Pay(PayCommand {
lamports: 50,
lamports: 50_000_000_000,
to: pubkey,
timestamp: Some(dt),
timestamp_pubkey: Some(witness0),
@@ -3273,7 +3202,6 @@ mod tests {
faucet_host: None,
faucet_port: 1234,
lamports: 50,
use_lamports_unit: true,
};
assert!(process_command(&config).is_ok());
@@ -3311,7 +3239,6 @@ mod tests {
faucet_host: None,
faucet_port: 1234,
lamports: 50,
use_lamports_unit: true,
};
assert!(process_command(&config).is_err());
@@ -3420,35 +3347,13 @@ mod tests {
fn test_parse_transfer_subcommand() {
let test_commands = app("test", "desc", "version");
//Test Transfer Subcommand, lamports
//Test Transfer Subcommand, SOL
let from_keypair = keypair_from_seed(&[0u8; 32]).unwrap();
let from_pubkey = from_keypair.pubkey();
let from_string = from_pubkey.to_string();
let to_keypair = keypair_from_seed(&[1u8; 32]).unwrap();
let to_pubkey = to_keypair.pubkey();
let to_string = to_pubkey.to_string();
let test_transfer = test_commands
.clone()
.get_matches_from(vec!["test", "transfer", &to_string, "42", "lamports"]);
assert_eq!(
parse_command(&test_transfer).unwrap(),
CliCommandInfo {
command: CliCommand::Transfer {
lamports: 42,
to: to_pubkey,
from: None,
sign_only: false,
signers: None,
blockhash_query: BlockhashQuery::All,
nonce_account: None,
nonce_authority: None,
fee_payer: None,
},
require_keypair: true,
}
);
//Test Transfer Subcommand, SOL
let test_transfer = test_commands
.clone()
.get_matches_from(vec!["test", "transfer", &to_string, "42"]);
@@ -3478,7 +3383,6 @@ mod tests {
"transfer",
&to_string,
"42",
"lamports",
"--blockhash",
&blockhash_string,
"--sign-only",
@@ -3487,7 +3391,7 @@ mod tests {
parse_command(&test_transfer).unwrap(),
CliCommandInfo {
command: CliCommand::Transfer {
lamports: 42,
lamports: 42_000_000_000,
to: to_pubkey,
from: None,
sign_only: true,
@@ -3509,7 +3413,6 @@ mod tests {
"transfer",
&to_string,
"42",
"lamports",
"--from",
&from_string,
"--fee-payer",
@@ -3523,7 +3426,7 @@ mod tests {
parse_command(&test_transfer).unwrap(),
CliCommandInfo {
command: CliCommand::Transfer {
lamports: 42,
lamports: 42_000_000_000,
to: to_pubkey,
from: Some(from_pubkey.into()),
sign_only: false,
@@ -3548,7 +3451,6 @@ mod tests {
"transfer",
&to_string,
"42",
"lamports",
"--blockhash",
&blockhash_string,
"--nonce",
@@ -3560,7 +3462,7 @@ mod tests {
parse_command(&test_transfer).unwrap(),
CliCommandInfo {
command: CliCommand::Transfer {
lamports: 42,
lamports: 42_000_000_000,
to: to_pubkey,
from: None,
sign_only: false,

View File

@@ -1,7 +1,7 @@
use crate::cli::{
build_balance_message, check_account_for_fee, check_unique_pubkeys,
log_instruction_custom_error, required_lamports_from, CliCommand, CliCommandInfo, CliConfig,
CliError, ProcessResult, SigningAuthority,
log_instruction_custom_error, CliCommand, CliCommandInfo, CliConfig, CliError, ProcessResult,
SigningAuthority,
};
use crate::offline::BLOCKHASH_ARG;
use clap::{App, Arg, ArgMatches, SubCommand};
@@ -121,15 +121,7 @@ impl NonceSubCommands for App<'_, '_> {
.takes_value(true)
.required(true)
.validator(is_amount)
.help("The amount to load the nonce account with (default unit SOL)"),
)
.arg(
Arg::with_name("unit")
.index(3)
.value_name("UNIT")
.takes_value(true)
.possible_values(&["SOL", "lamports"])
.help("Specify unit to use for request"),
.help("The amount to load the nonce account with, in SOL"),
)
.arg(
Arg::with_name(NONCE_AUTHORITY_ARG.name)
@@ -216,15 +208,7 @@ impl NonceSubCommands for App<'_, '_> {
.takes_value(true)
.required(true)
.validator(is_amount)
.help("The amount to withdraw from the nonce account (default unit SOL)"),
)
.arg(
Arg::with_name("unit")
.index(4)
.value_name("UNIT")
.takes_value(true)
.possible_values(&["SOL", "lamports"])
.help("Specify unit to use for request"),
.help("The amount to withdraw from the nonce account, in SOL"),
)
.arg(nonce_authority_arg()),
)
@@ -250,7 +234,7 @@ pub fn parse_authorize_nonce_account(matches: &ArgMatches<'_>) -> Result<CliComm
pub fn parse_nonce_create_account(matches: &ArgMatches<'_>) -> Result<CliCommandInfo, CliError> {
let nonce_account = keypair_of(matches, "nonce_account_keypair").unwrap();
let seed = matches.value_of("seed").map(|s| s.to_string());
let lamports = required_lamports_from(matches, "amount", "unit")?;
let lamports = lamports_of_sol(matches, "amount").unwrap();
let nonce_authority = pubkey_of(matches, NONCE_AUTHORITY_ARG.name);
Ok(CliCommandInfo {
@@ -305,7 +289,7 @@ pub fn parse_withdraw_from_nonce_account(
) -> Result<CliCommandInfo, CliError> {
let nonce_account = pubkey_of(matches, "nonce_account_keypair").unwrap();
let destination_account_pubkey = pubkey_of(matches, "destination_account_pubkey").unwrap();
let lamports = required_lamports_from(matches, "amount", "unit")?;
let lamports = lamports_of_sol(matches, "amount").unwrap();
let nonce_authority =
SigningAuthority::new_from_matches(&matches, NONCE_AUTHORITY_ARG.name, None)?;
@@ -689,7 +673,6 @@ mod tests {
"create-nonce-account",
&keypair_file,
"50",
"lamports",
]);
assert_eq!(
parse_command(&test_create_nonce_account).unwrap(),
@@ -698,7 +681,7 @@ mod tests {
nonce_account: read_keypair_file(&keypair_file).unwrap().into(),
seed: None,
nonce_authority: None,
lamports: 50,
lamports: 50_000_000_000,
},
require_keypair: true
}
@@ -710,7 +693,6 @@ mod tests {
"create-nonce-account",
&keypair_file,
"50",
"lamports",
"--nonce-authority",
&authority_keypair_file,
]);
@@ -723,7 +705,7 @@ mod tests {
nonce_authority: Some(
read_keypair_file(&authority_keypair_file).unwrap().pubkey()
),
lamports: 50,
lamports: 50_000_000_000,
},
require_keypair: true
}
@@ -806,7 +788,6 @@ mod tests {
&keypair_file,
&nonce_account_string,
"42",
"lamports",
]);
assert_eq!(
parse_command(&test_withdraw_from_nonce_account).unwrap(),
@@ -815,7 +796,7 @@ mod tests {
nonce_account: read_keypair_file(&keypair_file).unwrap().pubkey(),
nonce_authority: None,
destination_account_pubkey: nonce_account_pubkey,
lamports: 42
lamports: 42_000_000_000
},
require_keypair: true
}
@@ -827,7 +808,6 @@ mod tests {
&keypair_file,
&nonce_account_string,
"42",
"SOL",
]);
assert_eq!(
parse_command(&test_withdraw_from_nonce_account).unwrap(),
@@ -849,7 +829,6 @@ mod tests {
&keypair_file,
&nonce_account_string,
"42",
"lamports",
"--nonce-authority",
&authority_keypair_file,
]);
@@ -862,7 +841,7 @@ mod tests {
read_keypair_file(&authority_keypair_file).unwrap().into()
),
destination_account_pubkey: nonce_account_pubkey,
lamports: 42
lamports: 42_000_000_000
},
require_keypair: true
}

View File

@@ -1,9 +1,9 @@
use crate::{
cli::{
build_balance_message, check_account_for_fee, check_unique_pubkeys, fee_payer_arg,
log_instruction_custom_error, nonce_authority_arg, replace_signatures,
required_lamports_from, return_signers, CliCommand, CliCommandInfo, CliConfig, CliError,
ProcessResult, SigningAuthority, FEE_PAYER_ARG,
log_instruction_custom_error, nonce_authority_arg, replace_signatures, return_signers,
CliCommand, CliCommandInfo, CliConfig, CliError, ProcessResult, SigningAuthority,
FEE_PAYER_ARG,
},
nonce::{check_nonce_account, nonce_arg, NONCE_ARG, NONCE_AUTHORITY_ARG},
offline::*,
@@ -86,15 +86,7 @@ impl StakeSubCommands for App<'_, '_> {
.takes_value(true)
.validator(is_amount)
.required(true)
.help("The amount of send to the vote account (default unit SOL)")
)
.arg(
Arg::with_name("unit")
.index(3)
.value_name("UNIT")
.takes_value(true)
.possible_values(&["SOL", "lamports"])
.help("Specify unit to use for request")
.help("The amount of send to the vote account, in SOL")
)
.arg(
Arg::with_name("custodian")
@@ -287,15 +279,7 @@ impl StakeSubCommands for App<'_, '_> {
.takes_value(true)
.validator(is_amount)
.required(true)
.help("The amount to move into the new stake account (default unit SOL)")
)
.arg(
Arg::with_name("unit")
.index(4)
.value_name("UNIT")
.takes_value(true)
.possible_values(&["SOL", "lamports"])
.help("Specify unit to use for request")
.help("The amount to move into the new stake account, in unit SOL")
)
.arg(
Arg::with_name("seed")
@@ -338,15 +322,7 @@ impl StakeSubCommands for App<'_, '_> {
.takes_value(true)
.validator(is_amount)
.required(true)
.help("The amount to withdraw from the stake account (default unit SOL)")
)
.arg(
Arg::with_name("unit")
.index(4)
.value_name("UNIT")
.takes_value(true)
.possible_values(&["SOL", "lamports"])
.help("Specify unit to use for request")
.help("The amount to withdraw from the stake account, in SOL")
)
.arg(withdraw_authority_arg())
.offline_args()
@@ -443,7 +419,7 @@ pub fn parse_stake_create_account(matches: &ArgMatches<'_>) -> Result<CliCommand
let custodian = pubkey_of(matches, "custodian").unwrap_or_default();
let staker = pubkey_of(matches, STAKE_AUTHORITY_ARG.name);
let withdrawer = pubkey_of(matches, WITHDRAW_AUTHORITY_ARG.name);
let lamports = required_lamports_from(matches, "amount", "unit")?;
let lamports = lamports_of_sol(matches, "amount").unwrap();
let sign_only = matches.is_present(SIGN_ONLY_ARG.name);
let signers = pubkeys_sigs_of(&matches, SIGNER_ARG.name);
let blockhash_query = BlockhashQuery::new_from_matches(matches);
@@ -557,7 +533,7 @@ pub fn parse_stake_authorize(
pub fn parse_split_stake(matches: &ArgMatches<'_>) -> Result<CliCommandInfo, CliError> {
let stake_account_pubkey = pubkey_of(matches, "stake_account_pubkey").unwrap();
let split_stake_account = keypair_of(matches, "split_stake_account").unwrap();
let lamports = required_lamports_from(matches, "amount", "unit")?;
let lamports = lamports_of_sol(matches, "amount").unwrap();
let seed = matches.value_of("seed").map(|s| s.to_string());
let sign_only = matches.is_present(SIGN_ONLY_ARG.name);
@@ -622,7 +598,7 @@ pub fn parse_stake_deactivate_stake(matches: &ArgMatches<'_>) -> Result<CliComma
pub fn parse_stake_withdraw_stake(matches: &ArgMatches<'_>) -> Result<CliCommandInfo, CliError> {
let stake_account_pubkey = pubkey_of(matches, "stake_account_pubkey").unwrap();
let destination_account_pubkey = pubkey_of(matches, "destination_account_pubkey").unwrap();
let lamports = required_lamports_from(matches, "amount", "unit")?;
let lamports = lamports_of_sol(matches, "amount").unwrap();
let sign_only = matches.is_present(SIGN_ONLY_ARG.name);
let signers = pubkeys_sigs_of(&matches, SIGNER_ARG.name);
let blockhash_query = BlockhashQuery::new_from_matches(matches);
@@ -1865,7 +1841,6 @@ mod tests {
&custodian_string,
"--lockup-epoch",
"43",
"lamports",
]);
assert_eq!(
parse_command(&test_create_stake_account).unwrap(),
@@ -1880,7 +1855,7 @@ mod tests {
unix_timestamp: 0,
custodian,
},
lamports: 50,
lamports: 50_000_000_000,
sign_only: false,
signers: None,
blockhash_query: BlockhashQuery::All,
@@ -1904,7 +1879,6 @@ mod tests {
"create-stake-account",
&keypair_file,
"50",
"lamports",
]);
assert_eq!(
@@ -1916,7 +1890,7 @@ mod tests {
staker: None,
withdrawer: None,
lockup: Lockup::default(),
lamports: 50,
lamports: 50_000_000_000,
sign_only: false,
signers: None,
blockhash_query: BlockhashQuery::All,
@@ -1944,7 +1918,6 @@ mod tests {
"create-stake-account",
&keypair_file,
"50",
"lamports",
"--blockhash",
&nonce_hash_string,
"--nonce",
@@ -1968,7 +1941,7 @@ mod tests {
staker: None,
withdrawer: None,
lockup: Lockup::default(),
lamports: 50,
lamports: 50_000_000_000,
sign_only: false,
signers: Some(vec![(offline_pubkey, offline_sig)]),
blockhash_query: BlockhashQuery::FeeCalculator(nonce_hash),
@@ -2270,7 +2243,6 @@ mod tests {
&stake_account_string,
&stake_account_string,
"42",
"lamports",
]);
assert_eq!(
@@ -2279,7 +2251,7 @@ mod tests {
command: CliCommand::WithdrawStake {
stake_account_pubkey,
destination_account_pubkey: stake_account_pubkey,
lamports: 42,
lamports: 42_000_000_000,
withdraw_authority: None,
sign_only: false,
signers: None,
@@ -2299,7 +2271,6 @@ mod tests {
&stake_account_string,
&stake_account_string,
"42",
"lamports",
"--withdraw-authority",
&stake_authority_keypair_file,
]);
@@ -2310,7 +2281,7 @@ mod tests {
command: CliCommand::WithdrawStake {
stake_account_pubkey,
destination_account_pubkey: stake_account_pubkey,
lamports: 42,
lamports: 42_000_000_000,
withdraw_authority: Some(
read_keypair_file(&stake_authority_keypair_file)
.unwrap()
@@ -2334,7 +2305,6 @@ mod tests {
&stake_account_string,
&stake_account_string,
"42",
"lamports",
"--withdraw-authority",
&stake_authority_keypair_file,
"--blockhash",
@@ -2355,7 +2325,7 @@ mod tests {
command: CliCommand::WithdrawStake {
stake_account_pubkey,
destination_account_pubkey: stake_account_pubkey,
lamports: 42,
lamports: 42_000_000_000,
withdraw_authority: Some(
read_keypair_file(&stake_authority_keypair_file)
.unwrap()
@@ -2608,7 +2578,6 @@ mod tests {
&keypair_file,
&split_stake_account_keypair_file,
"50",
"lamports",
]);
assert_eq!(
parse_command(&test_split_stake_account).unwrap(),
@@ -2625,7 +2594,7 @@ mod tests {
.unwrap()
.into(),
seed: None,
lamports: 50,
lamports: 50_000_000_000,
fee_payer: None,
},
require_keypair: true
@@ -2654,7 +2623,6 @@ mod tests {
&keypair_file,
&split_stake_account_keypair_file,
"50",
"lamports",
"--stake-authority",
&stake_auth_string,
"--blockhash",
@@ -2688,7 +2656,7 @@ mod tests {
.unwrap()
.into(),
seed: None,
lamports: 50,
lamports: 50_000_000_000,
fee_payer: Some(nonce_auth_pubkey.into()),
},
require_keypair: false,

View File

@@ -43,7 +43,6 @@ fn test_cli_deploy_program() {
faucet_host: None,
faucet_port: faucet_addr.port(),
lamports: minimum_balance_for_rent_exemption + 1, // min balance for rent exemption + leftover for tx processing
use_lamports_unit: true,
};
process_command(&config).unwrap();

View File

@@ -19,7 +19,6 @@ fn test_cli_request_airdrop() {
faucet_host: None,
faucet_port: faucet_addr.port(),
lamports: 50,
use_lamports_unit: true,
};
let sig_response = process_command(&bob_config);