35
35
epoch_schedule:: EpochSchedule ,
36
36
genesis_config:: { ClusterType , GenesisConfig } ,
37
37
message:: Message ,
38
+ native_token:: LAMPORTS_PER_SOL ,
38
39
poh_config:: PohConfig ,
39
40
pubkey:: Pubkey ,
40
41
signature:: { Keypair , Signature , Signer } ,
69
70
} ;
70
71
71
72
const DUMMY_SNAPSHOT_CONFIG_PATH_MARKER : & str = "dummy" ;
73
+ pub const DEFAULT_CLUSTER_LAMPORTS : u64 = 10_000_000 * LAMPORTS_PER_SOL ;
72
74
73
75
pub struct ClusterConfig {
74
76
/// The validator config that should be applied to every node in the cluster
@@ -126,7 +128,7 @@ impl Default for ClusterConfig {
126
128
validator_keys : None ,
127
129
node_stakes : vec ! [ ] ,
128
130
node_vote_keys : None ,
129
- cluster_lamports : 0 ,
131
+ cluster_lamports : DEFAULT_CLUSTER_LAMPORTS ,
130
132
ticks_per_slot : DEFAULT_TICKS_PER_SLOT ,
131
133
slots_per_epoch : DEFAULT_DEV_SLOTS_PER_EPOCH ,
132
134
stakers_slot_offset : DEFAULT_DEV_SLOTS_PER_EPOCH ,
@@ -745,12 +747,21 @@ impl LocalCluster {
745
747
dest_pubkey : & Pubkey ,
746
748
lamports : u64 ,
747
749
) -> 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
750
757
. rpc_client ( )
751
758
. get_balance_with_commitment ( dest_pubkey, CommitmentConfig :: processed ( ) )
752
759
. unwrap ( )
753
760
. value ;
761
+ assert ! (
762
+ current_source_balance >= lamports + 5_000 ,
763
+ "{current_source_balance} {lamports}"
764
+ ) ;
754
765
trace ! ( "getting leader blockhash" ) ;
755
766
let ( blockhash, _) = client
756
767
. rpc_client ( )
@@ -762,7 +773,7 @@ impl LocalCluster {
762
773
lamports,
763
774
source_keypair. pubkey( ) ,
764
775
* dest_pubkey,
765
- current_balance
776
+ current_dest_balance
766
777
) ;
767
778
768
779
LocalCluster :: send_transaction_with_retries ( client, & [ source_keypair] , & mut tx, 10 , 0 )
@@ -771,7 +782,7 @@ impl LocalCluster {
771
782
. rpc_client ( )
772
783
. wait_for_balance_with_commitment (
773
784
dest_pubkey,
774
- Some ( lamports + current_balance ) ,
785
+ Some ( lamports + current_dest_balance ) ,
775
786
CommitmentConfig :: processed ( ) ,
776
787
)
777
788
. expect ( "get balance should succeed" )
0 commit comments