diff --git a/src/messaging/tests/TestExchangeMgr.cpp b/src/messaging/tests/TestExchangeMgr.cpp index d7cdbfe2d49fbf..94586aa4311f14 100644 --- a/src/messaging/tests/TestExchangeMgr.cpp +++ b/src/messaging/tests/TestExchangeMgr.cpp @@ -198,6 +198,11 @@ void CheckExchangeMessages(nlTestSuite * inSuite, void * inContext) CHIP_ERROR err; SecureSessionMgr conn; + ctx.GetInetLayer().SystemLayer()->Init(nullptr); + + err = conn.Init(kSourceNodeId, ctx.GetInetLayer().SystemLayer(), "LOOPBACK"); + NL_TEST_ASSERT(inSuite, err == CHIP_NO_ERROR); + IPAddress addr; IPAddress::FromString("127.0.0.1", addr); SecurePairingUsingTestSecret pairing1(Optional::Value(kSourceNodeId), 1, 2); @@ -209,11 +214,6 @@ void CheckExchangeMessages(nlTestSuite * inSuite, void * inContext) err = conn.NewPairing(peer2, kDestinationNodeId, &pairing2); NL_TEST_ASSERT(inSuite, err == CHIP_NO_ERROR); - ctx.GetInetLayer().SystemLayer()->Init(nullptr); - - err = conn.Init(kSourceNodeId, ctx.GetInetLayer().SystemLayer(), "LOOPBACK"); - NL_TEST_ASSERT(inSuite, err == CHIP_NO_ERROR); - ExchangeManager exchangeMgr; err = exchangeMgr.Init(&conn); NL_TEST_ASSERT(inSuite, err == CHIP_NO_ERROR);