Skip to content

Commit 29e01ba

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 5a23130 commit 29e01ba

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
@@ -562,14 +562,8 @@ mod tests {
562562
let ip = Ipv4Addr::from(DEFAULT_IPV4_ADDR);
563563
let other_ip = Ipv4Addr::new(5, 6, 7, 8);
564564
let mac = MacAddr::from_bytes_unchecked(&[0; 6]);
565-
let mut ns = MmdsNetworkStack::new(
566-
mac,
567-
ip,
568-
DEFAULT_TCP_PORT,
569-
NonZeroUsize::new(DEFAULT_MAX_CONNECTIONS).unwrap(),
570-
NonZeroUsize::new(DEFAULT_MAX_PENDING_RESETS).unwrap(),
571-
Arc::new(Mutex::new(Mmds::default())),
572-
);
565+
let mut ns =
566+
MmdsNetworkStack::new_with_defaults(Some(ip), Arc::new(Mutex::new(Mmds::default())));
573567

574568
let mut eth =
575569
EthernetFrame::write_incomplete(buf.as_mut(), mac, mac, ETHERTYPE_ARP).unwrap();
@@ -589,14 +583,8 @@ mod tests {
589583
let ip = Ipv4Addr::from(DEFAULT_IPV4_ADDR);
590584
let other_ip = Ipv4Addr::new(5, 6, 7, 8);
591585
let mac = MacAddr::from_bytes_unchecked(&[0; 6]);
592-
let ns = MmdsNetworkStack::new(
593-
mac,
594-
ip,
595-
DEFAULT_TCP_PORT,
596-
NonZeroUsize::new(DEFAULT_MAX_CONNECTIONS).unwrap(),
597-
NonZeroUsize::new(DEFAULT_MAX_PENDING_RESETS).unwrap(),
598-
Arc::new(Mutex::new(Mmds::default())),
599-
);
586+
let ns =
587+
MmdsNetworkStack::new_with_defaults(Some(ip), Arc::new(Mutex::new(Mmds::default())));
600588

601589
let mut eth =
602590
EthernetFrame::write_incomplete(buf.as_mut(), mac, mac, ETHERTYPE_IPV4).unwrap();
@@ -615,14 +603,8 @@ mod tests {
615603
let ip = Ipv4Addr::from(DEFAULT_IPV4_ADDR);
616604
let other_ip = Ipv4Addr::new(5, 6, 7, 8);
617605
let mac = MacAddr::from_bytes_unchecked(&[0; 6]);
618-
let mut ns = MmdsNetworkStack::new(
619-
mac,
620-
ip,
621-
DEFAULT_TCP_PORT,
622-
NonZeroUsize::new(DEFAULT_MAX_CONNECTIONS).unwrap(),
623-
NonZeroUsize::new(DEFAULT_MAX_PENDING_RESETS).unwrap(),
624-
Arc::new(Mutex::new(Mmds::default())),
625-
);
606+
let mut ns =
607+
MmdsNetworkStack::new_with_defaults(Some(ip), Arc::new(Mutex::new(Mmds::default())));
626608

627609
// try IPv4 with detour_arp
628610
let mut eth =

0 commit comments

Comments
 (0)