| 127 | }; |
| 128 | |
| 129 | TEST_F(NetworkTests, MapRequestWithoutPlayerDisconnectsAndDoesNotCrash) |
| 130 | { |
| 131 | NetworkBase network(*_context); |
| 132 | |
| 133 | Connection connection; |
| 134 | auto mockSocket = std::make_unique<MockTcpSocket>(); |
| 135 | connection.socket = std::move(mockSocket); |
| 136 | connection.authStatus = Auth::none; |
| 137 | connection.player = nullptr; |
| 138 | |
| 139 | Packet packet(Command::mapRequest); |
| 140 | packet << static_cast<uint32_t>(0); // 0 objects |
| 141 | |
| 142 | // Before the fix, this would crash because it accesses connection.player->Name |
| 143 | // After the fix, it should detect connection.player == nullptr and disconnect. |
| 144 | network.ServerHandleMapRequest(connection, packet); |
| 145 | |
| 146 | EXPECT_TRUE(connection.shouldDisconnect); |
| 147 | } |
nothing calls this directly
no test coverage detected