Rename drone to faucet (#7508)
This commit is contained in:
@ -32,7 +32,7 @@ solana-budget-program = { path = "../programs/budget", version = "0.22.0" }
|
||||
solana-clap-utils = { path = "../clap-utils", version = "0.22.0" }
|
||||
solana-client = { path = "../client", version = "0.22.0" }
|
||||
solana-config-program = { path = "../programs/config", version = "0.22.0" }
|
||||
solana-drone = { path = "../drone", version = "0.22.0" }
|
||||
solana-faucet = { path = "../faucet", version = "0.22.0" }
|
||||
solana-logger = { path = "../logger", version = "0.22.0" }
|
||||
solana-net-utils = { path = "../net-utils", version = "0.22.0" }
|
||||
solana-runtime = { path = "../runtime", version = "0.22.0" }
|
||||
|
@ -16,9 +16,9 @@ use solana_budget_program::budget_instruction::{self, BudgetError};
|
||||
use solana_clap_utils::{input_parsers::*, input_validators::*};
|
||||
use solana_client::{client_error::ClientError, rpc_client::RpcClient};
|
||||
#[cfg(not(test))]
|
||||
use solana_drone::drone::request_airdrop_transaction;
|
||||
use solana_faucet::faucet::request_airdrop_transaction;
|
||||
#[cfg(test)]
|
||||
use solana_drone::drone_mock::request_airdrop_transaction;
|
||||
use solana_faucet::faucet_mock::request_airdrop_transaction;
|
||||
use solana_sdk::{
|
||||
bpf_loader,
|
||||
clock::Slot,
|
||||
@ -208,8 +208,8 @@ pub enum CliCommand {
|
||||
// Wallet Commands
|
||||
Address,
|
||||
Airdrop {
|
||||
drone_host: Option<IpAddr>,
|
||||
drone_port: u16,
|
||||
faucet_host: Option<IpAddr>,
|
||||
faucet_port: u16,
|
||||
lamports: u64,
|
||||
use_lamports_unit: bool,
|
||||
},
|
||||
@ -401,21 +401,21 @@ pub fn parse_command(matches: &ArgMatches<'_>) -> Result<CliCommandInfo, Box<dyn
|
||||
require_keypair: true,
|
||||
}),
|
||||
("airdrop", Some(matches)) => {
|
||||
let drone_port = matches
|
||||
.value_of("drone_port")
|
||||
let faucet_port = matches
|
||||
.value_of("faucet_port")
|
||||
.unwrap()
|
||||
.parse()
|
||||
.or_else(|err| {
|
||||
Err(CliError::BadParameter(format!(
|
||||
"Invalid drone port: {:?}",
|
||||
"Invalid faucet port: {:?}",
|
||||
err
|
||||
)))
|
||||
})?;
|
||||
|
||||
let drone_host = if let Some(drone_host) = matches.value_of("drone_host") {
|
||||
Some(solana_net_utils::parse_host(drone_host).or_else(|err| {
|
||||
let faucet_host = if let Some(faucet_host) = matches.value_of("faucet_host") {
|
||||
Some(solana_net_utils::parse_host(faucet_host).or_else(|err| {
|
||||
Err(CliError::BadParameter(format!(
|
||||
"Invalid drone host: {:?}",
|
||||
"Invalid faucet host: {:?}",
|
||||
err
|
||||
)))
|
||||
})?)
|
||||
@ -426,8 +426,8 @@ pub fn parse_command(matches: &ArgMatches<'_>) -> Result<CliCommandInfo, Box<dyn
|
||||
let use_lamports_unit = matches.value_of("unit") == Some("lamports");
|
||||
Ok(CliCommandInfo {
|
||||
command: CliCommand::Airdrop {
|
||||
drone_host,
|
||||
drone_port,
|
||||
faucet_host,
|
||||
faucet_port,
|
||||
lamports,
|
||||
use_lamports_unit,
|
||||
},
|
||||
@ -684,14 +684,14 @@ fn process_create_address_with_seed(
|
||||
fn process_airdrop(
|
||||
rpc_client: &RpcClient,
|
||||
config: &CliConfig,
|
||||
drone_addr: &SocketAddr,
|
||||
faucet_addr: &SocketAddr,
|
||||
lamports: u64,
|
||||
use_lamports_unit: bool,
|
||||
) -> ProcessResult {
|
||||
println!(
|
||||
"Requesting airdrop of {} from {}",
|
||||
build_balance_message(lamports, use_lamports_unit, true),
|
||||
drone_addr
|
||||
faucet_addr
|
||||
);
|
||||
let previous_balance = match rpc_client.retry_get_balance(&config.keypair.pubkey(), 5)? {
|
||||
Some(lamports) => lamports,
|
||||
@ -703,7 +703,7 @@ fn process_airdrop(
|
||||
}
|
||||
};
|
||||
|
||||
request_and_confirm_airdrop(&rpc_client, drone_addr, &config.keypair.pubkey(), lamports)?;
|
||||
request_and_confirm_airdrop(&rpc_client, faucet_addr, &config.keypair.pubkey(), lamports)?;
|
||||
|
||||
let current_balance = rpc_client
|
||||
.retry_get_balance(&config.keypair.pubkey(), 5)?
|
||||
@ -1362,31 +1362,31 @@ pub fn process_command(config: &CliConfig) -> ProcessResult {
|
||||
|
||||
// Get address of this client
|
||||
CliCommand::Address => unreachable!(),
|
||||
// Request an airdrop from Solana Drone;
|
||||
// Request an airdrop from Solana Faucet;
|
||||
CliCommand::Airdrop {
|
||||
drone_host,
|
||||
drone_port,
|
||||
faucet_host,
|
||||
faucet_port,
|
||||
lamports,
|
||||
use_lamports_unit,
|
||||
} => {
|
||||
let drone_addr = SocketAddr::new(
|
||||
drone_host.unwrap_or_else(|| {
|
||||
let drone_host = url::Url::parse(&config.json_rpc_url)
|
||||
let faucet_addr = SocketAddr::new(
|
||||
faucet_host.unwrap_or_else(|| {
|
||||
let faucet_host = url::Url::parse(&config.json_rpc_url)
|
||||
.unwrap()
|
||||
.host()
|
||||
.unwrap()
|
||||
.to_string();
|
||||
solana_net_utils::parse_host(&drone_host).unwrap_or_else(|err| {
|
||||
panic!("Unable to resolve {}: {}", drone_host, err);
|
||||
solana_net_utils::parse_host(&faucet_host).unwrap_or_else(|err| {
|
||||
panic!("Unable to resolve {}: {}", faucet_host, err);
|
||||
})
|
||||
}),
|
||||
*drone_port,
|
||||
*faucet_port,
|
||||
);
|
||||
|
||||
process_airdrop(
|
||||
&rpc_client,
|
||||
config,
|
||||
&drone_addr,
|
||||
&faucet_addr,
|
||||
*lamports,
|
||||
*use_lamports_unit,
|
||||
)
|
||||
@ -1446,18 +1446,18 @@ pub fn process_command(config: &CliConfig) -> ProcessResult {
|
||||
|
||||
// Quick and dirty Keypair that assumes the client will do retries but not update the
|
||||
// blockhash. If the client updates the blockhash, the signature will be invalid.
|
||||
struct DroneKeypair {
|
||||
struct FaucetKeypair {
|
||||
transaction: Transaction,
|
||||
}
|
||||
|
||||
impl DroneKeypair {
|
||||
impl FaucetKeypair {
|
||||
fn new_keypair(
|
||||
drone_addr: &SocketAddr,
|
||||
faucet_addr: &SocketAddr,
|
||||
to_pubkey: &Pubkey,
|
||||
lamports: u64,
|
||||
blockhash: Hash,
|
||||
) -> Result<Self, Box<dyn error::Error>> {
|
||||
let transaction = request_airdrop_transaction(drone_addr, to_pubkey, lamports, blockhash)?;
|
||||
let transaction = request_airdrop_transaction(faucet_addr, to_pubkey, lamports, blockhash)?;
|
||||
Ok(Self { transaction })
|
||||
}
|
||||
|
||||
@ -1466,7 +1466,7 @@ impl DroneKeypair {
|
||||
}
|
||||
}
|
||||
|
||||
impl KeypairUtil for DroneKeypair {
|
||||
impl KeypairUtil for FaucetKeypair {
|
||||
fn new() -> Self {
|
||||
unimplemented!();
|
||||
}
|
||||
@ -1483,7 +1483,7 @@ impl KeypairUtil for DroneKeypair {
|
||||
|
||||
pub fn request_and_confirm_airdrop(
|
||||
rpc_client: &RpcClient,
|
||||
drone_addr: &SocketAddr,
|
||||
faucet_addr: &SocketAddr,
|
||||
to_pubkey: &Pubkey,
|
||||
lamports: u64,
|
||||
) -> ProcessResult {
|
||||
@ -1491,7 +1491,7 @@ pub fn request_and_confirm_airdrop(
|
||||
let keypair = {
|
||||
let mut retries = 5;
|
||||
loop {
|
||||
let result = DroneKeypair::new_keypair(drone_addr, to_pubkey, lamports, blockhash);
|
||||
let result = FaucetKeypair::new_keypair(faucet_addr, to_pubkey, lamports, blockhash);
|
||||
if result.is_ok() || retries == 0 {
|
||||
break result;
|
||||
}
|
||||
@ -1579,19 +1579,19 @@ pub fn app<'ab, 'v>(name: &str, about: &'ab str, version: &'v str) -> App<'ab, '
|
||||
SubCommand::with_name("airdrop")
|
||||
.about("Request lamports")
|
||||
.arg(
|
||||
Arg::with_name("drone_host")
|
||||
.long("drone-host")
|
||||
Arg::with_name("faucet_host")
|
||||
.long("faucet-host")
|
||||
.value_name("HOST")
|
||||
.takes_value(true)
|
||||
.help("Drone host to use [default: the --url host]"),
|
||||
.help("Faucet host to use [default: the --url host]"),
|
||||
)
|
||||
.arg(
|
||||
Arg::with_name("drone_port")
|
||||
.long("drone-port")
|
||||
Arg::with_name("faucet_port")
|
||||
.long("faucet-port")
|
||||
.value_name("PORT")
|
||||
.takes_value(true)
|
||||
.default_value(solana_drone::drone::DRONE_PORT_STR)
|
||||
.help("Drone port to use"),
|
||||
.default_value(solana_faucet::faucet::FAUCET_PORT_STR)
|
||||
.help("Faucet port to use"),
|
||||
)
|
||||
.arg(
|
||||
Arg::with_name("amount")
|
||||
@ -1907,8 +1907,8 @@ mod tests {
|
||||
parse_command(&test_airdrop).unwrap(),
|
||||
CliCommandInfo {
|
||||
command: CliCommand::Airdrop {
|
||||
drone_host: None,
|
||||
drone_port: solana_drone::drone::DRONE_PORT,
|
||||
faucet_host: None,
|
||||
faucet_port: solana_faucet::faucet::FAUCET_PORT,
|
||||
lamports: 50,
|
||||
use_lamports_unit: true,
|
||||
},
|
||||
@ -2545,8 +2545,8 @@ mod tests {
|
||||
|
||||
// Need airdrop cases
|
||||
config.command = CliCommand::Airdrop {
|
||||
drone_host: None,
|
||||
drone_port: 1234,
|
||||
faucet_host: None,
|
||||
faucet_port: 1234,
|
||||
lamports: 50,
|
||||
use_lamports_unit: true,
|
||||
};
|
||||
@ -2584,8 +2584,8 @@ mod tests {
|
||||
config.rpc_client = Some(RpcClient::new_mock("fails".to_string()));
|
||||
|
||||
config.command = CliCommand::Airdrop {
|
||||
drone_host: None,
|
||||
drone_port: 1234,
|
||||
faucet_host: None,
|
||||
faucet_port: 1234,
|
||||
lamports: 50,
|
||||
use_lamports_unit: true,
|
||||
};
|
||||
|
@ -2,7 +2,7 @@ use serde_json::Value;
|
||||
use solana_cli::cli::{process_command, CliCommand, CliConfig};
|
||||
use solana_client::rpc_client::RpcClient;
|
||||
use solana_core::validator::new_validator_for_tests;
|
||||
use solana_drone::drone::run_local_drone;
|
||||
use solana_faucet::faucet::run_local_faucet;
|
||||
use solana_sdk::{bpf_loader, pubkey::Pubkey};
|
||||
use std::{
|
||||
fs::{remove_dir_all, File},
|
||||
@ -25,8 +25,8 @@ fn test_cli_deploy_program() {
|
||||
let (server, leader_data, alice, ledger_path) = new_validator_for_tests();
|
||||
|
||||
let (sender, receiver) = channel();
|
||||
run_local_drone(alice, sender, None);
|
||||
let drone_addr = receiver.recv().unwrap();
|
||||
run_local_faucet(alice, sender, None);
|
||||
let faucet_addr = receiver.recv().unwrap();
|
||||
|
||||
let rpc_client = RpcClient::new_socket(leader_data.rpc);
|
||||
|
||||
@ -40,8 +40,8 @@ fn test_cli_deploy_program() {
|
||||
let mut config = CliConfig::default();
|
||||
config.json_rpc_url = format!("http://{}:{}", leader_data.rpc.ip(), leader_data.rpc.port());
|
||||
config.command = CliCommand::Airdrop {
|
||||
drone_host: None,
|
||||
drone_port: drone_addr.port(),
|
||||
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,
|
||||
};
|
||||
|
@ -1,6 +1,6 @@
|
||||
use solana_cli::cli::{process_command, request_and_confirm_airdrop, CliCommand, CliConfig};
|
||||
use solana_client::rpc_client::RpcClient;
|
||||
use solana_drone::drone::run_local_drone;
|
||||
use solana_faucet::faucet::run_local_faucet;
|
||||
use solana_sdk::{
|
||||
hash::Hash,
|
||||
pubkey::Pubkey,
|
||||
@ -38,8 +38,8 @@ fn check_balance(expected_balance: u64, client: &RpcClient, pubkey: &Pubkey) {
|
||||
fn test_nonce() {
|
||||
let (server, leader_data, alice, ledger_path) = new_validator_for_tests();
|
||||
let (sender, receiver) = channel();
|
||||
run_local_drone(alice, sender, None);
|
||||
let drone_addr = receiver.recv().unwrap();
|
||||
run_local_faucet(alice, sender, None);
|
||||
let faucet_addr = receiver.recv().unwrap();
|
||||
|
||||
let rpc_client = RpcClient::new_socket(leader_data.rpc);
|
||||
|
||||
@ -55,7 +55,7 @@ fn test_nonce() {
|
||||
|
||||
request_and_confirm_airdrop(
|
||||
&rpc_client,
|
||||
&drone_addr,
|
||||
&faucet_addr,
|
||||
&config_payer.keypair.pubkey(),
|
||||
2000,
|
||||
)
|
||||
|
@ -2,7 +2,7 @@ use chrono::prelude::*;
|
||||
use serde_json::Value;
|
||||
use solana_cli::cli::{process_command, request_and_confirm_airdrop, CliCommand, CliConfig};
|
||||
use solana_client::rpc_client::RpcClient;
|
||||
use solana_drone::drone::run_local_drone;
|
||||
use solana_faucet::faucet::run_local_faucet;
|
||||
use solana_sdk::{hash::Hash, pubkey::Pubkey, signature::KeypairUtil, signature::Signature};
|
||||
use std::fs::remove_dir_all;
|
||||
use std::str::FromStr;
|
||||
@ -32,8 +32,8 @@ fn test_cli_timestamp_tx() {
|
||||
let bob_pubkey = Pubkey::new_rand();
|
||||
|
||||
let (sender, receiver) = channel();
|
||||
run_local_drone(alice, sender, None);
|
||||
let drone_addr = receiver.recv().unwrap();
|
||||
run_local_faucet(alice, sender, None);
|
||||
let faucet_addr = receiver.recv().unwrap();
|
||||
|
||||
let rpc_client = RpcClient::new_socket(leader_data.rpc);
|
||||
|
||||
@ -49,13 +49,18 @@ fn test_cli_timestamp_tx() {
|
||||
config_witness.keypair.pubkey()
|
||||
);
|
||||
|
||||
request_and_confirm_airdrop(&rpc_client, &drone_addr, &config_payer.keypair.pubkey(), 50)
|
||||
.unwrap();
|
||||
request_and_confirm_airdrop(
|
||||
&rpc_client,
|
||||
&faucet_addr,
|
||||
&config_payer.keypair.pubkey(),
|
||||
50,
|
||||
)
|
||||
.unwrap();
|
||||
check_balance(50, &rpc_client, &config_payer.keypair.pubkey());
|
||||
|
||||
request_and_confirm_airdrop(
|
||||
&rpc_client,
|
||||
&drone_addr,
|
||||
&faucet_addr,
|
||||
&config_witness.keypair.pubkey(),
|
||||
1,
|
||||
)
|
||||
@ -106,8 +111,8 @@ fn test_cli_witness_tx() {
|
||||
let bob_pubkey = Pubkey::new_rand();
|
||||
|
||||
let (sender, receiver) = channel();
|
||||
run_local_drone(alice, sender, None);
|
||||
let drone_addr = receiver.recv().unwrap();
|
||||
run_local_faucet(alice, sender, None);
|
||||
let faucet_addr = receiver.recv().unwrap();
|
||||
|
||||
let rpc_client = RpcClient::new_socket(leader_data.rpc);
|
||||
|
||||
@ -123,11 +128,16 @@ fn test_cli_witness_tx() {
|
||||
config_witness.keypair.pubkey()
|
||||
);
|
||||
|
||||
request_and_confirm_airdrop(&rpc_client, &drone_addr, &config_payer.keypair.pubkey(), 50)
|
||||
.unwrap();
|
||||
request_and_confirm_airdrop(
|
||||
&rpc_client,
|
||||
&drone_addr,
|
||||
&faucet_addr,
|
||||
&config_payer.keypair.pubkey(),
|
||||
50,
|
||||
)
|
||||
.unwrap();
|
||||
request_and_confirm_airdrop(
|
||||
&rpc_client,
|
||||
&faucet_addr,
|
||||
&config_witness.keypair.pubkey(),
|
||||
1,
|
||||
)
|
||||
@ -176,8 +186,8 @@ fn test_cli_cancel_tx() {
|
||||
let bob_pubkey = Pubkey::new_rand();
|
||||
|
||||
let (sender, receiver) = channel();
|
||||
run_local_drone(alice, sender, None);
|
||||
let drone_addr = receiver.recv().unwrap();
|
||||
run_local_faucet(alice, sender, None);
|
||||
let faucet_addr = receiver.recv().unwrap();
|
||||
|
||||
let rpc_client = RpcClient::new_socket(leader_data.rpc);
|
||||
|
||||
@ -193,8 +203,13 @@ fn test_cli_cancel_tx() {
|
||||
config_witness.keypair.pubkey()
|
||||
);
|
||||
|
||||
request_and_confirm_airdrop(&rpc_client, &drone_addr, &config_payer.keypair.pubkey(), 50)
|
||||
.unwrap();
|
||||
request_and_confirm_airdrop(
|
||||
&rpc_client,
|
||||
&faucet_addr,
|
||||
&config_payer.keypair.pubkey(),
|
||||
50,
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
// Make transaction (from config_payer to bob_pubkey) requiring witness signature from config_witness
|
||||
config_payer.command = CliCommand::Pay {
|
||||
@ -239,8 +254,8 @@ fn test_offline_pay_tx() {
|
||||
let bob_pubkey = Pubkey::new_rand();
|
||||
|
||||
let (sender, receiver) = channel();
|
||||
run_local_drone(alice, sender, None);
|
||||
let drone_addr = receiver.recv().unwrap();
|
||||
run_local_faucet(alice, sender, None);
|
||||
let faucet_addr = receiver.recv().unwrap();
|
||||
|
||||
let rpc_client = RpcClient::new_socket(leader_data.rpc);
|
||||
|
||||
@ -257,7 +272,7 @@ fn test_offline_pay_tx() {
|
||||
|
||||
request_and_confirm_airdrop(
|
||||
&rpc_client,
|
||||
&drone_addr,
|
||||
&faucet_addr,
|
||||
&config_offline.keypair.pubkey(),
|
||||
50,
|
||||
)
|
||||
@ -265,7 +280,7 @@ fn test_offline_pay_tx() {
|
||||
|
||||
request_and_confirm_airdrop(
|
||||
&rpc_client,
|
||||
&drone_addr,
|
||||
&faucet_addr,
|
||||
&config_online.keypair.pubkey(),
|
||||
50,
|
||||
)
|
||||
|
@ -1,7 +1,7 @@
|
||||
use solana_cli::cli::{process_command, CliCommand, CliConfig};
|
||||
use solana_client::rpc_client::RpcClient;
|
||||
use solana_core::validator::new_validator_for_tests;
|
||||
use solana_drone::drone::run_local_drone;
|
||||
use solana_faucet::faucet::run_local_faucet;
|
||||
use solana_sdk::signature::KeypairUtil;
|
||||
use std::fs::remove_dir_all;
|
||||
use std::sync::mpsc::channel;
|
||||
@ -10,14 +10,14 @@ use std::sync::mpsc::channel;
|
||||
fn test_cli_request_airdrop() {
|
||||
let (server, leader_data, alice, ledger_path) = new_validator_for_tests();
|
||||
let (sender, receiver) = channel();
|
||||
run_local_drone(alice, sender, None);
|
||||
let drone_addr = receiver.recv().unwrap();
|
||||
run_local_faucet(alice, sender, None);
|
||||
let faucet_addr = receiver.recv().unwrap();
|
||||
|
||||
let mut bob_config = CliConfig::default();
|
||||
bob_config.json_rpc_url = format!("http://{}:{}", leader_data.rpc.ip(), leader_data.rpc.port());
|
||||
bob_config.command = CliCommand::Airdrop {
|
||||
drone_host: None,
|
||||
drone_port: drone_addr.port(),
|
||||
faucet_host: None,
|
||||
faucet_port: faucet_addr.port(),
|
||||
lamports: 50,
|
||||
use_lamports_unit: true,
|
||||
};
|
||||
|
@ -1,7 +1,7 @@
|
||||
use serde_json::Value;
|
||||
use solana_cli::cli::{process_command, request_and_confirm_airdrop, CliCommand, CliConfig};
|
||||
use solana_client::rpc_client::RpcClient;
|
||||
use solana_drone::drone::run_local_drone;
|
||||
use solana_faucet::faucet::run_local_faucet;
|
||||
use solana_sdk::{
|
||||
hash::Hash,
|
||||
pubkey::Pubkey,
|
||||
@ -43,8 +43,8 @@ fn test_stake_delegation_and_deactivation() {
|
||||
|
||||
let (server, leader_data, alice, ledger_path) = new_validator_for_tests();
|
||||
let (sender, receiver) = channel();
|
||||
run_local_drone(alice, sender, None);
|
||||
let drone_addr = receiver.recv().unwrap();
|
||||
run_local_faucet(alice, sender, None);
|
||||
let faucet_addr = receiver.recv().unwrap();
|
||||
|
||||
let rpc_client = RpcClient::new_socket(leader_data.rpc);
|
||||
|
||||
@ -66,7 +66,7 @@ fn test_stake_delegation_and_deactivation() {
|
||||
|
||||
request_and_confirm_airdrop(
|
||||
&rpc_client,
|
||||
&drone_addr,
|
||||
&faucet_addr,
|
||||
&config_validator.keypair.pubkey(),
|
||||
100_000,
|
||||
)
|
||||
@ -126,8 +126,8 @@ fn test_stake_delegation_and_deactivation_offline() {
|
||||
|
||||
let (server, leader_data, alice, ledger_path) = new_validator_for_tests();
|
||||
let (sender, receiver) = channel();
|
||||
run_local_drone(alice, sender, None);
|
||||
let drone_addr = receiver.recv().unwrap();
|
||||
run_local_faucet(alice, sender, None);
|
||||
let faucet_addr = receiver.recv().unwrap();
|
||||
|
||||
let rpc_client = RpcClient::new_socket(leader_data.rpc);
|
||||
|
||||
@ -153,7 +153,7 @@ fn test_stake_delegation_and_deactivation_offline() {
|
||||
|
||||
request_and_confirm_airdrop(
|
||||
&rpc_client,
|
||||
&drone_addr,
|
||||
&faucet_addr,
|
||||
&config_validator.keypair.pubkey(),
|
||||
100_000,
|
||||
)
|
||||
|
Reference in New Issue
Block a user