Add using OutputFormat enum to --sign-only transactions (#9650)
* Add using OutputFormat enum to --sign-only commands * Renaming * Code formating * Appease clippy * Add returning json string to pay command for tests * Code refactoring * Appease clippy * Rebase and dedupe signature prints Co-authored-by: Tyera Eulberg <teulberg@gmail.com> Co-authored-by: Tyera Eulberg <tyera@solana.com>
This commit is contained in:
@ -1,7 +1,7 @@
|
|||||||
use crate::{
|
use crate::{
|
||||||
cli_output::{CliAccount, OutputFormat},
|
cli_output::{CliAccount, CliSignOnlyData, CliSignature, OutputFormat},
|
||||||
cluster_query::*,
|
cluster_query::*,
|
||||||
display::{println_name_value, println_signers},
|
display::println_name_value,
|
||||||
nonce::{self, *},
|
nonce::{self, *},
|
||||||
offline::{blockhash_query::BlockhashQuery, *},
|
offline::{blockhash_query::BlockhashQuery, *},
|
||||||
stake::*,
|
stake::*,
|
||||||
@ -1050,7 +1050,7 @@ pub fn get_blockhash_and_fee_calculator(
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn return_signers(tx: &Transaction) -> ProcessResult {
|
pub fn return_signers(tx: &Transaction, config: &CliConfig) -> ProcessResult {
|
||||||
let verify_results = tx.verify_with_results();
|
let verify_results = tx.verify_with_results();
|
||||||
let mut signers = Vec::new();
|
let mut signers = Vec::new();
|
||||||
let mut absent = Vec::new();
|
let mut absent = Vec::new();
|
||||||
@ -1069,15 +1069,14 @@ pub fn return_signers(tx: &Transaction) -> ProcessResult {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
println_signers(&tx.message.recent_blockhash, &signers, &absent, &bad_sig);
|
let cli_command = CliSignOnlyData {
|
||||||
|
blockhash: tx.message.recent_blockhash.to_string(),
|
||||||
|
signers,
|
||||||
|
absent,
|
||||||
|
bad_sig,
|
||||||
|
};
|
||||||
|
|
||||||
Ok(json!({
|
Ok(config.output_format.formatted_string(&cli_command))
|
||||||
"blockhash": tx.message.recent_blockhash.to_string(),
|
|
||||||
"signers": &signers,
|
|
||||||
"absent": &absent,
|
|
||||||
"badSig": &bad_sig,
|
|
||||||
})
|
|
||||||
.to_string())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn parse_create_address_with_seed(
|
pub fn parse_create_address_with_seed(
|
||||||
@ -1165,7 +1164,7 @@ fn process_airdrop(
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
request_and_confirm_airdrop(&rpc_client, faucet_addr, &pubkey, lamports)?;
|
request_and_confirm_airdrop(&rpc_client, faucet_addr, &pubkey, lamports, &config)?;
|
||||||
|
|
||||||
let current_balance = rpc_client
|
let current_balance = rpc_client
|
||||||
.retry_get_balance(&pubkey, 5)?
|
.retry_get_balance(&pubkey, 5)?
|
||||||
@ -1346,7 +1345,7 @@ fn process_deploy(
|
|||||||
trace!("Creating program account");
|
trace!("Creating program account");
|
||||||
let result =
|
let result =
|
||||||
rpc_client.send_and_confirm_transaction_with_spinner(&mut create_account_tx, &signers);
|
rpc_client.send_and_confirm_transaction_with_spinner(&mut create_account_tx, &signers);
|
||||||
log_instruction_custom_error::<SystemError>(result).map_err(|_| {
|
log_instruction_custom_error::<SystemError>(result, &config).map_err(|_| {
|
||||||
CliError::DynamicProgramError("Program account allocation failed".to_string())
|
CliError::DynamicProgramError("Program account allocation failed".to_string())
|
||||||
})?;
|
})?;
|
||||||
|
|
||||||
@ -1411,7 +1410,7 @@ fn process_pay(
|
|||||||
|
|
||||||
if sign_only {
|
if sign_only {
|
||||||
tx.try_partial_sign(&config.signers, blockhash)?;
|
tx.try_partial_sign(&config.signers, blockhash)?;
|
||||||
return_signers(&tx)
|
return_signers(&tx, &config)
|
||||||
} else {
|
} else {
|
||||||
tx.try_sign(&config.signers, blockhash)?;
|
tx.try_sign(&config.signers, blockhash)?;
|
||||||
if let Some(nonce_account) = &nonce_account {
|
if let Some(nonce_account) = &nonce_account {
|
||||||
@ -1426,7 +1425,7 @@ fn process_pay(
|
|||||||
)?;
|
)?;
|
||||||
let result =
|
let result =
|
||||||
rpc_client.send_and_confirm_transaction_with_spinner(&mut tx, &config.signers);
|
rpc_client.send_and_confirm_transaction_with_spinner(&mut tx, &config.signers);
|
||||||
log_instruction_custom_error::<SystemError>(result)
|
log_instruction_custom_error::<SystemError>(result, &config)
|
||||||
}
|
}
|
||||||
} else if *witnesses == None {
|
} else if *witnesses == None {
|
||||||
let dt = timestamp.unwrap();
|
let dt = timestamp.unwrap();
|
||||||
@ -1451,7 +1450,7 @@ fn process_pay(
|
|||||||
let mut tx = Transaction::new_unsigned(message);
|
let mut tx = Transaction::new_unsigned(message);
|
||||||
if sign_only {
|
if sign_only {
|
||||||
tx.try_partial_sign(&[config.signers[0], &contract_state], blockhash)?;
|
tx.try_partial_sign(&[config.signers[0], &contract_state], blockhash)?;
|
||||||
return_signers(&tx)
|
return_signers(&tx, &config)
|
||||||
} else {
|
} else {
|
||||||
tx.try_sign(&[config.signers[0], &contract_state], blockhash)?;
|
tx.try_sign(&[config.signers[0], &contract_state], blockhash)?;
|
||||||
check_account_for_fee(
|
check_account_for_fee(
|
||||||
@ -1464,10 +1463,9 @@ fn process_pay(
|
|||||||
&mut tx,
|
&mut tx,
|
||||||
&[config.signers[0], &contract_state],
|
&[config.signers[0], &contract_state],
|
||||||
);
|
);
|
||||||
let signature_str = log_instruction_custom_error::<BudgetError>(result)?;
|
let signature = log_instruction_custom_error::<BudgetError>(result, &config)?;
|
||||||
|
|
||||||
Ok(json!({
|
Ok(json!({
|
||||||
"signature": signature_str,
|
"signature": signature,
|
||||||
"processId": format!("{}", contract_state.pubkey()),
|
"processId": format!("{}", contract_state.pubkey()),
|
||||||
})
|
})
|
||||||
.to_string())
|
.to_string())
|
||||||
@ -1497,7 +1495,7 @@ fn process_pay(
|
|||||||
let mut tx = Transaction::new_unsigned(message);
|
let mut tx = Transaction::new_unsigned(message);
|
||||||
if sign_only {
|
if sign_only {
|
||||||
tx.try_partial_sign(&[config.signers[0], &contract_state], blockhash)?;
|
tx.try_partial_sign(&[config.signers[0], &contract_state], blockhash)?;
|
||||||
return_signers(&tx)
|
return_signers(&tx, &config)
|
||||||
} else {
|
} else {
|
||||||
tx.try_sign(&[config.signers[0], &contract_state], blockhash)?;
|
tx.try_sign(&[config.signers[0], &contract_state], blockhash)?;
|
||||||
let result = rpc_client.send_and_confirm_transaction_with_spinner(
|
let result = rpc_client.send_and_confirm_transaction_with_spinner(
|
||||||
@ -1510,10 +1508,9 @@ fn process_pay(
|
|||||||
&fee_calculator,
|
&fee_calculator,
|
||||||
&tx.message,
|
&tx.message,
|
||||||
)?;
|
)?;
|
||||||
let signature_str = log_instruction_custom_error::<BudgetError>(result)?;
|
let signature = log_instruction_custom_error::<BudgetError>(result, &config)?;
|
||||||
|
|
||||||
Ok(json!({
|
Ok(json!({
|
||||||
"signature": signature_str,
|
"signature": signature,
|
||||||
"processId": format!("{}", contract_state.pubkey()),
|
"processId": format!("{}", contract_state.pubkey()),
|
||||||
})
|
})
|
||||||
.to_string())
|
.to_string())
|
||||||
@ -1541,7 +1538,7 @@ fn process_cancel(rpc_client: &RpcClient, config: &CliConfig, pubkey: &Pubkey) -
|
|||||||
)?;
|
)?;
|
||||||
let result =
|
let result =
|
||||||
rpc_client.send_and_confirm_transaction_with_spinner(&mut tx, &[config.signers[0]]);
|
rpc_client.send_and_confirm_transaction_with_spinner(&mut tx, &[config.signers[0]]);
|
||||||
log_instruction_custom_error::<BudgetError>(result)
|
log_instruction_custom_error::<BudgetError>(result, &config)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn process_time_elapsed(
|
fn process_time_elapsed(
|
||||||
@ -1565,7 +1562,7 @@ fn process_time_elapsed(
|
|||||||
)?;
|
)?;
|
||||||
let result =
|
let result =
|
||||||
rpc_client.send_and_confirm_transaction_with_spinner(&mut tx, &[config.signers[0]]);
|
rpc_client.send_and_confirm_transaction_with_spinner(&mut tx, &[config.signers[0]]);
|
||||||
log_instruction_custom_error::<BudgetError>(result)
|
log_instruction_custom_error::<BudgetError>(result, &config)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(clippy::too_many_arguments)]
|
#[allow(clippy::too_many_arguments)]
|
||||||
@ -1610,7 +1607,7 @@ fn process_transfer(
|
|||||||
|
|
||||||
if sign_only {
|
if sign_only {
|
||||||
tx.try_partial_sign(&config.signers, recent_blockhash)?;
|
tx.try_partial_sign(&config.signers, recent_blockhash)?;
|
||||||
return_signers(&tx)
|
return_signers(&tx, &config)
|
||||||
} else {
|
} else {
|
||||||
tx.try_sign(&config.signers, recent_blockhash)?;
|
tx.try_sign(&config.signers, recent_blockhash)?;
|
||||||
if let Some(nonce_account) = &nonce_account {
|
if let Some(nonce_account) = &nonce_account {
|
||||||
@ -1628,7 +1625,7 @@ fn process_transfer(
|
|||||||
} else {
|
} else {
|
||||||
rpc_client.send_and_confirm_transaction_with_spinner(&mut tx, &config.signers)
|
rpc_client.send_and_confirm_transaction_with_spinner(&mut tx, &config.signers)
|
||||||
};
|
};
|
||||||
log_instruction_custom_error::<SystemError>(result)
|
log_instruction_custom_error::<SystemError>(result, &config)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1652,7 +1649,7 @@ fn process_witness(
|
|||||||
)?;
|
)?;
|
||||||
let result =
|
let result =
|
||||||
rpc_client.send_and_confirm_transaction_with_spinner(&mut tx, &[config.signers[0]]);
|
rpc_client.send_and_confirm_transaction_with_spinner(&mut tx, &[config.signers[0]]);
|
||||||
log_instruction_custom_error::<BudgetError>(result)
|
log_instruction_custom_error::<BudgetError>(result, &config)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn process_command(config: &CliConfig) -> ProcessResult {
|
pub fn process_command(config: &CliConfig) -> ProcessResult {
|
||||||
@ -2268,6 +2265,7 @@ pub fn request_and_confirm_airdrop(
|
|||||||
faucet_addr: &SocketAddr,
|
faucet_addr: &SocketAddr,
|
||||||
to_pubkey: &Pubkey,
|
to_pubkey: &Pubkey,
|
||||||
lamports: u64,
|
lamports: u64,
|
||||||
|
config: &CliConfig,
|
||||||
) -> ProcessResult {
|
) -> ProcessResult {
|
||||||
let (blockhash, _fee_calculator) = rpc_client.get_recent_blockhash()?;
|
let (blockhash, _fee_calculator) = rpc_client.get_recent_blockhash()?;
|
||||||
let keypair = {
|
let keypair = {
|
||||||
@ -2283,10 +2281,13 @@ pub fn request_and_confirm_airdrop(
|
|||||||
}?;
|
}?;
|
||||||
let mut tx = keypair.airdrop_transaction();
|
let mut tx = keypair.airdrop_transaction();
|
||||||
let result = rpc_client.send_and_confirm_transaction_with_spinner(&mut tx, &[&keypair]);
|
let result = rpc_client.send_and_confirm_transaction_with_spinner(&mut tx, &[&keypair]);
|
||||||
log_instruction_custom_error::<SystemError>(result)
|
log_instruction_custom_error::<SystemError>(result, &config)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn log_instruction_custom_error<E>(result: ClientResult<Signature>) -> ProcessResult
|
pub fn log_instruction_custom_error<E>(
|
||||||
|
result: ClientResult<Signature>,
|
||||||
|
config: &CliConfig,
|
||||||
|
) -> ProcessResult
|
||||||
where
|
where
|
||||||
E: 'static + std::error::Error + DecodeError<E> + FromPrimitive,
|
E: 'static + std::error::Error + DecodeError<E> + FromPrimitive,
|
||||||
{
|
{
|
||||||
@ -2303,7 +2304,12 @@ where
|
|||||||
}
|
}
|
||||||
Err(err.into())
|
Err(err.into())
|
||||||
}
|
}
|
||||||
Ok(sig) => Ok(sig.to_string()),
|
Ok(sig) => {
|
||||||
|
let signature = CliSignature {
|
||||||
|
signature: sig.clone().to_string(),
|
||||||
|
};
|
||||||
|
Ok(config.output_format.formatted_string(&signature))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3827,6 +3833,8 @@ mod tests {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let mut config = CliConfig::default();
|
||||||
|
config.output_format = OutputFormat::JsonCompact;
|
||||||
let present: Box<dyn Signer> = Box::new(keypair_from_seed(&[2u8; 32]).unwrap());
|
let present: Box<dyn Signer> = Box::new(keypair_from_seed(&[2u8; 32]).unwrap());
|
||||||
let absent: Box<dyn Signer> = Box::new(NullSigner::new(&Pubkey::new(&[3u8; 32])));
|
let absent: Box<dyn Signer> = Box::new(NullSigner::new(&Pubkey::new(&[3u8; 32])));
|
||||||
let bad: Box<dyn Signer> = Box::new(BadSigner::new(Pubkey::new(&[4u8; 32])));
|
let bad: Box<dyn Signer> = Box::new(BadSigner::new(Pubkey::new(&[4u8; 32])));
|
||||||
@ -3845,7 +3853,7 @@ mod tests {
|
|||||||
let signers = vec![present.as_ref(), absent.as_ref(), bad.as_ref()];
|
let signers = vec![present.as_ref(), absent.as_ref(), bad.as_ref()];
|
||||||
let blockhash = Hash::new(&[7u8; 32]);
|
let blockhash = Hash::new(&[7u8; 32]);
|
||||||
tx.try_partial_sign(&signers, blockhash).unwrap();
|
tx.try_partial_sign(&signers, blockhash).unwrap();
|
||||||
let res = return_signers(&tx).unwrap();
|
let res = return_signers(&tx, &config).unwrap();
|
||||||
let sign_only = parse_sign_only_reply_string(&res);
|
let sign_only = parse_sign_only_reply_string(&res);
|
||||||
assert_eq!(sign_only.blockhash, blockhash);
|
assert_eq!(sign_only.blockhash, blockhash);
|
||||||
assert_eq!(sign_only.present_signers[0].0, present.pubkey());
|
assert_eq!(sign_only.present_signers[0].0, present.pubkey());
|
||||||
|
@ -856,3 +856,54 @@ impl fmt::Display for CliBlockTime {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Serialize, Deserialize, Default)]
|
||||||
|
#[serde(rename_all = "camelCase")]
|
||||||
|
pub struct CliSignOnlyData {
|
||||||
|
pub blockhash: String,
|
||||||
|
#[serde(skip_serializing_if = "Vec::is_empty", default)]
|
||||||
|
pub signers: Vec<String>,
|
||||||
|
#[serde(skip_serializing_if = "Vec::is_empty", default)]
|
||||||
|
pub absent: Vec<String>,
|
||||||
|
#[serde(skip_serializing_if = "Vec::is_empty", default)]
|
||||||
|
pub bad_sig: Vec<String>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl fmt::Display for CliSignOnlyData {
|
||||||
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||||
|
writeln!(f)?;
|
||||||
|
writeln_name_value(f, "Blockhash:", &self.blockhash)?;
|
||||||
|
if !self.signers.is_empty() {
|
||||||
|
writeln!(f, "{}", style("Signers (Pubkey=Signature):").bold())?;
|
||||||
|
for signer in self.signers.iter() {
|
||||||
|
writeln!(f, " {}", signer)?;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if !self.absent.is_empty() {
|
||||||
|
writeln!(f, "{}", style("Absent Signers (Pubkey):").bold())?;
|
||||||
|
for pubkey in self.absent.iter() {
|
||||||
|
writeln!(f, " {}", pubkey)?;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if !self.bad_sig.is_empty() {
|
||||||
|
writeln!(f, "{}", style("Bad Signatures (Pubkey):").bold())?;
|
||||||
|
for pubkey in self.bad_sig.iter() {
|
||||||
|
writeln!(f, " {}", pubkey)?;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Serialize, Deserialize)]
|
||||||
|
pub struct CliSignature {
|
||||||
|
pub signature: String,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl fmt::Display for CliSignature {
|
||||||
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||||
|
writeln!(f)?;
|
||||||
|
writeln_name_value(f, "Signature:", &self.signature)?;
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -2,8 +2,7 @@ use clap::{crate_description, crate_name, AppSettings, Arg, ArgGroup, ArgMatches
|
|||||||
use console::style;
|
use console::style;
|
||||||
|
|
||||||
use solana_clap_utils::{
|
use solana_clap_utils::{
|
||||||
input_validators::is_url, keypair::SKIP_SEED_PHRASE_VALIDATION_ARG, offline::SIGN_ONLY_ARG,
|
input_validators::is_url, keypair::SKIP_SEED_PHRASE_VALIDATION_ARG, DisplayError,
|
||||||
DisplayError,
|
|
||||||
};
|
};
|
||||||
use solana_cli::{
|
use solana_cli::{
|
||||||
cli::{app, parse_command, process_command, CliCommandInfo, CliConfig, CliSigners},
|
cli::{app, parse_command, process_command, CliCommandInfo, CliConfig, CliSigners},
|
||||||
@ -262,13 +261,7 @@ fn do_main(matches: &ArgMatches<'_>) -> Result<(), Box<dyn error::Error>> {
|
|||||||
let (mut config, signers) = parse_args(&matches, &mut wallet_manager)?;
|
let (mut config, signers) = parse_args(&matches, &mut wallet_manager)?;
|
||||||
config.signers = signers.iter().map(|s| s.as_ref()).collect();
|
config.signers = signers.iter().map(|s| s.as_ref()).collect();
|
||||||
let result = process_command(&config)?;
|
let result = process_command(&config)?;
|
||||||
let (_, submatches) = matches.subcommand();
|
println!("{}", result);
|
||||||
let sign_only = submatches
|
|
||||||
.map(|m| m.is_present(SIGN_ONLY_ARG.name))
|
|
||||||
.unwrap_or(false);
|
|
||||||
if !sign_only {
|
|
||||||
println!("{}", result);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
@ -447,7 +447,7 @@ pub fn process_authorize_nonce_account(
|
|||||||
&tx.message,
|
&tx.message,
|
||||||
)?;
|
)?;
|
||||||
let result = rpc_client.send_and_confirm_transaction_with_spinner(&mut tx, &config.signers);
|
let result = rpc_client.send_and_confirm_transaction_with_spinner(&mut tx, &config.signers);
|
||||||
log_instruction_custom_error::<NonceError>(result)
|
log_instruction_custom_error::<NonceError>(result, &config)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn process_create_nonce_account(
|
pub fn process_create_nonce_account(
|
||||||
@ -524,7 +524,7 @@ pub fn process_create_nonce_account(
|
|||||||
&tx.message,
|
&tx.message,
|
||||||
)?;
|
)?;
|
||||||
let result = rpc_client.send_and_confirm_transaction_with_spinner(&mut tx, &config.signers);
|
let result = rpc_client.send_and_confirm_transaction_with_spinner(&mut tx, &config.signers);
|
||||||
log_instruction_custom_error::<SystemError>(result)
|
log_instruction_custom_error::<SystemError>(result, &config)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn process_get_nonce(rpc_client: &RpcClient, nonce_account_pubkey: &Pubkey) -> ProcessResult {
|
pub fn process_get_nonce(rpc_client: &RpcClient, nonce_account_pubkey: &Pubkey) -> ProcessResult {
|
||||||
@ -566,7 +566,7 @@ pub fn process_new_nonce(
|
|||||||
)?;
|
)?;
|
||||||
let result = rpc_client
|
let result = rpc_client
|
||||||
.send_and_confirm_transaction_with_spinner(&mut tx, &[config.signers[0], nonce_authority]);
|
.send_and_confirm_transaction_with_spinner(&mut tx, &[config.signers[0], nonce_authority]);
|
||||||
log_instruction_custom_error::<SystemError>(result)
|
log_instruction_custom_error::<SystemError>(result, &config)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn process_show_nonce_account(
|
pub fn process_show_nonce_account(
|
||||||
@ -625,7 +625,7 @@ pub fn process_withdraw_from_nonce_account(
|
|||||||
&tx.message,
|
&tx.message,
|
||||||
)?;
|
)?;
|
||||||
let result = rpc_client.send_and_confirm_transaction_with_spinner(&mut tx, &config.signers);
|
let result = rpc_client.send_and_confirm_transaction_with_spinner(&mut tx, &config.signers);
|
||||||
log_instruction_custom_error::<NonceError>(result)
|
log_instruction_custom_error::<NonceError>(result, &config)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
@ -79,32 +79,47 @@ pub fn parse_sign_only_reply_string(reply: &str) -> SignOnly {
|
|||||||
let object: Value = serde_json::from_str(&reply).unwrap();
|
let object: Value = serde_json::from_str(&reply).unwrap();
|
||||||
let blockhash_str = object.get("blockhash").unwrap().as_str().unwrap();
|
let blockhash_str = object.get("blockhash").unwrap().as_str().unwrap();
|
||||||
let blockhash = blockhash_str.parse::<Hash>().unwrap();
|
let blockhash = blockhash_str.parse::<Hash>().unwrap();
|
||||||
let signer_strings = object.get("signers").unwrap().as_array().unwrap();
|
let mut present_signers: Vec<(Pubkey, Signature)> = Vec::new();
|
||||||
let present_signers = signer_strings
|
let signer_strings = object.get("signers");
|
||||||
.iter()
|
if let Some(sig_strings) = signer_strings {
|
||||||
.map(|signer_string| {
|
present_signers = sig_strings
|
||||||
let mut signer = signer_string.as_str().unwrap().split('=');
|
.as_array()
|
||||||
let key = Pubkey::from_str(signer.next().unwrap()).unwrap();
|
.unwrap()
|
||||||
let sig = Signature::from_str(signer.next().unwrap()).unwrap();
|
.iter()
|
||||||
(key, sig)
|
.map(|signer_string| {
|
||||||
})
|
let mut signer = signer_string.as_str().unwrap().split('=');
|
||||||
.collect();
|
let key = Pubkey::from_str(signer.next().unwrap()).unwrap();
|
||||||
let signer_strings = object.get("absent").unwrap().as_array().unwrap();
|
let sig = Signature::from_str(signer.next().unwrap()).unwrap();
|
||||||
let absent_signers = signer_strings
|
(key, sig)
|
||||||
.iter()
|
})
|
||||||
.map(|val| {
|
.collect();
|
||||||
let s = val.as_str().unwrap();
|
}
|
||||||
Pubkey::from_str(s).unwrap()
|
let mut absent_signers: Vec<Pubkey> = Vec::new();
|
||||||
})
|
let signer_strings = object.get("absent");
|
||||||
.collect();
|
if let Some(sig_strings) = signer_strings {
|
||||||
let signer_strings = object.get("badSig").unwrap().as_array().unwrap();
|
absent_signers = sig_strings
|
||||||
let bad_signers = signer_strings
|
.as_array()
|
||||||
.iter()
|
.unwrap()
|
||||||
.map(|val| {
|
.iter()
|
||||||
let s = val.as_str().unwrap();
|
.map(|val| {
|
||||||
Pubkey::from_str(s).unwrap()
|
let s = val.as_str().unwrap();
|
||||||
})
|
Pubkey::from_str(s).unwrap()
|
||||||
.collect();
|
})
|
||||||
|
.collect();
|
||||||
|
}
|
||||||
|
let mut bad_signers: Vec<Pubkey> = Vec::new();
|
||||||
|
let signer_strings = object.get("badSig");
|
||||||
|
if let Some(sig_strings) = signer_strings {
|
||||||
|
bad_signers = sig_strings
|
||||||
|
.as_array()
|
||||||
|
.unwrap()
|
||||||
|
.iter()
|
||||||
|
.map(|val| {
|
||||||
|
let s = val.as_str().unwrap();
|
||||||
|
Pubkey::from_str(s).unwrap()
|
||||||
|
})
|
||||||
|
.collect();
|
||||||
|
}
|
||||||
SignOnly {
|
SignOnly {
|
||||||
blockhash,
|
blockhash,
|
||||||
present_signers,
|
present_signers,
|
||||||
|
@ -856,7 +856,7 @@ pub fn process_create_stake_account(
|
|||||||
|
|
||||||
if sign_only {
|
if sign_only {
|
||||||
tx.try_partial_sign(&config.signers, recent_blockhash)?;
|
tx.try_partial_sign(&config.signers, recent_blockhash)?;
|
||||||
return_signers(&tx)
|
return_signers(&tx, &config)
|
||||||
} else {
|
} else {
|
||||||
tx.try_sign(&config.signers, recent_blockhash)?;
|
tx.try_sign(&config.signers, recent_blockhash)?;
|
||||||
if let Some(nonce_account) = &nonce_account {
|
if let Some(nonce_account) = &nonce_account {
|
||||||
@ -870,7 +870,7 @@ pub fn process_create_stake_account(
|
|||||||
&tx.message,
|
&tx.message,
|
||||||
)?;
|
)?;
|
||||||
let result = rpc_client.send_and_confirm_transaction_with_spinner(&mut tx, &config.signers);
|
let result = rpc_client.send_and_confirm_transaction_with_spinner(&mut tx, &config.signers);
|
||||||
log_instruction_custom_error::<SystemError>(result)
|
log_instruction_custom_error::<SystemError>(result, &config)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -921,7 +921,7 @@ pub fn process_stake_authorize(
|
|||||||
|
|
||||||
if sign_only {
|
if sign_only {
|
||||||
tx.try_partial_sign(&config.signers, recent_blockhash)?;
|
tx.try_partial_sign(&config.signers, recent_blockhash)?;
|
||||||
return_signers(&tx)
|
return_signers(&tx, &config)
|
||||||
} else {
|
} else {
|
||||||
tx.try_sign(&config.signers, recent_blockhash)?;
|
tx.try_sign(&config.signers, recent_blockhash)?;
|
||||||
if let Some(nonce_account) = &nonce_account {
|
if let Some(nonce_account) = &nonce_account {
|
||||||
@ -935,7 +935,7 @@ pub fn process_stake_authorize(
|
|||||||
&tx.message,
|
&tx.message,
|
||||||
)?;
|
)?;
|
||||||
let result = rpc_client.send_and_confirm_transaction_with_spinner(&mut tx, &config.signers);
|
let result = rpc_client.send_and_confirm_transaction_with_spinner(&mut tx, &config.signers);
|
||||||
log_instruction_custom_error::<StakeError>(result)
|
log_instruction_custom_error::<StakeError>(result, &config)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -975,7 +975,7 @@ pub fn process_deactivate_stake_account(
|
|||||||
|
|
||||||
if sign_only {
|
if sign_only {
|
||||||
tx.try_partial_sign(&config.signers, recent_blockhash)?;
|
tx.try_partial_sign(&config.signers, recent_blockhash)?;
|
||||||
return_signers(&tx)
|
return_signers(&tx, &config)
|
||||||
} else {
|
} else {
|
||||||
tx.try_sign(&config.signers, recent_blockhash)?;
|
tx.try_sign(&config.signers, recent_blockhash)?;
|
||||||
if let Some(nonce_account) = &nonce_account {
|
if let Some(nonce_account) = &nonce_account {
|
||||||
@ -989,7 +989,7 @@ pub fn process_deactivate_stake_account(
|
|||||||
&tx.message,
|
&tx.message,
|
||||||
)?;
|
)?;
|
||||||
let result = rpc_client.send_and_confirm_transaction_with_spinner(&mut tx, &config.signers);
|
let result = rpc_client.send_and_confirm_transaction_with_spinner(&mut tx, &config.signers);
|
||||||
log_instruction_custom_error::<StakeError>(result)
|
log_instruction_custom_error::<StakeError>(result, &config)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1038,7 +1038,7 @@ pub fn process_withdraw_stake(
|
|||||||
|
|
||||||
if sign_only {
|
if sign_only {
|
||||||
tx.try_partial_sign(&config.signers, recent_blockhash)?;
|
tx.try_partial_sign(&config.signers, recent_blockhash)?;
|
||||||
return_signers(&tx)
|
return_signers(&tx, &config)
|
||||||
} else {
|
} else {
|
||||||
tx.try_sign(&config.signers, recent_blockhash)?;
|
tx.try_sign(&config.signers, recent_blockhash)?;
|
||||||
if let Some(nonce_account) = &nonce_account {
|
if let Some(nonce_account) = &nonce_account {
|
||||||
@ -1052,7 +1052,7 @@ pub fn process_withdraw_stake(
|
|||||||
&tx.message,
|
&tx.message,
|
||||||
)?;
|
)?;
|
||||||
let result = rpc_client.send_and_confirm_transaction_with_spinner(&mut tx, &config.signers);
|
let result = rpc_client.send_and_confirm_transaction_with_spinner(&mut tx, &config.signers);
|
||||||
log_instruction_custom_error::<SystemError>(result)
|
log_instruction_custom_error::<SystemError>(result, &config)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1172,7 +1172,7 @@ pub fn process_split_stake(
|
|||||||
|
|
||||||
if sign_only {
|
if sign_only {
|
||||||
tx.try_partial_sign(&config.signers, recent_blockhash)?;
|
tx.try_partial_sign(&config.signers, recent_blockhash)?;
|
||||||
return_signers(&tx)
|
return_signers(&tx, &config)
|
||||||
} else {
|
} else {
|
||||||
tx.try_sign(&config.signers, recent_blockhash)?;
|
tx.try_sign(&config.signers, recent_blockhash)?;
|
||||||
if let Some(nonce_account) = &nonce_account {
|
if let Some(nonce_account) = &nonce_account {
|
||||||
@ -1186,7 +1186,7 @@ pub fn process_split_stake(
|
|||||||
&tx.message,
|
&tx.message,
|
||||||
)?;
|
)?;
|
||||||
let result = rpc_client.send_and_confirm_transaction_with_spinner(&mut tx, &config.signers);
|
let result = rpc_client.send_and_confirm_transaction_with_spinner(&mut tx, &config.signers);
|
||||||
log_instruction_custom_error::<StakeError>(result)
|
log_instruction_custom_error::<StakeError>(result, &config)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1229,7 +1229,7 @@ pub fn process_stake_set_lockup(
|
|||||||
|
|
||||||
if sign_only {
|
if sign_only {
|
||||||
tx.try_partial_sign(&config.signers, recent_blockhash)?;
|
tx.try_partial_sign(&config.signers, recent_blockhash)?;
|
||||||
return_signers(&tx)
|
return_signers(&tx, &config)
|
||||||
} else {
|
} else {
|
||||||
tx.try_sign(&config.signers, recent_blockhash)?;
|
tx.try_sign(&config.signers, recent_blockhash)?;
|
||||||
if let Some(nonce_account) = &nonce_account {
|
if let Some(nonce_account) = &nonce_account {
|
||||||
@ -1243,7 +1243,7 @@ pub fn process_stake_set_lockup(
|
|||||||
&tx.message,
|
&tx.message,
|
||||||
)?;
|
)?;
|
||||||
let result = rpc_client.send_and_confirm_transaction_with_spinner(&mut tx, &config.signers);
|
let result = rpc_client.send_and_confirm_transaction_with_spinner(&mut tx, &config.signers);
|
||||||
log_instruction_custom_error::<StakeError>(result)
|
log_instruction_custom_error::<StakeError>(result, &config)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1437,7 +1437,7 @@ pub fn process_delegate_stake(
|
|||||||
|
|
||||||
if sign_only {
|
if sign_only {
|
||||||
tx.try_partial_sign(&config.signers, recent_blockhash)?;
|
tx.try_partial_sign(&config.signers, recent_blockhash)?;
|
||||||
return_signers(&tx)
|
return_signers(&tx, &config)
|
||||||
} else {
|
} else {
|
||||||
tx.try_sign(&config.signers, recent_blockhash)?;
|
tx.try_sign(&config.signers, recent_blockhash)?;
|
||||||
if let Some(nonce_account) = &nonce_account {
|
if let Some(nonce_account) = &nonce_account {
|
||||||
@ -1451,7 +1451,7 @@ pub fn process_delegate_stake(
|
|||||||
&tx.message,
|
&tx.message,
|
||||||
)?;
|
)?;
|
||||||
let result = rpc_client.send_and_confirm_transaction_with_spinner(&mut tx, &config.signers);
|
let result = rpc_client.send_and_confirm_transaction_with_spinner(&mut tx, &config.signers);
|
||||||
log_instruction_custom_error::<StakeError>(result)
|
log_instruction_custom_error::<StakeError>(result, &config)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -243,7 +243,7 @@ pub fn process_create_storage_account(
|
|||||||
&tx.message,
|
&tx.message,
|
||||||
)?;
|
)?;
|
||||||
let result = rpc_client.send_and_confirm_transaction_with_spinner(&mut tx, &config.signers);
|
let result = rpc_client.send_and_confirm_transaction_with_spinner(&mut tx, &config.signers);
|
||||||
log_instruction_custom_error::<SystemError>(result)
|
log_instruction_custom_error::<SystemError>(result, &config)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn process_claim_storage_reward(
|
pub fn process_claim_storage_reward(
|
||||||
|
@ -438,7 +438,7 @@ pub fn process_create_vote_account(
|
|||||||
&tx.message,
|
&tx.message,
|
||||||
)?;
|
)?;
|
||||||
let result = rpc_client.send_and_confirm_transaction_with_spinner(&mut tx, &config.signers);
|
let result = rpc_client.send_and_confirm_transaction_with_spinner(&mut tx, &config.signers);
|
||||||
log_instruction_custom_error::<SystemError>(result)
|
log_instruction_custom_error::<SystemError>(result, &config)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn process_vote_authorize(
|
pub fn process_vote_authorize(
|
||||||
@ -479,7 +479,7 @@ pub fn process_vote_authorize(
|
|||||||
)?;
|
)?;
|
||||||
let result =
|
let result =
|
||||||
rpc_client.send_and_confirm_transaction_with_spinner(&mut tx, &[config.signers[0]]);
|
rpc_client.send_and_confirm_transaction_with_spinner(&mut tx, &[config.signers[0]]);
|
||||||
log_instruction_custom_error::<VoteError>(result)
|
log_instruction_custom_error::<VoteError>(result, &config)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn process_vote_update_validator(
|
pub fn process_vote_update_validator(
|
||||||
@ -512,7 +512,7 @@ pub fn process_vote_update_validator(
|
|||||||
&tx.message,
|
&tx.message,
|
||||||
)?;
|
)?;
|
||||||
let result = rpc_client.send_and_confirm_transaction_with_spinner(&mut tx, &config.signers);
|
let result = rpc_client.send_and_confirm_transaction_with_spinner(&mut tx, &config.signers);
|
||||||
log_instruction_custom_error::<VoteError>(result)
|
log_instruction_custom_error::<VoteError>(result, &config)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_vote_account(
|
fn get_vote_account(
|
||||||
@ -618,7 +618,7 @@ pub fn process_withdraw_from_vote_account(
|
|||||||
)?;
|
)?;
|
||||||
let result =
|
let result =
|
||||||
rpc_client.send_and_confirm_transaction_with_spinner(&mut transaction, &config.signers);
|
rpc_client.send_and_confirm_transaction_with_spinner(&mut transaction, &config.signers);
|
||||||
log_instruction_custom_error::<VoteError>(result)
|
log_instruction_custom_error::<VoteError>(result, &config)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
use solana_cli::test_utils::check_balance;
|
use solana_cli::test_utils::check_balance;
|
||||||
use solana_cli::{
|
use solana_cli::{
|
||||||
cli::{process_command, request_and_confirm_airdrop, CliCommand, CliConfig},
|
cli::{process_command, request_and_confirm_airdrop, CliCommand, CliConfig},
|
||||||
|
cli_output::OutputFormat,
|
||||||
nonce,
|
nonce,
|
||||||
offline::{
|
offline::{
|
||||||
blockhash_query::{self, BlockhashQuery},
|
blockhash_query::{self, BlockhashQuery},
|
||||||
@ -91,6 +92,7 @@ fn full_battery_tests(
|
|||||||
&faucet_addr,
|
&faucet_addr,
|
||||||
&config_payer.signers[0].pubkey(),
|
&config_payer.signers[0].pubkey(),
|
||||||
2000,
|
2000,
|
||||||
|
&config_payer,
|
||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
check_balance(2000, &rpc_client, &config_payer.signers[0].pubkey());
|
check_balance(2000, &rpc_client, &config_payer.signers[0].pubkey());
|
||||||
@ -247,6 +249,7 @@ fn test_create_account_with_seed() {
|
|||||||
let offline_nonce_authority_signer = keypair_from_seed(&[1u8; 32]).unwrap();
|
let offline_nonce_authority_signer = keypair_from_seed(&[1u8; 32]).unwrap();
|
||||||
let online_nonce_creator_signer = keypair_from_seed(&[2u8; 32]).unwrap();
|
let online_nonce_creator_signer = keypair_from_seed(&[2u8; 32]).unwrap();
|
||||||
let to_address = Pubkey::new(&[3u8; 32]);
|
let to_address = Pubkey::new(&[3u8; 32]);
|
||||||
|
let config = CliConfig::default();
|
||||||
|
|
||||||
// Setup accounts
|
// Setup accounts
|
||||||
let rpc_client = RpcClient::new_socket(leader_data.rpc);
|
let rpc_client = RpcClient::new_socket(leader_data.rpc);
|
||||||
@ -255,6 +258,7 @@ fn test_create_account_with_seed() {
|
|||||||
&faucet_addr,
|
&faucet_addr,
|
||||||
&offline_nonce_authority_signer.pubkey(),
|
&offline_nonce_authority_signer.pubkey(),
|
||||||
42,
|
42,
|
||||||
|
&config,
|
||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
request_and_confirm_airdrop(
|
request_and_confirm_airdrop(
|
||||||
@ -262,6 +266,7 @@ fn test_create_account_with_seed() {
|
|||||||
&faucet_addr,
|
&faucet_addr,
|
||||||
&online_nonce_creator_signer.pubkey(),
|
&online_nonce_creator_signer.pubkey(),
|
||||||
4242,
|
4242,
|
||||||
|
&config,
|
||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
check_balance(42, &rpc_client, &offline_nonce_authority_signer.pubkey());
|
check_balance(42, &rpc_client, &offline_nonce_authority_signer.pubkey());
|
||||||
@ -316,6 +321,7 @@ fn test_create_account_with_seed() {
|
|||||||
nonce_authority: 0,
|
nonce_authority: 0,
|
||||||
fee_payer: 0,
|
fee_payer: 0,
|
||||||
};
|
};
|
||||||
|
authority_config.output_format = OutputFormat::JsonCompact;
|
||||||
let sign_only_reply = process_command(&authority_config).unwrap();
|
let sign_only_reply = process_command(&authority_config).unwrap();
|
||||||
let sign_only = parse_sign_only_reply_string(&sign_only_reply);
|
let sign_only = parse_sign_only_reply_string(&sign_only_reply);
|
||||||
let authority_presigner = sign_only.presigner_of(&authority_pubkey).unwrap();
|
let authority_presigner = sign_only.presigner_of(&authority_pubkey).unwrap();
|
||||||
|
@ -3,6 +3,7 @@ use serde_json::Value;
|
|||||||
use solana_cli::test_utils::check_balance;
|
use solana_cli::test_utils::check_balance;
|
||||||
use solana_cli::{
|
use solana_cli::{
|
||||||
cli::{process_command, request_and_confirm_airdrop, CliCommand, CliConfig, PayCommand},
|
cli::{process_command, request_and_confirm_airdrop, CliCommand, CliConfig, PayCommand},
|
||||||
|
cli_output::OutputFormat,
|
||||||
nonce,
|
nonce,
|
||||||
offline::{
|
offline::{
|
||||||
blockhash_query::{self, BlockhashQuery},
|
blockhash_query::{self, BlockhashQuery},
|
||||||
@ -57,6 +58,7 @@ fn test_cli_timestamp_tx() {
|
|||||||
&faucet_addr,
|
&faucet_addr,
|
||||||
&config_payer.signers[0].pubkey(),
|
&config_payer.signers[0].pubkey(),
|
||||||
50,
|
50,
|
||||||
|
&config_witness,
|
||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
check_balance(50, &rpc_client, &config_payer.signers[0].pubkey());
|
check_balance(50, &rpc_client, &config_payer.signers[0].pubkey());
|
||||||
@ -66,6 +68,7 @@ fn test_cli_timestamp_tx() {
|
|||||||
&faucet_addr,
|
&faucet_addr,
|
||||||
&config_witness.signers[0].pubkey(),
|
&config_witness.signers[0].pubkey(),
|
||||||
1,
|
1,
|
||||||
|
&config_witness,
|
||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
@ -142,6 +145,7 @@ fn test_cli_witness_tx() {
|
|||||||
&faucet_addr,
|
&faucet_addr,
|
||||||
&config_payer.signers[0].pubkey(),
|
&config_payer.signers[0].pubkey(),
|
||||||
50,
|
50,
|
||||||
|
&config_witness,
|
||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
request_and_confirm_airdrop(
|
request_and_confirm_airdrop(
|
||||||
@ -149,6 +153,7 @@ fn test_cli_witness_tx() {
|
|||||||
&faucet_addr,
|
&faucet_addr,
|
||||||
&config_witness.signers[0].pubkey(),
|
&config_witness.signers[0].pubkey(),
|
||||||
1,
|
1,
|
||||||
|
&config_witness,
|
||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
@ -222,6 +227,7 @@ fn test_cli_cancel_tx() {
|
|||||||
&faucet_addr,
|
&faucet_addr,
|
||||||
&config_payer.signers[0].pubkey(),
|
&config_payer.signers[0].pubkey(),
|
||||||
50,
|
50,
|
||||||
|
&config_witness,
|
||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
@ -295,6 +301,7 @@ fn test_offline_pay_tx() {
|
|||||||
&faucet_addr,
|
&faucet_addr,
|
||||||
&config_offline.signers[0].pubkey(),
|
&config_offline.signers[0].pubkey(),
|
||||||
50,
|
50,
|
||||||
|
&config_offline,
|
||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
@ -303,6 +310,7 @@ fn test_offline_pay_tx() {
|
|||||||
&faucet_addr,
|
&faucet_addr,
|
||||||
&config_online.signers[0].pubkey(),
|
&config_online.signers[0].pubkey(),
|
||||||
50,
|
50,
|
||||||
|
&config_offline,
|
||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
check_balance(50, &rpc_client, &config_offline.signers[0].pubkey());
|
check_balance(50, &rpc_client, &config_offline.signers[0].pubkey());
|
||||||
@ -316,6 +324,7 @@ fn test_offline_pay_tx() {
|
|||||||
sign_only: true,
|
sign_only: true,
|
||||||
..PayCommand::default()
|
..PayCommand::default()
|
||||||
});
|
});
|
||||||
|
config_offline.output_format = OutputFormat::JsonCompact;
|
||||||
let sig_response = process_command(&config_offline).unwrap();
|
let sig_response = process_command(&config_offline).unwrap();
|
||||||
|
|
||||||
check_balance(50, &rpc_client, &config_offline.signers[0].pubkey());
|
check_balance(50, &rpc_client, &config_offline.signers[0].pubkey());
|
||||||
@ -376,6 +385,7 @@ fn test_nonced_pay_tx() {
|
|||||||
&faucet_addr,
|
&faucet_addr,
|
||||||
&config.signers[0].pubkey(),
|
&config.signers[0].pubkey(),
|
||||||
50 + minimum_nonce_balance,
|
50 + minimum_nonce_balance,
|
||||||
|
&config,
|
||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
check_balance(
|
check_balance(
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
use solana_cli::test_utils::check_balance;
|
use solana_cli::test_utils::check_balance;
|
||||||
use solana_cli::{
|
use solana_cli::{
|
||||||
cli::{process_command, request_and_confirm_airdrop, CliCommand, CliConfig},
|
cli::{process_command, request_and_confirm_airdrop, CliCommand, CliConfig},
|
||||||
|
cli_output::OutputFormat,
|
||||||
nonce,
|
nonce,
|
||||||
offline::{
|
offline::{
|
||||||
blockhash_query::{self, BlockhashQuery},
|
blockhash_query::{self, BlockhashQuery},
|
||||||
@ -47,6 +48,7 @@ fn test_stake_delegation_force() {
|
|||||||
&faucet_addr,
|
&faucet_addr,
|
||||||
&config.signers[0].pubkey(),
|
&config.signers[0].pubkey(),
|
||||||
100_000,
|
100_000,
|
||||||
|
&config,
|
||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
@ -143,6 +145,7 @@ fn test_seed_stake_delegation_and_deactivation() {
|
|||||||
&faucet_addr,
|
&faucet_addr,
|
||||||
&config_validator.signers[0].pubkey(),
|
&config_validator.signers[0].pubkey(),
|
||||||
100_000,
|
100_000,
|
||||||
|
&config_validator,
|
||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
check_balance(100_000, &rpc_client, &config_validator.signers[0].pubkey());
|
check_balance(100_000, &rpc_client, &config_validator.signers[0].pubkey());
|
||||||
@ -233,6 +236,7 @@ fn test_stake_delegation_and_deactivation() {
|
|||||||
&faucet_addr,
|
&faucet_addr,
|
||||||
&config_validator.signers[0].pubkey(),
|
&config_validator.signers[0].pubkey(),
|
||||||
100_000,
|
100_000,
|
||||||
|
&config_validator,
|
||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
check_balance(100_000, &rpc_client, &config_validator.signers[0].pubkey());
|
check_balance(100_000, &rpc_client, &config_validator.signers[0].pubkey());
|
||||||
@ -329,6 +333,7 @@ fn test_offline_stake_delegation_and_deactivation() {
|
|||||||
&faucet_addr,
|
&faucet_addr,
|
||||||
&config_validator.signers[0].pubkey(),
|
&config_validator.signers[0].pubkey(),
|
||||||
100_000,
|
100_000,
|
||||||
|
&config_offline,
|
||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
check_balance(100_000, &rpc_client, &config_validator.signers[0].pubkey());
|
check_balance(100_000, &rpc_client, &config_validator.signers[0].pubkey());
|
||||||
@ -338,6 +343,7 @@ fn test_offline_stake_delegation_and_deactivation() {
|
|||||||
&faucet_addr,
|
&faucet_addr,
|
||||||
&config_offline.signers[0].pubkey(),
|
&config_offline.signers[0].pubkey(),
|
||||||
100_000,
|
100_000,
|
||||||
|
&config_validator,
|
||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
check_balance(100_000, &rpc_client, &config_offline.signers[0].pubkey());
|
check_balance(100_000, &rpc_client, &config_offline.signers[0].pubkey());
|
||||||
@ -373,6 +379,7 @@ fn test_offline_stake_delegation_and_deactivation() {
|
|||||||
nonce_authority: 0,
|
nonce_authority: 0,
|
||||||
fee_payer: 0,
|
fee_payer: 0,
|
||||||
};
|
};
|
||||||
|
config_offline.output_format = OutputFormat::JsonCompact;
|
||||||
let sig_response = process_command(&config_offline).unwrap();
|
let sig_response = process_command(&config_offline).unwrap();
|
||||||
let sign_only = parse_sign_only_reply_string(&sig_response);
|
let sign_only = parse_sign_only_reply_string(&sig_response);
|
||||||
assert!(sign_only.has_all_signers());
|
assert!(sign_only.has_all_signers());
|
||||||
@ -458,6 +465,7 @@ fn test_nonced_stake_delegation_and_deactivation() {
|
|||||||
&faucet_addr,
|
&faucet_addr,
|
||||||
&config.signers[0].pubkey(),
|
&config.signers[0].pubkey(),
|
||||||
100_000,
|
100_000,
|
||||||
|
&config,
|
||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
@ -567,6 +575,7 @@ fn test_stake_authorize() {
|
|||||||
&faucet_addr,
|
&faucet_addr,
|
||||||
&config.signers[0].pubkey(),
|
&config.signers[0].pubkey(),
|
||||||
100_000,
|
100_000,
|
||||||
|
&config,
|
||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
@ -584,6 +593,7 @@ fn test_stake_authorize() {
|
|||||||
&faucet_addr,
|
&faucet_addr,
|
||||||
&config_offline.signers[0].pubkey(),
|
&config_offline.signers[0].pubkey(),
|
||||||
100_000,
|
100_000,
|
||||||
|
&config,
|
||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
@ -691,6 +701,7 @@ fn test_stake_authorize() {
|
|||||||
nonce_authority: 0,
|
nonce_authority: 0,
|
||||||
fee_payer: 0,
|
fee_payer: 0,
|
||||||
};
|
};
|
||||||
|
config_offline.output_format = OutputFormat::JsonCompact;
|
||||||
let sign_reply = process_command(&config_offline).unwrap();
|
let sign_reply = process_command(&config_offline).unwrap();
|
||||||
let sign_only = parse_sign_only_reply_string(&sign_reply);
|
let sign_only = parse_sign_only_reply_string(&sign_reply);
|
||||||
assert!(sign_only.has_all_signers());
|
assert!(sign_only.has_all_signers());
|
||||||
@ -829,13 +840,16 @@ fn test_stake_authorize_with_fee_payer() {
|
|||||||
config_offline.command = CliCommand::ClusterVersion;
|
config_offline.command = CliCommand::ClusterVersion;
|
||||||
process_command(&config_offline).unwrap_err();
|
process_command(&config_offline).unwrap_err();
|
||||||
|
|
||||||
request_and_confirm_airdrop(&rpc_client, &faucet_addr, &default_pubkey, 100_000).unwrap();
|
request_and_confirm_airdrop(&rpc_client, &faucet_addr, &default_pubkey, 100_000, &config)
|
||||||
|
.unwrap();
|
||||||
check_balance(100_000, &rpc_client, &config.signers[0].pubkey());
|
check_balance(100_000, &rpc_client, &config.signers[0].pubkey());
|
||||||
|
|
||||||
request_and_confirm_airdrop(&rpc_client, &faucet_addr, &payer_pubkey, 100_000).unwrap();
|
request_and_confirm_airdrop(&rpc_client, &faucet_addr, &payer_pubkey, 100_000, &config)
|
||||||
|
.unwrap();
|
||||||
check_balance(100_000, &rpc_client, &payer_pubkey);
|
check_balance(100_000, &rpc_client, &payer_pubkey);
|
||||||
|
|
||||||
request_and_confirm_airdrop(&rpc_client, &faucet_addr, &offline_pubkey, 100_000).unwrap();
|
request_and_confirm_airdrop(&rpc_client, &faucet_addr, &offline_pubkey, 100_000, &config)
|
||||||
|
.unwrap();
|
||||||
check_balance(100_000, &rpc_client, &offline_pubkey);
|
check_balance(100_000, &rpc_client, &offline_pubkey);
|
||||||
|
|
||||||
// Create stake account, identity is authority
|
// Create stake account, identity is authority
|
||||||
@ -889,6 +903,7 @@ fn test_stake_authorize_with_fee_payer() {
|
|||||||
nonce_authority: 0,
|
nonce_authority: 0,
|
||||||
fee_payer: 0,
|
fee_payer: 0,
|
||||||
};
|
};
|
||||||
|
config_offline.output_format = OutputFormat::JsonCompact;
|
||||||
let sign_reply = process_command(&config_offline).unwrap();
|
let sign_reply = process_command(&config_offline).unwrap();
|
||||||
let sign_only = parse_sign_only_reply_string(&sign_reply);
|
let sign_only = parse_sign_only_reply_string(&sign_reply);
|
||||||
assert!(sign_only.has_all_signers());
|
assert!(sign_only.has_all_signers());
|
||||||
@ -954,11 +969,13 @@ fn test_stake_split() {
|
|||||||
&faucet_addr,
|
&faucet_addr,
|
||||||
&config.signers[0].pubkey(),
|
&config.signers[0].pubkey(),
|
||||||
500_000,
|
500_000,
|
||||||
|
&config,
|
||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
check_balance(500_000, &rpc_client, &config.signers[0].pubkey());
|
check_balance(500_000, &rpc_client, &config.signers[0].pubkey());
|
||||||
|
|
||||||
request_and_confirm_airdrop(&rpc_client, &faucet_addr, &offline_pubkey, 100_000).unwrap();
|
request_and_confirm_airdrop(&rpc_client, &faucet_addr, &offline_pubkey, 100_000, &config)
|
||||||
|
.unwrap();
|
||||||
check_balance(100_000, &rpc_client, &offline_pubkey);
|
check_balance(100_000, &rpc_client, &offline_pubkey);
|
||||||
|
|
||||||
// Create stake account, identity is authority
|
// Create stake account, identity is authority
|
||||||
@ -1026,6 +1043,7 @@ fn test_stake_split() {
|
|||||||
lamports: 2 * minimum_stake_balance,
|
lamports: 2 * minimum_stake_balance,
|
||||||
fee_payer: 0,
|
fee_payer: 0,
|
||||||
};
|
};
|
||||||
|
config_offline.output_format = OutputFormat::JsonCompact;
|
||||||
let sig_response = process_command(&config_offline).unwrap();
|
let sig_response = process_command(&config_offline).unwrap();
|
||||||
let sign_only = parse_sign_only_reply_string(&sig_response);
|
let sign_only = parse_sign_only_reply_string(&sig_response);
|
||||||
assert!(sign_only.has_all_signers());
|
assert!(sign_only.has_all_signers());
|
||||||
@ -1102,11 +1120,13 @@ fn test_stake_set_lockup() {
|
|||||||
&faucet_addr,
|
&faucet_addr,
|
||||||
&config.signers[0].pubkey(),
|
&config.signers[0].pubkey(),
|
||||||
500_000,
|
500_000,
|
||||||
|
&config,
|
||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
check_balance(500_000, &rpc_client, &config.signers[0].pubkey());
|
check_balance(500_000, &rpc_client, &config.signers[0].pubkey());
|
||||||
|
|
||||||
request_and_confirm_airdrop(&rpc_client, &faucet_addr, &offline_pubkey, 100_000).unwrap();
|
request_and_confirm_airdrop(&rpc_client, &faucet_addr, &offline_pubkey, 100_000, &config)
|
||||||
|
.unwrap();
|
||||||
check_balance(100_000, &rpc_client, &offline_pubkey);
|
check_balance(100_000, &rpc_client, &offline_pubkey);
|
||||||
|
|
||||||
// Create stake account, identity is authority
|
// Create stake account, identity is authority
|
||||||
@ -1280,6 +1300,7 @@ fn test_stake_set_lockup() {
|
|||||||
nonce_authority: 0,
|
nonce_authority: 0,
|
||||||
fee_payer: 0,
|
fee_payer: 0,
|
||||||
};
|
};
|
||||||
|
config_offline.output_format = OutputFormat::JsonCompact;
|
||||||
let sig_response = process_command(&config_offline).unwrap();
|
let sig_response = process_command(&config_offline).unwrap();
|
||||||
let sign_only = parse_sign_only_reply_string(&sig_response);
|
let sign_only = parse_sign_only_reply_string(&sig_response);
|
||||||
assert!(sign_only.has_all_signers());
|
assert!(sign_only.has_all_signers());
|
||||||
@ -1352,11 +1373,13 @@ fn test_offline_nonced_create_stake_account_and_withdraw() {
|
|||||||
&faucet_addr,
|
&faucet_addr,
|
||||||
&config.signers[0].pubkey(),
|
&config.signers[0].pubkey(),
|
||||||
200_000,
|
200_000,
|
||||||
|
&config,
|
||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
check_balance(200_000, &rpc_client, &config.signers[0].pubkey());
|
check_balance(200_000, &rpc_client, &config.signers[0].pubkey());
|
||||||
|
|
||||||
request_and_confirm_airdrop(&rpc_client, &faucet_addr, &offline_pubkey, 100_000).unwrap();
|
request_and_confirm_airdrop(&rpc_client, &faucet_addr, &offline_pubkey, 100_000, &config)
|
||||||
|
.unwrap();
|
||||||
check_balance(100_000, &rpc_client, &offline_pubkey);
|
check_balance(100_000, &rpc_client, &offline_pubkey);
|
||||||
|
|
||||||
// Create nonce account
|
// Create nonce account
|
||||||
@ -1398,6 +1421,7 @@ fn test_offline_nonced_create_stake_account_and_withdraw() {
|
|||||||
fee_payer: 0,
|
fee_payer: 0,
|
||||||
from: 0,
|
from: 0,
|
||||||
};
|
};
|
||||||
|
config_offline.output_format = OutputFormat::JsonCompact;
|
||||||
let sig_response = process_command(&config_offline).unwrap();
|
let sig_response = process_command(&config_offline).unwrap();
|
||||||
let sign_only = parse_sign_only_reply_string(&sig_response);
|
let sign_only = parse_sign_only_reply_string(&sig_response);
|
||||||
assert!(sign_only.has_all_signers());
|
assert!(sign_only.has_all_signers());
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
use solana_cli::test_utils::check_balance;
|
use solana_cli::test_utils::check_balance;
|
||||||
use solana_cli::{
|
use solana_cli::{
|
||||||
cli::{process_command, request_and_confirm_airdrop, CliCommand, CliConfig},
|
cli::{process_command, request_and_confirm_airdrop, CliCommand, CliConfig},
|
||||||
|
cli_output::OutputFormat,
|
||||||
nonce,
|
nonce,
|
||||||
offline::{
|
offline::{
|
||||||
blockhash_query::{self, BlockhashQuery},
|
blockhash_query::{self, BlockhashQuery},
|
||||||
@ -47,7 +48,8 @@ fn test_transfer() {
|
|||||||
let sender_pubkey = config.signers[0].pubkey();
|
let sender_pubkey = config.signers[0].pubkey();
|
||||||
let recipient_pubkey = Pubkey::new(&[1u8; 32]);
|
let recipient_pubkey = Pubkey::new(&[1u8; 32]);
|
||||||
|
|
||||||
request_and_confirm_airdrop(&rpc_client, &faucet_addr, &sender_pubkey, 50_000).unwrap();
|
request_and_confirm_airdrop(&rpc_client, &faucet_addr, &sender_pubkey, 50_000, &config)
|
||||||
|
.unwrap();
|
||||||
check_balance(50_000, &rpc_client, &sender_pubkey);
|
check_balance(50_000, &rpc_client, &sender_pubkey);
|
||||||
check_balance(0, &rpc_client, &recipient_pubkey);
|
check_balance(0, &rpc_client, &recipient_pubkey);
|
||||||
|
|
||||||
@ -75,7 +77,7 @@ fn test_transfer() {
|
|||||||
process_command(&offline).unwrap_err();
|
process_command(&offline).unwrap_err();
|
||||||
|
|
||||||
let offline_pubkey = offline.signers[0].pubkey();
|
let offline_pubkey = offline.signers[0].pubkey();
|
||||||
request_and_confirm_airdrop(&rpc_client, &faucet_addr, &offline_pubkey, 50).unwrap();
|
request_and_confirm_airdrop(&rpc_client, &faucet_addr, &offline_pubkey, 50, &config).unwrap();
|
||||||
check_balance(50, &rpc_client, &offline_pubkey);
|
check_balance(50, &rpc_client, &offline_pubkey);
|
||||||
|
|
||||||
// Offline transfer
|
// Offline transfer
|
||||||
@ -91,6 +93,7 @@ fn test_transfer() {
|
|||||||
nonce_authority: 0,
|
nonce_authority: 0,
|
||||||
fee_payer: 0,
|
fee_payer: 0,
|
||||||
};
|
};
|
||||||
|
offline.output_format = OutputFormat::JsonCompact;
|
||||||
let sign_only_reply = process_command(&offline).unwrap();
|
let sign_only_reply = process_command(&offline).unwrap();
|
||||||
let sign_only = parse_sign_only_reply_string(&sign_only_reply);
|
let sign_only = parse_sign_only_reply_string(&sign_only_reply);
|
||||||
assert!(sign_only.has_all_signers());
|
assert!(sign_only.has_all_signers());
|
||||||
@ -235,16 +238,24 @@ fn test_transfer_multisession_signing() {
|
|||||||
let offline_from_signer = keypair_from_seed(&[2u8; 32]).unwrap();
|
let offline_from_signer = keypair_from_seed(&[2u8; 32]).unwrap();
|
||||||
let offline_fee_payer_signer = keypair_from_seed(&[3u8; 32]).unwrap();
|
let offline_fee_payer_signer = keypair_from_seed(&[3u8; 32]).unwrap();
|
||||||
let from_null_signer = NullSigner::new(&offline_from_signer.pubkey());
|
let from_null_signer = NullSigner::new(&offline_from_signer.pubkey());
|
||||||
|
let config = CliConfig::default();
|
||||||
|
|
||||||
// Setup accounts
|
// Setup accounts
|
||||||
let rpc_client = RpcClient::new_socket(leader_data.rpc);
|
let rpc_client = RpcClient::new_socket(leader_data.rpc);
|
||||||
request_and_confirm_airdrop(&rpc_client, &faucet_addr, &offline_from_signer.pubkey(), 43)
|
request_and_confirm_airdrop(
|
||||||
.unwrap();
|
&rpc_client,
|
||||||
|
&faucet_addr,
|
||||||
|
&offline_from_signer.pubkey(),
|
||||||
|
43,
|
||||||
|
&config,
|
||||||
|
)
|
||||||
|
.unwrap();
|
||||||
request_and_confirm_airdrop(
|
request_and_confirm_airdrop(
|
||||||
&rpc_client,
|
&rpc_client,
|
||||||
&faucet_addr,
|
&faucet_addr,
|
||||||
&offline_fee_payer_signer.pubkey(),
|
&offline_fee_payer_signer.pubkey(),
|
||||||
3,
|
3,
|
||||||
|
&config,
|
||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
check_balance(43, &rpc_client, &offline_from_signer.pubkey());
|
check_balance(43, &rpc_client, &offline_from_signer.pubkey());
|
||||||
@ -271,6 +282,7 @@ fn test_transfer_multisession_signing() {
|
|||||||
nonce_authority: 0,
|
nonce_authority: 0,
|
||||||
fee_payer: 0,
|
fee_payer: 0,
|
||||||
};
|
};
|
||||||
|
fee_payer_config.output_format = OutputFormat::JsonCompact;
|
||||||
let sign_only_reply = process_command(&fee_payer_config).unwrap();
|
let sign_only_reply = process_command(&fee_payer_config).unwrap();
|
||||||
let sign_only = parse_sign_only_reply_string(&sign_only_reply);
|
let sign_only = parse_sign_only_reply_string(&sign_only_reply);
|
||||||
assert!(!sign_only.has_all_signers());
|
assert!(!sign_only.has_all_signers());
|
||||||
@ -296,6 +308,7 @@ fn test_transfer_multisession_signing() {
|
|||||||
nonce_authority: 0,
|
nonce_authority: 0,
|
||||||
fee_payer: 0,
|
fee_payer: 0,
|
||||||
};
|
};
|
||||||
|
from_config.output_format = OutputFormat::JsonCompact;
|
||||||
let sign_only_reply = process_command(&from_config).unwrap();
|
let sign_only_reply = process_command(&from_config).unwrap();
|
||||||
let sign_only = parse_sign_only_reply_string(&sign_only_reply);
|
let sign_only = parse_sign_only_reply_string(&sign_only_reply);
|
||||||
assert!(sign_only.has_all_signers());
|
assert!(sign_only.has_all_signers());
|
||||||
|
@ -36,6 +36,7 @@ fn test_vote_authorize_and_withdraw() {
|
|||||||
&faucet_addr,
|
&faucet_addr,
|
||||||
&config.signers[0].pubkey(),
|
&config.signers[0].pubkey(),
|
||||||
100_000,
|
100_000,
|
||||||
|
&config,
|
||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user