Skip to content

Commit 8cf8e5e

Browse files
committed
various fixes to tests by having additional funds
1 parent be4bd0c commit 8cf8e5e

File tree

5 files changed

+21
-14
lines changed

5 files changed

+21
-14
lines changed

banks-client/src/lib.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -557,7 +557,7 @@ mod tests {
557557
// It creates a runtime explicitly (no globals via tokio macros) and calls
558558
// `runtime.block_on()` just once, to run all the async code.
559559

560-
let genesis = create_genesis_config(10);
560+
let genesis = create_genesis_config(10_000_000_000);
561561
let bank = Bank::new_for_tests(&genesis.genesis_config);
562562
let slot = bank.slot();
563563
let block_commitment_cache = Arc::new(RwLock::new(
@@ -596,7 +596,7 @@ mod tests {
596596
// is processed (or blockhash expires). In this test, we verify the
597597
// server-side functionality is available to the client.
598598

599-
let genesis = create_genesis_config(10);
599+
let genesis = create_genesis_config(10_000_000_000);
600600
let bank = Bank::new_for_tests(&genesis.genesis_config);
601601
let slot = bank.slot();
602602
let block_commitment_cache = Arc::new(RwLock::new(

bench-tps/tests/bench_tps.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ fn test_bench_tps_test_validator(config: Config) {
142142
.expect("Should build Quic Tpu Client."),
143143
);
144144

145-
let lamports_per_account = 1000;
145+
let lamports_per_account = 20000;
146146

147147
let keypair_count = config.tx_count * config.keypair_multiplier;
148148
let keypairs = generate_and_fund_keypairs(

local-cluster/src/integration_tests.rs

-4
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@ use {
6363
pub const RUST_LOG_FILTER: &str =
6464
"error,solana_core::replay_stage=warn,solana_local_cluster=info,local_cluster=info";
6565

66-
pub const DEFAULT_CLUSTER_LAMPORTS: u64 = 10_000_000 * LAMPORTS_PER_SOL;
6766
pub const DEFAULT_NODE_STAKE: u64 = 10 * LAMPORTS_PER_SOL;
6867

6968
pub fn last_vote_in_tower(tower_path: &Path, node_pubkey: &Pubkey) -> Option<(Slot, Hash)> {
@@ -319,7 +318,6 @@ pub fn run_cluster_partition<C>(
319318
.map(|stake_weight| 100 * *stake_weight as u64)
320319
.collect();
321320
assert_eq!(node_stakes.len(), num_nodes);
322-
let cluster_lamports = node_stakes.iter().sum::<u64>() * 2;
323321
let turbine_disabled = Arc::new(AtomicBool::new(false));
324322
let mut validator_config = ValidatorConfig {
325323
turbine_disabled: turbine_disabled.clone(),
@@ -351,7 +349,6 @@ pub fn run_cluster_partition<C>(
351349

352350
let slots_per_epoch = 2048;
353351
let mut config = ClusterConfig {
354-
cluster_lamports,
355352
node_stakes,
356353
validator_configs: make_identical_validator_configs(&validator_config, num_nodes),
357354
validator_keys: Some(
@@ -490,7 +487,6 @@ pub fn test_faulty_node(
490487
}
491488

492489
let mut cluster_config = ClusterConfig {
493-
cluster_lamports: 10_000,
494490
node_stakes,
495491
validator_configs,
496492
validator_keys: Some(validator_keys.clone()),

local-cluster/src/local_cluster.rs

+16-5
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ use {
3535
epoch_schedule::EpochSchedule,
3636
genesis_config::{ClusterType, GenesisConfig},
3737
message::Message,
38+
native_token::LAMPORTS_PER_SOL,
3839
poh_config::PohConfig,
3940
pubkey::Pubkey,
4041
signature::{Keypair, Signature, Signer},
@@ -69,6 +70,7 @@ use {
6970
};
7071

7172
const DUMMY_SNAPSHOT_CONFIG_PATH_MARKER: &str = "dummy";
73+
pub const DEFAULT_CLUSTER_LAMPORTS: u64 = 10_000_000 * LAMPORTS_PER_SOL;
7274

7375
pub struct ClusterConfig {
7476
/// The validator config that should be applied to every node in the cluster
@@ -126,7 +128,7 @@ impl Default for ClusterConfig {
126128
validator_keys: None,
127129
node_stakes: vec![],
128130
node_vote_keys: None,
129-
cluster_lamports: 0,
131+
cluster_lamports: DEFAULT_CLUSTER_LAMPORTS,
130132
ticks_per_slot: DEFAULT_TICKS_PER_SLOT,
131133
slots_per_epoch: DEFAULT_DEV_SLOTS_PER_EPOCH,
132134
stakers_slot_offset: DEFAULT_DEV_SLOTS_PER_EPOCH,
@@ -745,12 +747,21 @@ impl LocalCluster {
745747
dest_pubkey: &Pubkey,
746748
lamports: u64,
747749
) -> u64 {
748-
trace!("getting current balance");
749-
let current_balance = client
750+
trace!("getting current balances");
751+
let current_source_balance = client
752+
.rpc_client()
753+
.get_balance_with_commitment(&source_keypair.pubkey(), CommitmentConfig::processed())
754+
.unwrap()
755+
.value;
756+
let current_dest_balance = client
750757
.rpc_client()
751758
.get_balance_with_commitment(dest_pubkey, CommitmentConfig::processed())
752759
.unwrap()
753760
.value;
761+
assert!(
762+
current_source_balance >= lamports + 5_000,
763+
"{current_source_balance} {lamports}"
764+
);
754765
trace!("getting leader blockhash");
755766
let (blockhash, _) = client
756767
.rpc_client()
@@ -762,7 +773,7 @@ impl LocalCluster {
762773
lamports,
763774
source_keypair.pubkey(),
764775
*dest_pubkey,
765-
current_balance
776+
current_dest_balance
766777
);
767778

768779
LocalCluster::send_transaction_with_retries(client, &[source_keypair], &mut tx, 10, 0)
@@ -771,7 +782,7 @@ impl LocalCluster {
771782
.rpc_client()
772783
.wait_for_balance_with_commitment(
773784
dest_pubkey,
774-
Some(lamports + current_balance),
785+
Some(lamports + current_dest_balance),
775786
CommitmentConfig::processed(),
776787
)
777788
.expect("get balance should succeed")

local-cluster/tests/local_cluster.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,9 @@ use {
4141
run_cluster_partition, run_kill_partition_switch_threshold, save_tower,
4242
setup_snapshot_validator_config, test_faulty_node, wait_for_duplicate_proof,
4343
wait_for_last_vote_in_tower_to_land_in_ledger, SnapshotValidatorConfig,
44-
ValidatorTestConfig, DEFAULT_CLUSTER_LAMPORTS, DEFAULT_NODE_STAKE, RUST_LOG_FILTER,
44+
ValidatorTestConfig, DEFAULT_NODE_STAKE, RUST_LOG_FILTER,
4545
},
46-
local_cluster::{ClusterConfig, LocalCluster},
46+
local_cluster::{ClusterConfig, LocalCluster, DEFAULT_CLUSTER_LAMPORTS},
4747
validator_configs::*,
4848
},
4949
solana_pubsub_client::pubsub_client::PubsubClient,

0 commit comments

Comments
 (0)