From 4a104dd3d4df3c312c4458d1e2a38e506b7c3616 Mon Sep 17 00:00:00 2001 From: Bastian Gruber Date: Wed, 27 Mar 2024 13:20:49 -0300 Subject: [PATCH] fix: spam every target subnet --- crates/topos-certificate-spammer/src/lib.rs | 48 +++++++++++---------- 1 file changed, 25 insertions(+), 23 deletions(-) diff --git a/crates/topos-certificate-spammer/src/lib.rs b/crates/topos-certificate-spammer/src/lib.rs index 4e62dbaab..70b09039f 100644 --- a/crates/topos-certificate-spammer/src/lib.rs +++ b/crates/topos-certificate-spammer/src/lib.rs @@ -312,31 +312,33 @@ pub async fn run( let source_subnet = &mut source_subnets[rand::random::() % args.nb_subnets as usize]; // Randomize number of target subnets if target subnet list cli argument is provided - let target_subnets: Vec = if target_subnet_ids.is_empty() { - // Empty list of target subnets in certificate - Vec::new() - } else { - // Generate random list in size of 0..len(target_subnet_ids) as target subnets - let number_of_target_subnets = - rand::random::() % (target_subnet_ids.len() + 1); - let mut target_subnets = Vec::new(); - for _ in 0..number_of_target_subnets { - target_subnets.push( - target_subnet_ids - [rand::random::() % target_subnet_ids.len()], - ); + // let target_subnets: Vec = if target_subnet_ids.is_empty() { + // // Empty list of target subnets in certificate + // Vec::new() + // } else { + // // Generate random list in size of 0..len(target_subnet_ids) as target subnets + // let number_of_target_subnets = + // rand::random::() % (target_subnet_ids.len() + 1); + // let mut target_subnets = Vec::new(); + // for _ in 0..number_of_target_subnets { + // target_subnets.push( + // target_subnet_ids + // [rand::random::() % target_subnet_ids.len()], + // ); + // } + // target_subnets + // }; + + let new_cert = match generate_test_certificate( + source_subnet, + target_subnet_ids.as_slice(), + ) { + Ok(cert) => cert, + Err(e) => { + error!("Unable to generate certificate: {e}"); + continue; } - target_subnets }; - - let new_cert = - match generate_test_certificate(source_subnet, target_subnets.as_slice()) { - Ok(cert) => cert, - Err(e) => { - error!("Unable to generate certificate: {e}"); - continue; - } - }; debug!("New cert number {b} in batch {batch_number} generated"); batch.push(new_cert); }