* 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
17 lines
498 B
Rust
17 lines
498 B
Rust
use solana_client::rpc_client::RpcClient;
|
|
use solana_sdk::pubkey::Pubkey;
|
|
use std::{thread::sleep, time::Duration};
|
|
|
|
pub fn check_balance(expected_balance: u64, client: &RpcClient, pubkey: &Pubkey) {
|
|
(0..5).for_each(|tries| {
|
|
let balance = client.get_balance(pubkey).unwrap();
|
|
if balance == expected_balance {
|
|
return;
|
|
}
|
|
if tries == 4 {
|
|
assert_eq!(balance, expected_balance);
|
|
}
|
|
sleep(Duration::from_millis(500));
|
|
});
|
|
}
|