Skip to content

Commit

Permalink
transfer_with_client doesn't assume 0 starting funds
Browse files Browse the repository at this point in the history
  • Loading branch information
apfitzge committed Jan 14, 2025
1 parent d3dc3d0 commit 7fdaea4
Showing 1 changed file with 9 additions and 12 deletions.
21 changes: 9 additions & 12 deletions local-cluster/src/local_cluster.rs
Original file line number Diff line number Diff line change
Expand Up @@ -525,12 +525,17 @@ impl LocalCluster {
// setup as a listener
info!("listener {} ", validator_pubkey,);
} else if should_create_vote_pubkey {
let validator_balance = Self::transfer_with_client(
Self::transfer_with_client(
&client,
&self.funding_keypair,
&validator_pubkey,
Self::required_validator_funding(stake),
);
let validator_balance = client
.rpc_client()
.get_balance_with_commitment(&validator_pubkey, CommitmentConfig::processed())
.map(|response| response.value)
.unwrap_or_default();
info!(
"validator {} balance {}",
validator_pubkey, validator_balance
Expand Down Expand Up @@ -603,11 +608,11 @@ impl LocalCluster {
self.close_preserve_ledgers();
}

pub fn transfer(&self, source_keypair: &Keypair, dest_pubkey: &Pubkey, lamports: u64) -> u64 {
pub fn transfer(&self, source_keypair: &Keypair, dest_pubkey: &Pubkey, lamports: u64) {
let client = self
.build_validator_tpu_quic_client(self.entry_point_info.pubkey())
.expect("new tpu quic client");
Self::transfer_with_client(&client, source_keypair, dest_pubkey, lamports)
Self::transfer_with_client(&client, source_keypair, dest_pubkey, lamports);
}

fn discover_nodes(
Expand Down Expand Up @@ -751,7 +756,7 @@ impl LocalCluster {
source_keypair: &Keypair,
dest_pubkey: &Pubkey,
lamports: u64,
) -> u64 {
) {
trace!("getting leader blockhash");
let (blockhash, _) = client
.rpc_client()
Expand All @@ -767,14 +772,6 @@ impl LocalCluster {

LocalCluster::send_transaction_with_retries(client, &[source_keypair], &mut tx, 10, 0)
.expect("client transfer should succeed");
client
.rpc_client()
.wait_for_balance_with_commitment(
dest_pubkey,
Some(lamports),
CommitmentConfig::processed(),
)
.expect("get balance should succeed")
}

fn setup_vote_and_stake_accounts(
Expand Down

0 comments on commit 7fdaea4

Please sign in to comment.