fn should_fail_to_combine_insufficient_shares() {
    // Need >=4 nodes to have >=2 shares to combine in a low-threshold config
    let subnet_size = thread_rng().gen_range(4, 7);
    let (config, dkg_id, crypto_components) = setup_with_random_ni_dkg_config(subnet_size);
    let num_of_shares_to_combine = config.threshold().get() - ONE_NODE;

    run_ni_dkg_and_load_transcript_for_receivers(&config, &crypto_components);

    let sig_shares = sign_threshold_for_each(
        &n_random_nodes_in(&config.receivers().get(), num_of_shares_to_combine),
        &message(),
        dkg_id,
        &crypto_components,
    );
    let combination_result = crypto_for(
        random_node_in(&config.receivers().get()),
        &crypto_components,
    )
    .combine_threshold_sig_shares(sig_shares, dkg_id);

    assert_eq!(
        combination_result.unwrap_err(),
        CryptoError::InvalidArgument {
            message: format!(
                "Threshold too high: (threshold={} !<= {}=num_shares)",
                config.threshold().get(),
                num_of_shares_to_combine
            )
        }
    );
}
// Test uses a random NI-DKG config. A random receiver is chosen as combiner.
Test uses a random NI-DKG config. A random receiver is chosen as combiner.
Test uses a random NI - DKG config . A random receiver is chosen as combiner .
fn should_fail_to_combine_insufficient_shares() {
    // Need >=4 nodes to have >=2 shares to combine in a low-threshold config
    let subnet_size = thread_rng().gen_range(4, 7);
    let (config, dkg_id, crypto_components) = setup_with_random_ni_dkg_config(subnet_size);
    let num_of_shares_to_combine = config.threshold().get() - ONE_NODE;
    run_ni_dkg_and_load_transcript_for_receivers(&config, &crypto_components);
    let sig_shares = sign_threshold_for_each(
        &n_random_nodes_in(&config.receivers().get(), num_of_shares_to_combine),
        &message(),
        dkg_id,
        &crypto_components,
    );
    let combination_result = crypto_for(
        random_node_in(&config.receivers().get()),
        &crypto_components,
    )
    .combine_threshold_sig_shares(sig_shares, dkg_id);
    assert_eq!(
        combination_result.unwrap_err(),
        CryptoError::InvalidArgument {
            message: format!(
                "Threshold too high: (threshold={} !<= {}=num_shares)",
                config.threshold().get(),
                num_of_shares_to_combine
            )
        }
    );
}
fn should_fail_to_combine_insufficient_shares ( ) { // Need >=4 nodes to have >=2 shares to combine in a low-threshold config let subnet_size = thread_rng ( ) . gen_range ( 4 , 7 ) ; let ( config , dkg_id , crypto_components ) = setup_with_random_ni_dkg_config ( subnet_size ) ; let num_of_shares_to_combine = config . threshold ( ) . get ( ) - ONE_NODE ; run_ni_dkg_and_load_transcript_for_receivers ( & config , & crypto_components ) ; let sig_shares = sign_threshold_for_each ( & n_random_nodes_in ( & config . receivers ( ) . get ( ) , num_of_shares_to_combine ) , & message ( ) , dkg_id , & crypto_components , ) ; let combination_result = crypto_for ( random_node_in ( & config . receivers ( ) . get ( ) ) , & crypto_components , ) . combine_threshold_sig_shares ( sig_shares , dkg_id ) ; assert_eq ! ( combination_result unwrap_err ( ) CryptoError InvalidArgument { message format ( " " config threshold ( ) get ( ) num_of_shares_to_combine ) } ) ; }
Test uses a random NI-DKG config.
Test uses a random NI - DKG config .