Move mock request_airdrop_transaction into drone/, closer to the real impl
This commit is contained in:
parent
e2c24481e4
commit
97e73311c5
|
@ -2,14 +2,8 @@
|
||||||
|
|
||||||
use crate::rpc_request::{RpcRequest, RpcRequestHandler};
|
use crate::rpc_request::{RpcRequest, RpcRequestHandler};
|
||||||
use serde_json::{json, Number, Value};
|
use serde_json::{json, Number, Value};
|
||||||
use solana_sdk::hash::Hash;
|
|
||||||
use solana_sdk::pubkey::Pubkey;
|
use solana_sdk::pubkey::Pubkey;
|
||||||
use solana_sdk::signature::{Keypair, KeypairUtil};
|
|
||||||
use solana_sdk::system_transaction::SystemTransaction;
|
|
||||||
use solana_sdk::transaction::Transaction;
|
|
||||||
use std::error;
|
use std::error;
|
||||||
use std::io::{Error, ErrorKind};
|
|
||||||
use std::net::SocketAddr;
|
|
||||||
|
|
||||||
pub const PUBKEY: &str = "7RoSF9fUmdphVCpabEoefH81WwrW7orsWonXWqTXkKV8";
|
pub const PUBKEY: &str = "7RoSF9fUmdphVCpabEoefH81WwrW7orsWonXWqTXkKV8";
|
||||||
pub const SIGNATURE: &str =
|
pub const SIGNATURE: &str =
|
||||||
|
@ -90,19 +84,3 @@ impl RpcRequestHandler for MockRpcClient {
|
||||||
self.retry_make_rpc_request(&request, params, 0)
|
self.retry_make_rpc_request(&request, params, 0)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn request_airdrop_transaction(
|
|
||||||
_drone_addr: &SocketAddr,
|
|
||||||
_id: &Pubkey,
|
|
||||||
lamports: u64,
|
|
||||||
_blockhash: Hash,
|
|
||||||
) -> Result<Transaction, Error> {
|
|
||||||
if lamports == 0 {
|
|
||||||
Err(Error::new(ErrorKind::Other, "Airdrop failed"))?
|
|
||||||
}
|
|
||||||
let key = Keypair::new();
|
|
||||||
let to = Keypair::new().pubkey();
|
|
||||||
let blockhash = Hash::default();
|
|
||||||
let tx = SystemTransaction::new_account(&key, &to, lamports, blockhash, 0);
|
|
||||||
Ok(tx)
|
|
||||||
}
|
|
||||||
|
|
|
@ -0,0 +1,23 @@
|
||||||
|
use solana_sdk::hash::Hash;
|
||||||
|
use solana_sdk::pubkey::Pubkey;
|
||||||
|
use solana_sdk::signature::{Keypair, KeypairUtil};
|
||||||
|
use solana_sdk::system_transaction::SystemTransaction;
|
||||||
|
use solana_sdk::transaction::Transaction;
|
||||||
|
use std::io::{Error, ErrorKind};
|
||||||
|
use std::net::SocketAddr;
|
||||||
|
|
||||||
|
pub fn request_airdrop_transaction(
|
||||||
|
_drone_addr: &SocketAddr,
|
||||||
|
_id: &Pubkey,
|
||||||
|
lamports: u64,
|
||||||
|
_blockhash: Hash,
|
||||||
|
) -> Result<Transaction, Error> {
|
||||||
|
if lamports == 0 {
|
||||||
|
Err(Error::new(ErrorKind::Other, "Airdrop failed"))?
|
||||||
|
}
|
||||||
|
let key = Keypair::new();
|
||||||
|
let to = Keypair::new().pubkey();
|
||||||
|
let blockhash = Hash::default();
|
||||||
|
let tx = SystemTransaction::new_account(&key, &to, lamports, blockhash, 0);
|
||||||
|
Ok(tx)
|
||||||
|
}
|
|
@ -1 +1,2 @@
|
||||||
pub mod drone;
|
pub mod drone;
|
||||||
|
pub mod drone_mock;
|
||||||
|
|
|
@ -8,7 +8,7 @@ use serde_json::json;
|
||||||
use solana_budget_api;
|
use solana_budget_api;
|
||||||
use solana_budget_api::budget_transaction::BudgetTransaction;
|
use solana_budget_api::budget_transaction::BudgetTransaction;
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
use solana_client::rpc_mock::{request_airdrop_transaction, MockRpcClient as RpcClient};
|
use solana_client::rpc_mock::MockRpcClient as RpcClient;
|
||||||
#[cfg(not(test))]
|
#[cfg(not(test))]
|
||||||
use solana_client::rpc_request::RpcClient;
|
use solana_client::rpc_request::RpcClient;
|
||||||
use solana_client::rpc_request::{get_rpc_request_str, RpcRequest};
|
use solana_client::rpc_request::{get_rpc_request_str, RpcRequest};
|
||||||
|
@ -16,6 +16,8 @@ use solana_client::rpc_signature_status::RpcSignatureStatus;
|
||||||
#[cfg(not(test))]
|
#[cfg(not(test))]
|
||||||
use solana_drone::drone::request_airdrop_transaction;
|
use solana_drone::drone::request_airdrop_transaction;
|
||||||
use solana_drone::drone::DRONE_PORT;
|
use solana_drone::drone::DRONE_PORT;
|
||||||
|
#[cfg(test)]
|
||||||
|
use solana_drone::drone_mock::request_airdrop_transaction;
|
||||||
use solana_sdk::bpf_loader;
|
use solana_sdk::bpf_loader;
|
||||||
use solana_sdk::hash::Hash;
|
use solana_sdk::hash::Hash;
|
||||||
use solana_sdk::loader_transaction::LoaderTransaction;
|
use solana_sdk::loader_transaction::LoaderTransaction;
|
||||||
|
|
Loading…
Reference in New Issue