Skip to content
This repository has been archived by the owner on Jan 22, 2025. It is now read-only.

Commit

Permalink
local-cluster: fix flaky test_rpc_block_subscribe (#34421)
Browse files Browse the repository at this point in the history
* local-cluster: fix flaky test_rpc_block_subscribe

* reenable test

* pr feedback: add comment linking pr
  • Loading branch information
AshwinSekar authored Dec 14, 2023
1 parent c7a5767 commit 4f11161
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions local-cluster/tests/local_cluster.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2562,35 +2562,41 @@ fn run_test_load_program_accounts_partition(scan_commitment: CommitmentConfig) {

#[test]
#[serial]
#[ignore]
fn test_rpc_block_subscribe() {
let total_stake = 100 * DEFAULT_NODE_STAKE;
let leader_stake = total_stake;
let node_stakes = vec![leader_stake];
let leader_stake = 100 * DEFAULT_NODE_STAKE;
let rpc_stake = DEFAULT_NODE_STAKE;
let total_stake = leader_stake + rpc_stake;
let node_stakes = vec![leader_stake, rpc_stake];
let mut validator_config = ValidatorConfig::default_for_test();
validator_config.enable_default_rpc_block_subscribe();

let validator_keys = [
"28bN3xyvrP4E8LwEgtLjhnkb7cY4amQb6DrYAbAYjgRV4GAGgkVM2K7wnxnAS7WDneuavza7x21MiafLu1HkwQt4",
"2saHBBoTkLMmttmPQP8KfBkcCw45S5cwtV3wTdGCscRC8uxdgvHxpHiWXKx4LvJjNJtnNcbSv5NdheokFFqnNDt8",
]
.iter()
.map(|s| (Arc::new(Keypair::from_base58_string(s)), true))
.take(node_stakes.len())
.collect::<Vec<_>>();
let rpc_node_pubkey = &validator_keys[1].0.pubkey();

let mut config = ClusterConfig {
cluster_lamports: total_stake,
node_stakes,
validator_configs: vec![validator_config],
validator_configs: make_identical_validator_configs(&validator_config, 2),
validator_keys: Some(validator_keys),
skip_warmup_slots: true,
..ClusterConfig::default()
};
let cluster = LocalCluster::new(&mut config, SocketAddrSpace::Unspecified);
let rpc_node_contact_info = cluster.get_contact_info(rpc_node_pubkey).unwrap();
let (mut block_subscribe_client, receiver) = PubsubClient::block_subscribe(
&format!(
"ws://{}",
&cluster.entry_point_info.rpc_pubsub().unwrap().to_string()
// It is important that we subscribe to a non leader node as there
// is a race condition which can cause leader nodes to not send
// BlockUpdate notifications properly. See https://github.com/solana-labs/solana/pull/34421
&rpc_node_contact_info.rpc_pubsub().unwrap().to_string()
),
RpcBlockSubscribeFilter::All,
Some(RpcBlockSubscribeConfig {
Expand Down

0 comments on commit 4f11161

Please sign in to comment.