2020-05-14 11:24:14 -07:00
|
|
|
use crate::{
|
|
|
|
checks::{check_account_for_fee, check_unique_pubkeys},
|
|
|
|
cli::{
|
|
|
|
generate_unique_signers, log_instruction_custom_error, CliCommand, CliCommandInfo,
|
|
|
|
CliConfig, CliError, ProcessResult, SignerIndex,
|
|
|
|
},
|
2019-10-04 14:18:19 -07:00
|
|
|
};
|
|
|
|
use clap::{App, Arg, ArgMatches, SubCommand};
|
2020-02-24 16:03:30 -08:00
|
|
|
use solana_clap_utils::{input_parsers::*, input_validators::*, keypair::signer_from_path};
|
2019-10-04 14:18:19 -07:00
|
|
|
use solana_client::rpc_client::RpcClient;
|
2020-02-24 16:03:30 -08:00
|
|
|
use solana_remote_wallet::remote_wallet::RemoteWalletManager;
|
2019-10-04 14:18:19 -07:00
|
|
|
use solana_sdk::{
|
2020-02-24 16:03:30 -08:00
|
|
|
account_utils::StateMut, message::Message, pubkey::Pubkey, system_instruction::SystemError,
|
|
|
|
transaction::Transaction,
|
2019-10-04 14:18:19 -07:00
|
|
|
};
|
2019-11-20 16:32:19 -08:00
|
|
|
use solana_storage_program::storage_instruction::{self, StorageAccountType};
|
2020-02-24 16:03:30 -08:00
|
|
|
use std::sync::Arc;
|
2019-10-04 14:18:19 -07:00
|
|
|
|
|
|
|
pub trait StorageSubCommands {
|
|
|
|
fn storage_subcommands(self) -> Self;
|
|
|
|
}
|
|
|
|
|
|
|
|
impl StorageSubCommands for App<'_, '_> {
|
|
|
|
fn storage_subcommands(self) -> Self {
|
|
|
|
self.subcommand(
|
2019-10-21 10:29:37 -07:00
|
|
|
SubCommand::with_name("create-archiver-storage-account")
|
|
|
|
.about("Create an archiver storage account")
|
2019-10-04 14:18:19 -07:00
|
|
|
.arg(
|
|
|
|
Arg::with_name("storage_account_owner")
|
|
|
|
.index(1)
|
2020-03-19 20:43:11 -07:00
|
|
|
.value_name("AUTHORITY_PUBKEY")
|
2019-10-04 14:18:19 -07:00
|
|
|
.takes_value(true)
|
|
|
|
.required(true)
|
2020-03-16 15:17:13 -07:00
|
|
|
.validator(is_valid_pubkey),
|
2019-10-04 14:18:19 -07:00
|
|
|
)
|
|
|
|
.arg(
|
2019-11-06 06:47:34 -08:00
|
|
|
Arg::with_name("storage_account")
|
2019-10-04 14:18:19 -07:00
|
|
|
.index(2)
|
2020-03-19 20:43:11 -07:00
|
|
|
.value_name("ACCOUNT_KEYPAIR")
|
2019-10-04 14:18:19 -07:00
|
|
|
.takes_value(true)
|
|
|
|
.required(true)
|
2020-03-13 16:06:33 -07:00
|
|
|
.validator(is_valid_signer),
|
2019-10-04 14:18:19 -07:00
|
|
|
),
|
|
|
|
)
|
|
|
|
.subcommand(
|
|
|
|
SubCommand::with_name("create-validator-storage-account")
|
|
|
|
.about("Create a validator storage account")
|
|
|
|
.arg(
|
|
|
|
Arg::with_name("storage_account_owner")
|
|
|
|
.index(1)
|
2020-03-19 20:43:11 -07:00
|
|
|
.value_name("AUTHORITY_PUBKEY")
|
2019-10-04 14:18:19 -07:00
|
|
|
.takes_value(true)
|
|
|
|
.required(true)
|
2020-03-16 15:17:13 -07:00
|
|
|
.validator(is_valid_pubkey),
|
2019-10-04 14:18:19 -07:00
|
|
|
)
|
|
|
|
.arg(
|
2019-11-06 06:47:34 -08:00
|
|
|
Arg::with_name("storage_account")
|
2019-10-04 14:18:19 -07:00
|
|
|
.index(2)
|
2020-03-19 20:43:11 -07:00
|
|
|
.value_name("ACCOUNT_KEYPAIR")
|
2019-10-04 14:18:19 -07:00
|
|
|
.takes_value(true)
|
|
|
|
.required(true)
|
2020-03-13 16:06:33 -07:00
|
|
|
.validator(is_valid_signer),
|
2019-10-04 14:18:19 -07:00
|
|
|
),
|
|
|
|
)
|
|
|
|
.subcommand(
|
|
|
|
SubCommand::with_name("claim-storage-reward")
|
|
|
|
.about("Redeem storage reward credits")
|
|
|
|
.arg(
|
|
|
|
Arg::with_name("node_account_pubkey")
|
|
|
|
.index(1)
|
2020-03-21 12:30:01 -07:00
|
|
|
.value_name("NODE_ACCOUNT_ADDRESS")
|
2019-10-04 14:18:19 -07:00
|
|
|
.takes_value(true)
|
|
|
|
.required(true)
|
2020-03-16 15:17:13 -07:00
|
|
|
.validator(is_valid_pubkey)
|
2019-10-04 14:18:19 -07:00
|
|
|
.help("The node account to credit the rewards to"),
|
|
|
|
)
|
|
|
|
.arg(
|
|
|
|
Arg::with_name("storage_account_pubkey")
|
|
|
|
.index(2)
|
2020-03-21 12:30:01 -07:00
|
|
|
.value_name("STORAGE_ACCOUNT_ADDRESS")
|
2019-10-04 14:18:19 -07:00
|
|
|
.takes_value(true)
|
|
|
|
.required(true)
|
2020-03-16 15:17:13 -07:00
|
|
|
.validator(is_valid_pubkey)
|
2019-10-04 14:18:19 -07:00
|
|
|
.help("Storage account address to redeem credits for"),
|
|
|
|
),
|
|
|
|
)
|
|
|
|
.subcommand(
|
2020-01-20 22:06:47 -08:00
|
|
|
SubCommand::with_name("storage-account")
|
2019-10-04 14:18:19 -07:00
|
|
|
.about("Show the contents of a storage account")
|
2020-01-20 22:06:47 -08:00
|
|
|
.alias("show-storage-account")
|
2019-10-04 14:18:19 -07:00
|
|
|
.arg(
|
|
|
|
Arg::with_name("storage_account_pubkey")
|
|
|
|
.index(1)
|
2020-03-21 12:30:01 -07:00
|
|
|
.value_name("STORAGE_ACCOUNT_ADDRESS")
|
2019-10-04 14:18:19 -07:00
|
|
|
.takes_value(true)
|
|
|
|
.required(true)
|
2020-03-16 15:17:13 -07:00
|
|
|
.validator(is_valid_pubkey)
|
2020-03-21 12:30:01 -07:00
|
|
|
.help("Storage account address"),
|
2019-10-04 14:18:19 -07:00
|
|
|
),
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-10-21 10:29:37 -07:00
|
|
|
pub fn parse_storage_create_archiver_account(
|
2019-10-04 14:18:19 -07:00
|
|
|
matches: &ArgMatches<'_>,
|
2020-02-24 16:03:30 -08:00
|
|
|
default_signer_path: &str,
|
2020-04-18 11:54:21 -07:00
|
|
|
wallet_manager: &mut Option<Arc<RemoteWalletManager>>,
|
2019-10-21 16:08:09 -07:00
|
|
|
) -> Result<CliCommandInfo, CliError> {
|
2020-03-16 15:17:13 -07:00
|
|
|
let account_owner =
|
|
|
|
pubkey_of_signer(matches, "storage_account_owner", wallet_manager)?.unwrap();
|
2020-03-13 16:06:33 -07:00
|
|
|
let (storage_account, storage_account_pubkey) =
|
|
|
|
signer_of(matches, "storage_account", wallet_manager)?;
|
|
|
|
|
|
|
|
let payer_provided = None;
|
|
|
|
let signer_info = generate_unique_signers(
|
|
|
|
vec![payer_provided, storage_account],
|
|
|
|
matches,
|
|
|
|
default_signer_path,
|
|
|
|
wallet_manager,
|
|
|
|
)?;
|
|
|
|
|
2019-10-21 16:08:09 -07:00
|
|
|
Ok(CliCommandInfo {
|
|
|
|
command: CliCommand::CreateStorageAccount {
|
|
|
|
account_owner,
|
2020-03-13 16:06:33 -07:00
|
|
|
storage_account: signer_info.index_of(storage_account_pubkey).unwrap(),
|
2019-10-21 16:08:09 -07:00
|
|
|
account_type: StorageAccountType::Archiver,
|
|
|
|
},
|
2020-03-13 16:06:33 -07:00
|
|
|
signers: signer_info.signers,
|
2019-10-04 14:18:19 -07:00
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn parse_storage_create_validator_account(
|
|
|
|
matches: &ArgMatches<'_>,
|
2020-02-24 16:03:30 -08:00
|
|
|
default_signer_path: &str,
|
2020-04-18 11:54:21 -07:00
|
|
|
wallet_manager: &mut Option<Arc<RemoteWalletManager>>,
|
2019-10-21 16:08:09 -07:00
|
|
|
) -> Result<CliCommandInfo, CliError> {
|
2020-03-16 15:17:13 -07:00
|
|
|
let account_owner =
|
|
|
|
pubkey_of_signer(matches, "storage_account_owner", wallet_manager)?.unwrap();
|
2020-03-13 16:06:33 -07:00
|
|
|
let (storage_account, storage_account_pubkey) =
|
|
|
|
signer_of(matches, "storage_account", wallet_manager)?;
|
|
|
|
|
|
|
|
let payer_provided = None;
|
|
|
|
let signer_info = generate_unique_signers(
|
|
|
|
vec![payer_provided, storage_account],
|
|
|
|
matches,
|
|
|
|
default_signer_path,
|
|
|
|
wallet_manager,
|
|
|
|
)?;
|
|
|
|
|
2019-10-21 16:08:09 -07:00
|
|
|
Ok(CliCommandInfo {
|
|
|
|
command: CliCommand::CreateStorageAccount {
|
|
|
|
account_owner,
|
2020-03-13 16:06:33 -07:00
|
|
|
storage_account: signer_info.index_of(storage_account_pubkey).unwrap(),
|
2019-10-21 16:08:09 -07:00
|
|
|
account_type: StorageAccountType::Validator,
|
|
|
|
},
|
2020-03-13 16:06:33 -07:00
|
|
|
signers: signer_info.signers,
|
2019-10-04 14:18:19 -07:00
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2020-02-24 16:03:30 -08:00
|
|
|
pub fn parse_storage_claim_reward(
|
|
|
|
matches: &ArgMatches<'_>,
|
|
|
|
default_signer_path: &str,
|
2020-04-18 11:54:21 -07:00
|
|
|
wallet_manager: &mut Option<Arc<RemoteWalletManager>>,
|
2020-02-24 16:03:30 -08:00
|
|
|
) -> Result<CliCommandInfo, CliError> {
|
2020-03-16 15:17:13 -07:00
|
|
|
let node_account_pubkey =
|
|
|
|
pubkey_of_signer(matches, "node_account_pubkey", wallet_manager)?.unwrap();
|
|
|
|
let storage_account_pubkey =
|
|
|
|
pubkey_of_signer(matches, "storage_account_pubkey", wallet_manager)?.unwrap();
|
2019-10-21 16:08:09 -07:00
|
|
|
Ok(CliCommandInfo {
|
|
|
|
command: CliCommand::ClaimStorageReward {
|
|
|
|
node_account_pubkey,
|
|
|
|
storage_account_pubkey,
|
|
|
|
},
|
2020-02-24 16:03:30 -08:00
|
|
|
signers: vec![signer_from_path(
|
|
|
|
matches,
|
|
|
|
default_signer_path,
|
|
|
|
"keypair",
|
|
|
|
wallet_manager,
|
|
|
|
)?],
|
2019-10-04 14:18:19 -07:00
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2019-10-21 16:08:09 -07:00
|
|
|
pub fn parse_storage_get_account_command(
|
|
|
|
matches: &ArgMatches<'_>,
|
2020-04-18 11:54:21 -07:00
|
|
|
wallet_manager: &mut Option<Arc<RemoteWalletManager>>,
|
2019-10-21 16:08:09 -07:00
|
|
|
) -> Result<CliCommandInfo, CliError> {
|
2020-03-16 15:17:13 -07:00
|
|
|
let storage_account_pubkey =
|
|
|
|
pubkey_of_signer(matches, "storage_account_pubkey", wallet_manager)?.unwrap();
|
2019-10-21 16:08:09 -07:00
|
|
|
Ok(CliCommandInfo {
|
|
|
|
command: CliCommand::ShowStorageAccount(storage_account_pubkey),
|
2020-02-24 16:03:30 -08:00
|
|
|
signers: vec![],
|
2019-10-21 16:08:09 -07:00
|
|
|
})
|
2019-10-04 14:18:19 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
pub fn process_create_storage_account(
|
|
|
|
rpc_client: &RpcClient,
|
2019-10-04 15:13:21 -07:00
|
|
|
config: &CliConfig,
|
2020-02-24 16:03:30 -08:00
|
|
|
storage_account: SignerIndex,
|
2019-10-04 14:18:19 -07:00
|
|
|
account_owner: &Pubkey,
|
|
|
|
account_type: StorageAccountType,
|
|
|
|
) -> ProcessResult {
|
2020-02-24 16:03:30 -08:00
|
|
|
let storage_account = config.signers[storage_account];
|
2019-11-06 06:47:34 -08:00
|
|
|
let storage_account_pubkey = storage_account.pubkey();
|
2019-10-04 14:18:19 -07:00
|
|
|
check_unique_pubkeys(
|
2020-02-24 16:03:30 -08:00
|
|
|
(&config.signers[0].pubkey(), "cli keypair".to_string()),
|
2019-10-04 14:18:19 -07:00
|
|
|
(
|
|
|
|
&storage_account_pubkey,
|
|
|
|
"storage_account_pubkey".to_string(),
|
|
|
|
),
|
|
|
|
)?;
|
2020-01-09 20:25:07 -08:00
|
|
|
|
|
|
|
if let Ok(storage_account) = rpc_client.get_account(&storage_account_pubkey) {
|
|
|
|
let err_msg = if storage_account.owner == solana_storage_program::id() {
|
|
|
|
format!("Storage account {} already exists", storage_account_pubkey)
|
|
|
|
} else {
|
|
|
|
format!(
|
|
|
|
"Account {} already exists and is not a storage account",
|
|
|
|
storage_account_pubkey
|
|
|
|
)
|
|
|
|
};
|
|
|
|
return Err(CliError::BadParameter(err_msg).into());
|
|
|
|
}
|
|
|
|
|
2019-12-09 21:56:43 -08:00
|
|
|
use solana_storage_program::storage_contract::STORAGE_ACCOUNT_SPACE;
|
|
|
|
let required_balance = rpc_client
|
|
|
|
.get_minimum_balance_for_rent_exemption(STORAGE_ACCOUNT_SPACE as usize)?
|
|
|
|
.max(1);
|
|
|
|
|
2019-10-04 14:18:19 -07:00
|
|
|
let ixs = storage_instruction::create_storage_account(
|
2020-02-24 16:03:30 -08:00
|
|
|
&config.signers[0].pubkey(),
|
2019-10-04 14:18:19 -07:00
|
|
|
&account_owner,
|
2019-11-06 06:47:34 -08:00
|
|
|
&storage_account_pubkey,
|
2019-12-09 21:56:43 -08:00
|
|
|
required_balance,
|
2019-10-04 14:18:19 -07:00
|
|
|
account_type,
|
|
|
|
);
|
2019-12-09 21:56:43 -08:00
|
|
|
let (recent_blockhash, fee_calculator) = rpc_client.get_recent_blockhash()?;
|
|
|
|
|
2020-03-11 14:37:23 -07:00
|
|
|
let message = Message::new(&ixs);
|
2020-02-21 13:55:53 -08:00
|
|
|
let mut tx = Transaction::new_unsigned(message);
|
2020-02-24 16:03:30 -08:00
|
|
|
tx.try_sign(&config.signers, recent_blockhash)?;
|
2019-12-09 23:11:04 -08:00
|
|
|
check_account_for_fee(
|
|
|
|
rpc_client,
|
2020-02-24 16:03:30 -08:00
|
|
|
&config.signers[0].pubkey(),
|
2019-12-09 23:11:04 -08:00
|
|
|
&fee_calculator,
|
|
|
|
&tx.message,
|
|
|
|
)?;
|
2020-05-09 09:06:32 -07:00
|
|
|
let result = rpc_client.send_and_confirm_transaction_with_spinner(&tx);
|
2020-05-06 21:21:48 -07:00
|
|
|
log_instruction_custom_error::<SystemError>(result, &config)
|
2019-10-04 14:18:19 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
pub fn process_claim_storage_reward(
|
|
|
|
rpc_client: &RpcClient,
|
2019-10-04 15:13:21 -07:00
|
|
|
config: &CliConfig,
|
2019-10-04 14:18:19 -07:00
|
|
|
node_account_pubkey: &Pubkey,
|
|
|
|
storage_account_pubkey: &Pubkey,
|
|
|
|
) -> ProcessResult {
|
|
|
|
let (recent_blockhash, fee_calculator) = rpc_client.get_recent_blockhash()?;
|
|
|
|
|
|
|
|
let instruction =
|
|
|
|
storage_instruction::claim_reward(node_account_pubkey, storage_account_pubkey);
|
2020-02-24 16:03:30 -08:00
|
|
|
let signers = [config.signers[0]];
|
2020-03-11 14:37:23 -07:00
|
|
|
let message = Message::new_with_payer(&[instruction], Some(&signers[0].pubkey()));
|
2020-02-21 13:55:53 -08:00
|
|
|
let mut tx = Transaction::new_unsigned(message);
|
|
|
|
tx.try_sign(&signers, recent_blockhash)?;
|
2019-12-09 23:11:04 -08:00
|
|
|
check_account_for_fee(
|
|
|
|
rpc_client,
|
2020-02-24 16:03:30 -08:00
|
|
|
&config.signers[0].pubkey(),
|
2019-12-09 23:11:04 -08:00
|
|
|
&fee_calculator,
|
|
|
|
&tx.message,
|
|
|
|
)?;
|
2020-05-09 09:06:32 -07:00
|
|
|
let signature = rpc_client.send_and_confirm_transaction_with_spinner(&tx)?;
|
2020-03-27 15:46:00 -07:00
|
|
|
Ok(signature.to_string())
|
2019-10-04 14:18:19 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
pub fn process_show_storage_account(
|
|
|
|
rpc_client: &RpcClient,
|
2019-10-04 15:13:21 -07:00
|
|
|
_config: &CliConfig,
|
2019-10-04 14:18:19 -07:00
|
|
|
storage_account_pubkey: &Pubkey,
|
|
|
|
) -> ProcessResult {
|
|
|
|
let account = rpc_client.get_account(storage_account_pubkey)?;
|
|
|
|
|
2019-11-20 16:32:19 -08:00
|
|
|
if account.owner != solana_storage_program::id() {
|
2019-12-19 23:27:54 -08:00
|
|
|
return Err(CliError::RpcRequestError(format!(
|
|
|
|
"{:?} is not a storage account",
|
|
|
|
storage_account_pubkey
|
|
|
|
))
|
2019-10-04 14:18:19 -07:00
|
|
|
.into());
|
|
|
|
}
|
|
|
|
|
2019-11-20 16:32:19 -08:00
|
|
|
use solana_storage_program::storage_contract::StorageContract;
|
2019-10-04 14:18:19 -07:00
|
|
|
let storage_contract: StorageContract = account.state().map_err(|err| {
|
2020-03-12 23:20:49 -07:00
|
|
|
CliError::RpcRequestError(format!("Unable to deserialize storage account: {}", err))
|
2019-10-04 14:18:19 -07:00
|
|
|
})?;
|
|
|
|
println!("{:#?}", storage_contract);
|
2020-02-05 10:14:44 -08:00
|
|
|
println!("Account Lamports: {}", account.lamports);
|
2019-10-04 14:18:19 -07:00
|
|
|
Ok("".to_string())
|
|
|
|
}
|
|
|
|
|
|
|
|
#[cfg(test)]
|
|
|
|
mod tests {
|
|
|
|
use super::*;
|
2019-10-04 15:13:21 -07:00
|
|
|
use crate::cli::{app, parse_command};
|
2020-02-24 16:03:30 -08:00
|
|
|
use solana_sdk::signature::{read_keypair_file, write_keypair, Keypair, Signer};
|
2019-11-06 06:47:34 -08:00
|
|
|
use tempfile::NamedTempFile;
|
|
|
|
|
|
|
|
fn make_tmp_file() -> (String, NamedTempFile) {
|
|
|
|
let tmp_file = NamedTempFile::new().unwrap();
|
|
|
|
(String::from(tmp_file.path().to_str().unwrap()), tmp_file)
|
|
|
|
}
|
2019-10-04 14:18:19 -07:00
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_parse_command() {
|
|
|
|
let test_commands = app("test", "desc", "version");
|
|
|
|
let pubkey = Pubkey::new_rand();
|
|
|
|
let pubkey_string = pubkey.to_string();
|
2019-11-06 06:47:34 -08:00
|
|
|
|
2020-02-24 16:03:30 -08:00
|
|
|
let default_keypair = Keypair::new();
|
|
|
|
let (default_keypair_file, mut tmp_file) = make_tmp_file();
|
|
|
|
write_keypair(&default_keypair, tmp_file.as_file_mut()).unwrap();
|
|
|
|
|
2019-11-06 06:47:34 -08:00
|
|
|
let (keypair_file, mut tmp_file) = make_tmp_file();
|
|
|
|
let storage_account_keypair = Keypair::new();
|
|
|
|
write_keypair(&storage_account_keypair, tmp_file.as_file_mut()).unwrap();
|
2019-10-04 14:18:19 -07:00
|
|
|
|
2019-10-21 10:29:37 -07:00
|
|
|
let test_create_archiver_storage_account = test_commands.clone().get_matches_from(vec![
|
2019-10-04 14:18:19 -07:00
|
|
|
"test",
|
2019-10-21 10:29:37 -07:00
|
|
|
"create-archiver-storage-account",
|
2019-10-04 14:18:19 -07:00
|
|
|
&pubkey_string,
|
2019-11-06 06:47:34 -08:00
|
|
|
&keypair_file,
|
2019-10-04 14:18:19 -07:00
|
|
|
]);
|
|
|
|
assert_eq!(
|
2020-02-24 16:03:30 -08:00
|
|
|
parse_command(
|
|
|
|
&test_create_archiver_storage_account,
|
|
|
|
&default_keypair_file,
|
2020-04-18 11:54:21 -07:00
|
|
|
&mut None
|
2020-02-24 16:03:30 -08:00
|
|
|
)
|
|
|
|
.unwrap(),
|
2019-10-21 16:08:09 -07:00
|
|
|
CliCommandInfo {
|
|
|
|
command: CliCommand::CreateStorageAccount {
|
|
|
|
account_owner: pubkey,
|
2020-02-24 16:03:30 -08:00
|
|
|
storage_account: 1,
|
2019-10-21 16:08:09 -07:00
|
|
|
account_type: StorageAccountType::Archiver,
|
|
|
|
},
|
2020-02-24 16:03:30 -08:00
|
|
|
signers: vec![
|
|
|
|
read_keypair_file(&default_keypair_file).unwrap().into(),
|
|
|
|
storage_account_keypair.into()
|
|
|
|
],
|
2019-10-04 14:18:19 -07:00
|
|
|
}
|
|
|
|
);
|
|
|
|
|
2019-11-06 06:47:34 -08:00
|
|
|
let (keypair_file, mut tmp_file) = make_tmp_file();
|
|
|
|
let storage_account_keypair = Keypair::new();
|
|
|
|
write_keypair(&storage_account_keypair, tmp_file.as_file_mut()).unwrap();
|
|
|
|
let storage_account_pubkey = storage_account_keypair.pubkey();
|
|
|
|
let storage_account_string = storage_account_pubkey.to_string();
|
|
|
|
|
2019-10-04 14:18:19 -07:00
|
|
|
let test_create_validator_storage_account = test_commands.clone().get_matches_from(vec![
|
|
|
|
"test",
|
|
|
|
"create-validator-storage-account",
|
|
|
|
&pubkey_string,
|
2019-11-06 06:47:34 -08:00
|
|
|
&keypair_file,
|
2019-10-04 14:18:19 -07:00
|
|
|
]);
|
|
|
|
assert_eq!(
|
2020-02-24 16:03:30 -08:00
|
|
|
parse_command(
|
|
|
|
&test_create_validator_storage_account,
|
|
|
|
&default_keypair_file,
|
2020-04-18 11:54:21 -07:00
|
|
|
&mut None
|
2020-02-24 16:03:30 -08:00
|
|
|
)
|
|
|
|
.unwrap(),
|
2019-10-21 16:08:09 -07:00
|
|
|
CliCommandInfo {
|
|
|
|
command: CliCommand::CreateStorageAccount {
|
|
|
|
account_owner: pubkey,
|
2020-02-24 16:03:30 -08:00
|
|
|
storage_account: 1,
|
2019-10-21 16:08:09 -07:00
|
|
|
account_type: StorageAccountType::Validator,
|
|
|
|
},
|
2020-02-24 16:03:30 -08:00
|
|
|
signers: vec![
|
|
|
|
read_keypair_file(&default_keypair_file).unwrap().into(),
|
|
|
|
storage_account_keypair.into()
|
|
|
|
],
|
2019-10-04 14:18:19 -07:00
|
|
|
}
|
|
|
|
);
|
|
|
|
|
|
|
|
let test_claim_storage_reward = test_commands.clone().get_matches_from(vec![
|
|
|
|
"test",
|
|
|
|
"claim-storage-reward",
|
|
|
|
&pubkey_string,
|
|
|
|
&storage_account_string,
|
|
|
|
]);
|
|
|
|
assert_eq!(
|
2020-04-18 11:54:21 -07:00
|
|
|
parse_command(&test_claim_storage_reward, &default_keypair_file, &mut None).unwrap(),
|
2019-10-21 16:08:09 -07:00
|
|
|
CliCommandInfo {
|
|
|
|
command: CliCommand::ClaimStorageReward {
|
|
|
|
node_account_pubkey: pubkey,
|
|
|
|
storage_account_pubkey,
|
|
|
|
},
|
2020-02-24 16:03:30 -08:00
|
|
|
signers: vec![read_keypair_file(&default_keypair_file).unwrap().into()],
|
2019-10-04 14:18:19 -07:00
|
|
|
}
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|