From 2a120a9ddf5b96705a0f39c9139b35a490785f43 Mon Sep 17 00:00:00 2001 From: Abtin Keshavarzian Date: Wed, 8 Apr 2026 14:09:17 -0700 Subject: [PATCH] [nexus] remove redundant `mInfraIf` initializations (#12851) This commit removes redundant calls to `mInfraIf.Init()` and `mInfraIf.AddAddress()` from various Nexus test cases. The infrastructure interface (`mInfraIf`) is automatically initialized and assigned a link-local address by the core framework when a new `Node` is added. The `InfraIf::Init()` method derives the link-local address from the MAC address and adds it to the interface. Therefore, these explicit manual calls in individual test scripts are unnecessary and can be removed to simplify the test setup. --- tests/nexus/test_1_2_MATN_TC_1.cpp | 3 --- tests/nexus/test_1_2_MATN_TC_10.cpp | 3 --- tests/nexus/test_1_2_MATN_TC_21.cpp | 3 --- tests/nexus/test_1_2_MATN_TC_5.cpp | 3 --- tests/nexus/test_1_3_DBR_TC_1.cpp | 2 -- tests/nexus/test_1_3_DBR_TC_10.cpp | 3 --- tests/nexus/test_1_3_DBR_TC_2.cpp | 2 -- tests/nexus/test_1_3_DBR_TC_6.cpp | 4 ---- tests/nexus/test_1_3_DBR_TC_7A.cpp | 2 -- tests/nexus/test_1_3_DBR_TC_7B.cpp | 2 -- tests/nexus/test_1_3_DBR_TC_7C.cpp | 2 -- tests/nexus/test_1_3_DBR_TC_8.cpp | 1 - tests/nexus/test_1_3_DPR_TC_1.cpp | 2 -- tests/nexus/test_1_3_SRPC_TC_4.cpp | 1 - tests/nexus/test_1_3_SRPC_TC_5.cpp | 2 -- tests/nexus/test_1_4_TREL_TC_6.cpp | 3 --- 16 files changed, 38 deletions(-) diff --git a/tests/nexus/test_1_2_MATN_TC_1.cpp b/tests/nexus/test_1_2_MATN_TC_1.cpp index 9a5c91ff1..c82c67c14 100644 --- a/tests/nexus/test_1_2_MATN_TC_1.cpp +++ b/tests/nexus/test_1_2_MATN_TC_1.cpp @@ -152,9 +152,6 @@ void TestMatnTc1(void) VerifyOrQuit(router.Get().IsRouter()); - host.mInfraIf.Init(host); - host.mInfraIf.AddAddress(host.mInfraIf.GetLinkLocalAddress()); - nexus.AdvanceTime(kStabilizationTime); // Add multicast variables to test info manually to ensure verify script sees them. diff --git a/tests/nexus/test_1_2_MATN_TC_10.cpp b/tests/nexus/test_1_2_MATN_TC_10.cpp index 74ed8c3ee..e6a579f9f 100644 --- a/tests/nexus/test_1_2_MATN_TC_10.cpp +++ b/tests/nexus/test_1_2_MATN_TC_10.cpp @@ -181,9 +181,6 @@ void TestMatnTc10(void) SuccessOrQuit(br2.Get().SetConfig(config)); } - host.mInfraIf.Init(host); - host.mInfraIf.AddAddress(host.mInfraIf.GetLinkLocalAddress()); - { Ip6::Address hostGua; SuccessOrQuit(hostGua.FromString(kHostGua)); diff --git a/tests/nexus/test_1_2_MATN_TC_21.cpp b/tests/nexus/test_1_2_MATN_TC_21.cpp index b1e170202..5e45ecfd7 100644 --- a/tests/nexus/test_1_2_MATN_TC_21.cpp +++ b/tests/nexus/test_1_2_MATN_TC_21.cpp @@ -204,9 +204,6 @@ void TestMatnTc21(void) SuccessOrQuit(br2.Get().SetEnabled(true)); br2.Get().SetEnabled(true); - host.mInfraIf.Init(host); - host.mInfraIf.AddAddress(host.mInfraIf.GetLinkLocalAddress()); - nexus.AdvanceTime(kStabilizationTime * 2); VerifyOrQuit(br1.Get().IsPrimary()); diff --git a/tests/nexus/test_1_2_MATN_TC_5.cpp b/tests/nexus/test_1_2_MATN_TC_5.cpp index f1886e842..95fdde9ff 100644 --- a/tests/nexus/test_1_2_MATN_TC_5.cpp +++ b/tests/nexus/test_1_2_MATN_TC_5.cpp @@ -183,9 +183,6 @@ void TestMatnTc5(void) SuccessOrQuit(br2.Get().SetEnabled(true)); br2.Get().SetEnabled(true); - host.mInfraIf.Init(host); - host.mInfraIf.AddAddress(host.mInfraIf.GetLinkLocalAddress()); - nexus.AdvanceTime(kStabilizationTime * 2); VerifyOrQuit(br1.Get().IsPrimary()); diff --git a/tests/nexus/test_1_3_DBR_TC_1.cpp b/tests/nexus/test_1_3_DBR_TC_1.cpp index 5cc4fc264..b89b55a6d 100644 --- a/tests/nexus/test_1_3_DBR_TC_1.cpp +++ b/tests/nexus/test_1_3_DBR_TC_1.cpp @@ -116,8 +116,6 @@ void Test_1_3_DBR_TC_1(void) * - Pass Criteria: N/A */ - eth1.mInfraIf.Init(eth1); - Log("---------------------------------------------------------------------------------------"); Log("Step 2: Device: BR 1 (DUT) Description (DBR-1.1): Enable."); diff --git a/tests/nexus/test_1_3_DBR_TC_10.cpp b/tests/nexus/test_1_3_DBR_TC_10.cpp index 2979f22ea..8c908347a 100644 --- a/tests/nexus/test_1_3_DBR_TC_10.cpp +++ b/tests/nexus/test_1_3_DBR_TC_10.cpp @@ -162,8 +162,6 @@ void Test_1_3_DBR_TC_10(const char *aJsonFileName) */ Log("Step 0: Eth_1 configures Ethernet link with GUA_1 prefix and multicasts ND RA."); - eth1.mInfraIf.Init(eth1); - { Ip6::Address eth1Gua; SuccessOrQuit(eth1Gua.FromString(kEth1Gua)); @@ -188,7 +186,6 @@ void Test_1_3_DBR_TC_10(const char *aJsonFileName) */ Log("Step 1: BR_1 enables and configures OMR prefix and external route to GUA_1."); - br1.mInfraIf.Init(br1); br1.Get().Init(kInfraIfIndex, true); br1.Get().Init(); diff --git a/tests/nexus/test_1_3_DBR_TC_2.cpp b/tests/nexus/test_1_3_DBR_TC_2.cpp index c74e8fca2..25cdeb5ff 100644 --- a/tests/nexus/test_1_3_DBR_TC_2.cpp +++ b/tests/nexus/test_1_3_DBR_TC_2.cpp @@ -124,8 +124,6 @@ void Test_1_3_DBR_TC_2(void) * - Pass Criteria: N/A */ - eth1.mInfraIf.Init(eth1); - br2.AllowList(br1); br2.Form(); diff --git a/tests/nexus/test_1_3_DBR_TC_6.cpp b/tests/nexus/test_1_3_DBR_TC_6.cpp index d98abe084..b0bf9ac86 100644 --- a/tests/nexus/test_1_3_DBR_TC_6.cpp +++ b/tests/nexus/test_1_3_DBR_TC_6.cpp @@ -127,8 +127,6 @@ void Test_1_3_DBR_TC_6(void) Log("Step 0: Device: Eth 1 Description (DBR-1.6): Harness configures Ethernet link with an on-link IPv6 GUA prefix " "GUA 1. Eth 1 is configured to multicast ND RAS."); - eth1.mInfraIf.Init(eth1); - { Ip6::Address eth1Gua; SuccessOrQuit(eth1Gua.FromString(kEth1Gua)); @@ -147,7 +145,6 @@ void Test_1_3_DBR_TC_6(void) Log("Step 1: Device: Eth 1, BR 2 Description (DBR-1.6): Form topology. Wait for BR_2 to: 1. Register as border " "router in Thread Network Data with an OMR prefix OMR_1 2. Send multicast ND RAS"); - br2.mInfraIf.Init(br2); br2.Get().Init(kInfraIfIndex, true); br2.Get().Init(); @@ -167,7 +164,6 @@ void Test_1_3_DBR_TC_6(void) Log("---------------------------------------------------------------------------------------"); Log("Step 2: Device: BR 1 (DUT) Description (DBR-1.6): Enable: switch on."); - br1.mInfraIf.Init(br1); br1.Get().Init(kInfraIfIndex, true); br1.AllowList(br2); diff --git a/tests/nexus/test_1_3_DBR_TC_7A.cpp b/tests/nexus/test_1_3_DBR_TC_7A.cpp index 0a73784d7..8c54a3d5a 100644 --- a/tests/nexus/test_1_3_DBR_TC_7A.cpp +++ b/tests/nexus/test_1_3_DBR_TC_7A.cpp @@ -134,7 +134,6 @@ void Test_1_3_DBR_TC_7A(void) * - N/A */ - eth1.mInfraIf.Init(eth1); static const char kGua1Prefix[] = "2001:db8:1::/64"; Ip6::Prefix gua1Prefix; SuccessOrQuit(gua1Prefix.FromString(kGua1Prefix)); @@ -203,7 +202,6 @@ void Test_1_3_DBR_TC_7A(void) br2.Get().HandleServerDataUpdated(); br2.Get().Init(kInfraIfIndex, true); - br2.mInfraIf.Init(br2); Ip6::Prefix pre1Prefix; SuccessOrQuit(pre1Prefix.FromString(kPre1Prefix)); br2.mInfraIf.StartRouterAdvertisement(pre1Prefix); diff --git a/tests/nexus/test_1_3_DBR_TC_7B.cpp b/tests/nexus/test_1_3_DBR_TC_7B.cpp index 1f4ba0677..e68cbf1a7 100644 --- a/tests/nexus/test_1_3_DBR_TC_7B.cpp +++ b/tests/nexus/test_1_3_DBR_TC_7B.cpp @@ -134,7 +134,6 @@ void Test_1_3_DBR_TC_7B(void) * - N/A */ - eth1.mInfraIf.Init(eth1); static const char kGua1Prefix[] = "2001:db8:1::/64"; Ip6::Prefix gua1Prefix; SuccessOrQuit(gua1Prefix.FromString(kGua1Prefix)); @@ -203,7 +202,6 @@ void Test_1_3_DBR_TC_7B(void) br2.Get().HandleServerDataUpdated(); br2.Get().Init(kInfraIfIndex, true); - br2.mInfraIf.Init(br2); Ip6::Prefix pre1Prefix; SuccessOrQuit(pre1Prefix.FromString(kPre1Prefix)); br2.mInfraIf.StartRouterAdvertisement(pre1Prefix); diff --git a/tests/nexus/test_1_3_DBR_TC_7C.cpp b/tests/nexus/test_1_3_DBR_TC_7C.cpp index 886c5d360..b99d21cad 100644 --- a/tests/nexus/test_1_3_DBR_TC_7C.cpp +++ b/tests/nexus/test_1_3_DBR_TC_7C.cpp @@ -144,7 +144,6 @@ void Test_1_3_DBR_TC_7C(void) * - N/A */ - eth1.mInfraIf.Init(eth1); Ip6::Prefix gua1Prefix; SuccessOrQuit(gua1Prefix.FromString(kGua1Prefix)); @@ -211,7 +210,6 @@ void Test_1_3_DBR_TC_7C(void) br2.Get().HandleServerDataUpdated(); br2.Get().Init(kInfraIfIndex, true); - br2.mInfraIf.Init(br2); Ip6::Prefix pre1Prefix; SuccessOrQuit(pre1Prefix.FromString(kPre1Prefix)); br2.mInfraIf.StartRouterAdvertisement(pre1Prefix); diff --git a/tests/nexus/test_1_3_DBR_TC_8.cpp b/tests/nexus/test_1_3_DBR_TC_8.cpp index 4137cb201..c5c5e3ed7 100644 --- a/tests/nexus/test_1_3_DBR_TC_8.cpp +++ b/tests/nexus/test_1_3_DBR_TC_8.cpp @@ -250,7 +250,6 @@ void Test_1_3_DBR_TC_8(void) */ Log("Step 0: Eth_1 configured with GUA_1."); - eth1.mInfraIf.Init(eth1); Ip6::Address eth1Gua; SuccessOrQuit(eth1Gua.FromString(kEth1GuaAddrStr)); eth1.mInfraIf.AddAddress(eth1Gua); diff --git a/tests/nexus/test_1_3_DPR_TC_1.cpp b/tests/nexus/test_1_3_DPR_TC_1.cpp index da74c21d4..44ff96ac2 100644 --- a/tests/nexus/test_1_3_DPR_TC_1.cpp +++ b/tests/nexus/test_1_3_DPR_TC_1.cpp @@ -185,8 +185,6 @@ void Test_1_3_DPR_TC_1(const char *aJsonFileName) * - Pass Criteria: N/A */ - eth1.mInfraIf.Init(eth1); - ed1.Join(br1, Node::kAsFed); nexus.AdvanceTime(kJoinNetworkTime); VerifyOrQuit(ed1.Get().IsAttached()); diff --git a/tests/nexus/test_1_3_SRPC_TC_4.cpp b/tests/nexus/test_1_3_SRPC_TC_4.cpp index 8f3f2b175..47d669c93 100644 --- a/tests/nexus/test_1_3_SRPC_TC_4.cpp +++ b/tests/nexus/test_1_3_SRPC_TC_4.cpp @@ -168,7 +168,6 @@ void Test_1_3_SRPC_TC_4(const char *aJsonFileName) * - N/A */ - eth1.mInfraIf.Init(eth1); br1.Get().Init(kInfraIfIndex, true); br1.Get().Init(); SuccessOrQuit(br1.Get().SetEnabled(true)); diff --git a/tests/nexus/test_1_3_SRPC_TC_5.cpp b/tests/nexus/test_1_3_SRPC_TC_5.cpp index cb592e364..e13105cfd 100644 --- a/tests/nexus/test_1_3_SRPC_TC_5.cpp +++ b/tests/nexus/test_1_3_SRPC_TC_5.cpp @@ -326,8 +326,6 @@ void Test_1_3_SRPC_TC_5(const char *aJsonFileName) ed2.Join(br1, Node::kAsFed); nexus.AdvanceTime(kJoinNetworkTime); - eth1.mInfraIf.Init(eth1); - Log("---------------------------------------------------------------------------------------"); Log("Step 2: Device: BR 1 Description (SRPC-3.5): Automatically adds its SRP Server information"); diff --git a/tests/nexus/test_1_4_TREL_TC_6.cpp b/tests/nexus/test_1_4_TREL_TC_6.cpp index 498d2fa21..f6e9add19 100644 --- a/tests/nexus/test_1_4_TREL_TC_6.cpp +++ b/tests/nexus/test_1_4_TREL_TC_6.cpp @@ -120,7 +120,6 @@ void Test_1_4_TREL_TC_6(void) */ Log("Step 1: Form the topology"); - eth1.mInfraIf.Init(eth1); Ip6::Prefix guaPrefix; SuccessOrQuit(guaPrefix.FromString(kGuaPrefixStr)); eth1.mInfraIf.StartRouterAdvertisement(guaPrefix); @@ -128,7 +127,6 @@ void Test_1_4_TREL_TC_6(void) br.Form(); nexus.AdvanceTime(kFormNetworkTime); - br.mInfraIf.Init(br); br.Get().Init(kInfraIfIndex, true); br.Get().Init(); SuccessOrQuit(br.Get().SetEnabled(true)); @@ -149,7 +147,6 @@ void Test_1_4_TREL_TC_6(void) */ Log("Step 2: Eth_1 sends mDNS query PTR for _trel._udp.local"); - eth1.mInfraIf.Init(eth1); SuccessOrQuit(eth1.Get().SetEnabled(true, kInfraIfIndex)); { Dns::Multicast::Core::Browser browser;