Skip to content

Commit bc4da15

Browse files
committed
test(mmds): Do not use MmdsNetworkStack::new() in tests
There is no need to use MmdsNetworkStack::new() instead of MmdsNetworkStack::new_with_defaults() in tests that pass the same default values. Signed-off-by: Takahiro Itazuri <[email protected]>
1 parent 588c7f0 commit bc4da15

File tree

1 file changed

+6
-24
lines changed

1 file changed

+6
-24
lines changed

src/vmm/src/mmds/ns.rs

Lines changed: 6 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -553,14 +553,8 @@ mod tests {
553553
let ip = Ipv4Addr::from(DEFAULT_IPV4_ADDR);
554554
let other_ip = Ipv4Addr::new(5, 6, 7, 8);
555555
let mac = MacAddr::from_bytes_unchecked(&[0; 6]);
556-
let mut ns = MmdsNetworkStack::new(
557-
mac,
558-
ip,
559-
DEFAULT_TCP_PORT,
560-
NonZeroUsize::new(DEFAULT_MAX_CONNECTIONS).unwrap(),
561-
NonZeroUsize::new(DEFAULT_MAX_PENDING_RESETS).unwrap(),
562-
Arc::new(Mutex::new(Mmds::default())),
563-
);
556+
let mut ns =
557+
MmdsNetworkStack::new_with_defaults(Some(ip), Arc::new(Mutex::new(Mmds::default())));
564558

565559
let mut eth =
566560
EthernetFrame::write_incomplete(buf.as_mut(), mac, mac, ETHERTYPE_ARP).unwrap();
@@ -580,14 +574,8 @@ mod tests {
580574
let ip = Ipv4Addr::from(DEFAULT_IPV4_ADDR);
581575
let other_ip = Ipv4Addr::new(5, 6, 7, 8);
582576
let mac = MacAddr::from_bytes_unchecked(&[0; 6]);
583-
let ns = MmdsNetworkStack::new(
584-
mac,
585-
ip,
586-
DEFAULT_TCP_PORT,
587-
NonZeroUsize::new(DEFAULT_MAX_CONNECTIONS).unwrap(),
588-
NonZeroUsize::new(DEFAULT_MAX_PENDING_RESETS).unwrap(),
589-
Arc::new(Mutex::new(Mmds::default())),
590-
);
577+
let ns =
578+
MmdsNetworkStack::new_with_defaults(Some(ip), Arc::new(Mutex::new(Mmds::default())));
591579

592580
let mut eth =
593581
EthernetFrame::write_incomplete(buf.as_mut(), mac, mac, ETHERTYPE_IPV4).unwrap();
@@ -606,14 +594,8 @@ mod tests {
606594
let ip = Ipv4Addr::from(DEFAULT_IPV4_ADDR);
607595
let other_ip = Ipv4Addr::new(5, 6, 7, 8);
608596
let mac = MacAddr::from_bytes_unchecked(&[0; 6]);
609-
let mut ns = MmdsNetworkStack::new(
610-
mac,
611-
ip,
612-
DEFAULT_TCP_PORT,
613-
NonZeroUsize::new(DEFAULT_MAX_CONNECTIONS).unwrap(),
614-
NonZeroUsize::new(DEFAULT_MAX_PENDING_RESETS).unwrap(),
615-
Arc::new(Mutex::new(Mmds::default())),
616-
);
597+
let mut ns =
598+
MmdsNetworkStack::new_with_defaults(Some(ip), Arc::new(Mutex::new(Mmds::default())));
617599

618600
// try IPv4 with detour_arp
619601
let mut eth =

0 commit comments

Comments
 (0)