solana/cli/tests/request_airdrop.rs
Tyera Eulberg 7a741bb79a
Move commitment to CliConfig to enable faster integration tests (#10627)
* Add commitment config to CliConfig

* Use config.commitment in cluster_query

* Use config.commitment in vote

* Add method with spinner + commitment

* Add send-transaction config to CliConfig

* Remove superfluous nonce check

* Add with_commitment helper fns

* Update src to use commitment

* Fix pay and transfer integration tests

* Fix nonce int tests

* Fix deploy int test

* Fix vote int test

* Fix stake int tests

* Nightly clippy

* Review comments
2020-06-17 12:18:48 -06:00

46 lines
1.4 KiB
Rust

use solana_cli::cli::{process_command, CliCommand, CliConfig};
use solana_client::rpc_client::RpcClient;
use solana_core::validator::TestValidator;
use solana_faucet::faucet::run_local_faucet;
use solana_sdk::{commitment_config::CommitmentConfig, signature::Keypair};
use std::{fs::remove_dir_all, sync::mpsc::channel};
#[test]
fn test_cli_request_airdrop() {
let TestValidator {
server,
leader_data,
alice,
ledger_path,
..
} = TestValidator::run();
let (sender, receiver) = channel();
run_local_faucet(alice, sender, None);
let faucet_addr = receiver.recv().unwrap();
let mut bob_config = CliConfig::recent_for_tests();
bob_config.json_rpc_url = format!("http://{}:{}", leader_data.rpc.ip(), leader_data.rpc.port());
bob_config.command = CliCommand::Airdrop {
faucet_host: None,
faucet_port: faucet_addr.port(),
pubkey: None,
lamports: 50,
};
let keypair = Keypair::new();
bob_config.signers = vec![&keypair];
let sig_response = process_command(&bob_config);
sig_response.unwrap();
let rpc_client = RpcClient::new_socket(leader_data.rpc);
let balance = rpc_client
.get_balance_with_commitment(&bob_config.signers[0].pubkey(), CommitmentConfig::recent())
.unwrap()
.value;
assert_eq!(balance, 50);
server.close().unwrap();
remove_dir_all(ledger_path).unwrap();
}