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

Add set_identity tests #3794

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

Conversation

KirillLykov
Copy link

Problem

I haven't found tests for the set_identity call. I want this functionality to be covered by test because there will be a PR introducing a new network client that is subscribed to the change identity notification.

Summary of Changes

expected_validator_id.pubkey().to_string()
);

let contact_info_request =
Copy link
Author

@KirillLykov KirillLykov Nov 26, 2024

Choose a reason for hiding this comment

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

it also tests that exit call works properly but this is not reflected in the name of the test.

Copy link

@bw-solana bw-solana left a comment

Choose a reason for hiding this comment

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

I like that we're adding the test coverage! Left a couple comments to consider

}"#,
)
.expect("Failed to parse expected response");
assert_eq!(actual_parsed_response, expected_parsed_response);

Choose a reason for hiding this comment

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

this feels a little fragile. Could we just check for null result so that we don't have to update this for benign things like a version change?

Comment on lines 1347 to 1404
let leader_keypair = Keypair::new();
let leader_node = Node::new_localhost_with_pubkey(&leader_keypair.pubkey());

let validator_keypair = Keypair::new();
let validator_node = Node::new_localhost_with_pubkey(&validator_keypair.pubkey());
let genesis_config =
create_genesis_config_with_leader(10_000, &leader_keypair.pubkey(), 1000)
.genesis_config;
let (validator_ledger_path, _blockhash) = create_new_tmp_ledger!(&genesis_config);

let voting_keypair = Arc::new(Keypair::new());
let voting_pubkey = voting_keypair.pubkey();
let authorized_voter_keypairs = Arc::new(RwLock::new(vec![voting_keypair]));
let validator_config = ValidatorConfig {
rpc_addrs: Some((
validator_node.info.rpc().unwrap(),
validator_node.info.rpc_pubsub().unwrap(),
)),
..ValidatorConfig::default_for_test()
};
let start_progress = Arc::new(RwLock::new(ValidatorStartProgress::default()));

let post_init = Arc::new(RwLock::new(None));
let meta = AdminRpcRequestMetadata {
rpc_addr: validator_config.rpc_addrs.map(|(rpc_addr, _)| rpc_addr),
start_time: SystemTime::now(),
start_progress: start_progress.clone(),
validator_exit: validator_config.validator_exit.clone(),
authorized_voter_keypairs: authorized_voter_keypairs.clone(),
tower_storage: Arc::new(NullTowerStorage {}),
post_init: post_init.clone(),
staked_nodes_overrides: Arc::new(RwLock::new(HashMap::new())),
rpc_to_plugin_manager_sender: None,
};

let _validator = Validator::new(
validator_node,
Arc::new(validator_keypair),
&validator_ledger_path,
&voting_pubkey,
authorized_voter_keypairs,
vec![leader_node.info],
&validator_config,
true, // should_check_duplicate_instance
None, // rpc_to_plugin_manager_receiver
start_progress.clone(),
SocketAddrSpace::Unspecified,
DEFAULT_TPU_USE_QUIC,
DEFAULT_TPU_CONNECTION_POOL_SIZE,
DEFAULT_TPU_ENABLE_UDP,
32, // max connections per IpAddr per minute for test
post_init,
)
.expect("assume successful validator start");
assert_eq!(
*start_progress.read().unwrap(),
ValidatorStartProgress::Running
);

Choose a reason for hiding this comment

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

seems like we should have some test API that basically covers these setup activities and allows us to extract the RPC address

Copy link
Author

Choose a reason for hiding this comment

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

Do you propose to extract a function for this setup?

Choose a reason for hiding this comment

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

I'm sort of surprised that a setup abstraction doesn't already exist (or something really close to what you have).

But yes, I think pulling out the setup into a function would help with readability

Copy link
Author

@KirillLykov KirillLykov Nov 27, 2024

Choose a reason for hiding this comment

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

Got you. Yeah, i was also surprised. Maybe I was grepping wrong phrase but I could not find tests for this admin rpc. But I should say that there is LocalCluster helper but it doesn't work here without quite some modifications.

Copy link
Author

Choose a reason for hiding this comment

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

Updated

Copy link

@bw-solana bw-solana left a comment

Choose a reason for hiding this comment

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

LGTM

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