-
Notifications
You must be signed in to change notification settings - Fork 85
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1826 from Expensify/dan/prevent-double-detach-crash
Do not crash if the detach command is sent twice.
- Loading branch information
Showing
2 changed files
with
44 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#include <iostream> | ||
|
||
#include <libstuff/SData.h> | ||
#include <test/clustertest/BedrockClusterTester.h> | ||
|
||
struct DoubleDetachTest : tpunit::TestFixture { | ||
DoubleDetachTest() | ||
: tpunit::TestFixture("DoubleDetach", | ||
BEFORE_CLASS(DoubleDetachTest::setup), | ||
AFTER_CLASS(DoubleDetachTest::teardown), | ||
TEST(DoubleDetachTest::testDoubleDetach)) { } | ||
|
||
BedrockClusterTester* tester; | ||
|
||
void setup() { | ||
tester = new BedrockClusterTester(); | ||
} | ||
|
||
void teardown() { | ||
delete tester; | ||
} | ||
|
||
void testDoubleDetach() | ||
{ | ||
// Test a control command | ||
BedrockTester& follower = tester->getTester(1); | ||
|
||
// Detach | ||
SData detachCommand("detach"); | ||
follower.executeWaitVerifyContent(detachCommand, "203 DETACHING", true); | ||
|
||
// Wait for it to detach | ||
sleep(3); | ||
|
||
follower.executeWaitVerifyContent(detachCommand, "400 Already detached", true); | ||
} | ||
|
||
} __DoubleDetachTest; |