Surface faucet start failures to the user of solana-test-validator
This commit is contained in:
parent
fdfc0f409d
commit
8993ac0c74
|
@ -5,7 +5,7 @@ use solana_core::validator::ValidatorConfig;
|
||||||
use solana_exchange_program::exchange_processor::process_instruction;
|
use solana_exchange_program::exchange_processor::process_instruction;
|
||||||
use solana_exchange_program::id;
|
use solana_exchange_program::id;
|
||||||
use solana_exchange_program::solana_exchange_program;
|
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_local_cluster::local_cluster::{ClusterConfig, LocalCluster};
|
||||||
use solana_runtime::bank::Bank;
|
use solana_runtime::bank::Bank;
|
||||||
use solana_runtime::bank_client::BankClient;
|
use solana_runtime::bank_client::BankClient;
|
||||||
|
@ -57,8 +57,11 @@ fn test_exchange_local_cluster() {
|
||||||
);
|
);
|
||||||
|
|
||||||
let (addr_sender, addr_receiver) = channel();
|
let (addr_sender, addr_receiver) = channel();
|
||||||
run_local_faucet(faucet_keypair, addr_sender, Some(1_000_000_000_000));
|
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)).unwrap();
|
let faucet_addr = addr_receiver
|
||||||
|
.recv_timeout(Duration::from_secs(2))
|
||||||
|
.expect("run_local_faucet")
|
||||||
|
.expect("faucet_addr");
|
||||||
|
|
||||||
info!("Connecting to the cluster");
|
info!("Connecting to the cluster");
|
||||||
let nodes =
|
let nodes =
|
||||||
|
|
|
@ -4,7 +4,7 @@ use solana_bench_tps::cli::Config;
|
||||||
use solana_client::thin_client::create_client;
|
use solana_client::thin_client::create_client;
|
||||||
use solana_core::cluster_info::VALIDATOR_PORT_RANGE;
|
use solana_core::cluster_info::VALIDATOR_PORT_RANGE;
|
||||||
use solana_core::validator::ValidatorConfig;
|
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_local_cluster::local_cluster::{ClusterConfig, LocalCluster};
|
||||||
use solana_sdk::signature::{Keypair, Signer};
|
use solana_sdk::signature::{Keypair, Signer};
|
||||||
use std::sync::{mpsc::channel, Arc};
|
use std::sync::{mpsc::channel, Arc};
|
||||||
|
@ -36,8 +36,11 @@ fn test_bench_tps_local_cluster(config: Config) {
|
||||||
));
|
));
|
||||||
|
|
||||||
let (addr_sender, addr_receiver) = channel();
|
let (addr_sender, addr_receiver) = channel();
|
||||||
run_local_faucet(faucet_keypair, addr_sender, None);
|
run_local_faucet_with_port(faucet_keypair, addr_sender, None, 0);
|
||||||
let faucet_addr = addr_receiver.recv_timeout(Duration::from_secs(2)).unwrap();
|
let faucet_addr = addr_receiver
|
||||||
|
.recv_timeout(Duration::from_secs(2))
|
||||||
|
.expect("run_local_faucet")
|
||||||
|
.expect("faucet_addr");
|
||||||
|
|
||||||
let lamports_per_account = 100;
|
let lamports_per_account = 100;
|
||||||
|
|
||||||
|
|
|
@ -18,7 +18,6 @@ use solana_sdk::{
|
||||||
signature::{keypair_from_seed, Keypair, Signer},
|
signature::{keypair_from_seed, Keypair, Signer},
|
||||||
system_program,
|
system_program,
|
||||||
};
|
};
|
||||||
use std::sync::mpsc::channel;
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_nonce() {
|
fn test_nonce() {
|
||||||
|
@ -59,9 +58,7 @@ fn full_battery_tests(
|
||||||
seed: Option<String>,
|
seed: Option<String>,
|
||||||
use_nonce_authority: bool,
|
use_nonce_authority: bool,
|
||||||
) {
|
) {
|
||||||
let (sender, receiver) = channel();
|
let faucet_addr = run_local_faucet(mint_keypair, None);
|
||||||
run_local_faucet(mint_keypair, sender, None);
|
|
||||||
let faucet_addr = receiver.recv().unwrap();
|
|
||||||
|
|
||||||
let rpc_client =
|
let rpc_client =
|
||||||
RpcClient::new_with_commitment(test_validator.rpc_url(), CommitmentConfig::processed());
|
RpcClient::new_with_commitment(test_validator.rpc_url(), CommitmentConfig::processed());
|
||||||
|
@ -219,9 +216,7 @@ fn test_create_account_with_seed() {
|
||||||
let mint_keypair = Keypair::new();
|
let mint_keypair = Keypair::new();
|
||||||
let test_validator = TestValidator::with_custom_fees(mint_keypair.pubkey(), 1);
|
let test_validator = TestValidator::with_custom_fees(mint_keypair.pubkey(), 1);
|
||||||
|
|
||||||
let (sender, receiver) = channel();
|
let faucet_addr = run_local_faucet(mint_keypair, None);
|
||||||
run_local_faucet(mint_keypair, sender, None);
|
|
||||||
let faucet_addr = receiver.recv().unwrap();
|
|
||||||
|
|
||||||
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();
|
||||||
|
|
|
@ -14,7 +14,7 @@ use solana_sdk::{
|
||||||
pubkey::Pubkey,
|
pubkey::Pubkey,
|
||||||
signature::{Keypair, Signer},
|
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]
|
#[test]
|
||||||
fn test_cli_program_deploy_non_upgradeable() {
|
fn test_cli_program_deploy_non_upgradeable() {
|
||||||
|
@ -28,10 +28,7 @@ fn test_cli_program_deploy_non_upgradeable() {
|
||||||
|
|
||||||
let mint_keypair = Keypair::new();
|
let mint_keypair = Keypair::new();
|
||||||
let test_validator = TestValidator::with_no_fees(mint_keypair.pubkey());
|
let test_validator = TestValidator::with_no_fees(mint_keypair.pubkey());
|
||||||
|
let faucet_addr = run_local_faucet(mint_keypair, None);
|
||||||
let (sender, receiver) = channel();
|
|
||||||
run_local_faucet(mint_keypair, sender, None);
|
|
||||||
let faucet_addr = receiver.recv().unwrap();
|
|
||||||
|
|
||||||
let rpc_client =
|
let rpc_client =
|
||||||
RpcClient::new_with_commitment(test_validator.rpc_url(), CommitmentConfig::processed());
|
RpcClient::new_with_commitment(test_validator.rpc_url(), CommitmentConfig::processed());
|
||||||
|
@ -149,10 +146,7 @@ fn test_cli_program_deploy_no_authority() {
|
||||||
|
|
||||||
let mint_keypair = Keypair::new();
|
let mint_keypair = Keypair::new();
|
||||||
let test_validator = TestValidator::with_no_fees(mint_keypair.pubkey());
|
let test_validator = TestValidator::with_no_fees(mint_keypair.pubkey());
|
||||||
|
let faucet_addr = run_local_faucet(mint_keypair, None);
|
||||||
let (sender, receiver) = channel();
|
|
||||||
run_local_faucet(mint_keypair, sender, None);
|
|
||||||
let faucet_addr = receiver.recv().unwrap();
|
|
||||||
|
|
||||||
let rpc_client =
|
let rpc_client =
|
||||||
RpcClient::new_with_commitment(test_validator.rpc_url(), CommitmentConfig::processed());
|
RpcClient::new_with_commitment(test_validator.rpc_url(), CommitmentConfig::processed());
|
||||||
|
@ -237,10 +231,7 @@ fn test_cli_program_deploy_with_authority() {
|
||||||
|
|
||||||
let mint_keypair = Keypair::new();
|
let mint_keypair = Keypair::new();
|
||||||
let test_validator = TestValidator::with_no_fees(mint_keypair.pubkey());
|
let test_validator = TestValidator::with_no_fees(mint_keypair.pubkey());
|
||||||
|
let faucet_addr = run_local_faucet(mint_keypair, None);
|
||||||
let (sender, receiver) = channel();
|
|
||||||
run_local_faucet(mint_keypair, sender, None);
|
|
||||||
let faucet_addr = receiver.recv().unwrap();
|
|
||||||
|
|
||||||
let rpc_client =
|
let rpc_client =
|
||||||
RpcClient::new_with_commitment(test_validator.rpc_url(), CommitmentConfig::processed());
|
RpcClient::new_with_commitment(test_validator.rpc_url(), CommitmentConfig::processed());
|
||||||
|
@ -568,10 +559,7 @@ fn test_cli_program_write_buffer() {
|
||||||
|
|
||||||
let mint_keypair = Keypair::new();
|
let mint_keypair = Keypair::new();
|
||||||
let test_validator = TestValidator::with_no_fees(mint_keypair.pubkey());
|
let test_validator = TestValidator::with_no_fees(mint_keypair.pubkey());
|
||||||
|
let faucet_addr = run_local_faucet(mint_keypair, None);
|
||||||
let (sender, receiver) = channel();
|
|
||||||
run_local_faucet(mint_keypair, sender, None);
|
|
||||||
let faucet_addr = receiver.recv().unwrap();
|
|
||||||
|
|
||||||
let rpc_client =
|
let rpc_client =
|
||||||
RpcClient::new_with_commitment(test_validator.rpc_url(), CommitmentConfig::processed());
|
RpcClient::new_with_commitment(test_validator.rpc_url(), CommitmentConfig::processed());
|
||||||
|
@ -823,10 +811,7 @@ fn test_cli_program_set_buffer_authority() {
|
||||||
|
|
||||||
let mint_keypair = Keypair::new();
|
let mint_keypair = Keypair::new();
|
||||||
let test_validator = TestValidator::with_no_fees(mint_keypair.pubkey());
|
let test_validator = TestValidator::with_no_fees(mint_keypair.pubkey());
|
||||||
|
let faucet_addr = run_local_faucet(mint_keypair, None);
|
||||||
let (sender, receiver) = channel();
|
|
||||||
run_local_faucet(mint_keypair, sender, None);
|
|
||||||
let faucet_addr = receiver.recv().unwrap();
|
|
||||||
|
|
||||||
let rpc_client =
|
let rpc_client =
|
||||||
RpcClient::new_with_commitment(test_validator.rpc_url(), CommitmentConfig::processed());
|
RpcClient::new_with_commitment(test_validator.rpc_url(), CommitmentConfig::processed());
|
||||||
|
|
|
@ -6,16 +6,13 @@ use solana_sdk::{
|
||||||
commitment_config::CommitmentConfig,
|
commitment_config::CommitmentConfig,
|
||||||
signature::{Keypair, Signer},
|
signature::{Keypair, Signer},
|
||||||
};
|
};
|
||||||
use std::sync::mpsc::channel;
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_cli_request_airdrop() {
|
fn test_cli_request_airdrop() {
|
||||||
let mint_keypair = Keypair::new();
|
let mint_keypair = Keypair::new();
|
||||||
let test_validator = TestValidator::with_no_fees(mint_keypair.pubkey());
|
let test_validator = TestValidator::with_no_fees(mint_keypair.pubkey());
|
||||||
|
|
||||||
let (sender, receiver) = channel();
|
let faucet_addr = run_local_faucet(mint_keypair, None);
|
||||||
run_local_faucet(mint_keypair, sender, None);
|
|
||||||
let faucet_addr = receiver.recv().unwrap();
|
|
||||||
|
|
||||||
let mut bob_config = CliConfig::recent_for_tests();
|
let mut bob_config = CliConfig::recent_for_tests();
|
||||||
bob_config.json_rpc_url = test_validator.rpc_url();
|
bob_config.json_rpc_url = test_validator.rpc_url();
|
||||||
|
|
|
@ -22,15 +22,12 @@ use solana_stake_program::{
|
||||||
stake_instruction::LockupArgs,
|
stake_instruction::LockupArgs,
|
||||||
stake_state::{Lockup, StakeAuthorize, StakeState},
|
stake_state::{Lockup, StakeAuthorize, StakeState},
|
||||||
};
|
};
|
||||||
use std::sync::mpsc::channel;
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_stake_delegation_force() {
|
fn test_stake_delegation_force() {
|
||||||
let mint_keypair = Keypair::new();
|
let mint_keypair = Keypair::new();
|
||||||
let test_validator = TestValidator::with_no_fees(mint_keypair.pubkey());
|
let test_validator = TestValidator::with_no_fees(mint_keypair.pubkey());
|
||||||
let (sender, receiver) = channel();
|
let faucet_addr = run_local_faucet(mint_keypair, None);
|
||||||
run_local_faucet(mint_keypair, sender, None);
|
|
||||||
let faucet_addr = receiver.recv().unwrap();
|
|
||||||
|
|
||||||
let rpc_client =
|
let rpc_client =
|
||||||
RpcClient::new_with_commitment(test_validator.rpc_url(), CommitmentConfig::processed());
|
RpcClient::new_with_commitment(test_validator.rpc_url(), CommitmentConfig::processed());
|
||||||
|
@ -117,9 +114,7 @@ fn test_seed_stake_delegation_and_deactivation() {
|
||||||
|
|
||||||
let mint_keypair = Keypair::new();
|
let mint_keypair = Keypair::new();
|
||||||
let test_validator = TestValidator::with_no_fees(mint_keypair.pubkey());
|
let test_validator = TestValidator::with_no_fees(mint_keypair.pubkey());
|
||||||
let (sender, receiver) = channel();
|
let faucet_addr = run_local_faucet(mint_keypair, None);
|
||||||
run_local_faucet(mint_keypair, sender, None);
|
|
||||||
let faucet_addr = receiver.recv().unwrap();
|
|
||||||
|
|
||||||
let rpc_client =
|
let rpc_client =
|
||||||
RpcClient::new_with_commitment(test_validator.rpc_url(), CommitmentConfig::processed());
|
RpcClient::new_with_commitment(test_validator.rpc_url(), CommitmentConfig::processed());
|
||||||
|
@ -197,9 +192,7 @@ fn test_stake_delegation_and_deactivation() {
|
||||||
|
|
||||||
let mint_keypair = Keypair::new();
|
let mint_keypair = Keypair::new();
|
||||||
let test_validator = TestValidator::with_no_fees(mint_keypair.pubkey());
|
let test_validator = TestValidator::with_no_fees(mint_keypair.pubkey());
|
||||||
let (sender, receiver) = channel();
|
let faucet_addr = run_local_faucet(mint_keypair, None);
|
||||||
run_local_faucet(mint_keypair, sender, None);
|
|
||||||
let faucet_addr = receiver.recv().unwrap();
|
|
||||||
|
|
||||||
let rpc_client =
|
let rpc_client =
|
||||||
RpcClient::new_with_commitment(test_validator.rpc_url(), CommitmentConfig::processed());
|
RpcClient::new_with_commitment(test_validator.rpc_url(), CommitmentConfig::processed());
|
||||||
|
@ -273,9 +266,7 @@ fn test_offline_stake_delegation_and_deactivation() {
|
||||||
|
|
||||||
let mint_keypair = Keypair::new();
|
let mint_keypair = Keypair::new();
|
||||||
let test_validator = TestValidator::with_no_fees(mint_keypair.pubkey());
|
let test_validator = TestValidator::with_no_fees(mint_keypair.pubkey());
|
||||||
let (sender, receiver) = channel();
|
let faucet_addr = run_local_faucet(mint_keypair, None);
|
||||||
run_local_faucet(mint_keypair, sender, None);
|
|
||||||
let faucet_addr = receiver.recv().unwrap();
|
|
||||||
|
|
||||||
let rpc_client =
|
let rpc_client =
|
||||||
RpcClient::new_with_commitment(test_validator.rpc_url(), CommitmentConfig::processed());
|
RpcClient::new_with_commitment(test_validator.rpc_url(), CommitmentConfig::processed());
|
||||||
|
@ -406,9 +397,7 @@ fn test_nonced_stake_delegation_and_deactivation() {
|
||||||
|
|
||||||
let mint_keypair = Keypair::new();
|
let mint_keypair = Keypair::new();
|
||||||
let test_validator = TestValidator::with_no_fees(mint_keypair.pubkey());
|
let test_validator = TestValidator::with_no_fees(mint_keypair.pubkey());
|
||||||
let (sender, receiver) = channel();
|
let faucet_addr = run_local_faucet(mint_keypair, None);
|
||||||
run_local_faucet(mint_keypair, sender, None);
|
|
||||||
let faucet_addr = receiver.recv().unwrap();
|
|
||||||
|
|
||||||
let rpc_client =
|
let rpc_client =
|
||||||
RpcClient::new_with_commitment(test_validator.rpc_url(), CommitmentConfig::processed());
|
RpcClient::new_with_commitment(test_validator.rpc_url(), CommitmentConfig::processed());
|
||||||
|
@ -521,9 +510,7 @@ fn test_stake_authorize() {
|
||||||
|
|
||||||
let mint_keypair = Keypair::new();
|
let mint_keypair = Keypair::new();
|
||||||
let test_validator = TestValidator::with_no_fees(mint_keypair.pubkey());
|
let test_validator = TestValidator::with_no_fees(mint_keypair.pubkey());
|
||||||
let (sender, receiver) = channel();
|
let faucet_addr = run_local_faucet(mint_keypair, None);
|
||||||
run_local_faucet(mint_keypair, sender, None);
|
|
||||||
let faucet_addr = receiver.recv().unwrap();
|
|
||||||
|
|
||||||
let rpc_client =
|
let rpc_client =
|
||||||
RpcClient::new_with_commitment(test_validator.rpc_url(), CommitmentConfig::processed());
|
RpcClient::new_with_commitment(test_validator.rpc_url(), CommitmentConfig::processed());
|
||||||
|
@ -778,9 +765,7 @@ fn test_stake_authorize_with_fee_payer() {
|
||||||
|
|
||||||
let mint_keypair = Keypair::new();
|
let mint_keypair = Keypair::new();
|
||||||
let test_validator = TestValidator::with_custom_fees(mint_keypair.pubkey(), SIG_FEE);
|
let test_validator = TestValidator::with_custom_fees(mint_keypair.pubkey(), SIG_FEE);
|
||||||
let (sender, receiver) = channel();
|
let faucet_addr = run_local_faucet(mint_keypair, None);
|
||||||
run_local_faucet(mint_keypair, sender, None);
|
|
||||||
let faucet_addr = receiver.recv().unwrap();
|
|
||||||
|
|
||||||
let rpc_client =
|
let rpc_client =
|
||||||
RpcClient::new_with_commitment(test_validator.rpc_url(), CommitmentConfig::processed());
|
RpcClient::new_with_commitment(test_validator.rpc_url(), CommitmentConfig::processed());
|
||||||
|
@ -903,9 +888,7 @@ fn test_stake_split() {
|
||||||
|
|
||||||
let mint_keypair = Keypair::new();
|
let mint_keypair = Keypair::new();
|
||||||
let test_validator = TestValidator::with_custom_fees(mint_keypair.pubkey(), 1);
|
let test_validator = TestValidator::with_custom_fees(mint_keypair.pubkey(), 1);
|
||||||
let (sender, receiver) = channel();
|
let faucet_addr = run_local_faucet(mint_keypair, None);
|
||||||
run_local_faucet(mint_keypair, sender, None);
|
|
||||||
let faucet_addr = receiver.recv().unwrap();
|
|
||||||
|
|
||||||
let rpc_client =
|
let rpc_client =
|
||||||
RpcClient::new_with_commitment(test_validator.rpc_url(), CommitmentConfig::processed());
|
RpcClient::new_with_commitment(test_validator.rpc_url(), CommitmentConfig::processed());
|
||||||
|
@ -1047,9 +1030,7 @@ fn test_stake_set_lockup() {
|
||||||
|
|
||||||
let mint_keypair = Keypair::new();
|
let mint_keypair = Keypair::new();
|
||||||
let test_validator = TestValidator::with_custom_fees(mint_keypair.pubkey(), 1);
|
let test_validator = TestValidator::with_custom_fees(mint_keypair.pubkey(), 1);
|
||||||
let (sender, receiver) = channel();
|
let faucet_addr = run_local_faucet(mint_keypair, None);
|
||||||
run_local_faucet(mint_keypair, sender, None);
|
|
||||||
let faucet_addr = receiver.recv().unwrap();
|
|
||||||
|
|
||||||
let rpc_client =
|
let rpc_client =
|
||||||
RpcClient::new_with_commitment(test_validator.rpc_url(), CommitmentConfig::processed());
|
RpcClient::new_with_commitment(test_validator.rpc_url(), CommitmentConfig::processed());
|
||||||
|
@ -1299,9 +1280,7 @@ fn test_offline_nonced_create_stake_account_and_withdraw() {
|
||||||
|
|
||||||
let mint_keypair = Keypair::new();
|
let mint_keypair = Keypair::new();
|
||||||
let test_validator = TestValidator::with_no_fees(mint_keypair.pubkey());
|
let test_validator = TestValidator::with_no_fees(mint_keypair.pubkey());
|
||||||
let (sender, receiver) = channel();
|
let faucet_addr = run_local_faucet(mint_keypair, None);
|
||||||
run_local_faucet(mint_keypair, sender, None);
|
|
||||||
let faucet_addr = receiver.recv().unwrap();
|
|
||||||
|
|
||||||
let rpc_client =
|
let rpc_client =
|
||||||
RpcClient::new_with_commitment(test_validator.rpc_url(), CommitmentConfig::processed());
|
RpcClient::new_with_commitment(test_validator.rpc_url(), CommitmentConfig::processed());
|
||||||
|
|
|
@ -17,17 +17,13 @@ use solana_sdk::{
|
||||||
pubkey::Pubkey,
|
pubkey::Pubkey,
|
||||||
signature::{keypair_from_seed, Keypair, NullSigner, Signer},
|
signature::{keypair_from_seed, Keypair, NullSigner, Signer},
|
||||||
};
|
};
|
||||||
use std::sync::mpsc::channel;
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_transfer() {
|
fn test_transfer() {
|
||||||
solana_logger::setup();
|
solana_logger::setup();
|
||||||
let mint_keypair = Keypair::new();
|
let mint_keypair = Keypair::new();
|
||||||
let test_validator = TestValidator::with_custom_fees(mint_keypair.pubkey(), 1);
|
let test_validator = TestValidator::with_custom_fees(mint_keypair.pubkey(), 1);
|
||||||
|
let faucet_addr = run_local_faucet(mint_keypair, None);
|
||||||
let (sender, receiver) = channel();
|
|
||||||
run_local_faucet(mint_keypair, sender, None);
|
|
||||||
let faucet_addr = receiver.recv().unwrap();
|
|
||||||
|
|
||||||
let rpc_client =
|
let rpc_client =
|
||||||
RpcClient::new_with_commitment(test_validator.rpc_url(), CommitmentConfig::processed());
|
RpcClient::new_with_commitment(test_validator.rpc_url(), CommitmentConfig::processed());
|
||||||
|
@ -242,10 +238,7 @@ fn test_transfer_multisession_signing() {
|
||||||
solana_logger::setup();
|
solana_logger::setup();
|
||||||
let mint_keypair = Keypair::new();
|
let mint_keypair = Keypair::new();
|
||||||
let test_validator = TestValidator::with_custom_fees(mint_keypair.pubkey(), 1);
|
let test_validator = TestValidator::with_custom_fees(mint_keypair.pubkey(), 1);
|
||||||
|
let faucet_addr = run_local_faucet(mint_keypair, None);
|
||||||
let (sender, receiver) = channel();
|
|
||||||
run_local_faucet(mint_keypair, sender, None);
|
|
||||||
let faucet_addr = receiver.recv().unwrap();
|
|
||||||
|
|
||||||
let to_pubkey = Pubkey::new(&[1u8; 32]);
|
let to_pubkey = Pubkey::new(&[1u8; 32]);
|
||||||
let offline_from_signer = keypair_from_seed(&[2u8; 32]).unwrap();
|
let offline_from_signer = keypair_from_seed(&[2u8; 32]).unwrap();
|
||||||
|
@ -359,10 +352,7 @@ fn test_transfer_all() {
|
||||||
solana_logger::setup();
|
solana_logger::setup();
|
||||||
let mint_keypair = Keypair::new();
|
let mint_keypair = Keypair::new();
|
||||||
let test_validator = TestValidator::with_custom_fees(mint_keypair.pubkey(), 1);
|
let test_validator = TestValidator::with_custom_fees(mint_keypair.pubkey(), 1);
|
||||||
|
let faucet_addr = run_local_faucet(mint_keypair, None);
|
||||||
let (sender, receiver) = channel();
|
|
||||||
run_local_faucet(mint_keypair, sender, None);
|
|
||||||
let faucet_addr = receiver.recv().unwrap();
|
|
||||||
|
|
||||||
let rpc_client =
|
let rpc_client =
|
||||||
RpcClient::new_with_commitment(test_validator.rpc_url(), CommitmentConfig::processed());
|
RpcClient::new_with_commitment(test_validator.rpc_url(), CommitmentConfig::processed());
|
||||||
|
|
|
@ -15,15 +15,12 @@ use solana_sdk::{
|
||||||
signature::{Keypair, Signer},
|
signature::{Keypair, Signer},
|
||||||
};
|
};
|
||||||
use solana_vote_program::vote_state::{VoteAuthorize, VoteState, VoteStateVersions};
|
use solana_vote_program::vote_state::{VoteAuthorize, VoteState, VoteStateVersions};
|
||||||
use std::sync::mpsc::channel;
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_vote_authorize_and_withdraw() {
|
fn test_vote_authorize_and_withdraw() {
|
||||||
let mint_keypair = Keypair::new();
|
let mint_keypair = Keypair::new();
|
||||||
let test_validator = TestValidator::with_no_fees(mint_keypair.pubkey());
|
let test_validator = TestValidator::with_no_fees(mint_keypair.pubkey());
|
||||||
let (sender, receiver) = channel();
|
let faucet_addr = run_local_faucet(mint_keypair, None);
|
||||||
run_local_faucet(mint_keypair, sender, None);
|
|
||||||
let faucet_addr = receiver.recv().unwrap();
|
|
||||||
|
|
||||||
let rpc_client =
|
let rpc_client =
|
||||||
RpcClient::new_with_commitment(test_validator.rpc_url(), CommitmentConfig::processed());
|
RpcClient::new_with_commitment(test_validator.rpc_url(), CommitmentConfig::processed());
|
||||||
|
|
|
@ -265,9 +265,9 @@ pub fn request_airdrop_transaction(
|
||||||
|
|
||||||
pub fn run_local_faucet_with_port(
|
pub fn run_local_faucet_with_port(
|
||||||
faucet_keypair: Keypair,
|
faucet_keypair: Keypair,
|
||||||
sender: Sender<SocketAddr>,
|
sender: Sender<Result<SocketAddr, String>>,
|
||||||
per_time_cap: Option<u64>,
|
per_time_cap: Option<u64>,
|
||||||
port: u16,
|
port: u16, // 0 => auto assign
|
||||||
) {
|
) {
|
||||||
thread::spawn(move || {
|
thread::spawn(move || {
|
||||||
let faucet_addr = socketaddr!(0, port);
|
let faucet_addr = socketaddr!(0, port);
|
||||||
|
@ -283,23 +283,41 @@ pub fn run_local_faucet_with_port(
|
||||||
}
|
}
|
||||||
|
|
||||||
// For integration tests. Listens on random open port and reports port to Sender.
|
// For integration tests. Listens on random open port and reports port to Sender.
|
||||||
pub fn run_local_faucet(
|
pub fn run_local_faucet(faucet_keypair: Keypair, per_time_cap: Option<u64>) -> SocketAddr {
|
||||||
faucet_keypair: Keypair,
|
let (sender, receiver) = std::sync::mpsc::channel();
|
||||||
sender: Sender<SocketAddr>,
|
run_local_faucet_with_port(faucet_keypair, sender, per_time_cap, 0);
|
||||||
per_time_cap: Option<u64>,
|
receiver
|
||||||
) {
|
.recv()
|
||||||
run_local_faucet_with_port(faucet_keypair, sender, per_time_cap, 0)
|
.expect("run_local_faucet")
|
||||||
|
.expect("faucet_addr")
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn run_faucet(
|
pub async fn run_faucet(
|
||||||
faucet: Arc<Mutex<Faucet>>,
|
faucet: Arc<Mutex<Faucet>>,
|
||||||
faucet_addr: SocketAddr,
|
faucet_addr: SocketAddr,
|
||||||
send_addr: Option<Sender<SocketAddr>>,
|
sender: Option<Sender<Result<SocketAddr, String>>>,
|
||||||
) {
|
) {
|
||||||
let listener = TcpListener::bind(&faucet_addr).await.unwrap();
|
let listener = TcpListener::bind(&faucet_addr).await;
|
||||||
if let Some(send_addr) = send_addr {
|
if let Some(sender) = sender {
|
||||||
send_addr.send(listener.local_addr().unwrap()).unwrap();
|
sender.send(
|
||||||
|
listener.as_ref().map(|listener| listener.local_addr().unwrap())
|
||||||
|
.map_err(|err| {
|
||||||
|
format!(
|
||||||
|
"Unable to bind faucet to {:?}, check the address is not already in use: {}",
|
||||||
|
faucet_addr, err
|
||||||
|
)
|
||||||
|
})
|
||||||
|
)
|
||||||
|
.unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let listener = match listener {
|
||||||
|
Err(err) => {
|
||||||
|
error!("Faucet failed to start: {}", err);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Ok(listener) => listener,
|
||||||
|
};
|
||||||
info!("Faucet started. Listening on: {}", faucet_addr);
|
info!("Faucet started. Listening on: {}", faucet_addr);
|
||||||
info!(
|
info!(
|
||||||
"Faucet account address: {}",
|
"Faucet account address: {}",
|
||||||
|
|
|
@ -6,7 +6,6 @@ use solana_sdk::{
|
||||||
system_instruction,
|
system_instruction,
|
||||||
transaction::Transaction,
|
transaction::Transaction,
|
||||||
};
|
};
|
||||||
use std::sync::mpsc::channel;
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_local_faucet() {
|
fn test_local_faucet() {
|
||||||
|
@ -18,9 +17,7 @@ fn test_local_faucet() {
|
||||||
let message = Message::new(&[create_instruction], Some(&keypair.pubkey()));
|
let message = Message::new(&[create_instruction], Some(&keypair.pubkey()));
|
||||||
let expected_tx = Transaction::new(&[&keypair], message, blockhash);
|
let expected_tx = Transaction::new(&[&keypair], message, blockhash);
|
||||||
|
|
||||||
let (sender, receiver) = channel();
|
let faucet_addr = run_local_faucet(keypair, None);
|
||||||
run_local_faucet(keypair, sender, None);
|
|
||||||
let faucet_addr = receiver.recv().unwrap();
|
|
||||||
|
|
||||||
let result = request_airdrop_transaction(&faucet_addr, &to, lamports, blockhash);
|
let result = request_airdrop_transaction(&faucet_addr, &to, lamports, blockhash);
|
||||||
assert_eq!(expected_tx, result.unwrap());
|
assert_eq!(expected_tx, result.unwrap());
|
||||||
|
|
|
@ -23,7 +23,7 @@ use {
|
||||||
signature::{read_keypair_file, write_keypair_file, Keypair, Signer},
|
signature::{read_keypair_file, write_keypair_file, Keypair, Signer},
|
||||||
system_program,
|
system_program,
|
||||||
},
|
},
|
||||||
solana_validator::{start_logger, test_validator::*},
|
solana_validator::{redirect_stderr_to_file, test_validator::*},
|
||||||
std::{
|
std::{
|
||||||
collections::HashSet,
|
collections::HashSet,
|
||||||
fs, io,
|
fs, io,
|
||||||
|
@ -228,13 +228,13 @@ fn main() {
|
||||||
match address_program {
|
match address_program {
|
||||||
[address, program] => {
|
[address, program] => {
|
||||||
let address = address.parse::<Pubkey>().unwrap_or_else(|err| {
|
let address = address.parse::<Pubkey>().unwrap_or_else(|err| {
|
||||||
eprintln!("Error: invalid address {}: {}", address, err);
|
println!("Error: invalid address {}: {}", address, err);
|
||||||
exit(1);
|
exit(1);
|
||||||
});
|
});
|
||||||
|
|
||||||
let program_path = PathBuf::from(program);
|
let program_path = PathBuf::from(program);
|
||||||
if !program_path.exists() {
|
if !program_path.exists() {
|
||||||
eprintln!(
|
println!(
|
||||||
"Error: program file does not exist: {}",
|
"Error: program file does not exist: {}",
|
||||||
program_path.display()
|
program_path.display()
|
||||||
);
|
);
|
||||||
|
@ -261,12 +261,12 @@ fn main() {
|
||||||
Some(_) => value_t_or_exit!(matches, "warp_slot", Slot),
|
Some(_) => value_t_or_exit!(matches, "warp_slot", Slot),
|
||||||
None => {
|
None => {
|
||||||
cluster_rpc_client.as_ref().unwrap_or_else(|_| {
|
cluster_rpc_client.as_ref().unwrap_or_else(|_| {
|
||||||
eprintln!("The --url argument must be provided if --warp-slot/-w is used without an explicit slot");
|
println!("The --url argument must be provided if --warp-slot/-w is used without an explicit slot");
|
||||||
exit(1);
|
exit(1);
|
||||||
|
|
||||||
}).get_slot()
|
}).get_slot()
|
||||||
.unwrap_or_else(|err| {
|
.unwrap_or_else(|err| {
|
||||||
eprintln!("Unable to get current cluster slot: {}", err);
|
println!("Unable to get current cluster slot: {}", err);
|
||||||
exit(1);
|
exit(1);
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -277,7 +277,7 @@ fn main() {
|
||||||
|
|
||||||
if !ledger_path.exists() {
|
if !ledger_path.exists() {
|
||||||
fs::create_dir(&ledger_path).unwrap_or_else(|err| {
|
fs::create_dir(&ledger_path).unwrap_or_else(|err| {
|
||||||
eprintln!(
|
println!(
|
||||||
"Error: Unable to create directory {}: {}",
|
"Error: Unable to create directory {}: {}",
|
||||||
ledger_path.display(),
|
ledger_path.display(),
|
||||||
err
|
err
|
||||||
|
@ -288,7 +288,7 @@ fn main() {
|
||||||
|
|
||||||
let mut ledger_fd_lock = FdLock::new(fs::File::open(&ledger_path).unwrap());
|
let mut ledger_fd_lock = FdLock::new(fs::File::open(&ledger_path).unwrap());
|
||||||
let _ledger_lock = ledger_fd_lock.try_lock().unwrap_or_else(|_| {
|
let _ledger_lock = ledger_fd_lock.try_lock().unwrap_or_else(|_| {
|
||||||
eprintln!(
|
println!(
|
||||||
"Error: Unable to lock {} directory. Check if another solana-test-validator is running",
|
"Error: Unable to lock {} directory. Check if another solana-test-validator is running",
|
||||||
ledger_path.display()
|
ledger_path.display()
|
||||||
);
|
);
|
||||||
|
@ -297,7 +297,7 @@ fn main() {
|
||||||
|
|
||||||
if reset_ledger {
|
if reset_ledger {
|
||||||
remove_directory_contents(&ledger_path).unwrap_or_else(|err| {
|
remove_directory_contents(&ledger_path).unwrap_or_else(|err| {
|
||||||
eprintln!("Error: Unable to remove {}: {}", ledger_path.display(), err);
|
println!("Error: Unable to remove {}: {}", ledger_path.display(), err);
|
||||||
exit(1);
|
exit(1);
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -326,14 +326,14 @@ fn main() {
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
};
|
};
|
||||||
let _logger_thread = start_logger(logfile);
|
let _logger_thread = redirect_stderr_to_file(logfile);
|
||||||
|
|
||||||
let faucet_lamports = sol_to_lamports(1_000_000.);
|
let faucet_lamports = sol_to_lamports(1_000_000.);
|
||||||
let faucet_keypair_file = ledger_path.join("faucet-keypair.json");
|
let faucet_keypair_file = ledger_path.join("faucet-keypair.json");
|
||||||
if !faucet_keypair_file.exists() {
|
if !faucet_keypair_file.exists() {
|
||||||
write_keypair_file(&Keypair::new(), faucet_keypair_file.to_str().unwrap()).unwrap_or_else(
|
write_keypair_file(&Keypair::new(), faucet_keypair_file.to_str().unwrap()).unwrap_or_else(
|
||||||
|err| {
|
|err| {
|
||||||
eprintln!(
|
println!(
|
||||||
"Error: Failed to write {}: {}",
|
"Error: Failed to write {}: {}",
|
||||||
faucet_keypair_file.display(),
|
faucet_keypair_file.display(),
|
||||||
err
|
err
|
||||||
|
@ -344,7 +344,7 @@ fn main() {
|
||||||
}
|
}
|
||||||
let faucet_keypair =
|
let faucet_keypair =
|
||||||
read_keypair_file(faucet_keypair_file.to_str().unwrap()).unwrap_or_else(|err| {
|
read_keypair_file(faucet_keypair_file.to_str().unwrap()).unwrap_or_else(|err| {
|
||||||
eprintln!(
|
println!(
|
||||||
"Error: Failed to read {}: {}",
|
"Error: Failed to read {}: {}",
|
||||||
faucet_keypair_file.display(),
|
faucet_keypair_file.display(),
|
||||||
err
|
err
|
||||||
|
@ -397,14 +397,17 @@ fn main() {
|
||||||
genesis.start_with_mint_address(mint_address)
|
genesis.start_with_mint_address(mint_address)
|
||||||
}
|
}
|
||||||
.unwrap_or_else(|err| {
|
.unwrap_or_else(|err| {
|
||||||
eprintln!("Error: failed to start validator: {}", err);
|
println!("Error: failed to start validator: {}", err);
|
||||||
exit(1);
|
exit(1);
|
||||||
});
|
});
|
||||||
|
|
||||||
if let Some(faucet_addr) = &faucet_addr {
|
if let Some(faucet_addr) = &faucet_addr {
|
||||||
let (sender, receiver) = channel();
|
let (sender, receiver) = channel();
|
||||||
run_local_faucet_with_port(faucet_keypair, sender, None, faucet_addr.port());
|
run_local_faucet_with_port(faucet_keypair, sender, None, faucet_addr.port());
|
||||||
receiver.recv().expect("run faucet");
|
let _ = receiver.recv().expect("run faucet").unwrap_or_else(|err| {
|
||||||
|
println!("Error: failed to start faucet: {}", err);
|
||||||
|
exit(1);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if output == Output::Dashboard {
|
if output == Output::Dashboard {
|
||||||
|
|
|
@ -20,7 +20,10 @@ fn redirect_stderr(filename: &str) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn start_logger(logfile: Option<String>) -> Option<JoinHandle<()>> {
|
// Redirect stderr to a file with support for logrotate by sending a SIGUSR1 to the process.
|
||||||
|
//
|
||||||
|
// Upon success, future `log` macros and `eprintln!()` can be found in the specified log file.
|
||||||
|
pub fn redirect_stderr_to_file(logfile: Option<String>) -> Option<JoinHandle<()>> {
|
||||||
// Default to RUST_BACKTRACE=1 for more informative validator logs
|
// Default to RUST_BACKTRACE=1 for more informative validator logs
|
||||||
if env::var_os("RUST_BACKTRACE").is_none() {
|
if env::var_os("RUST_BACKTRACE").is_none() {
|
||||||
env::set_var("RUST_BACKTRACE", "1")
|
env::set_var("RUST_BACKTRACE", "1")
|
||||||
|
|
|
@ -41,7 +41,7 @@ use solana_sdk::{
|
||||||
pubkey::Pubkey,
|
pubkey::Pubkey,
|
||||||
signature::{Keypair, Signer},
|
signature::{Keypair, Signer},
|
||||||
};
|
};
|
||||||
use solana_validator::start_logger;
|
use solana_validator::redirect_stderr_to_file;
|
||||||
use std::{
|
use std::{
|
||||||
collections::HashSet,
|
collections::HashSet,
|
||||||
env,
|
env,
|
||||||
|
@ -1809,7 +1809,7 @@ pub fn main() {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
let use_progress_bar = logfile.is_none();
|
let use_progress_bar = logfile.is_none();
|
||||||
let _logger_thread = start_logger(logfile);
|
let _logger_thread = redirect_stderr_to_file(logfile);
|
||||||
|
|
||||||
info!("{} {}", crate_name!(), solana_version::version!());
|
info!("{} {}", crate_name!(), solana_version::version!());
|
||||||
info!("Starting validator with: {:#?}", std::env::args_os());
|
info!("Starting validator with: {:#?}", std::env::args_os());
|
||||||
|
|
Loading…
Reference in New Issue