Skip to content

Commit

Permalink
Revert "Fixup flaky tests (backport solana-labs#21617) (solana-labs#2…
Browse files Browse the repository at this point in the history
…1646)"

This reverts commit 922c74c.
  • Loading branch information
t-nelson authored and tao-stones committed Dec 13, 2021
1 parent ae11cc3 commit 156caeb
Show file tree
Hide file tree
Showing 2 changed files with 94 additions and 228 deletions.
83 changes: 23 additions & 60 deletions local-cluster/src/local_cluster.rs
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ impl LocalCluster {
let mut listener_config = safe_clone_config(&config.validator_configs[0]);
listener_config.voting_disabled = true;
(0..config.num_listeners).for_each(|_| {
cluster.add_validator_listener(
cluster.add_validator(
&listener_config,
0,
Arc::new(Keypair::new()),
Expand Down Expand Up @@ -316,50 +316,11 @@ impl LocalCluster {
}
}

/// Set up validator without voting or staking accounts
pub fn add_validator_listener(
&mut self,
validator_config: &ValidatorConfig,
stake: u64,
validator_keypair: Arc<Keypair>,
voting_keypair: Option<Arc<Keypair>>,
socket_addr_space: SocketAddrSpace,
) -> Pubkey {
self.do_add_validator(
validator_config,
true,
stake,
validator_keypair,
voting_keypair,
socket_addr_space,
)
}

/// Set up validator with voting and staking accounts
pub fn add_validator(
&mut self,
validator_config: &ValidatorConfig,
stake: u64,
validator_keypair: Arc<Keypair>,
voting_keypair: Option<Arc<Keypair>>,
socket_addr_space: SocketAddrSpace,
) -> Pubkey {
self.do_add_validator(
validator_config,
false,
stake,
validator_keypair,
voting_keypair,
socket_addr_space,
)
}

fn do_add_validator(
&mut self,
validator_config: &ValidatorConfig,
is_listener: bool,
stake: u64,
validator_keypair: Arc<Keypair>,
mut voting_keypair: Option<Arc<Keypair>>,
socket_addr_space: SocketAddrSpace,
) -> Pubkey {
Expand All @@ -378,28 +339,30 @@ impl LocalCluster {
let contact_info = validator_node.info.clone();
let (ledger_path, _blockhash) = create_new_tmp_ledger!(&self.genesis_config);

// Give the validator some lamports to setup vote accounts
if is_listener {
if validator_config.voting_disabled {
// setup as a listener
info!("listener {} ", validator_pubkey,);
} else if should_create_vote_pubkey {
let validator_balance = Self::transfer_with_client(
&client,
&self.funding_keypair,
&validator_pubkey,
stake * 2 + 2,
);
info!(
"validator {} balance {}",
validator_pubkey, validator_balance
);
Self::setup_vote_and_stake_accounts(
&client,
voting_keypair.as_ref().unwrap(),
&validator_keypair,
stake,
)
.unwrap();
} else {
// Give the validator some lamports to setup vote accounts
if should_create_vote_pubkey {
let validator_balance = Self::transfer_with_client(
&client,
&self.funding_keypair,
&validator_pubkey,
stake * 2 + 2,
);
info!(
"validator {} balance {}",
validator_pubkey, validator_balance
);
Self::setup_vote_and_stake_accounts(
&client,
voting_keypair.as_ref().unwrap(),
&validator_keypair,
stake,
)
.unwrap();
}
}

let mut config = safe_clone_config(validator_config);
Expand Down
Loading

0 comments on commit 156caeb

Please sign in to comment.