Skip to content

Commit

Permalink
[tests] check number of transfered datagrams for more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jlaine committed Mar 28, 2020
1 parent 9bfddce commit 770e56f
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions tests/test_connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -529,7 +529,7 @@ def test_connect_with_quantum_readiness(self):
stream_id = client.get_next_available_stream_id()
client.send_stream_data(stream_id, b"hello")

roundtrip(client, server)
self.assertEqual(roundtrip(client, server), (1, 1))

received = None
while True:
Expand Down Expand Up @@ -564,7 +564,7 @@ def save_session_ticket(ticket):
stream_id = client.get_next_available_stream_id()
client.send_stream_data(stream_id, b"hello")

roundtrip(client, server)
self.assertEqual(roundtrip(client, server), (2, 1))

event = server.next_event()
self.assertEqual(type(event), events.ProtocolNegotiated)
Expand Down Expand Up @@ -903,7 +903,7 @@ def test_handle_connection_close_frame(self):
frame_type=QuicFrameType.ACK,
reason_phrase="illegal ACK frame",
)
roundtrip(server, client)
self.assertEqual(roundtrip(server, client), (1, 0))

self.assertEqual(
client._close_event,
Expand All @@ -917,7 +917,7 @@ def test_handle_connection_close_frame(self):
def test_handle_connection_close_frame_app(self):
with client_and_server() as (client, server):
server.close(error_code=QuicErrorCode.NO_ERROR, reason_phrase="goodbye")
roundtrip(server, client)
self.assertEqual(roundtrip(server, client), (1, 0))

self.assertEqual(
client._close_event,
Expand Down Expand Up @@ -1564,7 +1564,7 @@ def test_send_max_stream_data_retransmit(self):
client.send_stream_data(0, b"hello")
self.assertEqual(stream.max_stream_data_local, 1048576)
self.assertEqual(stream.max_stream_data_local_sent, 1048576)
roundtrip(client, server)
self.assertEqual(roundtrip(client, server), (1, 1))

# server sends data, just before raising MAX_STREAM_DATA
server.send_stream_data(0, b"Z" * 524288) # 1048576 // 2
Expand All @@ -1575,7 +1575,7 @@ def test_send_max_stream_data_retransmit(self):

# server sends one more byte
server.send_stream_data(0, b"Z")
transfer(server, client)
self.assertEqual(transfer(server, client), 1)

# MAX_STREAM_DATA is sent and lost
self.assertEqual(drop(client), 1)
Expand All @@ -1596,7 +1596,7 @@ def test_send_ping(self):

# client sends ping, server ACKs it
client.send_ping(uid=12345)
roundtrip(client, server)
self.assertEqual(roundtrip(client, server), (1, 1))

# check event
event = client.next_event()
Expand Down Expand Up @@ -1678,23 +1678,23 @@ def test_send_stream_data_peer_initiated(self):
with client_and_server() as (client, server):
# server creates bidirectional stream
server.send_stream_data(1, b"hello")
roundtrip(server, client)
self.assertEqual(roundtrip(server, client), (1, 1))

# server creates unidirectional stream
server.send_stream_data(3, b"hello")
roundtrip(server, client)
self.assertEqual(roundtrip(server, client), (1, 1))

# client creates bidirectional stream
client.send_stream_data(0, b"hello")
roundtrip(client, server)
self.assertEqual(roundtrip(client, server), (1, 1))

# client sends data on server-initiated bidirectional stream
client.send_stream_data(1, b"hello")
roundtrip(client, server)
self.assertEqual(roundtrip(client, server), (1, 1))

# client create unidirectional stream
client.send_stream_data(2, b"hello")
roundtrip(client, server)
self.assertEqual(roundtrip(client, server), (1, 1))

# client tries to send data on server-initial unidirectional stream
with self.assertRaises(ValueError) as cm:
Expand Down

0 comments on commit 770e56f

Please sign in to comment.