Reduce rpc test code (#9413)

automerge
This commit is contained in:
sakridge
2020-04-09 18:05:56 -07:00
committed by GitHub
parent aeddd8c95a
commit 900933bbcc
9 changed files with 88 additions and 200 deletions

View File

@@ -25,5 +25,6 @@ pub mod nonce;
pub mod offline;
pub mod stake;
pub mod storage;
pub mod test_utils;
pub mod validator_info;
pub mod vote;

View File

@@ -456,8 +456,8 @@ pub fn process_create_nonce_account(
lamports: u64,
) -> ProcessResult {
let nonce_account_pubkey = config.signers[nonce_account].pubkey();
let nonce_account_address = if let Some(seed) = seed.clone() {
Pubkey::create_with_seed(&nonce_account_pubkey, &seed, &system_program::id())?
let nonce_account_address = if let Some(ref seed) = seed {
Pubkey::create_with_seed(&nonce_account_pubkey, seed, &system_program::id())?
} else {
nonce_account_pubkey
};

16
cli/src/test_utils.rs Normal file
View File

@@ -0,0 +1,16 @@
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.retry_get_balance(pubkey, 1).unwrap().unwrap();
if balance == expected_balance {
return;
}
if tries == 4 {
assert_eq!(balance, expected_balance);
}
sleep(Duration::from_millis(500));
});
}