diff --git a/sn_node/tests/verify_data_location.rs b/sn_node/tests/verify_data_location.rs index 2227b7e9ef..597f291dfd 100644 --- a/sn_node/tests/verify_data_location.rs +++ b/sn_node/tests/verify_data_location.rs @@ -142,11 +142,14 @@ async fn verify_data_location() -> Result<()> { fn print_node_close_groups(all_peers: &[PeerId]) { let all_peers = all_peers.to_vec(); println!("\nNode close groups:"); + + let all_peers_hashset = all_peers.iter().cloned().collect::>(); + for (node_index, peer) in all_peers.iter().enumerate() { let node_index = node_index + 1; let key = NetworkAddress::from_peer(*peer).as_kbucket_key(); - let closest_peers = - sort_peers_by_key(&all_peers, &key, CLOSE_GROUP_SIZE).expect("failed to sort peer"); + let closest_peers = sort_peers_by_key(&all_peers_hashset, &key, CLOSE_GROUP_SIZE) + .expect("failed to sort peer"); let closest_peers_idx = closest_peers .iter() .map(|&&peer| all_peers.iter().position(|&p| p == peer).unwrap() + 1) @@ -181,16 +184,20 @@ async fn get_records_and_holders() -> Result { // Verifies that the chunk is stored by the actual closest peers to the RecordKey async fn verify_location(record_holders: &RecordHolders, all_peers: &[PeerId]) -> Result<()> { let mut failed = HashMap::new(); + + let all_peers_hashset = all_peers.iter().cloned().collect::>(); + let mut verification_attempts = 0; while verification_attempts < VERIFICATION_ATTEMPTS { failed.clear(); for (key, actual_holders_idx) in record_holders.iter() { println!("Verifying {:?}", PrettyPrintRecordKey::from(key)); let record_key = KBucketKey::from(key.to_vec()); - let expected_holders = sort_peers_by_key(all_peers, &record_key, CLOSE_GROUP_SIZE)? - .into_iter() - .cloned() - .collect::>(); + let expected_holders = + sort_peers_by_key(&all_peers_hashset, &record_key, CLOSE_GROUP_SIZE)? + .into_iter() + .cloned() + .collect::>(); let actual_holders = actual_holders_idx .iter()