Skip to content

Commit

Permalink
Update names in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
erjiaqing committed Nov 6, 2020
1 parent bc0528f commit c31fd69
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 32 deletions.
40 changes: 20 additions & 20 deletions src/messaging/tests/TestExchangeMgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,38 +78,38 @@ void CheckSimpleInitTest(nlTestSuite * inSuite, void * inContext)
{
TestContext & ctx = *reinterpret_cast<TestContext *>(inContext);

TransportMgr<LoopbackTransport> tm;
SecureSessionMgr conn;
TransportMgr<LoopbackTransport> transportManager;
SecureSessionMgr secureSessionManager;
CHIP_ERROR err;

ctx.GetInetLayer().SystemLayer()->Init(nullptr);

err = conn.Init(kSourceNodeId, ctx.GetInetLayer().SystemLayer());
tm.Init(&conn, nullptr, "LOOPBACK");
err = secureSessionManager.Init(kSourceNodeId, ctx.GetInetLayer().SystemLayer());
transportManager.Init(&secureSessionManager, nullptr, "LOOPBACK");

NL_TEST_ASSERT(inSuite, err == CHIP_NO_ERROR);

ExchangeManager exchangeMgr;
err = exchangeMgr.Init(&conn);
err = exchangeMgr.Init(&secureSessionManager);
NL_TEST_ASSERT(inSuite, err == CHIP_NO_ERROR);
}

