From 15e1c233bf639f70e74370cc025e9fad6e26f06a Mon Sep 17 00:00:00 2001 From: Abtin Keshavarzian Date: Wed, 3 Jun 2026 14:45:42 -0700 Subject: [PATCH] [tests] simplify RLOC address creation using `GetMeshLocalRloc()` (#13198) This commit refactors several Nexus diagnostic test cases to use the existing `Mle::GetMeshLocalRloc()` method instead of manually assembling the RLOC by combining the mesh-local prefix and the node's RLOC16. This improves code readability and adheres to the standard pattern for retrieving a node's Routing Locator. --- tests/nexus/test_1_3_DIAG_TC_1.cpp | 3 +-- tests/nexus/test_1_3_DIAG_TC_2.cpp | 3 +-- tests/nexus/test_1_3_GEN_TC_1.cpp | 11 ++++------- 3 files changed, 6 insertions(+), 11 deletions(-) diff --git a/tests/nexus/test_1_3_DIAG_TC_1.cpp b/tests/nexus/test_1_3_DIAG_TC_1.cpp index ac7684947..482573d83 100644 --- a/tests/nexus/test_1_3_DIAG_TC_1.cpp +++ b/tests/nexus/test_1_3_DIAG_TC_1.cpp @@ -161,8 +161,7 @@ void TestDiagTc1(const char *aJsonFileName) * - Pass Criteria: * - N/A */ - Ip6::Address dutRloc; - dutRloc.InitAsRoutingLocator(leader.Get().GetMeshLocalPrefix(), router1.Get().GetRloc16()); + Ip6::Address dutRloc = router1.Get().GetMeshLocalRloc(); uint8_t tlvTypesStep2[] = { NetDiag::Tlv::kMaxChildTimeout, NetDiag::Tlv::kEui64, NetDiag::Tlv::kVersion, diff --git a/tests/nexus/test_1_3_DIAG_TC_2.cpp b/tests/nexus/test_1_3_DIAG_TC_2.cpp index 904ecb17a..b2ea5cd0d 100644 --- a/tests/nexus/test_1_3_DIAG_TC_2.cpp +++ b/tests/nexus/test_1_3_DIAG_TC_2.cpp @@ -149,8 +149,7 @@ void TestDiagTc2(const char *aJsonFile) * - Pass Criteria: * - N/A */ - Ip6::Address td1Rloc; - td1Rloc.InitAsRoutingLocator(leader1.Get().GetMeshLocalPrefix(), td1.Get().GetRloc16()); + Ip6::Address td1Rloc = td1.Get().GetMeshLocalRloc(); uint8_t tlvTypesStep2[] = { NetDiag::Tlv::kMaxChildTimeout, NetDiag::Tlv::kEui64, NetDiag::Tlv::kVersion, diff --git a/tests/nexus/test_1_3_GEN_TC_1.cpp b/tests/nexus/test_1_3_GEN_TC_1.cpp index 6b04979ca..1437802c8 100644 --- a/tests/nexus/test_1_3_GEN_TC_1.cpp +++ b/tests/nexus/test_1_3_GEN_TC_1.cpp @@ -279,9 +279,8 @@ void Test_1_3_GEN_TC_1(Topology aTopology, const char *aJsonFileName) * - Pass Criteria (only applies if Device == DUT): * - N/A */ - Ip6::Address br1Rloc; - br1Rloc.InitAsRoutingLocator(router1.Get().GetMeshLocalPrefix(), br1.Get().GetRloc16()); - uint8_t tlvTypes[] = {NetDiag::Tlv::kVersion}; + Ip6::Address br1Rloc = br1.Get().GetMeshLocalRloc(); + uint8_t tlvTypes[] = {NetDiag::Tlv::kVersion}; SuccessOrQuit( router1.Get().SendDiagnosticGet(br1Rloc, tlvTypes, sizeof(tlvTypes), nullptr, nullptr)); @@ -311,8 +310,7 @@ void Test_1_3_GEN_TC_1(Topology aTopology, const char *aJsonFileName) * - Pass Criteria (only applies if Device == DUT): * - N/A */ - Ip6::Address router1Rloc; - router1Rloc.InitAsRoutingLocator(br1.Get().GetMeshLocalPrefix(), router1.Get().GetRloc16()); + Ip6::Address router1Rloc = router1.Get().GetMeshLocalRloc(); SuccessOrQuit( br1.Get().SendDiagnosticGet(router1Rloc, tlvTypes, sizeof(tlvTypes), nullptr, nullptr)); @@ -342,8 +340,7 @@ void Test_1_3_GEN_TC_1(Topology aTopology, const char *aJsonFileName) * - Pass Criteria (only applies if Device == DUT): * - N/A */ - Ip6::Address ed1Rloc; - ed1Rloc.InitAsRoutingLocator(router1.Get().GetMeshLocalPrefix(), ed1.Get().GetRloc16()); + Ip6::Address ed1Rloc = ed1.Get().GetMeshLocalRloc(); SuccessOrQuit( router1.Get().SendDiagnosticGet(ed1Rloc, tlvTypes, sizeof(tlvTypes), nullptr, nullptr));