From 82010dca0ed84b553a93c03d2be2cf14ff2604a7 Mon Sep 17 00:00:00 2001 From: NegroDCC Date: Thu, 4 Jan 2024 14:41:45 -0300 Subject: [PATCH] add test get ip V6 in TCP connection --- src/client/tcp_connection.rs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/client/tcp_connection.rs b/src/client/tcp_connection.rs index 252b486f..f9f8adff 100644 --- a/src/client/tcp_connection.rs +++ b/src/client/tcp_connection.rs @@ -106,7 +106,7 @@ mod tcp_connection_test{ use super::*; use core::time; - use std::net::{IpAddr,Ipv4Addr}; + use std::net::{IpAddr,Ipv4Addr,Ipv6Addr}; use crate::domain_name::DomainName; use crate::message::type_qtype::Qtype; use crate::message::class_qclass::Qclass; @@ -135,6 +135,15 @@ mod tcp_connection_test{ assert_eq!(connection.get_ip(), IpAddr::V4(Ipv4Addr::new(192, 168, 0, 1))); } + #[test] + fn get_ip_v6(){ + let ip_address = IpAddr::V6(Ipv6Addr::new(0xc0, 0xa8, 0, 1, 0, 0, 0, 0)); + let timeout = Duration::from_secs(100); + let connection = ClientTCPConnection::new(ip_address, timeout); + //check if the ip is the same + assert_eq!(connection.get_ip(), IpAddr::V6(Ipv6Addr::new(0xc0, 0xa8, 0, 1, 0, 0, 0, 0))); + } + //Setters and Getters test #[test] fn get_server_addr(){