* lamports->SOL in user-facing error msg * Check for sufficient balance for spend and fee * Add ALL option to solana transfer * Rework TransferAmount to check for sign_only in parse * Refactor TransferAmount & fee-check handling to be more general * Add addl checks mechanism * Move checks out of cli.rs * Rename to SpendAmount to be more general & move * Impl ALL/spend helpers for create-nonce-account * Impl spend helpers for create-vote-account * Impl ALL/spend helpers for create-stake-account * Impl spend helpers for ping * Impl ALL/spend helpers for pay * Impl spend helpers for validator-info * Remove unused fns * Remove retry_get_balance * Add a couple unit tests * Rework send_util fn signatures
		
			
				
	
	
		
			45 lines
		
	
	
		
			1.3 KiB
		
	
	
	
		
			Rust
		
	
	
	
	
	
			
		
		
	
	
			45 lines
		
	
	
		
			1.3 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::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::default();
 | 
						|
    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(&bob_config.signers[0].pubkey())
 | 
						|
        .unwrap();
 | 
						|
    assert_eq!(balance, 50);
 | 
						|
 | 
						|
    server.close().unwrap();
 | 
						|
    remove_dir_all(ledger_path).unwrap();
 | 
						|
}
 |