/// Verifies that dealing with an invalid threshold returns an error
///
/// # Side effects
/// None, other than consuming randomness.
Verifies that dealing with an invalid threshold returns an error
Verifies that dealing with an invalid threshold returns an error
pub fn deal_with_incorrect_threshold_should_fail(&mut self, rng: &mut ChaCha20Rng) {
        let (_dealer_index, dealer_id) = self
            .config
            .dealers
            .iter()
            .choose(rng)
            .expect("Config has no dealers");
        let dealer_node = self
            .network
            .nodes_by_node_id
            .get_mut(&dealer_id)
            .expect("Could not find dealer in nodes");
        let num_receivers = self.config.receivers.count().get();
        for incorrect_threshold in &[0, num_receivers + 1, num_receivers + 2] {
            let dealing = dealer_node.create_dealing(
                self.config.algorithm_id,
                self.config.dkg_id,
                self.config
                    .dealers
                    .position(dealer_node.node_id)
                    .expect("The node is not in the set of Dealers"),
                NumberOfNodes::from(*incorrect_threshold),
                self.config.epoch,
                self.config.receiver_keys.clone(),
                self.config
                    .resharing_transcript
                    .as_ref()
                    .map(CspPublicCoefficients::from),
            );
            match dealing {
                Ok(_) => panic!("Dealing should fail with incorrect threshold.\n  Threshold: {}\n  Num receivers: {}", incorrect_threshold, num_receivers),
                Err(CspDkgCreateReshareDealingError::InvalidThresholdError(_)) => (),
                Err(error) => panic!("Incorrect error: {:?}", error),
            }
        }
    }
pub fn deal_with_incorrect_threshold_should_fail ( & mut self , rng : & mut ChaCha20Rng ) { let ( _dealer_index , dealer_id ) = self . config . dealers . iter ( ) . choose ( rng ) . expect ( " " ) ; let dealer_node = self . network . nodes_by_node_id . get_mut ( & dealer_id ) . expect ( " " ) ; let num_receivers = self . config . receivers . count ( ) . get ( ) ; for incorrect_threshold in & [ 0 , num_receivers + 1 , num_receivers + 2 ] { let dealing = dealer_node . create_dealing ( self . config . algorithm_id , self . config . dkg_id , self . config . dealers . position ( dealer_node . node_id ) . expect ( " " ) , NumberOfNodes :: from ( * incorrect_threshold ) , self . config . epoch , self . config . receiver_keys . clone ( ) , self . config . resharing_transcript . as_ref ( ) . map ( CspPublicCoefficients :: from ) , ) ; match dealing { Ok ( _ ) => panic ! ( " \n \n " incorrect_threshold num_receivers ) , Err ( CspDkgCreateReshareDealingError :: InvalidThresholdError ( _ ) ) => ( ) , Err ( error ) => panic ! ( " " error ) , } } }
Verifies that dealing with an invalid threshold returns an error
Verifies that dealing with an invalid threshold returns an error
&mut self
rng
&mut ChaCha20Rng
side effects
None, other than consuming randomness.
None other than consuming randomness .