2019-01-17 14:18:27 -08:00
|
|
|
use solana_drone::drone::{request_airdrop_transaction, run_local_drone};
|
|
|
|
use solana_sdk::hash::Hash;
|
2019-03-26 19:31:14 -07:00
|
|
|
use solana_sdk::message::Message;
|
2019-03-30 20:37:33 -07:00
|
|
|
use solana_sdk::pubkey::Pubkey;
|
2019-01-17 14:18:27 -08:00
|
|
|
use solana_sdk::signature::{Keypair, KeypairUtil};
|
2019-04-03 08:45:57 -07:00
|
|
|
use solana_sdk::system_instruction;
|
2019-01-17 14:18:27 -08:00
|
|
|
use solana_sdk::transaction::Transaction;
|
|
|
|
use std::sync::mpsc::channel;
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_local_drone() {
|
|
|
|
let keypair = Keypair::new();
|
2019-03-30 20:37:33 -07:00
|
|
|
let to = Pubkey::new_rand();
|
2019-03-05 16:28:14 -08:00
|
|
|
let lamports = 50;
|
2019-03-02 10:25:16 -08:00
|
|
|
let blockhash = Hash::new(&to.as_ref());
|
2019-04-03 08:45:57 -07:00
|
|
|
let create_instruction =
|
|
|
|
system_instruction::create_user_account(&keypair.pubkey(), &to, lamports);
|
2019-03-26 19:31:14 -07:00
|
|
|
let message = Message::new(vec![create_instruction]);
|
|
|
|
let expected_tx = Transaction::new(&[&keypair], message, blockhash);
|
2019-01-17 14:18:27 -08:00
|
|
|
|
|
|
|
let (sender, receiver) = channel();
|
|
|
|
run_local_drone(keypair, sender);
|
|
|
|
let drone_addr = receiver.recv().unwrap();
|
|
|
|
|
2019-03-05 16:28:14 -08:00
|
|
|
let result = request_airdrop_transaction(&drone_addr, &to, lamports, blockhash);
|
2019-01-17 14:18:27 -08:00
|
|
|
assert_eq!(expected_tx, result.unwrap());
|
|
|
|
}
|