Skip to content

Commit

Permalink
replace solana_sdk::pubkey with solana_pubkey in solana-cli
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinheavey committed Dec 19, 2024
1 parent f06f5db commit c3159e5
Show file tree
Hide file tree
Showing 10 changed files with 39 additions and 40 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ solana-feature-set = { workspace = true }
solana-loader-v4-program = { workspace = true }
solana-logger = { workspace = true }
solana-program-runtime = { workspace = true }
solana-pubkey = { workspace = true }
solana-pubsub-client = { workspace = true }
solana-quic-client = { workspace = true }
solana-remote-wallet = { workspace = true, features = ["default"] }
Expand Down
8 changes: 4 additions & 4 deletions cli/src/checks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ mod tests {
},
value: json!(account_balance),
});
let pubkey = solana_sdk::pubkey::new_rand();
let pubkey = solana_pubkey::new_rand();

let pubkey0 = Pubkey::from([0; 32]);
let pubkey1 = Pubkey::from([1; 32]);
Expand Down Expand Up @@ -271,7 +271,7 @@ mod tests {
},
value: json!(account_balance),
});
let pubkey = solana_sdk::pubkey::new_rand();
let pubkey = solana_pubkey::new_rand();

let mut mocks = HashMap::new();
mocks.insert(RpcRequest::GetBalance, account_balance_response);
Expand Down Expand Up @@ -325,9 +325,9 @@ mod tests {

#[test]
fn test_check_unique_pubkeys() {
let pubkey0 = solana_sdk::pubkey::new_rand();
let pubkey0 = solana_pubkey::new_rand();
let pubkey_clone = pubkey0;
let pubkey1 = solana_sdk::pubkey::new_rand();
let pubkey1 = solana_pubkey::new_rand();

check_unique_pubkeys((&pubkey0, "foo".to_string()), (&pubkey1, "bar".to_string()))
.expect("unexpected result");
Expand Down
29 changes: 13 additions & 16 deletions cli/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1840,10 +1840,7 @@ mod tests {
.unwrap();
assert_eq!(signer_info.signers.len(), 1);
assert_eq!(signer_info.index_of(None), Some(0));
assert_eq!(
signer_info.index_of(Some(solana_sdk::pubkey::new_rand())),
None
);
assert_eq!(signer_info.index_of(Some(solana_pubkey::new_rand())), None);

let keypair0 = keypair_from_seed(&[1u8; 32]).unwrap();
let keypair0_pubkey = keypair0.pubkey();
Expand Down Expand Up @@ -1904,7 +1901,7 @@ mod tests {
fn test_cli_parse_command() {
let test_commands = get_clap_app("test", "desc", "version");

let pubkey = solana_sdk::pubkey::new_rand();
let pubkey = solana_pubkey::new_rand();
let pubkey_string = format!("{pubkey}");

let default_keypair = Keypair::new();
Expand Down Expand Up @@ -1983,7 +1980,7 @@ mod tests {
assert!(parse_command(&test_bad_signature, &default_signer, &mut None).is_err());

// Test CreateAddressWithSeed
let from_pubkey = solana_sdk::pubkey::new_rand();
let from_pubkey = solana_pubkey::new_rand();
let from_str = from_pubkey.to_string();
for (name, program_id) in &[
("STAKE", stake::program::id()),
Expand Down Expand Up @@ -2166,7 +2163,7 @@ mod tests {
..CliConfig::default()
};
let current_authority = keypair_from_seed(&[5; 32]).unwrap();
let new_authorized_pubkey = solana_sdk::pubkey::new_rand();
let new_authorized_pubkey = solana_pubkey::new_rand();
vote_config.signers = vec![&current_authority];
vote_config.command = CliCommand::VoteAuthorize {
vote_account_pubkey: bob_pubkey,
Expand Down Expand Up @@ -2206,7 +2203,7 @@ mod tests {

let bob_keypair = Keypair::new();
let bob_pubkey = bob_keypair.pubkey();
let custodian = solana_sdk::pubkey::new_rand();
let custodian = solana_pubkey::new_rand();
config.command = CliCommand::CreateStakeAccount {
stake_account: 1,
seed: None,
Expand All @@ -2233,8 +2230,8 @@ mod tests {
let result = process_command(&config);
assert!(result.is_ok());

let stake_account_pubkey = solana_sdk::pubkey::new_rand();
let to_pubkey = solana_sdk::pubkey::new_rand();
let stake_account_pubkey = solana_pubkey::new_rand();
let to_pubkey = solana_pubkey::new_rand();
config.command = CliCommand::WithdrawStake {
stake_account_pubkey,
destination_account_pubkey: to_pubkey,
Expand All @@ -2255,7 +2252,7 @@ mod tests {
let result = process_command(&config);
assert!(result.is_ok());

let stake_account_pubkey = solana_sdk::pubkey::new_rand();
let stake_account_pubkey = solana_pubkey::new_rand();
config.command = CliCommand::DeactivateStake {
stake_account_pubkey,
stake_authority: 0,
Expand All @@ -2273,7 +2270,7 @@ mod tests {
let result = process_command(&config);
assert!(result.is_ok());

let stake_account_pubkey = solana_sdk::pubkey::new_rand();
let stake_account_pubkey = solana_pubkey::new_rand();
let split_stake_account = Keypair::new();
config.command = CliCommand::SplitStake {
stake_account_pubkey,
Expand All @@ -2295,8 +2292,8 @@ mod tests {
let result = process_command(&config);
assert!(result.is_ok());

let stake_account_pubkey = solana_sdk::pubkey::new_rand();
let source_stake_account_pubkey = solana_sdk::pubkey::new_rand();
let stake_account_pubkey = solana_pubkey::new_rand();
let source_stake_account_pubkey = solana_pubkey::new_rand();
let merge_stake_account = Keypair::new();
config.command = CliCommand::MergeStake {
stake_account_pubkey,
Expand All @@ -2322,7 +2319,7 @@ mod tests {
assert_eq!(process_command(&config).unwrap(), "1234");

// CreateAddressWithSeed
let from_pubkey = solana_sdk::pubkey::new_rand();
let from_pubkey = solana_pubkey::new_rand();
config.signers = vec![];
config.command = CliCommand::CreateAddressWithSeed {
from_pubkey: Some(from_pubkey),
Expand All @@ -2335,7 +2332,7 @@ mod tests {
assert_eq!(address.unwrap(), expected_address.to_string());

// Need airdrop cases
let to = solana_sdk::pubkey::new_rand();
let to = solana_pubkey::new_rand();
config.signers = vec![&keypair];
config.command = CliCommand::Airdrop {
pubkey: Some(to),
Expand Down
4 changes: 2 additions & 2 deletions cli/src/nonce.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1044,7 +1044,7 @@ mod tests {
fn test_check_nonce_account() {
let durable_nonce = DurableNonce::from_blockhash(&Hash::default());
let blockhash = *durable_nonce.as_hash();
let nonce_pubkey = solana_sdk::pubkey::new_rand();
let nonce_pubkey = solana_pubkey::new_rand();
let data = Versions::new(State::Initialized(nonce::state::Data::new(
nonce_pubkey,
durable_nonce,
Expand Down Expand Up @@ -1086,7 +1086,7 @@ mod tests {
);
}

let new_nonce_authority = solana_sdk::pubkey::new_rand();
let new_nonce_authority = solana_pubkey::new_rand();
let data = Versions::new(State::Initialized(nonce::state::Data::new(
new_nonce_authority,
durable_nonce,
Expand Down
18 changes: 9 additions & 9 deletions cli/src/stake.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3975,9 +3975,9 @@ mod tests {
);

// Test CreateStakeAccount SubCommand
let custodian = solana_sdk::pubkey::new_rand();
let custodian = solana_pubkey::new_rand();
let custodian_string = format!("{custodian}");
let authorized = solana_sdk::pubkey::new_rand();
let authorized = solana_pubkey::new_rand();
let authorized_string = format!("{authorized}");
let test_create_stake_account = test_commands.clone().get_matches_from(vec![
"test",
Expand Down Expand Up @@ -4180,7 +4180,7 @@ mod tests {
);

// Test DelegateStake Subcommand
let vote_account_pubkey = solana_sdk::pubkey::new_rand();
let vote_account_pubkey = solana_pubkey::new_rand();
let vote_account_string = vote_account_pubkey.to_string();
let test_delegate_stake = test_commands.clone().get_matches_from(vec![
"test",
Expand Down Expand Up @@ -4210,7 +4210,7 @@ mod tests {
);

// Test DelegateStake Subcommand w/ authority
let vote_account_pubkey = solana_sdk::pubkey::new_rand();
let vote_account_pubkey = solana_pubkey::new_rand();
let vote_account_string = vote_account_pubkey.to_string();
let test_delegate_stake = test_commands.clone().get_matches_from(vec![
"test",
Expand Down Expand Up @@ -4339,7 +4339,7 @@ mod tests {
);

// Test Delegate Subcommand w/ absent fee payer
let key1 = solana_sdk::pubkey::new_rand();
let key1 = solana_pubkey::new_rand();
let sig1 = Keypair::new().sign_message(&[0u8]);
let signer1 = format!("{key1}={sig1}");
let test_delegate_stake = test_commands.clone().get_matches_from(vec![
Expand Down Expand Up @@ -4382,7 +4382,7 @@ mod tests {
);

// Test Delegate Subcommand w/ absent fee payer and absent nonce authority
let key2 = solana_sdk::pubkey::new_rand();
let key2 = solana_pubkey::new_rand();
let sig2 = Keypair::new().sign_message(&[0u8]);
let signer2 = format!("{key2}={sig2}");
let test_delegate_stake = test_commands.clone().get_matches_from(vec![
Expand Down Expand Up @@ -4808,7 +4808,7 @@ mod tests {
);

// Test Deactivate Subcommand w/ absent fee payer
let key1 = solana_sdk::pubkey::new_rand();
let key1 = solana_pubkey::new_rand();
let sig1 = Keypair::new().sign_message(&[0u8]);
let signer1 = format!("{key1}={sig1}");
let test_deactivate_stake = test_commands.clone().get_matches_from(vec![
Expand Down Expand Up @@ -4850,7 +4850,7 @@ mod tests {
);

// Test Deactivate Subcommand w/ absent fee payer and nonce authority
let key2 = solana_sdk::pubkey::new_rand();
let key2 = solana_pubkey::new_rand();
let sig2 = Keypair::new().sign_message(&[0u8]);
let signer2 = format!("{key2}={sig2}");
let test_deactivate_stake = test_commands.clone().get_matches_from(vec![
Expand Down Expand Up @@ -5043,7 +5043,7 @@ mod tests {
let stake_account_keypair = Keypair::new();
write_keypair(&stake_account_keypair, tmp_file.as_file_mut()).unwrap();

let source_stake_account_pubkey = solana_sdk::pubkey::new_rand();
let source_stake_account_pubkey = solana_pubkey::new_rand();
let test_merge_stake_account = test_commands.clone().get_matches_from(vec![
"test",
"merge-stake",
Expand Down
6 changes: 3 additions & 3 deletions cli/src/validator_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -505,7 +505,7 @@ mod tests {

#[test]
fn test_verify_keybase_username_not_string() {
let pubkey = solana_sdk::pubkey::new_rand();
let pubkey = solana_pubkey::new_rand();
let value = Value::Bool(true);

assert_eq!(
Expand Down Expand Up @@ -570,7 +570,7 @@ mod tests {

#[test]
fn test_parse_validator_info() {
let pubkey = solana_sdk::pubkey::new_rand();
let pubkey = solana_pubkey::new_rand();
let keys = vec![(validator_info::id(), false), (pubkey, true)];
let config = ConfigKeys { keys };

Expand Down Expand Up @@ -599,7 +599,7 @@ mod tests {
assert!(parse_validator_info(
&Pubkey::default(),
&Account {
owner: solana_sdk::pubkey::new_rand(),
owner: solana_pubkey::new_rand(),
..Account::default()
}
)
Expand Down
2 changes: 1 addition & 1 deletion cli/src/vote.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1991,7 +1991,7 @@ mod tests {
);

// test init with an authed voter
let authed = solana_sdk::pubkey::new_rand();
let authed = solana_pubkey::new_rand();
let (keypair_file, mut tmp_file) = make_tmp_file();
let keypair = Keypair::new();
write_keypair(&keypair, tmp_file.as_file_mut()).unwrap();
Expand Down
2 changes: 1 addition & 1 deletion cli/tests/nonce.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ fn test_nonce(seed: Option<String>, use_nonce_authority: bool, compute_unit_pric
assert_ne!(first_nonce, third_nonce);

// Withdraw from nonce account
let payee_pubkey = solana_sdk::pubkey::new_rand();
let payee_pubkey = solana_pubkey::new_rand();
config_payer.signers = authorized_signers;
config_payer.command = CliCommand::WithdrawFromNonceAccount {
nonce_account,
Expand Down
8 changes: 4 additions & 4 deletions cli/tests/vote.rs
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ fn test_vote_authorize_and_withdraw(compute_unit_price: Option<u64>) {
assert_eq!(authorized_withdrawer, withdraw_authority.pubkey());

// Withdraw from vote account
let destination_account = solana_sdk::pubkey::new_rand(); // Send withdrawal to new account to make balance check easy
let destination_account = solana_pubkey::new_rand(); // Send withdrawal to new account to make balance check easy
config.signers = vec![&default_signer, &withdraw_authority];
config.command = CliCommand::WithdrawFromVoteAccount {
vote_account_pubkey,
Expand Down Expand Up @@ -210,7 +210,7 @@ fn test_vote_authorize_and_withdraw(compute_unit_price: Option<u64>) {
process_command(&config).unwrap();

// Close vote account
let destination_account = solana_sdk::pubkey::new_rand(); // Send withdrawal to new account to make balance check easy
let destination_account = solana_pubkey::new_rand(); // Send withdrawal to new account to make balance check easy
config.signers = vec![&default_signer, &withdraw_authority];
config.command = CliCommand::CloseVoteAccount {
vote_account_pubkey,
Expand Down Expand Up @@ -374,7 +374,7 @@ fn test_offline_vote_authorize_and_withdraw(compute_unit_price: Option<u64>) {
assert_eq!(authorized_withdrawer, withdraw_authority.pubkey());

// Withdraw from vote account offline
let destination_account = solana_sdk::pubkey::new_rand(); // Send withdrawal to new account to make balance check easy
let destination_account = solana_pubkey::new_rand(); // Send withdrawal to new account to make balance check easy
let blockhash = rpc_client.get_latest_blockhash().unwrap();
let fee_payer_null_signer = NullSigner::new(&default_signer.pubkey());
config_offline.signers = vec![&fee_payer_null_signer, &withdraw_authority];
Expand Down Expand Up @@ -465,7 +465,7 @@ fn test_offline_vote_authorize_and_withdraw(compute_unit_price: Option<u64>) {

// Close vote account offline. Must use WithdrawFromVoteAccount and specify amount, since
// CloseVoteAccount requires RpcClient
let destination_account = solana_sdk::pubkey::new_rand(); // Send withdrawal to new account to make balance check easy
let destination_account = solana_pubkey::new_rand(); // Send withdrawal to new account to make balance check easy
config_offline.signers = vec![&fee_payer_null_signer, &withdraw_authority];
config_offline.command = CliCommand::WithdrawFromVoteAccount {
vote_account_pubkey,
Expand Down

0 comments on commit c3159e5

Please sign in to comment.