Skip to content

Commit

Permalink
v2.1: make new_from_bank to be only for tests (backport of #3455) (#3484
Browse files Browse the repository at this point in the history
)

make new_from_bank to be only for tests (#3455)

* make new_from_bank to be only for tests

* moved unnecessary use to cfg(test)

* remove new line which breaks checks

(cherry picked from commit 4e7f7f7)

Co-authored-by: kirill lykov <[email protected]>
  • Loading branch information
mergify[bot] and KirillLykov authored Nov 7, 2024
1 parent 95ee9c1 commit c1bddce
Showing 1 changed file with 23 additions and 13 deletions.
36 changes: 23 additions & 13 deletions rpc/src/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ use {
accounts::AccountAddressFilter,
accounts_index::{AccountIndex, AccountSecondaryIndexes, IndexKey, ScanConfig},
},
solana_client::connection_cache::{ConnectionCache, Protocol},
solana_client::connection_cache::Protocol,
solana_entry::entry::Entry,
solana_faucet::faucet::request_airdrop_transaction,
solana_feature_set as feature_set,
solana_gossip::{cluster_info::ClusterInfo, contact_info::ContactInfo},
solana_gossip::cluster_info::ClusterInfo,
solana_inline_spl::{
token::{SPL_TOKEN_ACCOUNT_MINT_OFFSET, SPL_TOKEN_ACCOUNT_OWNER_OFFSET},
token_2022::{self, ACCOUNTTYPE_ACCOUNT},
Expand All @@ -33,7 +33,6 @@ use {
blockstore::{Blockstore, SignatureInfosForAddress},
blockstore_db::BlockstoreError,
blockstore_meta::{PerfSample, PerfSampleV1, PerfSampleV2},
get_tmp_ledger_path,
leader_schedule_cache::LeaderScheduleCache,
},
solana_metrics::inc_new_counter_info,
Expand All @@ -54,7 +53,7 @@ use {
solana_runtime::{
bank::{Bank, TransactionSimulationResult},
bank_forks::BankForks,
commitment::{BlockCommitmentArray, BlockCommitmentCache, CommitmentSlots},
commitment::{BlockCommitmentArray, BlockCommitmentCache},
installed_scheduler_pool::BankWithScheduler,
non_circulating_supply::calculate_non_circulating_supply,
prioritization_fee_cache::PrioritizationFeeCache,
Expand All @@ -80,13 +79,9 @@ use {
VersionedTransaction, MAX_TX_ACCOUNT_LOCKS,
},
},
solana_send_transaction_service::{
send_transaction_service::{SendTransactionService, TransactionInfo},
tpu_info::NullTpuInfo,
},
solana_send_transaction_service::send_transaction_service::TransactionInfo,
solana_stake_program,
solana_storage_bigtable::Error as StorageError,
solana_streamer::socket::SocketAddrSpace,
solana_transaction_status::{
map_inner_instructions, BlockEncodingOptions, ConfirmedBlock,
ConfirmedTransactionStatusWithSignature, ConfirmedTransactionWithStatusMeta,
Expand Down Expand Up @@ -117,6 +112,17 @@ use {
time::Duration,
},
};
#[cfg(test)]
use {
solana_client::connection_cache::ConnectionCache,
solana_gossip::contact_info::ContactInfo,
solana_ledger::get_tmp_ledger_path,
solana_runtime::commitment::CommitmentSlots,
solana_send_transaction_service::{
send_transaction_service::SendTransactionService, tpu_info::NullTpuInfo,
},
solana_streamer::socket::SocketAddrSpace,
};

pub mod account_resolver;

Expand Down Expand Up @@ -348,7 +354,7 @@ impl JsonRpcRequestProcessor {
)
}

// Useful for unit testing
#[cfg(test)]
pub fn new_from_bank(
bank: Bank,
socket_addr_space: SocketAddrSpace,
Expand Down Expand Up @@ -4332,11 +4338,12 @@ pub mod tests {
serde::de::DeserializeOwned,
solana_accounts_db::accounts_db::{AccountsDbConfig, ACCOUNTS_DB_CONFIG_FOR_TESTING},
solana_entry::entry::next_versioned_entry,
solana_gossip::socketaddr,
solana_gossip::{contact_info::ContactInfo, socketaddr},
solana_ledger::{
blockstore_meta::PerfSampleV2,
blockstore_processor::fill_blockstore_slot_with_ticks,
genesis_utils::{create_genesis_config, GenesisConfigInfo},
get_tmp_ledger_path,
},
solana_rpc_client_api::{
custom_error::{
Expand All @@ -4347,8 +4354,10 @@ pub mod tests {
filter::MemcmpEncodedBytes,
},
solana_runtime::{
accounts_background_service::AbsRequestSender, bank::BankTestConfig,
commitment::BlockCommitment, non_circulating_supply::non_circulating_accounts,
accounts_background_service::AbsRequestSender,
bank::BankTestConfig,
commitment::{BlockCommitment, CommitmentSlots},
non_circulating_supply::non_circulating_accounts,
},
solana_sdk::{
account::{Account, WritableAccount},
Expand Down Expand Up @@ -4376,6 +4385,7 @@ pub mod tests {
},
vote::state::VoteState,
},
solana_send_transaction_service::tpu_info::NullTpuInfo,
solana_transaction_status::{
EncodedConfirmedBlock, EncodedTransaction, EncodedTransactionWithStatusMeta,
TransactionDetails,
Expand Down

0 comments on commit c1bddce

Please sign in to comment.