Skip to content

Commit

Permalink
Surface faucet start failures to the user of solana-test-validator
Browse files Browse the repository at this point in the history
  • Loading branch information
mvines authored and mergify[bot] committed Jan 28, 2021
1 parent fdfc0f4 commit 8993ac0
Show file tree
Hide file tree
Showing 13 changed files with 88 additions and 118 deletions.
9 changes: 6 additions & 3 deletions bench-exchange/tests/bench_exchange.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use solana_core::validator::ValidatorConfig;
use solana_exchange_program::exchange_processor::process_instruction;
use solana_exchange_program::id;
use solana_exchange_program::solana_exchange_program;
use solana_faucet::faucet::run_local_faucet;
use solana_faucet::faucet::run_local_faucet_with_port;
use solana_local_cluster::local_cluster::{ClusterConfig, LocalCluster};
use solana_runtime::bank::Bank;
use solana_runtime::bank_client::BankClient;
Expand Down Expand Up @@ -57,8 +57,11 @@ fn test_exchange_local_cluster() {
);

let (addr_sender, addr_receiver) = channel();
run_local_faucet(faucet_keypair, addr_sender, Some(1_000_000_000_000));
let faucet_addr = addr_receiver.recv_timeout(Duration::from_secs(2)).unwrap();
run_local_faucet_with_port(faucet_keypair, addr_sender, Some(1_000_000_000_000), 0);
let faucet_addr = addr_receiver
.recv_timeout(Duration::from_secs(2))
.expect("run_local_faucet")
.expect("faucet_addr");

info!("Connecting to the cluster");
let nodes =
Expand Down
9 changes: 6 additions & 3 deletions bench-tps/tests/bench_tps.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use solana_bench_tps::cli::Config;
use solana_client::thin_client::create_client;
use solana_core::cluster_info::VALIDATOR_PORT_RANGE;
use solana_core::validator::ValidatorConfig;
use solana_faucet::faucet::run_local_faucet;
use solana_faucet::faucet::run_local_faucet_with_port;
use solana_local_cluster::local_cluster::{ClusterConfig, LocalCluster};
use solana_sdk::signature::{Keypair, Signer};
use std::sync::{mpsc::channel, Arc};
Expand Down Expand Up @@ -36,8 +36,11 @@ fn test_bench_tps_local_cluster(config: Config) {
));

let (addr_sender, addr_receiver) = channel();
run_local_faucet(faucet_keypair, addr_sender, None);
let faucet_addr = addr_receiver.recv_timeout(Duration::from_secs(2)).unwrap();
run_local_faucet_with_port(faucet_keypair, addr_sender, None, 0);
let faucet_addr = addr_receiver
.recv_timeout(Duration::from_secs(2))
.expect("run_local_faucet")
.expect("faucet_addr");

let lamports_per_account = 100;

Expand Down
9 changes: 2 additions & 7 deletions cli/tests/nonce.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ use solana_sdk::{
signature::{keypair_from_seed, Keypair, Signer},
system_program,
};
use std::sync::mpsc::channel;

