-
Notifications
You must be signed in to change notification settings - Fork 344
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
agave-validator: add args tests for set-identity #4929
base: master
Are you sure you want to change the base?
Conversation
85fc50f
to
57e6304
Compare
const COMMAND: &str = "set-identity"; | ||
|
||
#[derive(Debug, PartialEq)] | ||
pub struct SetIdentityArg { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: SetIdentityArg
==> SetIdentityArgs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
2414260 🫡
let set_identity_args = SetIdentityArgs::from_clap_arg_match(matches); | ||
let require_tower = set_identity_args.require_tower; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Let's just destructure the return value:
let SetIdentityArgs {
identity,
require_tower
} = SetIdentityArgs::from_clap_arg_match(matches);
let tmp_path = tmp_dir.path().join("id.json"); | ||
let keypair_string = "[99,66,147,169,175,95,166,214,27,255,19,64,81,255,101,39,10,24,205,48,226,191,98,234,210,86,174,34,2,121,173,223,9,36,145,159,1,95,129,252,249,189,217,191,13,169,231,216,4,181,124,105,193,20,61,251,197,68,44,240,205,70,115,226]"; | ||
std::fs::write(&tmp_path, keypair_string).unwrap(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can make this significantly easier:
let file = tmp_dir.path().join("id.json");
let keypair = Keypair::new();
solana_keypair::write_keypair_file(&keypair, file).unwrap();
Basically, avoid the hard-coded string + use the helper here:
https://github.com/anza-xyz/solana-sdk/blob/f93ad76f6a051550b8ceb7301813553112d1d4e2/keypair/src/lib.rs#L261-L267
Problem
#4082
Summary of Changes
extracting args parsing logic and adding tests