void CheckNewContextTest(nlTestSuite * inSuite, void * inContext)
{
TestContext & ctx = *reinterpret_cast<TestContext *>(inContext);

TransportMgr<LoopbackTransport> tm;
SecureSessionMgr conn;
TransportMgr<LoopbackTransport> transportManager;
SecureSessionMgr secureSessionManager;
CHIP_ERROR err;

ctx.GetInetLayer().SystemLayer()->Init(nullptr);

err = conn.Init(kSourceNodeId, ctx.GetInetLayer().SystemLayer());
tm.Init(&conn, nullptr, "LOOPBACK");
err = secureSessionManager.Init(kSourceNodeId, ctx.GetInetLayer().SystemLayer());
transportManager.Init(&secureSessionManager, nullptr, "LOOPBACK");
NL_TEST_ASSERT(inSuite, err == CHIP_NO_ERROR);

ExchangeManager exchangeMgr;
err = exchangeMgr.Init(&conn);
err = exchangeMgr.Init(&secureSessionManager);
NL_TEST_ASSERT(inSuite, err == CHIP_NO_ERROR);

ExchangeContext * ec1 = exchangeMgr.NewContext(kSourceNodeId, (void *) 0x1234);
Expand All @@ -129,19 +129,19 @@ void CheckFindContextTest(nlTestSuite * inSuite, void * inContext)
{
TestContext & ctx = *reinterpret_cast<TestContext *>(inContext);

TransportMgr<LoopbackTransport> tm;
SecureSessionMgr conn;
TransportMgr<LoopbackTransport> transportManager;
SecureSessionMgr secureSessionManager;
CHIP_ERROR err;

ctx.GetInetLayer().SystemLayer()->Init(nullptr);

err = conn.Init(kSourceNodeId, ctx.GetInetLayer().SystemLayer());
err = secureSessionManager.Init(kSourceNodeId, ctx.GetInetLayer().SystemLayer());
NL_TEST_ASSERT(inSuite, err == CHIP_NO_ERROR);
err = tm.Init(&conn, nullptr, "LOOPBACK");
err = transportManager.Init(&secureSessionManager, nullptr, "LOOPBACK");
NL_TEST_ASSERT(inSuite, err == CHIP_NO_ERROR);

ExchangeManager exchangeMgr;
err = exchangeMgr.Init(&conn);
err = exchangeMgr.Init(&secureSessionManager);
NL_TEST_ASSERT(inSuite, err == CHIP_NO_ERROR);

ExchangeContext * ec = exchangeMgr.NewContext(kDestinationNodeId, nullptr);
Expand All @@ -158,19 +158,19 @@ void CheckUmhRegistrationTest(nlTestSuite * inSuite, void * inContext)
{
TestContext & ctx = *reinterpret_cast<TestContext *>(inContext);

TransportMgr<LoopbackTransport> tm;
SecureSessionMgr conn;
TransportMgr<LoopbackTransport> transportManager;
SecureSessionMgr secureSessionManager;
CHIP_ERROR err;

ctx.GetInetLayer().SystemLayer()->Init(nullptr);

err = conn.Init(kSourceNodeId, ctx.GetInetLayer().SystemLayer());
err = secureSessionManager.Init(kSourceNodeId, ctx.GetInetLayer().SystemLayer());
NL_TEST_ASSERT(inSuite, err == CHIP_NO_ERROR);
err = tm.Init(&conn, nullptr, "LOOPBACK");
err = transportManager.Init(&secureSessionManager, nullptr, "LOOPBACK");
NL_TEST_ASSERT(inSuite, err == CHIP_NO_ERROR);

ExchangeManager exchangeMgr;
err = exchangeMgr.Init(&conn);
err = exchangeMgr.Init(&secureSessionManager);
NL_TEST_ASSERT(inSuite, err == CHIP_NO_ERROR);

err = exchangeMgr.RegisterUnsolicitedMessageHandler(0x0001, HanldeAllUnsolicitedMessage, nullptr);
Expand Down
24 changes: 12 additions & 12 deletions src/transport/tests/TestSecureSessionMgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,15 +95,15 @@ void CheckSimpleInitTest(nlTestSuite * inSuite, void * inContext)
{
TestContext & ctx = *reinterpret_cast<TestContext *>(inContext);

TransportMgr<LoopbackTransport> tm;
SecureSessionMgr conn;
TransportMgr<LoopbackTransport> transportManager;
SecureSessionMgr secureSessionManager;
CHIP_ERROR err;

ctx.GetInetLayer().SystemLayer()->Init(nullptr);

err = conn.Init(kSourceNodeId, ctx.GetInetLayer().SystemLayer());
err = secureSessionManager.Init(kSourceNodeId, ctx.GetInetLayer().SystemLayer());
NL_TEST_ASSERT(inSuite, err == CHIP_NO_ERROR);
err = tm.Init(&conn, nullptr, "LOOPBACK");
err = transportManager.Init(&secureSessionManager, nullptr, "LOOPBACK");
NL_TEST_ASSERT(inSuite, err == CHIP_NO_ERROR);
}

Expand All @@ -125,32 +125,32 @@ void CheckMessageTest(nlTestSuite * inSuite, void * inContext)
IPAddress::FromString("127.0.0.1", addr);
CHIP_ERROR err = CHIP_NO_ERROR;

TransportMgr<LoopbackTransport> tm;
SecureSessionMgr conn;
TransportMgr<LoopbackTransport> transportManager;
SecureSessionMgr secureSessionManager;

err = conn.Init(kSourceNodeId, ctx.GetInetLayer().SystemLayer());
err = secureSessionManager.Init(kSourceNodeId, ctx.GetInetLayer().SystemLayer());
NL_TEST_ASSERT(inSuite, err == CHIP_NO_ERROR);
err = tm.Init(&conn, nullptr, "LOOPBACK");
err = transportManager.Init(&secureSessionManager, nullptr, "LOOPBACK");
NL_TEST_ASSERT(inSuite, err == CHIP_NO_ERROR);

callback.mSuite = inSuite;

conn.SetDelegate(&callback);
secureSessionManager.SetDelegate(&callback);

SecurePairingUsingTestSecret pairing1(Optional<NodeId>::Value(kSourceNodeId), 1, 2);
Optional<Transport::PeerAddress> peer(Transport::PeerAddress::UDP(addr, CHIP_PORT));

err = conn.NewPairing(peer, &pairing1);
err = secureSessionManager.NewPairing(peer, &pairing1);
NL_TEST_ASSERT(inSuite, err == CHIP_NO_ERROR);

SecurePairingUsingTestSecret pairing2(Optional<NodeId>::Value(kDestinationNodeId), 2, 1);
err = conn.NewPairing(peer, &pairing2);
err = secureSessionManager.NewPairing(peer, &pairing2);
NL_TEST_ASSERT(inSuite, err == CHIP_NO_ERROR);

// Should be able to send a message to itself by just calling send.
callback.ReceiveHandlerCallCount = 0;

err = conn.SendMessage(kDestinationNodeId, buffer);
err = secureSessionManager.SendMessage(kDestinationNodeId, buffer);
NL_TEST_ASSERT(inSuite, err == CHIP_NO_ERROR);

ctx.DriveIOUntil(1000 /* ms */, []() { return callback.ReceiveHandlerCallCount != 0; });
Expand Down

0 comments on commit c31fd69

Please sign in to comment.