From 0206020104743b69ff711f0ef6feefffac103afd Mon Sep 17 00:00:00 2001 From: Michael Vines Date: Tue, 24 Jul 2018 15:41:14 -0700 Subject: [PATCH] Make airdrops more robust --- src/bin/bench-tps.rs | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/src/bin/bench-tps.rs b/src/bin/bench-tps.rs index 91b98355d7..d8f1d63e6e 100644 --- a/src/bin/bench-tps.rs +++ b/src/bin/bench-tps.rs @@ -301,10 +301,13 @@ fn main() { if starting_balance < txs { let airdrop_amount = txs - starting_balance; - println!("Airdropping {:?} tokens", airdrop_amount); + println!( + "Airdropping {:?} tokens from {}", + airdrop_amount, drone_addr + ); + + let previous_balance = starting_balance; request_airdrop(&drone_addr, &id, airdrop_amount as u64).unwrap(); - // TODO: return airdrop Result from Drone - sleep(Duration::from_millis(100)); let balance = client.poll_get_balance(&id.pubkey()).unwrap(); println!("Your balance is: {:?}", balance); @@ -313,6 +316,23 @@ fn main() { println!("TPS airdrop limit reached; wait 60sec to retry"); exit(1); } + + // TODO: return airdrop Result from Drone instead of polling the + // network + let mut current_balance = previous_balance; + for _ in 0..20 { + sleep(Duration::from_millis(500)); + current_balance = client.poll_get_balance(&id.pubkey()).unwrap(); + if starting_balance != current_balance { + break; + } + println!("."); + } + println!("Your balance is: {:?}", current_balance); + if current_balance - starting_balance != airdrop_amount { + println!("Airdrop failed!"); + exit(1); + } } println!("Get last ID...");