Notice the user when the --mint, --bpf-program, or --clone arguments are ignored

This commit is contained in:
Michael Vines 2021-03-17 11:01:49 -07:00 committed by mergify[bot]
parent 8a9b51952e
commit 59c19d9fbf
2 changed files with 23 additions and 2 deletions

View File

@ -27,7 +27,7 @@ use {
collections::HashMap,
fs::remove_dir_all,
net::{IpAddr, Ipv4Addr, SocketAddr},
path::PathBuf,
path::{Path, PathBuf},
sync::{Arc, RwLock},
thread::sleep,
time::Duration,
@ -62,6 +62,11 @@ impl TestValidatorGenesis {
self
}
/// Check if a given TestValidator ledger has already been initialized
pub fn ledger_exists(ledger_path: &Path) -> bool {
ledger_path.join("vote-account-keypair.json").exists()
}
pub fn fee_rate_governor(&mut self, fee_rate_governor: FeeRateGovernor) -> &mut Self {
self.fee_rate_governor = fee_rate_governor;
self
@ -313,7 +318,7 @@ impl TestValidator {
let ledger_path = match &config.ledger_path {
None => create_new_tmp_ledger!(&genesis_config).0,
Some(ledger_path) => {
if ledger_path.join("validator-keypair.json").exists() {
if TestValidatorGenesis::ledger_exists(ledger_path) {
return Ok(ledger_path.to_path_buf());
}
@ -338,6 +343,10 @@ impl TestValidator {
&validator_identity,
ledger_path.join("validator-keypair.json").to_str().unwrap(),
)?;
// `ledger_exists` should fail until the vote account keypair is written
assert!(!TestValidatorGenesis::ledger_exists(&ledger_path));
write_keypair_file(
&validator_vote_account,
ledger_path

View File

@ -354,6 +354,18 @@ fn main() {
});
}
if TestValidatorGenesis::ledger_exists(&ledger_path) {
for (name, long) in &[
("bpf_program", "--bpf-program"),
("clone_account", "--clone"),
("mint_address", "--mint"),
] {
if matches.is_present(name) {
println!("{} argument ignored, ledger already exists", long);
}
}
}
let mut genesis = TestValidatorGenesis::default();
admin_rpc_service::run(