Skip to content

Commit 82010dc

Browse files
committed
add test get ip V6 in TCP connection
1 parent 3b3be06 commit 82010dc

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/client/tcp_connection.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ mod tcp_connection_test{
106106

107107
use super::*;
108108
use core::time;
109-
use std::net::{IpAddr,Ipv4Addr};
109+
use std::net::{IpAddr,Ipv4Addr,Ipv6Addr};
110110
use crate::domain_name::DomainName;
111111
use crate::message::type_qtype::Qtype;
112112
use crate::message::class_qclass::Qclass;
@@ -135,6 +135,15 @@ mod tcp_connection_test{
135135
assert_eq!(connection.get_ip(), IpAddr::V4(Ipv4Addr::new(192, 168, 0, 1)));
136136
}
137137

138+
#[test]
139+
fn get_ip_v6(){
140+
let ip_address = IpAddr::V6(Ipv6Addr::new(0xc0, 0xa8, 0, 1, 0, 0, 0, 0));
141+
let timeout = Duration::from_secs(100);
142+
let connection = ClientTCPConnection::new(ip_address, timeout);
143+
//check if the ip is the same
144+
assert_eq!(connection.get_ip(), IpAddr::V6(Ipv6Addr::new(0xc0, 0xa8, 0, 1, 0, 0, 0, 0)));
145+
}
146+
138147
//Setters and Getters test
139148
#[test]
140149
fn get_server_addr(){

0 commit comments

Comments
 (0)