Revert solana-tokens to RpcClient (#13623)

* Revert solana-tokens to RpcClient

* Fixup check_payer_balances tests

* Use RpcClient::new_with_commitment in other tests

Co-authored-by: Tyera Eulberg <tyera@solana.com>
This commit is contained in:
Greg Fitzgerald 2020-11-17 14:53:49 -07:00 committed by GitHub
parent 645598e615
commit 47fbfc52de
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 480 additions and 483 deletions

5
Cargo.lock generated
View File

@ -4958,8 +4958,6 @@ dependencies = [
"indicatif",
"pickledb",
"serde",
"solana-banks-client",
"solana-banks-server",
"solana-clap-utils",
"solana-cli-config",
"solana-client",
@ -4969,10 +4967,9 @@ dependencies = [
"solana-runtime",
"solana-sdk",
"solana-stake-program",
"solana-transaction-status",
"tempfile",
"thiserror",
"tokio 0.3.2",
"url 2.1.1",
]
[[package]]

View File

@ -18,7 +18,6 @@ indexmap = "1.5.1"
indicatif = "0.15.0"
pickledb = "0.4.1"
serde = { version = "1.0", features = ["derive"] }
solana-banks-client = { path = "../banks-client", version = "1.5.0" }
solana-clap-utils = { path = "../clap-utils", version = "1.5.0" }
solana-cli-config = { path = "../cli-config", version = "1.5.0" }
solana-client = { path = "../client", version = "1.5.0" }
@ -26,14 +25,11 @@ solana-remote-wallet = { path = "../remote-wallet", version = "1.5.0" }
solana-runtime = { path = "../runtime", version = "1.5.0" }
solana-sdk = { path = "../sdk", version = "1.5.0" }
solana-stake-program = { path = "../programs/stake", version = "1.5.0" }
solana-transaction-status = { path = "../transaction-status", version = "1.5.0" }
tempfile = "3.1.0"
thiserror = "1.0"
tokio = { version = "0.3", features = ["full"] }
url = "2.1"
[dev-dependencies]
bincode = "1.3.1"
solana-banks-server = { path = "../banks-server", version = "1.5.0" }
solana-core = { path = "../core", version = "1.5.0" }
solana-logger = { path = "../logger", version = "1.5.0" }
solana-runtime = { path = "../runtime", version = "1.5.0" }

File diff suppressed because it is too large Load Diff

View File

@ -1,8 +1,8 @@
use chrono::prelude::*;
use pickledb::{error::Error, PickleDb, PickleDbDumpPolicy};
use serde::{Deserialize, Serialize};
use solana_banks_client::TransactionStatus;
use solana_sdk::{clock::Slot, pubkey::Pubkey, signature::Signature, transaction::Transaction};
use solana_transaction_status::TransactionStatus;
use std::{cmp::Ordering, fs, io, path::Path};
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq)]
@ -306,6 +306,7 @@ mod tests {
slot: 0,
confirmations: Some(1),
err: None,
status: Ok(()),
};
assert_eq!(
update_finalized_transaction(&mut db, &signature, Some(transaction_status), 0, 0)
@ -332,6 +333,7 @@ mod tests {
slot: 0,
confirmations: None,
err: Some(TransactionError::AccountNotFound),
status: Ok(()),
};
assert_eq!(
update_finalized_transaction(&mut db, &signature, Some(transaction_status), 0, 0)
@ -355,6 +357,7 @@ mod tests {
slot: 0,
confirmations: None,
err: None,
status: Ok(()),
};
assert_eq!(
update_finalized_transaction(&mut db, &signature, Some(transaction_status), 0, 0)

View File

@ -1,9 +1,7 @@
use solana_banks_client::start_tcp_client;
use solana_cli_config::{Config, CONFIG_FILE};
use solana_client::rpc_client::RpcClient;
use solana_tokens::{arg_parser::parse_args, args::Command, commands};
use std::{env, error::Error, path::Path, process};
use tokio::runtime::Runtime;
use url::Url;
fn main() -> Result<(), Box<dyn Error>> {
let command_args = parse_args(env::args_os())?;
@ -18,19 +16,14 @@ fn main() -> Result<(), Box<dyn Error>> {
Config::default()
};
let json_rpc_url = command_args.url.unwrap_or(config.json_rpc_url);
let rpc_banks_url = Config::compute_rpc_banks_url(&json_rpc_url);
let url = Url::parse(&rpc_banks_url)?;
let host_port = (url.host_str().unwrap(), url.port().unwrap());
let runtime = Runtime::new().unwrap();
let mut banks_client = runtime.block_on(start_tcp_client(&host_port))?;
let client = RpcClient::new(json_rpc_url);
match command_args.command {
Command::DistributeTokens(args) => {
runtime.block_on(commands::process_allocations(&mut banks_client, &args))?;
commands::process_allocations(&client, &args)?;
}
Command::Balances(args) => {
runtime.block_on(commands::process_balances(&mut banks_client, &args))?;
commands::process_balances(&client, &args)?;
}
Command::TransactionLog(args) => {
commands::process_transaction_log(&args)?;

View File

@ -1,8 +1,7 @@
use solana_banks_client::start_tcp_client;
use solana_client::rpc_client::RpcClient;
use solana_core::test_validator::TestValidator;
use solana_tokens::commands::test_process_distribute_tokens_with_client;
use std::fs::remove_dir_all;
use tokio::runtime::Runtime;
#[test]
fn test_process_distribute_with_rpc_client() {
@ -15,10 +14,8 @@ fn test_process_distribute_with_rpc_client() {
..
} = TestValidator::run();
Runtime::new().unwrap().block_on(async {
let mut banks_client = start_tcp_client(leader_data.rpc_banks).await.unwrap();
test_process_distribute_tokens_with_client(&mut banks_client, alice, None).await
});
let client = RpcClient::new_socket(leader_data.rpc);
test_process_distribute_tokens_with_client(&client, alice, None);
// Explicit cleanup, otherwise "pure virtual method called" crash in Docker
server.close().unwrap();