Notice the user when the --mint, --bpf-program, or --clone arguments are ignored
This commit is contained in:
parent
8a9b51952e
commit
59c19d9fbf
|
@ -27,7 +27,7 @@ use {
|
||||||
collections::HashMap,
|
collections::HashMap,
|
||||||
fs::remove_dir_all,
|
fs::remove_dir_all,
|
||||||
net::{IpAddr, Ipv4Addr, SocketAddr},
|
net::{IpAddr, Ipv4Addr, SocketAddr},
|
||||||
path::PathBuf,
|
path::{Path, PathBuf},
|
||||||
sync::{Arc, RwLock},
|
sync::{Arc, RwLock},
|
||||||
thread::sleep,
|
thread::sleep,
|
||||||
time::Duration,
|
time::Duration,
|
||||||
|
@ -62,6 +62,11 @@ impl TestValidatorGenesis {
|
||||||
self
|
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 {
|
pub fn fee_rate_governor(&mut self, fee_rate_governor: FeeRateGovernor) -> &mut Self {
|
||||||
self.fee_rate_governor = fee_rate_governor;
|
self.fee_rate_governor = fee_rate_governor;
|
||||||
self
|
self
|
||||||
|
@ -313,7 +318,7 @@ impl TestValidator {
|
||||||
let ledger_path = match &config.ledger_path {
|
let ledger_path = match &config.ledger_path {
|
||||||
None => create_new_tmp_ledger!(&genesis_config).0,
|
None => create_new_tmp_ledger!(&genesis_config).0,
|
||||||
Some(ledger_path) => {
|
Some(ledger_path) => {
|
||||||
if ledger_path.join("validator-keypair.json").exists() {
|
if TestValidatorGenesis::ledger_exists(ledger_path) {
|
||||||
return Ok(ledger_path.to_path_buf());
|
return Ok(ledger_path.to_path_buf());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -338,6 +343,10 @@ impl TestValidator {
|
||||||
&validator_identity,
|
&validator_identity,
|
||||||
ledger_path.join("validator-keypair.json").to_str().unwrap(),
|
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(
|
write_keypair_file(
|
||||||
&validator_vote_account,
|
&validator_vote_account,
|
||||||
ledger_path
|
ledger_path
|
||||||
|
|
|
@ -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();
|
let mut genesis = TestValidatorGenesis::default();
|
||||||
|
|
||||||
admin_rpc_service::run(
|
admin_rpc_service::run(
|
||||||
|
|
Loading…
Reference in New Issue