From 10519966a4f01e34561e992596bdc8edca9b6fb7 Mon Sep 17 00:00:00 2001 From: Zang MingJie Date: Sat, 5 Mar 2022 02:28:33 +0800 Subject: [PATCH] Access FabricTable in SessionManager (#15774) --- examples/shell/shell_common/cmd_ping.cpp | 7 +- examples/shell/shell_common/cmd_send.cpp | 7 +- examples/shell/shell_common/globals.cpp | 1 + examples/shell/shell_common/include/Globals.h | 2 + src/app/server/Server.cpp | 2 +- .../tests/integration/chip_im_initiator.cpp | 6 +- .../tests/integration/chip_im_responder.cpp | 6 +- src/app/tests/integration/common.cpp | 1 + src/app/tests/integration/common.h | 2 + .../CHIPDeviceControllerFactory.cpp | 3 +- src/messaging/tests/MessagingContext.cpp | 3 +- src/messaging/tests/MessagingContext.h | 1 + src/messaging/tests/echo/common.cpp | 1 + src/messaging/tests/echo/common.h | 2 + src/messaging/tests/echo/echo_requester.cpp | 9 +- src/messaging/tests/echo/echo_responder.cpp | 9 +- src/transport/SessionManager.cpp | 4 +- src/transport/SessionManager.h | 3 +- src/transport/tests/TestSessionManager.cpp | 93 +++++++++++-------- 19 files changed, 110 insertions(+), 52 deletions(-) diff --git a/examples/shell/shell_common/cmd_ping.cpp b/examples/shell/shell_common/cmd_ping.cpp index 2dd01eda676aa5..9d44e016aa6c4e 100644 --- a/examples/shell/shell_common/cmd_ping.cpp +++ b/examples/shell/shell_common/cmd_ping.cpp @@ -291,6 +291,9 @@ void StartPinging(streamer_t * stream, char * destination) ExitNow(err = CHIP_ERROR_INVALID_ARGUMENT); } + err = gFabricTable.Init(&gStorage); + SuccessOrExit(err); + #if INET_CONFIG_ENABLE_TCP_ENDPOINT err = gTCPManager.Init(Transport::TcpListenParameters(DeviceLayer::TCPEndPointManager()) .SetAddressType(gDestAddr.Type()) @@ -306,7 +309,7 @@ void StartPinging(streamer_t * stream, char * destination) #if INET_CONFIG_ENABLE_TCP_ENDPOINT if (gPingArguments.IsUsingTCP()) { - err = gSessionManager.Init(&DeviceLayer::SystemLayer(), &gTCPManager, &gMessageCounterManager, &gStorage); + err = gSessionManager.Init(&DeviceLayer::SystemLayer(), &gTCPManager, &gMessageCounterManager, &gStorage, &gFabricTable); SuccessOrExit(err); err = gExchangeManager.Init(&gSessionManager); @@ -315,7 +318,7 @@ void StartPinging(streamer_t * stream, char * destination) else #endif { - err = gSessionManager.Init(&DeviceLayer::SystemLayer(), &gUDPManager, &gMessageCounterManager, &gStorage); + err = gSessionManager.Init(&DeviceLayer::SystemLayer(), &gUDPManager, &gMessageCounterManager, &gStorage, &gFabricTable); SuccessOrExit(err); err = gExchangeManager.Init(&gSessionManager); diff --git a/examples/shell/shell_common/cmd_send.cpp b/examples/shell/shell_common/cmd_send.cpp index 0b22150f69cd83..c9cb5c1425fc98 100644 --- a/examples/shell/shell_common/cmd_send.cpp +++ b/examples/shell/shell_common/cmd_send.cpp @@ -210,6 +210,9 @@ void ProcessCommand(streamer_t * stream, char * destination) ExitNow(err = CHIP_ERROR_INVALID_ARGUMENT); } + err = gFabricTable.Init(&gStorage); + SuccessOrExit(err); + #if INET_CONFIG_ENABLE_TCP_ENDPOINT err = gTCPManager.Init(Transport::TcpListenParameters(DeviceLayer::TCPEndPointManager()) .SetAddressType(gDestAddr.Type()) @@ -227,7 +230,7 @@ void ProcessCommand(streamer_t * stream, char * destination) { peerAddress = Transport::PeerAddress::TCP(gDestAddr, gSendArguments.GetPort()); - err = gSessionManager.Init(&DeviceLayer::SystemLayer(), &gTCPManager, &gMessageCounterManager, &gStorage); + err = gSessionManager.Init(&DeviceLayer::SystemLayer(), &gTCPManager, &gMessageCounterManager, &gStorage, &gFabricTable); SuccessOrExit(err); } else @@ -235,7 +238,7 @@ void ProcessCommand(streamer_t * stream, char * destination) { peerAddress = Transport::PeerAddress::UDP(gDestAddr, gSendArguments.GetPort(), chip::Inet::InterfaceId::Null()); - err = gSessionManager.Init(&DeviceLayer::SystemLayer(), &gUDPManager, &gMessageCounterManager, &gStorage); + err = gSessionManager.Init(&DeviceLayer::SystemLayer(), &gUDPManager, &gMessageCounterManager, &gStorage, &gFabricTable); SuccessOrExit(err); } diff --git a/examples/shell/shell_common/globals.cpp b/examples/shell/shell_common/globals.cpp index ca8830977ce9c6..4504a57d7abcfa 100644 --- a/examples/shell/shell_common/globals.cpp +++ b/examples/shell/shell_common/globals.cpp @@ -17,6 +17,7 @@ #include +chip::FabricTable gFabricTable; chip::secure_channel::MessageCounterManager gMessageCounterManager; chip::Messaging::ExchangeManager gExchangeManager; chip::SessionManager gSessionManager; diff --git a/examples/shell/shell_common/include/Globals.h b/examples/shell/shell_common/include/Globals.h index f40d11c0ecc6c5..fd2726c3e1f6ef 100644 --- a/examples/shell/shell_common/include/Globals.h +++ b/examples/shell/shell_common/include/Globals.h @@ -17,6 +17,7 @@ #pragma once +#include #include #include #include @@ -32,6 +33,7 @@ constexpr size_t kMaxTcpPendingPackets = 4; #endif constexpr chip::System::Clock::Timeout kResponseTimeOut = chip::System::Clock::Seconds16(1); +extern chip::FabricTable gFabricTable; extern chip::secure_channel::MessageCounterManager gMessageCounterManager; extern chip::Messaging::ExchangeManager gExchangeManager; extern chip::SessionManager gSessionManager; diff --git a/src/app/server/Server.cpp b/src/app/server/Server.cpp index ef3e0e89dffd99..a898bccdb0d196 100644 --- a/src/app/server/Server.cpp +++ b/src/app/server/Server.cpp @@ -180,7 +180,7 @@ CHIP_ERROR Server::Init(AppDelegate * delegate, uint16_t secureServicePort, uint #endif SuccessOrExit(err); - err = mSessions.Init(&DeviceLayer::SystemLayer(), &mTransports, &mMessageCounterManager, &mDeviceStorage); + err = mSessions.Init(&DeviceLayer::SystemLayer(), &mTransports, &mMessageCounterManager, &mDeviceStorage, &GetFabricTable()); SuccessOrExit(err); err = mExchangeMgr.Init(&mSessions); diff --git a/src/app/tests/integration/chip_im_initiator.cpp b/src/app/tests/integration/chip_im_initiator.cpp index c4784b0b63eb6f..721fc3335be1c9 100644 --- a/src/app/tests/integration/chip_im_initiator.cpp +++ b/src/app/tests/integration/chip_im_initiator.cpp @@ -698,12 +698,16 @@ int main(int argc, char * argv[]) InitializeChip(); + err = gFabricTable.Init(&gStorage); + SuccessOrExit(err); + err = gTransportManager.Init(chip::Transport::UdpListenParameters(chip::DeviceLayer::UDPEndPointManager()) .SetAddressType(chip::Inet::IPAddressType::kIPv6) .SetListenPort(IM_CLIENT_PORT)); SuccessOrExit(err); - err = gSessionManager.Init(&chip::DeviceLayer::SystemLayer(), &gTransportManager, &gMessageCounterManager, &gStorage); + err = gSessionManager.Init(&chip::DeviceLayer::SystemLayer(), &gTransportManager, &gMessageCounterManager, &gStorage, + &gFabricTable); SuccessOrExit(err); err = gExchangeManager.Init(&gSessionManager); diff --git a/src/app/tests/integration/chip_im_responder.cpp b/src/app/tests/integration/chip_im_responder.cpp index 6efbb2f5e2d915..01fcbbb40851de 100644 --- a/src/app/tests/integration/chip_im_responder.cpp +++ b/src/app/tests/integration/chip_im_responder.cpp @@ -169,11 +169,15 @@ int main(int argc, char * argv[]) InitializeChip(); + err = gFabricTable.Init(&gStorage); + SuccessOrExit(err); + err = gTransportManager.Init(chip::Transport::UdpListenParameters(chip::DeviceLayer::UDPEndPointManager()) .SetAddressType(chip::Inet::IPAddressType::kIPv6)); SuccessOrExit(err); - err = gSessionManager.Init(&chip::DeviceLayer::SystemLayer(), &gTransportManager, &gMessageCounterManager, &gStorage); + err = gSessionManager.Init(&chip::DeviceLayer::SystemLayer(), &gTransportManager, &gMessageCounterManager, &gStorage, + &gFabricTable); SuccessOrExit(err); err = gExchangeManager.Init(&gSessionManager); diff --git a/src/app/tests/integration/common.cpp b/src/app/tests/integration/common.cpp index 48362a84abc5fc..8deb0ce5519c53 100644 --- a/src/app/tests/integration/common.cpp +++ b/src/app/tests/integration/common.cpp @@ -32,6 +32,7 @@ #include #include +chip::FabricTable gFabricTable; chip::Messaging::ExchangeManager gExchangeManager; chip::SessionManager gSessionManager; chip::secure_channel::MessageCounterManager gMessageCounterManager; diff --git a/src/app/tests/integration/common.h b/src/app/tests/integration/common.h index 9df1531ed73d71..2b1865561c259a 100644 --- a/src/app/tests/integration/common.h +++ b/src/app/tests/integration/common.h @@ -25,6 +25,7 @@ #pragma once #include +#include #include #include #include @@ -33,6 +34,7 @@ #define MAX_MESSAGE_SOURCE_STR_LENGTH (100) #define NETWORK_SLEEP_TIME_MSECS (100 * 1000) +extern chip::FabricTable gFabricTable; extern chip::Messaging::ExchangeManager gExchangeManager; extern chip::SessionManager gSessionManager; extern chip::secure_channel::MessageCounterManager gMessageCounterManager; diff --git a/src/controller/CHIPDeviceControllerFactory.cpp b/src/controller/CHIPDeviceControllerFactory.cpp index 2472f2c637ee71..bcdfdaa3b30bd8 100644 --- a/src/controller/CHIPDeviceControllerFactory.cpp +++ b/src/controller/CHIPDeviceControllerFactory.cpp @@ -148,7 +148,8 @@ CHIP_ERROR DeviceControllerFactory::InitSystemState(FactoryInitParams params) ReturnErrorOnFailure(stateParams.fabricTable->Init(mFabricStorage)); ReturnErrorOnFailure(stateParams.sessionMgr->Init(stateParams.systemLayer, stateParams.transportMgr, - stateParams.messageCounterManager, params.fabricIndependentStorage)); + stateParams.messageCounterManager, params.fabricIndependentStorage, + stateParams.fabricTable)); ReturnErrorOnFailure(stateParams.exchangeMgr->Init(stateParams.sessionMgr)); ReturnErrorOnFailure(stateParams.messageCounterManager->Init(stateParams.exchangeMgr)); diff --git a/src/messaging/tests/MessagingContext.cpp b/src/messaging/tests/MessagingContext.cpp index a9e48e66a2015b..ea280ed400d063 100644 --- a/src/messaging/tests/MessagingContext.cpp +++ b/src/messaging/tests/MessagingContext.cpp @@ -32,7 +32,8 @@ CHIP_ERROR MessagingContext::Init(TransportMgrBase * transport, IOContext * ioCo mTransport = transport; ReturnErrorOnFailure(PlatformMemoryUser::Init()); - ReturnErrorOnFailure(mSessionManager.Init(&GetSystemLayer(), transport, &mMessageCounterManager, &mStorage)); + ReturnErrorOnFailure(mFabricTable.Init(&mStorage)); + ReturnErrorOnFailure(mSessionManager.Init(&GetSystemLayer(), transport, &mMessageCounterManager, &mStorage, &mFabricTable)); ReturnErrorOnFailure(mExchangeManager.Init(&mSessionManager)); ReturnErrorOnFailure(mMessageCounterManager.Init(&mExchangeManager)); diff --git a/src/messaging/tests/MessagingContext.h b/src/messaging/tests/MessagingContext.h index 823e53760251ce..3d289de7bdb3d7 100644 --- a/src/messaging/tests/MessagingContext.h +++ b/src/messaging/tests/MessagingContext.h @@ -142,6 +142,7 @@ class MessagingContext : public PlatformMemoryUser private: bool mInitialized; + FabricTable mFabricTable; SessionManager mSessionManager; Messaging::ExchangeManager mExchangeManager; secure_channel::MessageCounterManager mMessageCounterManager; diff --git a/src/messaging/tests/echo/common.cpp b/src/messaging/tests/echo/common.cpp index fdebf3e6bf1cdb..84e8b09cb9b531 100644 --- a/src/messaging/tests/echo/common.cpp +++ b/src/messaging/tests/echo/common.cpp @@ -30,6 +30,7 @@ #include #include +chip::FabricTable gFabricTable; chip::SessionManager gSessionManager; chip::Messaging::ExchangeManager gExchangeManager; chip::secure_channel::MessageCounterManager gMessageCounterManager; diff --git a/src/messaging/tests/echo/common.h b/src/messaging/tests/echo/common.h index cea330d0c93a3b..ba02d83df3a2b6 100644 --- a/src/messaging/tests/echo/common.h +++ b/src/messaging/tests/echo/common.h @@ -24,6 +24,7 @@ #pragma once +#include #include #include #include @@ -33,6 +34,7 @@ constexpr size_t kMaxTcpActiveConnectionCount = 4; constexpr size_t kMaxTcpPendingPackets = 4; constexpr size_t kNetworkSleepTimeMsecs = (100 * 1000); +extern chip::FabricTable gFabricTable; extern chip::SessionManager gSessionManager; extern chip::Messaging::ExchangeManager gExchangeManager; extern chip::secure_channel::MessageCounterManager gMessageCounterManager; diff --git a/src/messaging/tests/echo/echo_requester.cpp b/src/messaging/tests/echo/echo_requester.cpp index db85a300ea10d3..e8c35e798d8937 100644 --- a/src/messaging/tests/echo/echo_requester.cpp +++ b/src/messaging/tests/echo/echo_requester.cpp @@ -231,6 +231,9 @@ int main(int argc, char * argv[]) InitializeChip(); + err = gFabricTable.Init(&gStorage); + SuccessOrExit(err); + if (gUseTCP) { err = gTCPManager.Init(chip::Transport::TcpListenParameters(chip::DeviceLayer::TCPEndPointManager()) @@ -238,7 +241,8 @@ int main(int argc, char * argv[]) .SetListenPort(ECHO_CLIENT_PORT)); SuccessOrExit(err); - err = gSessionManager.Init(&chip::DeviceLayer::SystemLayer(), &gTCPManager, &gMessageCounterManager, &gStorage); + err = gSessionManager.Init(&chip::DeviceLayer::SystemLayer(), &gTCPManager, &gMessageCounterManager, &gStorage, + &gFabricTable); SuccessOrExit(err); } else @@ -248,7 +252,8 @@ int main(int argc, char * argv[]) .SetListenPort(ECHO_CLIENT_PORT)); SuccessOrExit(err); - err = gSessionManager.Init(&chip::DeviceLayer::SystemLayer(), &gUDPManager, &gMessageCounterManager, &gStorage); + err = gSessionManager.Init(&chip::DeviceLayer::SystemLayer(), &gUDPManager, &gMessageCounterManager, &gStorage, + &gFabricTable); SuccessOrExit(err); } diff --git a/src/messaging/tests/echo/echo_responder.cpp b/src/messaging/tests/echo/echo_responder.cpp index 3702ef4974b771..c8255b1ef2703c 100644 --- a/src/messaging/tests/echo/echo_responder.cpp +++ b/src/messaging/tests/echo/echo_responder.cpp @@ -82,6 +82,9 @@ int main(int argc, char * argv[]) InitializeChip(); + err = gFabricTable.Init(&gStorage); + SuccessOrExit(err); + if (useTCP) { err = gTCPManager.Init(chip::Transport::TcpListenParameters(chip::DeviceLayer::TCPEndPointManager()) @@ -93,7 +96,8 @@ int main(int argc, char * argv[]) ); SuccessOrExit(err); - err = gSessionManager.Init(&chip::DeviceLayer::SystemLayer(), &gTCPManager, &gMessageCounterManager, &gStorage); + err = gSessionManager.Init(&chip::DeviceLayer::SystemLayer(), &gTCPManager, &gMessageCounterManager, &gStorage, + &gFabricTable); SuccessOrExit(err); } else @@ -102,7 +106,8 @@ int main(int argc, char * argv[]) .SetAddressType(chip::Inet::IPAddressType::kIPv6)); SuccessOrExit(err); - err = gSessionManager.Init(&chip::DeviceLayer::SystemLayer(), &gUDPManager, &gMessageCounterManager, &gStorage); + err = gSessionManager.Init(&chip::DeviceLayer::SystemLayer(), &gUDPManager, &gMessageCounterManager, &gStorage, + &gFabricTable); SuccessOrExit(err); } diff --git a/src/transport/SessionManager.cpp b/src/transport/SessionManager.cpp index 461da04d762669..58c5ee2ace5ad7 100644 --- a/src/transport/SessionManager.cpp +++ b/src/transport/SessionManager.cpp @@ -77,16 +77,18 @@ SessionManager::~SessionManager() {} CHIP_ERROR SessionManager::Init(System::Layer * systemLayer, TransportMgrBase * transportMgr, Transport::MessageCounterManagerInterface * messageCounterManager, - chip::PersistentStorageDelegate * storageDelegate) + chip::PersistentStorageDelegate * storageDelegate, FabricTable * fabricTable) { VerifyOrReturnError(mState == State::kNotReady, CHIP_ERROR_INCORRECT_STATE); VerifyOrReturnError(transportMgr != nullptr, CHIP_ERROR_INVALID_ARGUMENT); VerifyOrReturnError(storageDelegate != nullptr, CHIP_ERROR_INVALID_ARGUMENT); + VerifyOrReturnError(fabricTable != nullptr, CHIP_ERROR_INVALID_ARGUMENT); mState = State::kInitialized; mSystemLayer = systemLayer; mTransportMgr = transportMgr; mMessageCounterManager = messageCounterManager; + mFabricTable = fabricTable; // TODO: Handle error from mGlobalEncryptedMessageCounter! Unit tests currently crash if you do! (void) mGlobalEncryptedMessageCounter.Init(); diff --git a/src/transport/SessionManager.h b/src/transport/SessionManager.h index 98b23cad54cb03..554a009ddbfe76 100644 --- a/src/transport/SessionManager.h +++ b/src/transport/SessionManager.h @@ -188,7 +188,7 @@ class DLL_EXPORT SessionManager : public TransportMgrDelegate */ CHIP_ERROR Init(System::Layer * systemLayer, TransportMgrBase * transportMgr, Transport::MessageCounterManagerInterface * messageCounterManager, - chip::PersistentStorageDelegate * storageDelegate); + chip::PersistentStorageDelegate * storageDelegate, FabricTable * fabricTable); /** * @brief @@ -244,6 +244,7 @@ class DLL_EXPORT SessionManager : public TransportMgrDelegate }; System::Layer * mSystemLayer = nullptr; + FabricTable * mFabricTable = nullptr; Transport::UnauthenticatedSessionTable mUnauthenticatedSessions; Transport::SecureSessionTable mSecureSessions; State mState; // < Initialization state of the object diff --git a/src/transport/tests/TestSessionManager.cpp b/src/transport/tests/TestSessionManager.cpp index ff944bfd86693e..57784a48c00a06 100644 --- a/src/transport/tests/TestSessionManager.cpp +++ b/src/transport/tests/TestSessionManager.cpp @@ -100,17 +100,18 @@ void CheckSimpleInitTest(nlTestSuite * inSuite, void * inContext) TestContext & ctx = *reinterpret_cast(inContext); TransportMgr transportMgr; + SimpleFabricStorage fabricStorage; + FabricTable fabricTable; SessionManager sessionManager; secure_channel::MessageCounterManager gMessageCounterManager; chip::TestPersistentStorageDelegate deviceStorage; - CHIP_ERROR err; - - err = transportMgr.Init("LOOPBACK"); - NL_TEST_ASSERT(inSuite, err == CHIP_NO_ERROR); - - err = sessionManager.Init(&ctx.GetSystemLayer(), &transportMgr, &gMessageCounterManager, &deviceStorage); - NL_TEST_ASSERT(inSuite, err == CHIP_NO_ERROR); + NL_TEST_ASSERT(inSuite, CHIP_NO_ERROR == transportMgr.Init("LOOPBACK")); + NL_TEST_ASSERT(inSuite, CHIP_NO_ERROR == fabricTable.Init(&fabricStorage)); + NL_TEST_ASSERT( + inSuite, + CHIP_NO_ERROR == + sessionManager.Init(&ctx.GetSystemLayer(), &transportMgr, &gMessageCounterManager, &deviceStorage, &fabricTable)); } void CheckMessageTest(nlTestSuite * inSuite, void * inContext) @@ -130,15 +131,18 @@ void CheckMessageTest(nlTestSuite * inSuite, void * inContext) CHIP_ERROR err = CHIP_NO_ERROR; TransportMgr transportMgr; + SimpleFabricStorage fabricStorage; + FabricTable fabricTable; SessionManager sessionManager; secure_channel::MessageCounterManager gMessageCounterManager; chip::TestPersistentStorageDelegate deviceStorage; - err = transportMgr.Init("LOOPBACK"); - NL_TEST_ASSERT(inSuite, err == CHIP_NO_ERROR); - - err = sessionManager.Init(&ctx.GetSystemLayer(), &transportMgr, &gMessageCounterManager, &deviceStorage); - NL_TEST_ASSERT(inSuite, err == CHIP_NO_ERROR); + NL_TEST_ASSERT(inSuite, CHIP_NO_ERROR == transportMgr.Init("LOOPBACK")); + NL_TEST_ASSERT(inSuite, CHIP_NO_ERROR == fabricTable.Init(&fabricStorage)); + NL_TEST_ASSERT( + inSuite, + CHIP_NO_ERROR == + sessionManager.Init(&ctx.GetSystemLayer(), &transportMgr, &gMessageCounterManager, &deviceStorage, &fabricTable)); callback.mSuite = inSuite; @@ -223,15 +227,18 @@ void SendEncryptedPacketTest(nlTestSuite * inSuite, void * inContext) CHIP_ERROR err = CHIP_NO_ERROR; TransportMgr transportMgr; + SimpleFabricStorage fabricStorage; + FabricTable fabricTable; SessionManager sessionManager; secure_channel::MessageCounterManager gMessageCounterManager; chip::TestPersistentStorageDelegate deviceStorage; - err = transportMgr.Init("LOOPBACK"); - NL_TEST_ASSERT(inSuite, err == CHIP_NO_ERROR); - - err = sessionManager.Init(&ctx.GetSystemLayer(), &transportMgr, &gMessageCounterManager, &deviceStorage); - NL_TEST_ASSERT(inSuite, err == CHIP_NO_ERROR); + NL_TEST_ASSERT(inSuite, CHIP_NO_ERROR == transportMgr.Init("LOOPBACK")); + NL_TEST_ASSERT(inSuite, CHIP_NO_ERROR == fabricTable.Init(&fabricStorage)); + NL_TEST_ASSERT( + inSuite, + CHIP_NO_ERROR == + sessionManager.Init(&ctx.GetSystemLayer(), &transportMgr, &gMessageCounterManager, &deviceStorage, &fabricTable)); callback.mSuite = inSuite; @@ -302,15 +309,18 @@ void SendBadEncryptedPacketTest(nlTestSuite * inSuite, void * inContext) CHIP_ERROR err = CHIP_NO_ERROR; TransportMgr transportMgr; + SimpleFabricStorage fabricStorage; + FabricTable fabricTable; SessionManager sessionManager; secure_channel::MessageCounterManager gMessageCounterManager; chip::TestPersistentStorageDelegate deviceStorage; - err = transportMgr.Init("LOOPBACK"); - NL_TEST_ASSERT(inSuite, err == CHIP_NO_ERROR); - - err = sessionManager.Init(&ctx.GetSystemLayer(), &transportMgr, &gMessageCounterManager, &deviceStorage); - NL_TEST_ASSERT(inSuite, err == CHIP_NO_ERROR); + NL_TEST_ASSERT(inSuite, CHIP_NO_ERROR == transportMgr.Init("LOOPBACK")); + NL_TEST_ASSERT(inSuite, CHIP_NO_ERROR == fabricTable.Init(&fabricStorage)); + NL_TEST_ASSERT( + inSuite, + CHIP_NO_ERROR == + sessionManager.Init(&ctx.GetSystemLayer(), &transportMgr, &gMessageCounterManager, &deviceStorage, &fabricTable)); callback.mSuite = inSuite; @@ -409,15 +419,18 @@ void StaleConnectionDropTest(nlTestSuite * inSuite, void * inContext) CHIP_ERROR err = CHIP_NO_ERROR; TransportMgr transportMgr; + SimpleFabricStorage fabricStorage; + FabricTable fabricTable; SessionManager sessionManager; secure_channel::MessageCounterManager gMessageCounterManager; chip::TestPersistentStorageDelegate deviceStorage; - err = transportMgr.Init("LOOPBACK"); - NL_TEST_ASSERT(inSuite, err == CHIP_NO_ERROR); - - err = sessionManager.Init(&ctx.GetSystemLayer(), &transportMgr, &gMessageCounterManager, &deviceStorage); - NL_TEST_ASSERT(inSuite, err == CHIP_NO_ERROR); + NL_TEST_ASSERT(inSuite, CHIP_NO_ERROR == transportMgr.Init("LOOPBACK")); + NL_TEST_ASSERT(inSuite, CHIP_NO_ERROR == fabricTable.Init(&fabricStorage)); + NL_TEST_ASSERT( + inSuite, + CHIP_NO_ERROR == + sessionManager.Init(&ctx.GetSystemLayer(), &transportMgr, &gMessageCounterManager, &deviceStorage, &fabricTable)); Optional peer(Transport::PeerAddress::UDP(addr, CHIP_PORT)); TestSessionReleaseCallback callback; @@ -482,15 +495,18 @@ void SendPacketWithOldCounterTest(nlTestSuite * inSuite, void * inContext) CHIP_ERROR err = CHIP_NO_ERROR; TransportMgr transportMgr; + SimpleFabricStorage fabricStorage; + FabricTable fabricTable; SessionManager sessionManager; secure_channel::MessageCounterManager gMessageCounterManager; chip::TestPersistentStorageDelegate deviceStorage; - err = transportMgr.Init("LOOPBACK"); - NL_TEST_ASSERT(inSuite, err == CHIP_NO_ERROR); - - err = sessionManager.Init(&ctx.GetSystemLayer(), &transportMgr, &gMessageCounterManager, &deviceStorage); - NL_TEST_ASSERT(inSuite, err == CHIP_NO_ERROR); + NL_TEST_ASSERT(inSuite, CHIP_NO_ERROR == transportMgr.Init("LOOPBACK")); + NL_TEST_ASSERT(inSuite, CHIP_NO_ERROR == fabricTable.Init(&fabricStorage)); + NL_TEST_ASSERT( + inSuite, + CHIP_NO_ERROR == + sessionManager.Init(&ctx.GetSystemLayer(), &transportMgr, &gMessageCounterManager, &deviceStorage, &fabricTable)); callback.mSuite = inSuite; @@ -574,15 +590,18 @@ void SendPacketWithTooOldCounterTest(nlTestSuite * inSuite, void * inContext) CHIP_ERROR err = CHIP_NO_ERROR; TransportMgr transportMgr; + SimpleFabricStorage fabricStorage; + FabricTable fabricTable; SessionManager sessionManager; secure_channel::MessageCounterManager gMessageCounterManager; chip::TestPersistentStorageDelegate deviceStorage; - err = transportMgr.Init("LOOPBACK"); - NL_TEST_ASSERT(inSuite, err == CHIP_NO_ERROR); - - err = sessionManager.Init(&ctx.GetSystemLayer(), &transportMgr, &gMessageCounterManager, &deviceStorage); - NL_TEST_ASSERT(inSuite, err == CHIP_NO_ERROR); + NL_TEST_ASSERT(inSuite, CHIP_NO_ERROR == transportMgr.Init("LOOPBACK")); + NL_TEST_ASSERT(inSuite, CHIP_NO_ERROR == fabricTable.Init(&fabricStorage)); + NL_TEST_ASSERT( + inSuite, + CHIP_NO_ERROR == + sessionManager.Init(&ctx.GetSystemLayer(), &transportMgr, &gMessageCounterManager, &deviceStorage, &fabricTable)); callback.mSuite = inSuite;