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(){