From 8b1a1d9c9989254d262fc81bba2cefe2a1d25995 Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Fri, 28 May 2021 10:43:31 -0700 Subject: [PATCH] test-validator: add an arg to control faucet genesis balance (#17581) (cherry picked from commit 974a96738a4db390bb589544b8fc3ff66312b094) Co-authored-by: Trent Nelson --- validator/src/bin/solana-test-validator.rs | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/validator/src/bin/solana-test-validator.rs b/validator/src/bin/solana-test-validator.rs index 2215aecd61..78137628d0 100644 --- a/validator/src/bin/solana-test-validator.rs +++ b/validator/src/bin/solana-test-validator.rs @@ -42,6 +42,8 @@ use { */ const DEFAULT_MAX_LEDGER_SHREDS: u64 = 10_000; +const DEFAULT_FAUCET_SOL: f64 = 1_000_000.; + #[derive(PartialEq)] enum Output { None, @@ -53,6 +55,7 @@ fn main() { let default_rpc_port = rpc_port::DEFAULT_RPC_PORT.to_string(); let default_faucet_port = FAUCET_PORT.to_string(); let default_limit_ledger_size = DEFAULT_MAX_LEDGER_SHREDS.to_string(); + let default_faucet_sol = DEFAULT_FAUCET_SOL.to_string(); let matches = App::new("solana-test-validator") .about("Test Validator") @@ -264,6 +267,17 @@ fn main() { .default_value(default_limit_ledger_size.as_str()) .help("Keep this amount of shreds in root slots."), ) + .arg( + Arg::with_name("faucet_sol") + .long("faucet-sol") + .takes_value(true) + .value_name("SOL") + .default_value(default_faucet_sol.as_str()) + .help( + "Give the faucet address this much SOL in genesis. \ + If the ledger already exists then this parameter is silently ignored", + ), + ) .get_matches(); let cli_config = if let Some(config_file) = matches.value_of("config_file") { @@ -429,7 +443,7 @@ fn main() { }; let _logger_thread = redirect_stderr_to_file(logfile); - let faucet_lamports = sol_to_lamports(1_000_000.); + let faucet_lamports = sol_to_lamports(value_of(&matches, "faucet_sol").unwrap()); let faucet_keypair_file = ledger_path.join("faucet-keypair.json"); if !faucet_keypair_file.exists() { write_keypair_file(&Keypair::new(), faucet_keypair_file.to_str().unwrap()).unwrap_or_else( @@ -470,6 +484,7 @@ fn main() { ("clone_account", "--clone"), ("mint_address", "--mint"), ("slots_per_epoch", "--slots-per-epoch"), + ("faucet_sol", "--faucet-sol"), ] { if matches.is_present(name) { println!("{} argument ignored, ledger already exists", long);