diff --git a/src/rpc.rs b/src/rpc.rs index 8b44919f1d..4559b5b201 100644 --- a/src/rpc.rs +++ b/src/rpc.rs @@ -372,6 +372,7 @@ mod tests { use mint::Mint; use reqwest; use reqwest::header::CONTENT_TYPE; + use rpc_request::get_rpc_request_str; use solana_sdk::hash::{hash, Hash}; use solana_sdk::signature::{Keypair, KeypairUtil}; use solana_sdk::transaction::Transaction; @@ -418,7 +419,7 @@ mod tests { let thread = rpc_service.thread_hdl.thread(); assert_eq!(thread.name().unwrap(), "solana-jsonrpc"); - let rpc_string = format!("http://{}", rpc_addr.to_string()); + let rpc_string = get_rpc_request_str(rpc_addr); let client = reqwest::Client::new(); let request = json!({ "jsonrpc": "2.0", @@ -662,7 +663,7 @@ mod tests { "params": json!([serial_tx]) }); let rpc_addr = leader_data.rpc; - let rpc_string = format!("http://{}", rpc_addr.to_string()); + let rpc_string = get_rpc_request_str(rpc_addr); let mut response = client .post(&rpc_string) .header(CONTENT_TYPE, "application/json") diff --git a/src/rpc_request.rs b/src/rpc_request.rs index f86121e5dc..9ac36b0bfb 100644 --- a/src/rpc_request.rs +++ b/src/rpc_request.rs @@ -1,8 +1,45 @@ use reqwest; use reqwest::header::CONTENT_TYPE; use serde_json::{self, Value}; +use std::net::SocketAddr; +use std::time::Duration; use std::{error, fmt}; +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); + let client = reqwest::Client::builder() + .timeout(timeout) + .build() + .expect("build rpc client"); + RpcClient { client, addr } + } + + pub fn new_from_socket(addr: SocketAddr) -> Self { + let addr = get_rpc_request_str(addr); + RpcClient { + client: reqwest::Client::new(), + addr, + } + } +} + +pub fn get_rpc_request_str(rpc_addr: SocketAddr) -> String { + format!("http://{}", rpc_addr) +} + pub enum RpcRequest { ConfirmTransaction, GetAccountInfo, @@ -17,20 +54,19 @@ pub enum RpcRequest { SignVote, DeregisterNode, } -pub type RpcClient = reqwest::Client; impl RpcRequest { pub fn make_rpc_request( &self, client: &RpcClient, - rpc_addr: &str, id: u64, params: Option, ) -> Result> { let request = self.build_request_json(id, params); let mut response = client - .post(rpc_addr) + .client + .post(&client.addr) .header(CONTENT_TYPE, "application/json") .body(request.to_string()) .send()?; @@ -177,19 +213,17 @@ mod tests { }); let rpc_addr = receiver.recv().unwrap(); - let rpc_addr = format!("http://{}", rpc_addr.to_string()); - let rpc_client = RpcClient::new(); + let rpc_client = RpcClient::new_from_socket(rpc_addr); let balance = RpcRequest::GetBalance.make_rpc_request( &rpc_client, - &rpc_addr, 1, Some(json!(["deadbeefXjn8o3yroDHxUtKsZZgoy4GPkPPXfouKNHhx"])), ); assert!(balance.is_ok()); assert_eq!(balance.unwrap().as_u64().unwrap(), 50); - let last_id = RpcRequest::GetLastId.make_rpc_request(&rpc_client, &rpc_addr, 2, None); + let last_id = RpcRequest::GetLastId.make_rpc_request(&rpc_client, 2, None); assert!(last_id.is_ok()); assert_eq!( last_id.unwrap().as_str().unwrap(), @@ -197,12 +231,8 @@ mod tests { ); // Send erroneous parameter - let last_id = RpcRequest::GetLastId.make_rpc_request( - &rpc_client, - &rpc_addr, - 3, - Some(json!("paramter")), - ); + let last_id = + RpcRequest::GetLastId.make_rpc_request(&rpc_client, 3, Some(json!("paramter"))); assert_eq!(last_id.is_err(), true); } } diff --git a/src/thin_client.rs b/src/thin_client.rs index 25a63554ff..ac0312ef76 100644 --- a/src/thin_client.rs +++ b/src/thin_client.rs @@ -10,7 +10,6 @@ use cluster_info::{ClusterInfo, ClusterInfoError, NodeInfo}; use log::Level; use ncp::Ncp; use packet::PACKET_DATA_SIZE; -use reqwest; use result::{Error, Result}; use rpc_request::{RpcClient, RpcRequest}; use serde_json; @@ -59,7 +58,7 @@ impl ThinClient { rpc_addr, transactions_addr, transactions_socket, - RpcClient::new(), + RpcClient::new_from_socket(rpc_addr), ) } @@ -69,10 +68,7 @@ impl ThinClient { transactions_socket: UdpSocket, timeout: Duration, ) -> Self { - let rpc_client = reqwest::Client::builder() - .timeout(timeout) - .build() - .expect("build rpc client"); + let rpc_client = RpcClient::new_with_timeout(rpc_addr, timeout); Self::new_from_client(rpc_addr, transactions_addr, transactions_socket, rpc_client) } @@ -152,13 +148,7 @@ impl ThinClient { pub fn get_account_userdata(&mut self, pubkey: &Pubkey) -> io::Result>> { let params = json!([format!("{}", pubkey)]); - let rpc_string = format!("http://{}", self.rpc_addr.to_string()); - let resp = RpcRequest::GetAccountInfo.make_rpc_request( - &self.rpc_client, - &rpc_string, - 1, - Some(params), - ); + let resp = RpcRequest::GetAccountInfo.make_rpc_request(&self.rpc_client, 1, Some(params)); if let Ok(account_json) = resp { let account: Account = serde_json::from_value(account_json).expect("deserialize account"); @@ -176,13 +166,7 @@ impl ThinClient { pub fn get_balance(&mut self, pubkey: &Pubkey) -> io::Result { trace!("get_balance sending request to {}", self.rpc_addr); let params = json!([format!("{}", pubkey)]); - let rpc_string = format!("http://{}", self.rpc_addr.to_string()); - let resp = RpcRequest::GetAccountInfo.make_rpc_request( - &self.rpc_client, - &rpc_string, - 1, - Some(params), - ); + let resp = RpcRequest::GetAccountInfo.make_rpc_request(&self.rpc_client, 1, Some(params)); if let Ok(account_json) = resp { let account: Account = serde_json::from_value(account_json).expect("deserialize account"); @@ -206,11 +190,9 @@ impl ThinClient { pub fn get_finality(&mut self) -> usize { trace!("get_finality"); let mut done = false; - let rpc_string = format!("http://{}", self.rpc_addr.to_string()); while !done { debug!("get_finality send_to {}", &self.rpc_addr); - let resp = - RpcRequest::GetFinality.make_rpc_request(&self.rpc_client, &rpc_string, 1, None); + let resp = RpcRequest::GetFinality.make_rpc_request(&self.rpc_client, 1, None); if let Ok(value) = resp { done = true; @@ -228,14 +210,8 @@ impl ThinClient { pub fn transaction_count(&mut self) -> u64 { debug!("transaction_count"); let mut tries_left = 5; - let rpc_string = format!("http://{}", self.rpc_addr.to_string()); while tries_left > 0 { - let resp = RpcRequest::GetTransactionCount.make_rpc_request( - &self.rpc_client, - &rpc_string, - 1, - None, - ); + let resp = RpcRequest::GetTransactionCount.make_rpc_request(&self.rpc_client, 1, None); if let Ok(value) = resp { debug!("transaction_count recv_response: {:?}", value); @@ -254,11 +230,9 @@ impl ThinClient { pub fn get_last_id(&mut self) -> Hash { trace!("get_last_id"); let mut done = false; - let rpc_string = format!("http://{}", self.rpc_addr.to_string()); while !done { debug!("get_last_id send_to {}", &self.rpc_addr); - let resp = - RpcRequest::GetLastId.make_rpc_request(&self.rpc_client, &rpc_string, 1, None); + let resp = RpcRequest::GetLastId.make_rpc_request(&self.rpc_client, 1, None); if let Ok(value) = resp { done = true; @@ -331,12 +305,10 @@ impl ThinClient { trace!("check_signature"); let params = json!([format!("{}", signature)]); let now = Instant::now(); - let rpc_string = format!("http://{}", self.rpc_addr.to_string()); let mut done = false; while !done { let resp = RpcRequest::ConfirmTransaction.make_rpc_request( &self.rpc_client, - &rpc_string, 1, Some(params.clone()), ); diff --git a/src/wallet.rs b/src/wallet.rs index 67da04400d..01fbe456e0 100644 --- a/src/wallet.rs +++ b/src/wallet.rs @@ -11,7 +11,7 @@ use loader_transaction::LoaderTransaction; use ring::rand::SystemRandom; use ring::signature::Ed25519KeyPair; use rpc::RpcSignatureStatus; -use rpc_request::{RpcClient, RpcRequest}; +use rpc_request::{get_rpc_request_str, RpcClient, RpcRequest}; use serde_json; use solana_drone::drone::{request_airdrop_transaction, DRONE_PORT}; use solana_sdk::hash::Hash; @@ -112,7 +112,7 @@ impl WalletConfig { } pub fn rpc_addr(&self, rpc_addr: SocketAddr) -> String { - let rpc_addr_str = format!("http://{}", rpc_addr.to_string()); + let rpc_addr_str = get_rpc_request_str(rpc_addr); self.proxy.clone().unwrap_or(rpc_addr_str) } } @@ -318,7 +318,7 @@ pub fn process_command(config: &WalletConfig) -> Result Result tokens, @@ -340,14 +340,14 @@ pub fn process_command(config: &WalletConfig) -> Result Result Ok("No account found! Request an airdrop to get started.".to_string()), @@ -373,17 +373,17 @@ pub fn process_command(config: &WalletConfig) -> Result { - let last_id = get_last_id(&rpc_client, &rpc_addr)?; + let last_id = get_last_id(&rpc_client)?; let tx = Transaction::budget_new_signature(&config.id, pubkey, config.id.pubkey(), last_id); - let signature_str = send_tx(&rpc_client, &rpc_addr, &tx)?; + let signature_str = send_tx(&rpc_client, &tx)?; Ok(signature_str.to_string()) } // Confirm the last client transaction by signature WalletCommand::Confirm(signature) => { let params = json!([format!("{}", signature)]); let confirmation = RpcRequest::ConfirmTransaction - .make_rpc_request(&rpc_client, &rpc_addr, 1, Some(params))? + .make_rpc_request(&rpc_client, 1, Some(params))? .as_bool(); match confirmation { Some(b) => { @@ -402,7 +402,7 @@ pub fn process_command(config: &WalletConfig) -> Result { let params = json!([format!("{}", config.id.pubkey())]); let balance = RpcRequest::GetBalance - .make_rpc_request(&rpc_client, &rpc_addr, 1, Some(params))? + .make_rpc_request(&rpc_client, 1, Some(params))? .as_u64(); if let Some(tokens) = balance { if tokens < 1 { @@ -412,7 +412,7 @@ pub fn process_command(config: &WalletConfig) -> Result Result Result Result Result { let transaction_count = RpcRequest::GetTransactionCount - .make_rpc_request(&rpc_client, &rpc_addr, 1, None)? + .make_rpc_request(&rpc_client, 1, None)? .as_u64(); match transaction_count { Some(count) => Ok(count.to_string()), @@ -485,11 +485,11 @@ pub fn process_command(config: &WalletConfig) -> Result { - let last_id = get_last_id(&rpc_client, &rpc_addr)?; + let last_id = get_last_id(&rpc_client)?; if timestamp == None && *witnesses == None { let tx = Transaction::system_new(&config.id, to, tokens, last_id); - let signature_str = send_tx(&rpc_client, &rpc_addr, &tx)?; + let signature_str = send_tx(&rpc_client, &tx)?; Ok(signature_str.to_string()) } else if *witnesses == None { let dt = timestamp.unwrap(); @@ -512,7 +512,7 @@ pub fn process_command(config: &WalletConfig) -> Result Result Result Result Result Result Result { let params = json!(format!("{}", config.id.pubkey())); let balance = RpcRequest::GetBalance - .make_rpc_request(&rpc_client, &rpc_addr, 1, Some(params))? + .make_rpc_request(&rpc_client, 1, Some(params))? .as_u64(); if let Some(0) = balance { let params = json!([format!("{}", config.id.pubkey()), 1]); RpcRequest::RequestAirdrop - .make_rpc_request(&rpc_client, &rpc_addr, 1, Some(params)) + .make_rpc_request(&rpc_client, 1, Some(params)) .unwrap(); } - let last_id = get_last_id(&rpc_client, &rpc_addr)?; + let last_id = get_last_id(&rpc_client)?; let tx = Transaction::budget_new_timestamp(&config.id, pubkey, to, dt, last_id); - let signature_str = send_tx(&rpc_client, &rpc_addr, &tx)?; + let signature_str = send_tx(&rpc_client, &tx)?; Ok(signature_str.to_string()) } @@ -627,19 +627,19 @@ pub fn process_command(config: &WalletConfig) -> Result { let params = json!([format!("{}", config.id.pubkey())]); let balance = RpcRequest::GetBalance - .make_rpc_request(&rpc_client, &rpc_addr, 1, Some(params))? + .make_rpc_request(&rpc_client, 1, Some(params))? .as_u64(); if let Some(0) = balance { let params = json!([format!("{}", config.id.pubkey()), 1]); RpcRequest::RequestAirdrop - .make_rpc_request(&rpc_client, &rpc_addr, 1, Some(params)) + .make_rpc_request(&rpc_client, 1, Some(params)) .unwrap(); } - let last_id = get_last_id(&rpc_client, &rpc_addr)?; + let last_id = get_last_id(&rpc_client)?; let tx = Transaction::budget_new_signature(&config.id, pubkey, to, last_id); - let signature_str = send_tx(&rpc_client, &rpc_addr, &tx)?; + let signature_str = send_tx(&rpc_client, &tx)?; Ok(signature_str.to_string()) } @@ -677,8 +677,8 @@ pub fn gen_keypair_file(outfile: String) -> Result> { Ok(serialized) } -fn get_last_id(rpc_client: &RpcClient, rpc_addr: &str) -> Result> { - let result = RpcRequest::GetLastId.make_rpc_request(rpc_client, &rpc_addr, 1, None)?; +fn get_last_id(rpc_client: &RpcClient) -> Result> { + let result = RpcRequest::GetLastId.make_rpc_request(rpc_client, 1, None)?; if result.as_str().is_none() { Err(WalletError::RpcRequestError( "Received bad last_id".to_string(), @@ -691,15 +691,10 @@ fn get_last_id(rpc_client: &RpcClient, rpc_addr: &str) -> Result Result> { +fn send_tx(rpc_client: &RpcClient, tx: &Transaction) -> Result> { let serialized = serialize(tx).unwrap(); let params = json!([serialized]); - let signature = - RpcRequest::SendTransaction.make_rpc_request(rpc_client, &rpc_addr, 2, Some(params))?; + let signature = RpcRequest::SendTransaction.make_rpc_request(rpc_client, 2, Some(params))?; if signature.as_str().is_none() { Err(WalletError::RpcRequestError( "Received result of an unexpected type".to_string(), @@ -710,12 +705,11 @@ fn send_tx( fn confirm_tx( rpc_client: &RpcClient, - rpc_addr: &str, signature: &str, ) -> Result> { let params = json!([signature.to_string()]); let signature_status = - RpcRequest::GetSignatureStatus.make_rpc_request(rpc_client, &rpc_addr, 1, Some(params))?; + RpcRequest::GetSignatureStatus.make_rpc_request(rpc_client, 1, Some(params))?; if let Some(status) = signature_status.as_str() { let rpc_status = RpcSignatureStatus::from_str(status).map_err(|_| { WalletError::RpcRequestError("Unable to parse signature status".to_string()) @@ -728,17 +722,13 @@ fn confirm_tx( } } -fn send_and_confirm_tx( - rpc_client: &RpcClient, - rpc_addr: &str, - tx: &Transaction, -) -> Result<(), Box> { +fn send_and_confirm_tx(rpc_client: &RpcClient, tx: &Transaction) -> Result<(), Box> { let mut send_retries = 3; while send_retries > 0 { let mut status_retries = 4; - let signature_str = send_tx(rpc_client, rpc_addr, tx)?; + let signature_str = send_tx(rpc_client, tx)?; let status = loop { - let status = confirm_tx(rpc_client, rpc_addr, &signature_str)?; + let status = confirm_tx(rpc_client, &signature_str)?; if status == RpcSignatureStatus::SignatureNotFound { status_retries -= 1; if status_retries == 0 { @@ -1216,12 +1206,11 @@ mod tests { let sig_response = process_command(&bob_config); assert!(sig_response.is_ok()); - let rpc_addr = format!("http://{}", leader_data.rpc.to_string()); - let rpc_client = RpcClient::new(); + let rpc_client = RpcClient::new_from_socket(leader_data.rpc); let params = json!([format!("{}", bob_config.id.pubkey())]); let balance = RpcRequest::GetBalance - .make_rpc_request(&rpc_client, &rpc_addr, 1, Some(params)) + .make_rpc_request(&rpc_client, 1, Some(params)) .unwrap() .as_u64() .unwrap(); @@ -1290,8 +1279,7 @@ mod tests { run_local_drone(alice.keypair(), sender); let drone_addr = receiver.recv().unwrap(); - let rpc_addr = format!("http://{}", leader_data.rpc.to_string()); - let rpc_client = RpcClient::new(); + let rpc_client = RpcClient::new_from_socket(leader_data.rpc); let mut config_payer = WalletConfig::default(); config_payer.network = leader_data.ncp; @@ -1303,11 +1291,11 @@ mod tests { assert_ne!(config_payer.id.pubkey(), config_witness.id.pubkey()); - let last_id = get_last_id(&rpc_client, &rpc_addr).unwrap(); + let last_id = get_last_id(&rpc_client).unwrap(); let transaction = request_airdrop_transaction(&drone_addr, &config_payer.id.pubkey(), 50, last_id) .unwrap(); - send_and_confirm_tx(&rpc_client, &rpc_addr, &transaction).unwrap(); + send_and_confirm_tx(&rpc_client, &transaction).unwrap(); // Make transaction (from config_payer to bob_pubkey) requiring timestamp from config_witness let date_string = "\"2018-09-19T17:30:59Z\""; @@ -1332,21 +1320,21 @@ mod tests { let params = json!([format!("{}", config_payer.id.pubkey())]); let config_payer_balance = RpcRequest::GetBalance - .make_rpc_request(&rpc_client, &rpc_addr, 1, Some(params)) + .make_rpc_request(&rpc_client, 1, Some(params)) .unwrap() .as_u64() .unwrap(); assert_eq!(config_payer_balance, 39); let params = json!([format!("{}", process_id)]); let contract_balance = RpcRequest::GetBalance - .make_rpc_request(&rpc_client, &rpc_addr, 1, Some(params)) + .make_rpc_request(&rpc_client, 1, Some(params)) .unwrap() .as_u64() .unwrap(); assert_eq!(contract_balance, 11); let params = json!([format!("{}", bob_pubkey)]); let recipient_balance = RpcRequest::GetBalance - .make_rpc_request(&rpc_client, &rpc_addr, 1, Some(params)) + .make_rpc_request(&rpc_client, 1, Some(params)) .unwrap() .as_u64() .unwrap(); @@ -1359,21 +1347,21 @@ mod tests { let params = json!([format!("{}", config_payer.id.pubkey())]); let config_payer_balance = RpcRequest::GetBalance - .make_rpc_request(&rpc_client, &rpc_addr, 1, Some(params)) + .make_rpc_request(&rpc_client, 1, Some(params)) .unwrap() .as_u64() .unwrap(); assert_eq!(config_payer_balance, 39); let params = json!([format!("{}", process_id)]); let contract_balance = RpcRequest::GetBalance - .make_rpc_request(&rpc_client, &rpc_addr, 1, Some(params)) + .make_rpc_request(&rpc_client, 1, Some(params)) .unwrap() .as_u64() .unwrap(); assert_eq!(contract_balance, 1); let params = json!([format!("{}", bob_pubkey)]); let recipient_balance = RpcRequest::GetBalance - .make_rpc_request(&rpc_client, &rpc_addr, 1, Some(params)) + .make_rpc_request(&rpc_client, 1, Some(params)) .unwrap() .as_u64() .unwrap(); @@ -1419,16 +1407,15 @@ mod tests { run_local_drone(alice.keypair(), sender); let drone_addr = receiver.recv().unwrap(); - let rpc_addr = format!("http://{}", leader_data.rpc.to_string()); - let rpc_client = RpcClient::new(); + let rpc_client = RpcClient::new_from_socket(leader_data.rpc); assert_ne!(config_payer.id.pubkey(), config_witness.id.pubkey()); - let last_id = get_last_id(&rpc_client, &rpc_addr).unwrap(); + let last_id = get_last_id(&rpc_client).unwrap(); let transaction = request_airdrop_transaction(&drone_addr, &config_payer.id.pubkey(), 50, last_id) .unwrap(); - send_and_confirm_tx(&rpc_client, &rpc_addr, &transaction).unwrap(); + send_and_confirm_tx(&rpc_client, &transaction).unwrap(); // Make transaction (from config_payer to bob_pubkey) requiring witness signature from config_witness config_payer.command = WalletCommand::Pay( @@ -1451,21 +1438,21 @@ mod tests { let params = json!([format!("{}", config_payer.id.pubkey())]); let config_payer_balance = RpcRequest::GetBalance - .make_rpc_request(&rpc_client, &rpc_addr, 1, Some(params)) + .make_rpc_request(&rpc_client, 1, Some(params)) .unwrap() .as_u64() .unwrap(); assert_eq!(config_payer_balance, 39); let params = json!([format!("{}", process_id)]); let contract_balance = RpcRequest::GetBalance - .make_rpc_request(&rpc_client, &rpc_addr, 1, Some(params)) + .make_rpc_request(&rpc_client, 1, Some(params)) .unwrap() .as_u64() .unwrap(); assert_eq!(contract_balance, 11); let params = json!([format!("{}", bob_pubkey)]); let recipient_balance = RpcRequest::GetBalance - .make_rpc_request(&rpc_client, &rpc_addr, 1, Some(params)) + .make_rpc_request(&rpc_client, 1, Some(params)) .unwrap() .as_u64() .unwrap(); @@ -1478,21 +1465,21 @@ mod tests { let params = json!([format!("{}", config_payer.id.pubkey())]); let config_payer_balance = RpcRequest::GetBalance - .make_rpc_request(&rpc_client, &rpc_addr, 1, Some(params)) + .make_rpc_request(&rpc_client, 1, Some(params)) .unwrap() .as_u64() .unwrap(); assert_eq!(config_payer_balance, 39); let params = json!([format!("{}", process_id)]); let contract_balance = RpcRequest::GetBalance - .make_rpc_request(&rpc_client, &rpc_addr, 1, Some(params)) + .make_rpc_request(&rpc_client, 1, Some(params)) .unwrap() .as_u64() .unwrap(); assert_eq!(contract_balance, 1); let params = json!([format!("{}", bob_pubkey)]); let recipient_balance = RpcRequest::GetBalance - .make_rpc_request(&rpc_client, &rpc_addr, 1, Some(params)) + .make_rpc_request(&rpc_client, 1, Some(params)) .unwrap() .as_u64() .unwrap(); @@ -1537,8 +1524,7 @@ mod tests { run_local_drone(alice.keypair(), sender); let drone_addr = receiver.recv().unwrap(); - let rpc_addr = format!("http://{}", leader_data.rpc.to_string()); - let rpc_client = RpcClient::new(); + let rpc_client = RpcClient::new_from_socket(leader_data.rpc); let mut config_payer = WalletConfig::default(); config_payer.network = leader_data.ncp; @@ -1550,11 +1536,11 @@ mod tests { assert_ne!(config_payer.id.pubkey(), config_witness.id.pubkey()); - let last_id = get_last_id(&rpc_client, &rpc_addr).unwrap(); + let last_id = get_last_id(&rpc_client).unwrap(); let transaction = request_airdrop_transaction(&drone_addr, &config_payer.id.pubkey(), 50, last_id) .unwrap(); - send_and_confirm_tx(&rpc_client, &rpc_addr, &transaction).unwrap(); + send_and_confirm_tx(&rpc_client, &transaction).unwrap(); // Make transaction (from config_payer to bob_pubkey) requiring witness signature from config_witness config_payer.command = WalletCommand::Pay( @@ -1577,21 +1563,21 @@ mod tests { let params = json!([format!("{}", config_payer.id.pubkey())]); let config_payer_balance = RpcRequest::GetBalance - .make_rpc_request(&rpc_client, &rpc_addr, 1, Some(params)) + .make_rpc_request(&rpc_client, 1, Some(params)) .unwrap() .as_u64() .unwrap(); assert_eq!(config_payer_balance, 39); let params = json!([format!("{}", process_id)]); let contract_balance = RpcRequest::GetBalance - .make_rpc_request(&rpc_client, &rpc_addr, 1, Some(params)) + .make_rpc_request(&rpc_client, 1, Some(params)) .unwrap() .as_u64() .unwrap(); assert_eq!(contract_balance, 11); let params = json!([format!("{}", bob_pubkey)]); let recipient_balance = RpcRequest::GetBalance - .make_rpc_request(&rpc_client, &rpc_addr, 1, Some(params)) + .make_rpc_request(&rpc_client, 1, Some(params)) .unwrap() .as_u64() .unwrap(); @@ -1604,21 +1590,21 @@ mod tests { let params = json!([format!("{}", config_payer.id.pubkey())]); let config_payer_balance = RpcRequest::GetBalance - .make_rpc_request(&rpc_client, &rpc_addr, 1, Some(params)) + .make_rpc_request(&rpc_client, 1, Some(params)) .unwrap() .as_u64() .unwrap(); assert_eq!(config_payer_balance, 49); let params = json!([format!("{}", process_id)]); let contract_balance = RpcRequest::GetBalance - .make_rpc_request(&rpc_client, &rpc_addr, 1, Some(params)) + .make_rpc_request(&rpc_client, 1, Some(params)) .unwrap() .as_u64() .unwrap(); assert_eq!(contract_balance, 1); let params = json!([format!("{}", bob_pubkey)]); let recipient_balance = RpcRequest::GetBalance - .make_rpc_request(&rpc_client, &rpc_addr, 1, Some(params)) + .make_rpc_request(&rpc_client, 1, Some(params)) .unwrap() .as_u64() .unwrap();