src/net/third_party/quiche/src/quic/core/quic_dispatcher_test.cc
// Duplicated CHLO shouldn't be buffered.
Duplicated CHLO shouldn't be buffered.
Duplicated CHLO shouldn ' t be buffered .
TEST_P(BufferedPacketStoreTest, BufferDuplicatedCHLO) {
  for (uint64_t conn_id = 1; conn_id <= kMaxNumSessionsToCreate + 1;
       ++conn_id) {
    if (conn_id <= kMaxNumSessionsToCreate) {
      EXPECT_CALL(*dispatcher_,
                  CreateQuicSession(TestConnectionId(conn_id), client_addr_,
                                    quiche::QuicheStringPiece(), _))
          .WillOnce(Return(ByMove(CreateSession(
              dispatcher_.get(), config_, TestConnectionId(conn_id),
              client_addr_, &mock_helper_, &mock_alarm_factory_,
              &crypto_config_, QuicDispatcherPeer::GetCache(dispatcher_.get()),
              &session1_))));
      EXPECT_CALL(
          *reinterpret_cast<MockQuicConnection*>(session1_->connection()),
          ProcessUdpPacket(_, _, _))
          .WillOnce(WithArg<2>(
              Invoke([this, conn_id](const QuicEncryptedPacket& packet) {
                ValidatePacket(TestConnectionId(conn_id), packet);
              })));
    }
    ProcessPacket(client_addr_, TestConnectionId(conn_id), true,
                  SerializeFullCHLO());
  }
  QuicConnectionId last_connection =
      TestConnectionId(kMaxNumSessionsToCreate + 1);
  ProcessPacket(client_addr_, last_connection, true, SerializeFullCHLO());
  size_t packets_buffered = 2;
  EXPECT_CALL(*dispatcher_, CreateQuicSession(last_connection, client_addr_,
                                              quiche::QuicheStringPiece(), _))
      .WillOnce(Return(ByMove(CreateSession(
          dispatcher_.get(), config_, last_connection, client_addr_,
          &mock_helper_, &mock_alarm_factory_, &crypto_config_,
          QuicDispatcherPeer::GetCache(dispatcher_.get()), &session1_))));
  EXPECT_CALL(*reinterpret_cast<MockQuicConnection*>(session1_->connection()),
              ProcessUdpPacket(_, _, _))
      .Times(packets_buffered)
      .WillRepeatedly(WithArg<2>(
          Invoke([this, last_connection](const QuicEncryptedPacket& packet) {
            ValidatePacket(last_connection, packet);
          })));
  dispatcher_->ProcessBufferedChlos(kMaxNumSessionsToCreate);
}
TEST_P ( BufferedPacketStoreTest , BufferDuplicatedCHLO ) { for ( uint64_t conn_id = 1 ; conn_id <= kMaxNumSessionsToCreate + 1 ; ++ conn_id ) { if ( conn_id <= kMaxNumSessionsToCreate ) { EXPECT_CALL ( * dispatcher_ , CreateQuicSession ( TestConnectionId ( conn_id ) , client_addr_ , quiche :: QuicheStringPiece ( ) , _ ) ) . WillOnce ( Return ( ByMove ( CreateSession ( dispatcher_ . get ( ) , config_ , TestConnectionId ( conn_id ) , client_addr_ , & mock_helper_ , & mock_alarm_factory_ , & crypto_config_ , QuicDispatcherPeer :: GetCache ( dispatcher_ . get ( ) ) , & session1_ ) ) ) ) ; EXPECT_CALL ( * reinterpret_cast < MockQuicConnection * > ( session1_ -> connection ( ) ) , ProcessUdpPacket ( _ , _ , _ ) ) . WillOnce ( WithArg < 2 > ( Invoke ( [ this , conn_id ] ( const QuicEncryptedPacket & packet ) { ValidatePacket ( TestConnectionId ( conn_id ) , packet ) ; } ) ) ) ; } ProcessPacket ( client_addr_ , TestConnectionId ( conn_id ) , true , SerializeFullCHLO ( ) ) ; } QuicConnectionId last_connection = TestConnectionId ( kMaxNumSessionsToCreate + 1 ) ; ProcessPacket ( client_addr_ , last_connection , true , SerializeFullCHLO ( ) ) ; size_t packets_buffered = 2 ; EXPECT_CALL ( * dispatcher_ , CreateQuicSession ( last_connection , client_addr_ , quiche :: QuicheStringPiece ( ) , _ ) ) . WillOnce ( Return ( ByMove ( CreateSession ( dispatcher_ . get ( ) , config_ , last_connection , client_addr_ , & mock_helper_ , & mock_alarm_factory_ , & crypto_config_ , QuicDispatcherPeer :: GetCache ( dispatcher_ . get ( ) ) , & session1_ ) ) ) ) ; EXPECT_CALL ( * reinterpret_cast < MockQuicConnection * > ( session1_ -> connection ( ) ) , ProcessUdpPacket ( _ , _ , _ ) ) . Times ( packets_buffered ) . WillRepeatedly ( WithArg < 2 > ( Invoke ( [ this , last_connection ] ( const QuicEncryptedPacket & packet ) { ValidatePacket ( last_connection , packet ) ; } ) ) ) ; dispatcher_ -> ProcessBufferedChlos ( kMaxNumSessionsToCreate ) ; }
Duplicated CHLO shouldn't be buffered.
Duplicated CHLO shouldn ' t be buffered .
// Last CHLO will be buffered. Others will create connection right away. // Retransmit CHLO on last connection should be dropped. // Reset counter and process buffered CHLO. // Only one packet(CHLO) should be process.