From fd207b6907e99f13287506f0e3d34eff41c23b1e Mon Sep 17 00:00:00 2001 From: carllin Date: Thu, 30 Jan 2020 21:51:11 -0800 Subject: [PATCH] Fix stale gossip entrypoint (#8053) --- local-cluster/src/cluster.rs | 1 + local-cluster/src/local_cluster.rs | 4 ++++ local-cluster/tests/local_cluster.rs | 5 ++++- 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/local-cluster/src/cluster.rs b/local-cluster/src/cluster.rs index beb47dda57f5b5..1a83b05b1c2b6b 100644 --- a/local-cluster/src/cluster.rs +++ b/local-cluster/src/cluster.rs @@ -38,6 +38,7 @@ impl ClusterValidatorInfo { pub trait Cluster { fn get_node_pubkeys(&self) -> Vec; fn get_validator_client(&self, pubkey: &Pubkey) -> Option; + fn get_contact_info(&self, pubkey: &Pubkey) -> Option<&ContactInfo>; fn exit_node(&mut self, pubkey: &Pubkey) -> ClusterValidatorInfo; fn restart_node(&mut self, pubkey: &Pubkey, cluster_validator_info: ClusterValidatorInfo); fn exit_restart_node(&mut self, pubkey: &Pubkey, config: ValidatorConfig); diff --git a/local-cluster/src/local_cluster.rs b/local-cluster/src/local_cluster.rs index 1d8b2c786fd331..a3d5a4fdedec94 100644 --- a/local-cluster/src/local_cluster.rs +++ b/local-cluster/src/local_cluster.rs @@ -705,6 +705,10 @@ impl Cluster for LocalCluster { cluster_validator_info.config = validator_config; self.restart_node(pubkey, cluster_validator_info); } + + fn get_contact_info(&self, pubkey: &Pubkey) -> Option<&ContactInfo> { + self.validators.get(pubkey).map(|v| &v.info.contact_info) + } } impl Drop for LocalCluster { diff --git a/local-cluster/tests/local_cluster.rs b/local-cluster/tests/local_cluster.rs index b695eb8272cd9d..fcd120a2d7195a 100644 --- a/local-cluster/tests/local_cluster.rs +++ b/local-cluster/tests/local_cluster.rs @@ -662,8 +662,11 @@ fn test_snapshot_restart_tower() { cluster.restart_node(&validator_id, validator_info); // Test cluster can still make progress and get confirmations in tower + // Use the restarted node as the discovery point so that we get updated + // validator's ContactInfo + let restarted_node_info = cluster.get_contact_info(&validator_id).unwrap(); cluster_tests::spend_and_verify_all_nodes( - &cluster.entry_point_info, + &restarted_node_info, &cluster.funding_keypair, 1, HashSet::new(),