Skip to content
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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

yihau
Copy link
Member

@yihau yihau commented Feb 11, 2025

Problem

#4082

Summary of Changes

extracting args parsing logic and adding tests

@yihau yihau mentioned this pull request Feb 11, 2025
@yihau yihau requested a review from steviez February 12, 2025 05:24
@yihau yihau force-pushed the add-set-identity-test branch from 85fc50f to 57e6304 Compare February 14, 2025 12:29
const COMMAND: &str = "set-identity";

#[derive(Debug, PartialEq)]
pub struct SetIdentityArg {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: SetIdentityArg ==> SetIdentityArgs

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2414260 🫡

Comment on lines +49 to +50
let set_identity_args = SetIdentityArgs::from_clap_arg_match(matches);
let require_tower = set_identity_args.require_tower;
Copy link

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);

Comment on lines +117 to +119
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();
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants