From 2a4f4b3e5356d771b65eaa76be4d64e684c75a60 Mon Sep 17 00:00:00 2001 From: Tyera Eulberg Date: Tue, 12 Mar 2019 18:27:52 -0600 Subject: [PATCH] Update crate references --- bench-tps/Cargo.toml | 1 + bench-tps/src/bench.rs | 4 +- bench-tps/src/main.rs | 2 +- core/Cargo.toml | 3 +- core/src/{client.rs => cluster_client.rs} | 2 +- core/src/cluster_tests.rs | 2 +- core/src/fullnode.rs | 25 ++ core/src/lib.rs | 6 +- core/src/local_cluster.rs | 5 +- core/src/replicator.rs | 6 +- core/src/rpc_mock.rs | 111 -------- core/src/rpc_request.rs | 330 ---------------------- core/src/storage_stage.rs | 2 +- core/src/voting_keypair.rs | 2 +- tests/replicator.rs | 4 +- tests/rpc.rs | 6 +- wallet/Cargo.toml | 4 + wallet/src/wallet.rs | 12 +- wallet/tests/deploy.rs | 6 +- wallet/tests/pay.rs | 10 +- wallet/tests/request_airdrop.rs | 6 +- 21 files changed, 66 insertions(+), 483 deletions(-) rename core/src/{client.rs => cluster_client.rs} (92%) delete mode 100644 core/src/rpc_mock.rs delete mode 100644 core/src/rpc_request.rs diff --git a/bench-tps/Cargo.toml b/bench-tps/Cargo.toml index 4ef47ad108..0add6522c1 100644 --- a/bench-tps/Cargo.toml +++ b/bench-tps/Cargo.toml @@ -12,6 +12,7 @@ clap = "2.32.0" rayon = "1.0.3" serde_json = "1.0.39" solana = { path = "../core", version = "0.12.1" } +solana-client = { path = "../client", version = "0.12.1" } solana-drone = { path = "../drone", version = "0.12.1" } solana-logger = { path = "../logger", version = "0.12.1" } solana-metrics = { path = "../metrics", version = "0.12.1" } diff --git a/bench-tps/src/bench.rs b/bench-tps/src/bench.rs index 2970614b99..880d8a58b4 100644 --- a/bench-tps/src/bench.rs +++ b/bench-tps/src/bench.rs @@ -1,9 +1,9 @@ use solana_metrics; use rayon::prelude::*; -use solana::client::mk_client; +use solana::cluster_client::mk_client; use solana::contact_info::ContactInfo; -use solana::thin_client::ThinClient; +use solana_client::thin_client::ThinClient; use solana_drone::drone::request_airdrop_transaction; use solana_metrics::influxdb; use solana_sdk::hash::Hash; diff --git a/bench-tps/src/main.rs b/bench-tps/src/main.rs index a339db3dd5..8ff4039335 100644 --- a/bench-tps/src/main.rs +++ b/bench-tps/src/main.rs @@ -2,7 +2,7 @@ mod bench; mod cli; use crate::bench::*; -use solana::client::mk_client; +use solana::cluster_client::mk_client; use solana::gen_keys::GenKeys; use solana::gossip_service::discover; use solana_metrics; diff --git a/core/Cargo.toml b/core/Cargo.toml index b5d6be63bf..e66a279495 100644 --- a/core/Cargo.toml +++ b/core/Cargo.toml @@ -39,13 +39,13 @@ nix = "0.13.0" rand = "0.6.5" rand_chacha = "0.1.1" rayon = "1.0.0" -reqwest = "0.9.11" ring = "0.13.2" rocksdb = "0.11.0" serde = "1.0.89" serde_derive = "1.0.88" serde_json = "1.0.39" solana-budget-api = { path = "../programs/budget_api", version = "0.12.1" } +solana-client = { path = "../client", version = "0.12.1" } solana-drone = { path = "../drone", version = "0.12.1" } solana-logger = { path = "../logger", version = "0.12.1" } solana-metrics = { path = "../metrics", version = "0.12.1" } @@ -65,4 +65,3 @@ hex-literal = "0.1.3" matches = "0.1.6" solana-vote-program = { path = "../programs/vote", version = "0.12.1" } solana-budget-program = { path = "../programs/budget", version = "0.12.1" } - diff --git a/core/src/client.rs b/core/src/cluster_client.rs similarity index 92% rename from core/src/client.rs rename to core/src/cluster_client.rs index 033530d522..edba859b49 100644 --- a/core/src/client.rs +++ b/core/src/cluster_client.rs @@ -1,6 +1,6 @@ use crate::cluster_info::FULLNODE_PORT_RANGE; use crate::contact_info::ContactInfo; -use crate::thin_client::ThinClient; +use solana_client::thin_client::ThinClient; use std::time::Duration; pub fn mk_client(r: &ContactInfo) -> ThinClient { diff --git a/core/src/cluster_tests.rs b/core/src/cluster_tests.rs index 214cc831d8..31cb699b3b 100644 --- a/core/src/cluster_tests.rs +++ b/core/src/cluster_tests.rs @@ -3,7 +3,7 @@ use crate::blocktree::Blocktree; /// /// All tests must start from an entry point and a funding keypair and /// discover the rest of the network. -use crate::client::mk_client; +use crate::cluster_client::mk_client; use crate::contact_info::ContactInfo; use crate::entry::{Entry, EntrySlice}; use crate::gossip_service::discover; diff --git a/core/src/fullnode.rs b/core/src/fullnode.rs index f3d7fc6329..4cba28b701 100644 --- a/core/src/fullnode.rs +++ b/core/src/fullnode.rs @@ -372,6 +372,31 @@ pub fn make_active_set_entries( (entries, voting_keypair) } +pub fn new_fullnode_for_tests() -> (Fullnode, ContactInfo, Keypair, String) { + use crate::blocktree::create_new_tmp_ledger; + use crate::cluster_info::Node; + + let node_keypair = Arc::new(Keypair::new()); + let node = Node::new_localhost_with_pubkey(&node_keypair.pubkey()); + let contact_info = node.info.clone(); + + let (genesis_block, mint_keypair) = GenesisBlock::new_with_leader(10_000, &contact_info.id, 42); + let (ledger_path, _blockhash) = create_new_tmp_ledger!(&genesis_block); + + let voting_keypair = Keypair::new(); + let node = Fullnode::new( + node, + &node_keypair, + &ledger_path, + &voting_keypair.pubkey(), + voting_keypair, + None, + &FullnodeConfig::default(), + ); + + (node, contact_info, mint_keypair, ledger_path) +} + #[cfg(test)] mod tests { use super::*; diff --git a/core/src/lib.rs b/core/src/lib.rs index f55981b381..79545c668d 100644 --- a/core/src/lib.rs +++ b/core/src/lib.rs @@ -3,7 +3,6 @@ //! [Fullnode](server/struct.Fullnode.html)) as well as hooks to GPU implementations of its most //! paralellizable components (i.e. [SigVerify](sigverify/index.html)). It also includes //! command-line tools to spin up fullnodes and a Rust library -//! (see [ThinClient](thin_client/struct.ThinClient.html)) to interact with them. //! pub mod bank_forks; @@ -14,7 +13,7 @@ pub mod broadcast_stage; pub mod chacha; #[cfg(all(feature = "chacha", feature = "cuda"))] pub mod chacha_cuda; -pub mod client; +pub mod cluster_client; pub mod cluster_info_vote_listener; #[macro_use] pub mod contact_info; @@ -57,10 +56,8 @@ pub mod replicator; pub mod result; pub mod retransmit_stage; pub mod rpc; -pub mod rpc_mock; pub mod rpc_pubsub; pub mod rpc_pubsub_service; -pub mod rpc_request; pub mod rpc_service; pub mod rpc_status; pub mod rpc_subscriptions; @@ -71,7 +68,6 @@ pub mod staking_utils; pub mod storage_stage; pub mod streamer; pub mod test_tx; -pub mod thin_client; pub mod tpu; pub mod tvu; pub mod voting_keypair; diff --git a/core/src/local_cluster.rs b/core/src/local_cluster.rs index 10b8f2e08c..d83fcee610 100644 --- a/core/src/local_cluster.rs +++ b/core/src/local_cluster.rs @@ -1,12 +1,11 @@ use crate::blocktree::{create_new_tmp_ledger, tmp_copy_blocktree}; -use crate::client::mk_client; +use crate::cluster_client::mk_client; use crate::cluster_info::Node; use crate::contact_info::ContactInfo; use crate::fullnode::{Fullnode, FullnodeConfig}; use crate::gossip_service::discover; use crate::service::Service; -use crate::thin_client::retry_get_balance; -use crate::thin_client::ThinClient; +use solana_client::thin_client::{retry_get_balance, ThinClient}; use solana_sdk::genesis_block::GenesisBlock; use solana_sdk::pubkey::Pubkey; use solana_sdk::signature::{Keypair, KeypairUtil}; diff --git a/core/src/replicator.rs b/core/src/replicator.rs index ce8f9a7d5d..1b2b5ee8e3 100644 --- a/core/src/replicator.rs +++ b/core/src/replicator.rs @@ -3,19 +3,19 @@ use crate::blocktree::Blocktree; use crate::blocktree_processor; #[cfg(feature = "chacha")] use crate::chacha::{chacha_cbc_encrypt_ledger, CHACHA_BLOCK_SIZE}; -use crate::client::mk_client; +use crate::cluster_client::mk_client; use crate::cluster_info::{ClusterInfo, Node}; use crate::contact_info::ContactInfo; use crate::gossip_service::GossipService; use crate::result::Result; -use crate::rpc_request::{RpcClient, RpcRequest, RpcRequestHandler}; use crate::service::Service; use crate::storage_stage::{get_segment_from_entry, ENTRIES_PER_SEGMENT}; use crate::streamer::BlobReceiver; -use crate::thin_client::{retry_get_balance, ThinClient}; use crate::window_service::WindowService; use rand::thread_rng; use rand::Rng; +use solana_client::rpc_request::{RpcClient, RpcRequest, RpcRequestHandler}; +use solana_client::thin_client::{retry_get_balance, ThinClient}; use solana_drone::drone::{request_airdrop_transaction, DRONE_PORT}; use solana_sdk::genesis_block::GenesisBlock; use solana_sdk::hash::{Hash, Hasher}; diff --git a/core/src/rpc_mock.rs b/core/src/rpc_mock.rs deleted file mode 100644 index eafd792ec5..0000000000 --- a/core/src/rpc_mock.rs +++ /dev/null @@ -1,111 +0,0 @@ -// Implementation of RpcRequestHandler trait for testing Rpc requests without i/o - -use crate::rpc_request::{RpcRequest, RpcRequestHandler}; -use serde_json::{Number, Value}; -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::error; -use std::io::{Error, ErrorKind}; -use std::net::SocketAddr; - -pub const PUBKEY: &str = "7RoSF9fUmdphVCpabEoefH81WwrW7orsWonXWqTXkKV8"; -pub const SIGNATURE: &str = - "43yNSFC6fYTuPgTNFFhF4axw7AfWxB2BPdurme8yrsWEYwm8299xh8n6TAHjGymiSub1XtyxTNyd9GBfY2hxoBw8"; - -#[derive(Clone)] -pub struct MockRpcClient { - pub addr: String, -} - -impl MockRpcClient { - pub fn new(addr: String) -> Self { - MockRpcClient { addr } - } - - pub fn retry_get_balance( - &self, - id: u64, - pubkey: &Pubkey, - retries: usize, - ) -> Result, Box> { - let params = json!([format!("{}", pubkey)]); - let res = self - .retry_make_rpc_request(id, &RpcRequest::GetBalance, Some(params), retries)? - .as_u64(); - Ok(res) - } - - pub fn retry_make_rpc_request( - &self, - _id: u64, - request: &RpcRequest, - params: Option, - mut _retries: usize, - ) -> Result> { - if self.addr == "fails" { - return Ok(Value::Null); - } - let val = match request { - RpcRequest::ConfirmTransaction => { - if let Some(Value::Array(param_array)) = params { - if let Value::String(param_string) = ¶m_array[0] { - Value::Bool(param_string == SIGNATURE) - } else { - Value::Null - } - } else { - Value::Null - } - } - RpcRequest::GetBalance => { - let n = if self.addr == "airdrop" { 0 } else { 50 }; - Value::Number(Number::from(n)) - } - RpcRequest::GetRecentBlockhash => Value::String(PUBKEY.to_string()), - RpcRequest::GetSignatureStatus => { - let str = if self.addr == "account_in_use" { - "AccountInUse" - } else if self.addr == "bad_sig_status" { - "Nonexistent" - } else { - "Confirmed" - }; - Value::String(str.to_string()) - } - RpcRequest::GetTransactionCount => Value::Number(Number::from(1234)), - RpcRequest::SendTransaction => Value::String(SIGNATURE.to_string()), - _ => Value::Null, - }; - Ok(val) - } -} - -impl RpcRequestHandler for MockRpcClient { - fn make_rpc_request( - &self, - id: u64, - request: RpcRequest, - params: Option, - ) -> Result> { - self.retry_make_rpc_request(id, &request, params, 0) - } -} - -pub fn request_airdrop_transaction( - _drone_addr: &SocketAddr, - _id: &Pubkey, - lamports: u64, - _blockhash: Hash, -) -> Result { - 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) -} diff --git a/core/src/rpc_request.rs b/core/src/rpc_request.rs deleted file mode 100644 index 82af7181a0..0000000000 --- a/core/src/rpc_request.rs +++ /dev/null @@ -1,330 +0,0 @@ -use reqwest; -use reqwest::header::CONTENT_TYPE; -use serde_json::{self, Value}; -use solana_sdk::timing::{DEFAULT_TICKS_PER_SLOT, NUM_TICKS_PER_SECOND}; -use std::net::SocketAddr; -use std::thread::sleep; -use std::time::Duration; -use std::{error, fmt}; - -use solana_sdk::pubkey::Pubkey; - -#[derive(Clone)] -pub struct RpcClient { - pub client: reqwest::Client, - pub addr: String, -} - -impl RpcClient { - pub fn new(addr: String) -> Self { - RpcClient { - client: reqwest::Client::new(), - addr, - } - } - - pub fn new_with_timeout(addr: SocketAddr, timeout: Duration) -> Self { - let addr = get_rpc_request_str(addr, false); - let client = reqwest::Client::builder() - .timeout(timeout) - .build() - .expect("build rpc client"); - RpcClient { client, addr } - } - - pub fn new_from_socket(addr: SocketAddr) -> Self { - Self::new(get_rpc_request_str(addr, false)) - } - - pub fn retry_get_balance( - &self, - id: u64, - pubkey: &Pubkey, - retries: usize, - ) -> Result, Box> { - let params = json!([format!("{}", pubkey)]); - let res = self - .retry_make_rpc_request(id, &RpcRequest::GetBalance, Some(params), retries)? - .as_u64(); - Ok(res) - } - - pub fn retry_make_rpc_request( - &self, - id: u64, - request: &RpcRequest, - params: Option, - mut retries: usize, - ) -> Result> { - let request_json = request.build_request_json(id, params); - - loop { - match self - .client - .post(&self.addr) - .header(CONTENT_TYPE, "application/json") - .body(request_json.to_string()) - .send() - { - Ok(mut response) => { - let json: Value = serde_json::from_str(&response.text()?)?; - if json["error"].is_object() { - Err(RpcError::RpcRequestError(format!( - "RPC Error response: {}", - serde_json::to_string(&json["error"]).unwrap() - )))? - } - return Ok(json["result"].clone()); - } - Err(e) => { - info!( - "make_rpc_request() failed, {} retries left: {:?}", - retries, e - ); - if retries == 0 { - Err(e)?; - } - retries -= 1; - - // Sleep for approximately half a slot - sleep(Duration::from_millis( - 500 * DEFAULT_TICKS_PER_SLOT / NUM_TICKS_PER_SECOND, - )); - } - } - } - } -} - -pub fn get_rpc_request_str(rpc_addr: SocketAddr, tls: bool) -> String { - if tls { - format!("https://{}", rpc_addr) - } else { - format!("http://{}", rpc_addr) - } -} - -pub trait RpcRequestHandler { - fn make_rpc_request( - &self, - id: u64, - request: RpcRequest, - params: Option, - ) -> Result>; -} - -impl RpcRequestHandler for RpcClient { - fn make_rpc_request( - &self, - id: u64, - request: RpcRequest, - params: Option, - ) -> Result> { - self.retry_make_rpc_request(id, &request, params, 0) - } -} - -#[derive(Debug, PartialEq)] -pub enum RpcRequest { - ConfirmTransaction, - GetAccountInfo, - GetBalance, - GetRecentBlockhash, - GetSignatureStatus, - GetTransactionCount, - RequestAirdrop, - SendTransaction, - RegisterNode, - SignVote, - DeregisterNode, - GetStorageBlockhash, - GetStorageEntryHeight, - GetStoragePubkeysForEntryHeight, - FullnodeExit, -} - -impl RpcRequest { - fn build_request_json(&self, id: u64, params: Option) -> Value { - let jsonrpc = "2.0"; - let method = match self { - RpcRequest::ConfirmTransaction => "confirmTransaction", - RpcRequest::GetAccountInfo => "getAccountInfo", - RpcRequest::GetBalance => "getBalance", - RpcRequest::GetRecentBlockhash => "getRecentBlockhash", - RpcRequest::GetSignatureStatus => "getSignatureStatus", - RpcRequest::GetTransactionCount => "getTransactionCount", - RpcRequest::RequestAirdrop => "requestAirdrop", - RpcRequest::SendTransaction => "sendTransaction", - RpcRequest::RegisterNode => "registerNode", - RpcRequest::SignVote => "signVote", - RpcRequest::DeregisterNode => "deregisterNode", - RpcRequest::GetStorageBlockhash => "getStorageBlockhash", - RpcRequest::GetStorageEntryHeight => "getStorageEntryHeight", - RpcRequest::GetStoragePubkeysForEntryHeight => "getStoragePubkeysForEntryHeight", - RpcRequest::FullnodeExit => "fullnodeExit", - }; - let mut request = json!({ - "jsonrpc": jsonrpc, - "id": id, - "method": method, - }); - if let Some(param_string) = params { - request["params"] = param_string; - } - request - } -} - -#[derive(Debug, Clone, PartialEq)] -pub enum RpcError { - RpcRequestError(String), -} - -impl fmt::Display for RpcError { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - write!(f, "invalid") - } -} - -impl error::Error for RpcError { - fn description(&self) -> &str { - "invalid" - } - - fn cause(&self) -> Option<&dyn error::Error> { - // Generic error, underlying cause isn't tracked. - None - } -} - -#[cfg(test)] -mod tests { - use super::*; - use jsonrpc_core::{Error, IoHandler, Params}; - use jsonrpc_http_server::{AccessControlAllowOrigin, DomainsValidation, ServerBuilder}; - use serde_json::Number; - use std::net::Ipv4Addr; - use std::sync::mpsc::channel; - use std::thread; - - #[test] - fn test_build_request_json() { - let test_request = RpcRequest::GetAccountInfo; - let addr = json!(["deadbeefXjn8o3yroDHxUtKsZZgoy4GPkPPXfouKNHhx"]); - let request = test_request.build_request_json(1, Some(addr.clone())); - assert_eq!(request["method"], "getAccountInfo"); - assert_eq!(request["params"], addr,); - - let test_request = RpcRequest::GetBalance; - let request = test_request.build_request_json(1, Some(addr)); - assert_eq!(request["method"], "getBalance"); - - let test_request = RpcRequest::GetRecentBlockhash; - let request = test_request.build_request_json(1, None); - assert_eq!(request["method"], "getRecentBlockhash"); - - let test_request = RpcRequest::GetTransactionCount; - let request = test_request.build_request_json(1, None); - assert_eq!(request["method"], "getTransactionCount"); - - let test_request = RpcRequest::RequestAirdrop; - let request = test_request.build_request_json(1, None); - assert_eq!(request["method"], "requestAirdrop"); - - let test_request = RpcRequest::SendTransaction; - let request = test_request.build_request_json(1, None); - assert_eq!(request["method"], "sendTransaction"); - } - #[test] - fn test_make_rpc_request() { - let (sender, receiver) = channel(); - thread::spawn(move || { - let rpc_addr = socketaddr!(0, 0); - let mut io = IoHandler::default(); - // Successful request - io.add_method("getBalance", |_params: Params| { - Ok(Value::Number(Number::from(50))) - }); - // Failed request - io.add_method("getRecentBlockhash", |params: Params| { - if params != Params::None { - Err(Error::invalid_request()) - } else { - Ok(Value::String( - "deadbeefXjn8o3yroDHxUtKsZZgoy4GPkPPXfouKNHhx".to_string(), - )) - } - }); - - let server = ServerBuilder::new(io) - .threads(1) - .cors(DomainsValidation::AllowOnly(vec![ - AccessControlAllowOrigin::Any, - ])) - .start_http(&rpc_addr) - .expect("Unable to start RPC server"); - sender.send(*server.address()).unwrap(); - server.wait(); - }); - - let rpc_addr = receiver.recv().unwrap(); - let rpc_client = RpcClient::new_from_socket(rpc_addr); - - let balance = rpc_client.make_rpc_request( - 1, - RpcRequest::GetBalance, - Some(json!(["deadbeefXjn8o3yroDHxUtKsZZgoy4GPkPPXfouKNHhx"])), - ); - assert_eq!(balance.unwrap().as_u64().unwrap(), 50); - - let blockhash = rpc_client.make_rpc_request(2, RpcRequest::GetRecentBlockhash, None); - assert_eq!( - blockhash.unwrap().as_str().unwrap(), - "deadbeefXjn8o3yroDHxUtKsZZgoy4GPkPPXfouKNHhx" - ); - - // Send erroneous parameter - let blockhash = - rpc_client.make_rpc_request(3, RpcRequest::GetRecentBlockhash, Some(json!("paramter"))); - assert_eq!(blockhash.is_err(), true); - } - - #[test] - fn test_retry_make_rpc_request() { - solana_logger::setup(); - let (sender, receiver) = channel(); - thread::spawn(move || { - // 1. Pick a random port - // 2. Tell the client to start using it - // 3. Delay for 1.5 seconds before starting the server to ensure the client will fail - // and need to retry - let rpc_addr = socketaddr!(0, 4242); - sender.send(rpc_addr.clone()).unwrap(); - sleep(Duration::from_millis(1500)); - - let mut io = IoHandler::default(); - io.add_method("getBalance", move |_params: Params| { - Ok(Value::Number(Number::from(5))) - }); - let server = ServerBuilder::new(io) - .threads(1) - .cors(DomainsValidation::AllowOnly(vec![ - AccessControlAllowOrigin::Any, - ])) - .start_http(&rpc_addr) - .expect("Unable to start RPC server"); - server.wait(); - }); - - let rpc_addr = receiver.recv().unwrap(); - let rpc_client = RpcClient::new_from_socket(rpc_addr); - - let balance = rpc_client.retry_make_rpc_request( - 1, - &RpcRequest::GetBalance, - Some(json!(["deadbeefXjn8o3yroDHxUtKsZZgoy4GPkPPXfouKNHhw"])), - 10, - ); - assert_eq!(balance.unwrap().as_u64().unwrap(), 5); - } -} diff --git a/core/src/storage_stage.rs b/core/src/storage_stage.rs index 44694ea326..84fa81cd52 100644 --- a/core/src/storage_stage.rs +++ b/core/src/storage_stage.rs @@ -5,7 +5,7 @@ use crate::blocktree::Blocktree; #[cfg(all(feature = "chacha", feature = "cuda"))] use crate::chacha_cuda::chacha_cbc_encrypt_file_many_keys; -use crate::client::mk_client_with_timeout; +use crate::cluster_client::mk_client_with_timeout; use crate::cluster_info::ClusterInfo; use crate::entry::{Entry, EntryReceiver}; use crate::result::{Error, Result}; diff --git a/core/src/voting_keypair.rs b/core/src/voting_keypair.rs index 95ee51da2b..24f5e99376 100644 --- a/core/src/voting_keypair.rs +++ b/core/src/voting_keypair.rs @@ -1,7 +1,7 @@ //! The `vote_signer_proxy` votes on the `blockhash` of the bank at a regular cadence -use crate::rpc_request::{RpcClient, RpcRequest}; use jsonrpc_core; +use solana_client::rpc_request::{RpcClient, RpcRequest}; use solana_sdk::pubkey::Pubkey; use solana_sdk::signature::{Keypair, KeypairUtil, Signature}; use solana_vote_signer::rpc::LocalVoteSigner; diff --git a/tests/replicator.rs b/tests/replicator.rs index d9446e6031..448fc67014 100644 --- a/tests/replicator.rs +++ b/tests/replicator.rs @@ -12,7 +12,7 @@ use bincode::deserialize; use solana::blocktree::{ create_new_tmp_ledger, get_tmp_ledger_path, tmp_copy_blocktree, Blocktree, }; -use solana::client::mk_client; +use solana::cluster_client::mk_client; use solana::cluster_info::{ClusterInfo, Node}; use solana::contact_info::ContactInfo; use solana::entry::Entry; @@ -190,7 +190,7 @@ fn test_replicator_startup_basic() { // chacha is not enabled #[cfg(feature = "chacha")] { - use solana::rpc_request::{RpcClient, RpcRequest, RpcRequestHandler}; + use solana_client::rpc_request::{RpcClient, RpcRequest, RpcRequestHandler}; use std::thread::sleep; info!( diff --git a/tests/rpc.rs b/tests/rpc.rs index ac798ceb9e..588a68dece 100644 --- a/tests/rpc.rs +++ b/tests/rpc.rs @@ -3,8 +3,8 @@ use log::*; use reqwest; use reqwest::header::CONTENT_TYPE; use serde_json::{json, Value}; -use solana::rpc_request::get_rpc_request_str; -use solana::thin_client::new_fullnode; +use solana::fullnode::new_fullnode_for_tests; +use solana_client::rpc_request::get_rpc_request_str; use solana_sdk::hash::Hash; use solana_sdk::signature::{Keypair, KeypairUtil}; use solana_sdk::system_transaction::SystemTransaction; @@ -16,7 +16,7 @@ use std::time::Duration; fn test_rpc_send_tx() { solana_logger::setup(); - let (server, leader_data, alice, ledger_path) = new_fullnode(); + let (server, leader_data, alice, ledger_path) = new_fullnode_for_tests(); let bob_pubkey = Keypair::new().pubkey(); let client = reqwest::Client::new(); diff --git a/wallet/Cargo.toml b/wallet/Cargo.toml index 60af107e49..550fab4362 100644 --- a/wallet/Cargo.toml +++ b/wallet/Cargo.toml @@ -18,11 +18,15 @@ log = "0.4.2" serde_json = "1.0.39" solana = { path = "../core", version = "0.12.1" } solana-budget-api = { path = "../programs/budget_api", version = "0.12.1" } +solana-client = { path = "../client", version = "0.12.1" } solana-drone = { path = "../drone", version = "0.12.1" } solana-logger = { path = "../logger", version = "0.12.1" } solana-sdk = { path = "../sdk", version = "0.12.1" } solana-vote-api = { path = "../programs/vote_api", version = "0.12.1" } solana-vote-signer = { path = "../vote-signer", version = "0.12.1" } +[dev-dependencies] +solana-budget-program = { path = "../programs/budget", version = "0.12.1" } + [features] cuda = ["solana/cuda"] diff --git a/wallet/src/wallet.rs b/wallet/src/wallet.rs index 9c006c32bd..02166bb6cd 100644 --- a/wallet/src/wallet.rs +++ b/wallet/src/wallet.rs @@ -5,15 +5,15 @@ use clap::ArgMatches; use log::*; use serde_json; use serde_json::json; -#[cfg(test)] -use solana::rpc_mock::{request_airdrop_transaction, MockRpcClient as RpcClient}; -#[cfg(not(test))] -use solana::rpc_request::RpcClient; -use solana::rpc_request::{get_rpc_request_str, RpcRequest}; use solana::rpc_service::RPC_PORT; use solana::rpc_status::RpcSignatureStatus; use solana_budget_api; use solana_budget_api::budget_transaction::BudgetTransaction; +#[cfg(test)] +use solana_client::rpc_mock::{request_airdrop_transaction, MockRpcClient as RpcClient}; +#[cfg(not(test))] +use solana_client::rpc_request::RpcClient; +use solana_client::rpc_request::{get_rpc_request_str, RpcRequest}; #[cfg(not(test))] use solana_drone::drone::request_airdrop_transaction; use solana_drone::drone::DRONE_PORT; @@ -996,8 +996,8 @@ mod tests { use super::*; use clap::{App, Arg, ArgGroup, SubCommand}; use serde_json::Value; - use solana::rpc_mock::{PUBKEY, SIGNATURE}; use solana::socketaddr; + use solana_client::rpc_mock::{PUBKEY, SIGNATURE}; use solana_sdk::signature::{gen_keypair_file, read_keypair, read_pkcs8, Keypair, KeypairUtil}; use std::fs; use std::net::{Ipv4Addr, SocketAddr}; diff --git a/wallet/tests/deploy.rs b/wallet/tests/deploy.rs index 91bfa3f330..a9eea663c7 100644 --- a/wallet/tests/deploy.rs +++ b/wallet/tests/deploy.rs @@ -1,6 +1,6 @@ use serde_json::{json, Value}; -use solana::rpc_request::{RpcClient, RpcRequest, RpcRequestHandler}; -use solana::thin_client::new_fullnode; +use solana::fullnode::new_fullnode_for_tests; +use solana_client::rpc_request::{RpcClient, RpcRequest, RpcRequestHandler}; use solana_drone::drone::run_local_drone; use solana_sdk::bpf_loader; use solana_wallet::wallet::{process_command, WalletCommand, WalletConfig}; @@ -19,7 +19,7 @@ fn test_wallet_deploy_program() { pathbuf.push("noop"); pathbuf.set_extension("so"); - let (server, leader_data, alice, ledger_path) = new_fullnode(); + let (server, leader_data, alice, ledger_path) = new_fullnode_for_tests(); let (sender, receiver) = channel(); run_local_drone(alice, sender); diff --git a/wallet/tests/pay.rs b/wallet/tests/pay.rs index 1f72fb1d2f..0dd950e387 100644 --- a/wallet/tests/pay.rs +++ b/wallet/tests/pay.rs @@ -1,6 +1,6 @@ use chrono::prelude::*; use serde_json::Value; -use solana::rpc_request::RpcClient; +use solana_client::rpc_request::RpcClient; use solana_drone::drone::run_local_drone; use solana_sdk::pubkey::Pubkey; use solana_sdk::signature::{Keypair, KeypairUtil}; @@ -11,7 +11,7 @@ use std::fs::remove_dir_all; use std::sync::mpsc::channel; #[cfg(test)] -use solana::thin_client::new_fullnode; +use solana::fullnode::new_fullnode_for_tests; fn check_balance(expected_balance: u64, client: &RpcClient, pubkey: &Pubkey) { let balance = client.retry_get_balance(1, pubkey, 1).unwrap().unwrap(); @@ -20,7 +20,7 @@ fn check_balance(expected_balance: u64, client: &RpcClient, pubkey: &Pubkey) { #[test] fn test_wallet_timestamp_tx() { - let (server, leader_data, alice, ledger_path) = new_fullnode(); + let (server, leader_data, alice, ledger_path) = new_fullnode_for_tests(); let bob_pubkey = Keypair::new().pubkey(); let (sender, receiver) = channel(); @@ -80,7 +80,7 @@ fn test_wallet_timestamp_tx() { #[test] fn test_wallet_witness_tx() { - let (server, leader_data, alice, ledger_path) = new_fullnode(); + let (server, leader_data, alice, ledger_path) = new_fullnode_for_tests(); let bob_pubkey = Keypair::new().pubkey(); let (sender, receiver) = channel(); @@ -137,7 +137,7 @@ fn test_wallet_witness_tx() { #[test] fn test_wallet_cancel_tx() { - let (server, leader_data, alice, ledger_path) = new_fullnode(); + let (server, leader_data, alice, ledger_path) = new_fullnode_for_tests(); let bob_pubkey = Keypair::new().pubkey(); let (sender, receiver) = channel(); diff --git a/wallet/tests/request_airdrop.rs b/wallet/tests/request_airdrop.rs index 2c3153a5f1..5d723b09fa 100644 --- a/wallet/tests/request_airdrop.rs +++ b/wallet/tests/request_airdrop.rs @@ -1,5 +1,5 @@ -use solana::rpc_request::RpcClient; -use solana::thin_client::new_fullnode; +use solana::fullnode::new_fullnode_for_tests; +use solana_client::rpc_request::RpcClient; use solana_drone::drone::run_local_drone; use solana_sdk::signature::KeypairUtil; use solana_wallet::wallet::{process_command, WalletCommand, WalletConfig}; @@ -8,7 +8,7 @@ use std::sync::mpsc::channel; #[test] fn test_wallet_request_airdrop() { - let (server, leader_data, alice, ledger_path) = new_fullnode(); + let (server, leader_data, alice, ledger_path) = new_fullnode_for_tests(); let (sender, receiver) = channel(); run_local_drone(alice, sender); let drone_addr = receiver.recv().unwrap();