Skip to content

Commit

Permalink
udplistensocket
Browse files Browse the repository at this point in the history
Signed-off-by: Ali Beyad <abeyad@google.com>
  • Loading branch information
abeyad committed Aug 24, 2024
1 parent f3893e7 commit 3af46d9
Showing 1 changed file with 7 additions and 13 deletions.
20 changes: 7 additions & 13 deletions test/common/quic/envoy_quic_client_session_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ class EnvoyQuicClientSessionTest : public testing::TestWithParam<quic::ParsedQui
self_addr_(Network::Utility::getAddressWithPort(
*Network::Test::getCanonicalLoopbackAddress(TestEnvironment::getIpVersionsForTest()[0]),
54321)),
peer_socket_(createUnconnectedSocket(self_addr_, peer_addr_)),
peer_socket_(createListenSocket(peer_addr_)),
crypto_config_(std::make_shared<quic::QuicCryptoClientConfig>(
quic::test::crypto_test_utils::ProofVerifierForTesting())),
quic_stat_names_(store_.symbolTable()),
Expand Down Expand Up @@ -159,17 +159,11 @@ class EnvoyQuicClientSessionTest : public testing::TestWithParam<quic::ParsedQui
peer_socket_->close();
}

Network::ConnectionSocketPtr
createUnconnectedSocket(const Network::Address::InstanceConstSharedPtr& peer_addr,
Network::Address::InstanceConstSharedPtr& local_addr) {
auto connection_socket = std::make_unique<Network::ConnectionSocketImpl>(
Network::Socket::Type::Datagram, local_addr, peer_addr,
Network::SocketCreationOptions{false, 0});
connection_socket->setDetectedTransportProtocol("quic");
ASSERT(connection_socket->isOpen());
connection_socket->bind(local_addr);
local_addr = connection_socket->connectionInfoProvider().localAddress();
return connection_socket;
Network::UdpListenSocketPtr createListenSocket(Network::Address::InstanceConstSharedPtr& addr) {
auto socket =
std::make_unique<Network::UdpListenSocket>(addr, /*options=*/nullptr, /*bind=*/true);
addr = socket->connectionInfoProvider().localAddress();
return socket;
}

EnvoyQuicClientStream& sendGetRequest(Http::ResponseDecoder& response_decoder,
Expand Down Expand Up @@ -199,7 +193,7 @@ class EnvoyQuicClientSessionTest : public testing::TestWithParam<quic::ParsedQui
Network::Address::InstanceConstSharedPtr self_addr_;
// Used in some tests to trigger a read event on the connection to test its full interaction with
// socket read utility functions.
Network::ConnectionSocketPtr peer_socket_;
Network::UdpListenSocketPtr peer_socket_;
quic::DeterministicConnectionIdGenerator connection_id_generator_{
quic::kQuicDefaultConnectionIdLength};
TestEnvoyQuicClientConnection* quic_connection_;
Expand Down

0 comments on commit 3af46d9

Please sign in to comment.