* Add recent_blockhash to requestAirdrop * Move tx confirmation to separate method * Add RpcClient airdrop methods * Request cli airdrop via RpcClient * Pass optional faucet_addr into TestValidator and fix tests * Update client/src/rpc_client.rs Co-authored-by: Michael Vines <mvines@gmail.com> Co-authored-by: Michael Vines <mvines@gmail.com>
		
			
				
	
	
		
			37 lines
		
	
	
		
			1.2 KiB
		
	
	
	
		
			Rust
		
	
	
	
	
	
			
		
		
	
	
			37 lines
		
	
	
		
			1.2 KiB
		
	
	
	
		
			Rust
		
	
	
	
	
	
| use solana_cli::cli::{process_command, CliCommand, CliConfig};
 | |
| use solana_client::rpc_client::RpcClient;
 | |
| use solana_core::test_validator::TestValidator;
 | |
| use solana_faucet::faucet::run_local_faucet;
 | |
| use solana_sdk::{
 | |
|     commitment_config::CommitmentConfig,
 | |
|     signature::{Keypair, Signer},
 | |
| };
 | |
| 
 | |
| #[test]
 | |
| fn test_cli_request_airdrop() {
 | |
|     let mint_keypair = Keypair::new();
 | |
|     let mint_pubkey = mint_keypair.pubkey();
 | |
|     let faucet_addr = run_local_faucet(mint_keypair, None);
 | |
|     let test_validator = TestValidator::with_no_fees(mint_pubkey, Some(faucet_addr));
 | |
| 
 | |
|     let mut bob_config = CliConfig::recent_for_tests();
 | |
|     bob_config.json_rpc_url = test_validator.rpc_url();
 | |
|     bob_config.command = CliCommand::Airdrop {
 | |
|         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_with_commitment(test_validator.rpc_url(), CommitmentConfig::processed());
 | |
| 
 | |
|     let balance = rpc_client
 | |
|         .get_balance(&bob_config.signers[0].pubkey())
 | |
|         .unwrap();
 | |
|     assert_eq!(balance, 50);
 | |
| }
 |