Skip to content

Commit

Permalink
Added test max number of retry
Browse files Browse the repository at this point in the history
  • Loading branch information
FranciscaOrtegaG committed Nov 11, 2023
1 parent 246c8bc commit 0fb26b4
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions src/resolver/async_resolver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,43 @@ mod async_resolver_test {


//TODO: test max number of retry
#[tokio::test]
async fn max_number_of_retry() {
let mut config = ResolverConfig::default();
let max_retries = 6;
config.set_retry(max_retries);
let mut resolver = AsyncResolver::new(config);

// Realiza una resolución de DNS que sabes que fallará
//let result = resolver.lookup_ip("nonexistent-domain.com", "UDP").await;

let mut retries_attempted = 0;

// Realiza la resolución de DNS que sabes que fallará
while retries_attempted < max_retries {
let result = resolver.lookup_ip("nonexistent-domain.com", "UDP").await;
retries_attempted += 1;

if result.is_ok() {
break; // La resolución tuvo éxito, sal del bucle
}
}
if retries_attempted == max_retries {
assert!(retries_attempted == max_retries, "Número incorrecto de reintentos");
} else {
panic!("La resolución DNS tuvo éxito antes de lo esperado");
}
// // Verifica que se hayan intentado los reintentos especificados
// match result {
// Ok(_) => {
// panic!("Se esperaba un error de timeout, pero se resolvió exitosamente");
// }
// Err(_) => {
// panic!("El timeout no se manejó correctamente");
// }
// }

}

//TODO: use UDP

Expand Down

0 comments on commit 0fb26b4

Please sign in to comment.