mirror of
https://github.com/sigp/lighthouse.git
synced 2026-04-29 02:33:48 +00:00
Add an account command to enable/disable validators (#2386)
## Issue Addressed Resolves #2322 ## Proposed Changes Adds a `modify` command to `lighthouse account validator` with subcommands to enable and disable specific or all pubkeys.
This commit is contained in:
@@ -2,6 +2,7 @@ use account_manager::{
|
||||
validator::{
|
||||
create::*,
|
||||
import::{self, CMD as IMPORT_CMD},
|
||||
modify::{ALL, CMD as MODIFY_CMD, DISABLE, ENABLE, PUBKEY_FLAG},
|
||||
CMD as VALIDATOR_CMD,
|
||||
},
|
||||
wallet::{
|
||||
@@ -475,10 +476,21 @@ fn validator_import_launchpad() {
|
||||
// Validator should be registered with slashing protection.
|
||||
check_slashing_protection(&dst_dir, std::iter::once(keystore.public_key().unwrap()));
|
||||
|
||||
// Disable all the validators in validator_definition.
|
||||
output_result(
|
||||
validator_cmd()
|
||||
.arg(format!("--{}", VALIDATOR_DIR_FLAG))
|
||||
.arg(dst_dir.path().as_os_str())
|
||||
.arg(MODIFY_CMD)
|
||||
.arg(DISABLE)
|
||||
.arg(format!("--{}", ALL)),
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
let defs = ValidatorDefinitions::open(&dst_dir).unwrap();
|
||||
|
||||
let expected_def = ValidatorDefinition {
|
||||
enabled: true,
|
||||
let mut expected_def = ValidatorDefinition {
|
||||
enabled: false,
|
||||
description: "".into(),
|
||||
graffiti: None,
|
||||
voting_public_key: keystore.public_key().unwrap(),
|
||||
@@ -490,7 +502,28 @@ fn validator_import_launchpad() {
|
||||
};
|
||||
|
||||
assert!(
|
||||
defs.as_slice() == &[expected_def],
|
||||
defs.as_slice() == &[expected_def.clone()],
|
||||
"validator defs file should be accurate"
|
||||
);
|
||||
|
||||
// Enable keystore validator again
|
||||
output_result(
|
||||
validator_cmd()
|
||||
.arg(format!("--{}", VALIDATOR_DIR_FLAG))
|
||||
.arg(dst_dir.path().as_os_str())
|
||||
.arg(MODIFY_CMD)
|
||||
.arg(ENABLE)
|
||||
.arg(format!("--{}", PUBKEY_FLAG))
|
||||
.arg(format!("{}", keystore.public_key().unwrap())),
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
let defs = ValidatorDefinitions::open(&dst_dir).unwrap();
|
||||
|
||||
expected_def.enabled = true;
|
||||
|
||||
assert!(
|
||||
defs.as_slice() == &[expected_def.clone()],
|
||||
"validator defs file should be accurate"
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user