#[test]
fn test_nonce() {
Expand Down Expand Up @@ -59,9 +58,7 @@ fn full_battery_tests(
seed: Option<String>,
use_nonce_authority: bool,
) {
let (sender, receiver) = channel();
run_local_faucet(mint_keypair, sender, None);
let faucet_addr = receiver.recv().unwrap();
let faucet_addr = run_local_faucet(mint_keypair, None);

let rpc_client =
RpcClient::new_with_commitment(test_validator.rpc_url(), CommitmentConfig::processed());
Expand Down Expand Up @@ -219,9 +216,7 @@ fn test_create_account_with_seed() {
let mint_keypair = Keypair::new();
let test_validator = TestValidator::with_custom_fees(mint_keypair.pubkey(), 1);

let (sender, receiver) = channel();
run_local_faucet(mint_keypair, sender, None);
let faucet_addr = receiver.recv().unwrap();
let faucet_addr = run_local_faucet(mint_keypair, None);

let offline_nonce_authority_signer = keypair_from_seed(&[1u8; 32]).unwrap();
let online_nonce_creator_signer = keypair_from_seed(&[2u8; 32]).unwrap();
Expand Down
27 changes: 6 additions & 21 deletions cli/tests/program.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use solana_sdk::{
pubkey::Pubkey,
signature::{Keypair, Signer},
};
use std::{fs::File, io::Read, path::PathBuf, str::FromStr, sync::mpsc::channel};
use std::{fs::File, io::Read, path::PathBuf, str::FromStr};

#[test]
fn test_cli_program_deploy_non_upgradeable() {
Expand All @@ -28,10 +28,7 @@ fn test_cli_program_deploy_non_upgradeable() {

let mint_keypair = Keypair::new();
let test_validator = TestValidator::with_no_fees(mint_keypair.pubkey());

let (sender, receiver) = channel();
run_local_faucet(mint_keypair, sender, None);
let faucet_addr = receiver.recv().unwrap();
let faucet_addr = run_local_faucet(mint_keypair, None);

let rpc_client =
RpcClient::new_with_commitment(test_validator.rpc_url(), CommitmentConfig::processed());
Expand Down Expand Up @@ -149,10 +146,7 @@ fn test_cli_program_deploy_no_authority() {

let mint_keypair = Keypair::new();
let test_validator = TestValidator::with_no_fees(mint_keypair.pubkey());

let (sender, receiver) = channel();
run_local_faucet(mint_keypair, sender, None);
let faucet_addr = receiver.recv().unwrap();
let faucet_addr = run_local_faucet(mint_keypair, None);

let rpc_client =
RpcClient::new_with_commitment(test_validator.rpc_url(), CommitmentConfig::processed());
Expand Down Expand Up @@ -237,10 +231,7 @@ fn test_cli_program_deploy_with_authority() {

let mint_keypair = Keypair::new();
let test_validator = TestValidator::with_no_fees(mint_keypair.pubkey());

let (sender, receiver) = channel();
run_local_faucet(mint_keypair, sender, None);
let faucet_addr = receiver.recv().unwrap();
let faucet_addr = run_local_faucet(mint_keypair, None);

let rpc_client =
RpcClient::new_with_commitment(test_validator.rpc_url(), CommitmentConfig::processed());
Expand Down Expand Up @@ -568,10 +559,7 @@ fn test_cli_program_write_buffer() {

let mint_keypair = Keypair::new();
let test_validator = TestValidator::with_no_fees(mint_keypair.pubkey());

let (sender, receiver) = channel();
run_local_faucet(mint_keypair, sender, None);
let faucet_addr = receiver.recv().unwrap();
let faucet_addr = run_local_faucet(mint_keypair, None);

let rpc_client =
RpcClient::new_with_commitment(test_validator.rpc_url(), CommitmentConfig::processed());
Expand Down Expand Up @@ -823,10 +811,7 @@ fn test_cli_program_set_buffer_authority() {

let mint_keypair = Keypair::new();
let test_validator = TestValidator::with_no_fees(mint_keypair.pubkey());

let (sender, receiver) = channel();
run_local_faucet(mint_keypair, sender, None);
let faucet_addr = receiver.recv().unwrap();
let faucet_addr = run_local_faucet(mint_keypair, None);

let rpc_client =
RpcClient::new_with_commitment(test_validator.rpc_url(), CommitmentConfig::processed());
Expand Down
5 changes: 1 addition & 4 deletions cli/tests/request_airdrop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,13 @@ use solana_sdk::{
commitment_config::CommitmentConfig,
signature::{Keypair, Signer},
};
use std::sync::mpsc::channel;

#[test]
fn test_cli_request_airdrop() {
let mint_keypair = Keypair::new();
let test_validator = TestValidator::with_no_fees(mint_keypair.pubkey());

let (sender, receiver) = channel();
run_local_faucet(mint_keypair, sender, None);
let faucet_addr = receiver.recv().unwrap();
let faucet_addr = run_local_faucet(mint_keypair, None);

let mut bob_config = CliConfig::recent_for_tests();
bob_config.json_rpc_url = test_validator.rpc_url();
Expand Down
41 changes: 10 additions & 31 deletions cli/tests/stake.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,12 @@ use solana_stake_program::{
stake_instruction::LockupArgs,
stake_state::{Lockup, StakeAuthorize, StakeState},
};
use std::sync::mpsc::channel;

#[test]
fn test_stake_delegation_force() {
let mint_keypair = Keypair::new();
let test_validator = TestValidator::with_no_fees(mint_keypair.pubkey());
let (sender, receiver) = channel();
run_local_faucet(mint_keypair, sender, None);
let faucet_addr = receiver.recv().unwrap();
let faucet_addr = run_local_faucet(mint_keypair, None);

let rpc_client =
RpcClient::new_with_commitment(test_validator.rpc_url(), CommitmentConfig::processed());
Expand Down Expand Up @@ -117,9 +114,7 @@ fn test_seed_stake_delegation_and_deactivation() {

let mint_keypair = Keypair::new();
let test_validator = TestValidator::with_no_fees(mint_keypair.pubkey());
let (sender, receiver) = channel();
run_local_faucet(mint_keypair, sender, None);
let faucet_addr = receiver.recv().unwrap();
let faucet_addr = run_local_faucet(mint_keypair, None);

let rpc_client =
RpcClient::new_with_commitment(test_validator.rpc_url(), CommitmentConfig::processed());
Expand Down Expand Up @@ -197,9 +192,7 @@ fn test_stake_delegation_and_deactivation() {

let mint_keypair = Keypair::new();
let test_validator = TestValidator::with_no_fees(mint_keypair.pubkey());
let (sender, receiver) = channel();
run_local_faucet(mint_keypair, sender, None);
let faucet_addr = receiver.recv().unwrap();
let faucet_addr = run_local_faucet(mint_keypair, None);

let rpc_client =
RpcClient::new_with_commitment(test_validator.rpc_url(), CommitmentConfig::processed());
Expand Down Expand Up @@ -273,9 +266,7 @@ fn test_offline_stake_delegation_and_deactivation() {

let mint_keypair = Keypair::new();
let test_validator = TestValidator::with_no_fees(mint_keypair.pubkey());
let (sender, receiver) = channel();
run_local_faucet(mint_keypair, sender, None);
let faucet_addr = receiver.recv().unwrap();
let faucet_addr = run_local_faucet(mint_keypair, None);

let rpc_client =
RpcClient::new_with_commitment(test_validator.rpc_url(), CommitmentConfig::processed());
Expand Down Expand Up @@ -406,9 +397,7 @@ fn test_nonced_stake_delegation_and_deactivation() {

let mint_keypair = Keypair::new();
let test_validator = TestValidator::with_no_fees(mint_keypair.pubkey());
let (sender, receiver) = channel();
run_local_faucet(mint_keypair, sender, None);
let faucet_addr = receiver.recv().unwrap();
let faucet_addr = run_local_faucet(mint_keypair, None);

let rpc_client =
RpcClient::new_with_commitment(test_validator.rpc_url(), CommitmentConfig::processed());
Expand Down Expand Up @@ -521,9 +510,7 @@ fn test_stake_authorize() {

let mint_keypair = Keypair::new();
let test_validator = TestValidator::with_no_fees(mint_keypair.pubkey());
let (sender, receiver) = channel();
run_local_faucet(mint_keypair, sender, None);
let faucet_addr = receiver.recv().unwrap();
let faucet_addr = run_local_faucet(mint_keypair, None);

let rpc_client =
RpcClient::new_with_commitment(test_validator.rpc_url(), CommitmentConfig::processed());
Expand Down Expand Up @@ -778,9 +765,7 @@ fn test_stake_authorize_with_fee_payer() {

let mint_keypair = Keypair::new();
let test_validator = TestValidator::with_custom_fees(mint_keypair.pubkey(), SIG_FEE);
let (sender, receiver) = channel();
run_local_faucet(mint_keypair, sender, None);
let faucet_addr = receiver.recv().unwrap();
let faucet_addr = run_local_faucet(mint_keypair, None);

let rpc_client =
RpcClient::new_with_commitment(test_validator.rpc_url(), CommitmentConfig::processed());
Expand Down Expand Up @@ -903,9 +888,7 @@ fn test_stake_split() {

let mint_keypair = Keypair::new();
let test_validator = TestValidator::with_custom_fees(mint_keypair.pubkey(), 1);
let (sender, receiver) = channel();
run_local_faucet(mint_keypair, sender, None);
let faucet_addr = receiver.recv().unwrap();
let faucet_addr = run_local_faucet(mint_keypair, None);

let rpc_client =
RpcClient::new_with_commitment(test_validator.rpc_url(), CommitmentConfig::processed());
Expand Down Expand Up @@ -1047,9 +1030,7 @@ fn test_stake_set_lockup() {

let mint_keypair = Keypair::new();
let test_validator = TestValidator::with_custom_fees(mint_keypair.pubkey(), 1);
let (sender, receiver) = channel();
run_local_faucet(mint_keypair, sender, None);
let faucet_addr = receiver.recv().unwrap();
let faucet_addr = run_local_faucet(mint_keypair, None);

let rpc_client =
RpcClient::new_with_commitment(test_validator.rpc_url(), CommitmentConfig::processed());
Expand Down Expand Up @@ -1299,9 +1280,7 @@ fn test_offline_nonced_create_stake_account_and_withdraw() {

let mint_keypair = Keypair::new();
let test_validator = TestValidator::with_no_fees(mint_keypair.pubkey());
let (sender, receiver) = channel();
run_local_faucet(mint_keypair, sender, None);
let faucet_addr = receiver.recv().unwrap();
let faucet_addr = run_local_faucet(mint_keypair, None);

let rpc_client =
RpcClient::new_with_commitment(test_validator.rpc_url(), CommitmentConfig::processed());
Expand Down
16 changes: 3 additions & 13 deletions cli/tests/transfer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,13 @@ use solana_sdk::{
pubkey::Pubkey,
signature::{keypair_from_seed, Keypair, NullSigner, Signer},
};
use std::sync::mpsc::channel;

#[test]
fn test_transfer() {
solana_logger::setup();
let mint_keypair = Keypair::new();
let test_validator = TestValidator::with_custom_fees(mint_keypair.pubkey(), 1);

let (sender, receiver) = channel();
run_local_faucet(mint_keypair, sender, None);
let faucet_addr = receiver.recv().unwrap();
let faucet_addr = run_local_faucet(mint_keypair, None);

let rpc_client =
RpcClient::new_with_commitment(test_validator.rpc_url(), CommitmentConfig::processed());
Expand Down Expand Up @@ -242,10 +238,7 @@ fn test_transfer_multisession_signing() {
solana_logger::setup();
let mint_keypair = Keypair::new();
let test_validator = TestValidator::with_custom_fees(mint_keypair.pubkey(), 1);

let (sender, receiver) = channel();
run_local_faucet(mint_keypair, sender, None);
let faucet_addr = receiver.recv().unwrap();
let faucet_addr = run_local_faucet(mint_keypair, None);

let to_pubkey = Pubkey::new(&[1u8; 32]);
let offline_from_signer = keypair_from_seed(&[2u8; 32]).unwrap();
Expand Down Expand Up @@ -359,10 +352,7 @@ fn test_transfer_all() {
solana_logger::setup();
let mint_keypair = Keypair::new();
let test_validator = TestValidator::with_custom_fees(mint_keypair.pubkey(), 1);

let (sender, receiver) = channel();
run_local_faucet(mint_keypair, sender, None);
let faucet_addr = receiver.recv().unwrap();
let faucet_addr = run_local_faucet(mint_keypair, None);

let rpc_client =
RpcClient::new_with_commitment(test_validator.rpc_url(), CommitmentConfig::processed());
Expand Down
5 changes: 1 addition & 4 deletions cli/tests/vote.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,12 @@ use solana_sdk::{
signature::{Keypair, Signer},
};
use solana_vote_program::vote_state::{VoteAuthorize, VoteState, VoteStateVersions};
use std::sync::mpsc::channel;

#[test]
fn test_vote_authorize_and_withdraw() {
let mint_keypair = Keypair::new();
let test_validator = TestValidator::with_no_fees(mint_keypair.pubkey());
let (sender, receiver) = channel();
run_local_faucet(mint_keypair, sender, None);
let faucet_addr = receiver.recv().unwrap();
let faucet_addr = run_local_faucet(mint_keypair, None);

let rpc_client =
RpcClient::new_with_commitment(test_validator.rpc_url(), CommitmentConfig::processed());
Expand Down
Loading

0 comments on commit 8993ac0

Please sign in to comment.