mirror of
https://github.com/znc/znc.git
synced 2026-07-28 04:23:38 +02:00
Add IsParting() flag to track PART commands waiting IRCd response.
Fixes potential desync where ZNC marks channel as parted before server confirms the PART, which could cause issues if the server never replies. Add unittests and integration tests.
This commit is contained in:
@@ -558,3 +558,44 @@ TEST_F(IRCSockTest, ChanMode) {
|
||||
":are supported by this server");
|
||||
m_pTestSock->ReadLine(":irc.znc.in 324 me #chan +ntf ");
|
||||
}
|
||||
|
||||
TEST_F(IRCSockTest, PartingFlag) {
|
||||
// Set channel as joined
|
||||
m_pTestChan->SetIsOn(true);
|
||||
|
||||
CMessage clientPart("PART #chan");
|
||||
m_pTestClient->ReadLine(clientPart.ToString());
|
||||
|
||||
EXPECT_THAT(m_pTestSock->vsLines, ElementsAre("PART #chan"));
|
||||
EXPECT_TRUE(m_pTestChan->IsParting());
|
||||
|
||||
m_pTestSock->Reset();
|
||||
|
||||
CMessage serverPart(":me PART #chan");
|
||||
m_pTestSock->ReadLine(serverPart.ToString());
|
||||
|
||||
// IsParting() should be free
|
||||
EXPECT_FALSE(m_pTestChan->IsParting());
|
||||
|
||||
// Verify channel was deleted
|
||||
EXPECT_EQ(m_pTestNetwork->FindChan("#chan"), nullptr);
|
||||
}
|
||||
|
||||
TEST_F(IRCSockTest, PartingFlagOnError) {
|
||||
// Set channel as joined
|
||||
m_pTestChan->SetIsOn(true);
|
||||
|
||||
CMessage clientPart("PART #chan");
|
||||
m_pTestClient->ReadLine(clientPart.ToString());
|
||||
|
||||
m_pTestSock->Reset();
|
||||
|
||||
CMessage errorMsg(":server 442 me #chan :You're not on that channel");
|
||||
m_pTestSock->ReadLine(errorMsg.ToString());
|
||||
|
||||
// IsParting() should be free
|
||||
EXPECT_FALSE(m_pTestChan->IsParting());
|
||||
|
||||
// Verify channel was deleted
|
||||
EXPECT_NE(m_pTestNetwork->FindChan("#chan"), nullptr);
|
||||
}
|
||||
Reference in New Issue
Block a user