Skip to content

Commit

Permalink
Add test for Connection Close() and checking for TCPEndPoint.
Browse files Browse the repository at this point in the history
  • Loading branch information
pidarped committed Dec 18, 2024
1 parent 361adab commit 89a611c
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions src/transport/raw/tests/TestTCP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -609,6 +609,29 @@ TEST_F(TestTCP, HandleConnCloseCalledTest6)
HandleConnCloseTest(addr);
}

TEST_F(TestTCP, CheckTCPEndpointAfterCloseTest)
{
TCPImpl tcp;

IPAddress addr;
IPAddress::FromString("::1", addr);

MockTransportMgrDelegate gMockTransportMgrDelegate(mIOContext);
gMockTransportMgrDelegate.InitializeMessageTest(tcp, addr);
gMockTransportMgrDelegate.ConnectTest(tcp, addr);

Transport::PeerAddress lPeerAddress = Transport::PeerAddress::TCP(addr, gChipTCPPort);
void * state = TestAccess::FindActiveConnection(tcp, lPeerAddress);
ASSERT_NE(state, nullptr);
TCPEndPoint * lEndPoint = TestAccess::GetEndpoint(state);
ASSERT_NE(lEndPoint, nullptr);

// Call Close and check the TCPEndpoint
tcp.Close();
lEndPoint = TestAccess::GetEndpoint(state);
ASSERT_EQ(lEndPoint, nullptr);
}

TEST_F(TestTCP, CheckProcessReceivedBuffer)
{
TCPImpl tcp;
Expand Down

0 comments on commit 89a611c

Please sign in to comment.