fn run_add_multiple_correct_and_incorrect_responses(
        incorrect_responses: Vec<(Vec<(Slot, Hash)>, usize)>,
        test_setup: &mut TestSetup,
    ) -> DuplicateAncestorDecision {
        let &mut TestSetup {
            ref sampled_addresses,
            ref correct_ancestors_response,
            ref blockstore,
            ref mut status,
            ..
        } = test_setup;

        // Generate an event order of adding correct/incorrect responses
        let events: BTreeMap<usize, Vec<(Slot, Hash)>> = incorrect_responses
            .into_iter()
            .scan(
                0,
                |total_count, /*accumulated state*/
                 (
                    incorrect_response,
                    num_responses, /*number of validators returning this response*/
                )| {
                    assert!(num_responses > 0);
                    *total_count += num_responses;
                    Some((*total_count, incorrect_response))
                },
            )
            .collect();

        let total_incorrect_responses = events.iter().last().map(|(count, _)| *count).unwrap_or(0);
        assert!(total_incorrect_responses <= ANCESTOR_HASH_REPAIR_SAMPLE_SIZE);

        let mut event_order: Vec<usize> = (0..sampled_addresses.len()).collect();
        event_order.shuffle(&mut thread_rng());

        for (event, responder_addr) in event_order.iter().zip(sampled_addresses.iter()) {
            let response = events
                .range((event + 1)..)
                .next()
                .map(|(_count, response)| response)
                .unwrap_or_else(|| correct_ancestors_response)
                .clone();

            if let Some(decision) = status.add_response(responder_addr, response, blockstore) {
                // Note we may get a decision before we've heard back from all the
                // sampled validators
                return decision;
            }
        }

        // Should never get here
        panic!("Decision must be made after hearing back from all the sampled validators");
    }
/// Add `num_correct_responses` correct responses from the sampled valdiators, and
/// then add incorrect responses from the remaining validators.
Add `num_correct_responses` correct responses from the sampled valdiators, and
then add incorrect responses from the remaining validators.
Add ` num_correct_responses ` correct responses from the sampled valdiators and then add incorrect responses from the remaining validators .
fn run_add_multiple_correct_and_incorrect_responses(
        incorrect_responses: Vec<(Vec<(Slot, Hash)>, usize)>,
        test_setup: &mut TestSetup,
    ) -> DuplicateAncestorDecision {
        let &mut TestSetup {
            ref sampled_addresses,
            ref correct_ancestors_response,
            ref blockstore,
            ref mut status,
            ..
        } = test_setup;
        // Generate an event order of adding correct/incorrect responses
        let events: BTreeMap<usize, Vec<(Slot, Hash)>> = incorrect_responses
            .into_iter()
            .scan(
                0,
                |total_count, /*accumulated state*/
                 (
                    incorrect_response,
                    num_responses, /*number of validators returning this response*/
                )| {
                    assert!(num_responses > 0);
                    *total_count += num_responses;
                    Some((*total_count, incorrect_response))
                },
            )
            .collect();
        let total_incorrect_responses = events.iter().last().map(|(count, _)| *count).unwrap_or(0);
        assert!(total_incorrect_responses <= ANCESTOR_HASH_REPAIR_SAMPLE_SIZE);
        let mut event_order: Vec<usize> = (0..sampled_addresses.len()).collect();
        event_order.shuffle(&mut thread_rng());
        for (event, responder_addr) in event_order.iter().zip(sampled_addresses.iter()) {
            let response = events
                .range((event + 1)..)
                .next()
                .map(|(_count, response)| response)
                .unwrap_or_else(|| correct_ancestors_response)
                .clone();
            if let Some(decision) = status.add_response(responder_addr, response, blockstore) {
                // Note we may get a decision before we've heard back from all the
                // sampled validators
                return decision;
            }
        }
        // Should never get here
        panic!("Decision must be made after hearing back from all the sampled validators");
    }
fn run_add_multiple_correct_and_incorrect_responses ( incorrect_responses : Vec < ( Vec < ( Slot , Hash ) > , usize ) > , test_setup : & mut TestSetup , ) -> DuplicateAncestorDecision { let & mut TestSetup { ref sampled_addresses , ref correct_ancestors_response , ref blockstore , ref mut status , .. } = test_setup ; // Generate an event order of adding correct/incorrect responses let events : BTreeMap < usize , Vec < ( Slot , Hash ) > > = incorrect_responses . into_iter ( ) . scan ( 0 , | total_count , /*accumulated state*/ ( incorrect_response , num_responses , /*number of validators returning this response*/ ) | { assert ! ( num_responses 0 ) ; * total_count += num_responses ; Some ( ( * total_count , incorrect_response ) ) } , ) . collect ( ) ; let total_incorrect_responses = events . iter ( ) . last ( ) . map ( | ( count , _ ) | * count ) . unwrap_or ( 0 ) ; assert ! ( total_incorrect_responses ANCESTOR_HASH_REPAIR_SAMPLE_SIZE ) ; let mut event_order : Vec < usize > = ( 0 .. sampled_addresses . len ( ) ) . collect ( ) ; event_order . shuffle ( & mut thread_rng ( ) ) ; for ( event , responder_addr ) in event_order . iter ( ) . zip ( sampled_addresses . iter ( ) ) { let response = events . range ( ( event + 1 ) .. ) . next ( ) . map ( | ( _count , response ) | response ) . unwrap_or_else ( | | correct_ancestors_response ) . clone ( ) ; if let Some ( decision ) = status . add_response ( responder_addr , response , blockstore ) { // Note we may get a decision before we've heard back from all the // sampled validators return decision ; } } // Should never get here panic ! ( " " ) ; }
Add `num_correct_responses` correct responses from the sampled valdiators, and
then add incorrect responses from the remaining validators.
Add ` num_correct_responses ` correct responses from the sampled valdiators and then add incorrect responses from the remaining validators .
incorrect_responses
Vec<(Vec<(Slot, Hash)>, usize)>
test_setup
&mut TestSetup