Skip to content

Commit

Permalink
tests: Fix RST_STREAM asserts not conforming to RFC
Browse files Browse the repository at this point in the history
  • Loading branch information
MadMockers committed Mar 27, 2022
1 parent 3b27b2d commit 397c071
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions test/test_closed_streams.py
Original file line number Diff line number Diff line change
Expand Up @@ -390,17 +390,22 @@ def test_resets_further_frames_after_recv_reset(self,
assert not events
assert c.data_to_send() == rst_frame.serialize()

# "An endpoint MUST ignore frames that it receives on closed streams
# after it has sent a RST_STREAM frame."
# The initial RST_STREAM was seen in the previous assert. Additional
# frames should be ignored.
events = c.receive_data(f.serialize() * 3)
assert not events
assert c.data_to_send() == rst_frame.serialize() * 3
assert c.data_to_send() == b""

# Iterate over the streams to make sure it's gone, then confirm the
# behaviour is unchanged.
c.open_outbound_streams

# Additional frames should continue to be ignored
events = c.receive_data(f.serialize() * 3)
assert not events
assert c.data_to_send() == rst_frame.serialize() * 3
assert c.data_to_send() == b""

def test_resets_further_data_frames_after_recv_reset(self,
frame_factory):
Expand Down Expand Up @@ -486,6 +491,7 @@ def test_resets_further_frames_after_send_reset(self,
end_stream=False
)

# Send initial RST_STREAM
c.reset_stream(1, h2.errors.ErrorCodes.INTERNAL_ERROR)

rst_frame = frame_factory.build_rst_stream_frame(
Expand All @@ -496,23 +502,24 @@ def test_resets_further_frames_after_send_reset(self,
f = frame(self, frame_factory)
events = c.receive_data(f.serialize())

rst_frame = frame_factory.build_rst_stream_frame(
1, h2.errors.ErrorCodes.STREAM_CLOSED
)
# "An endpoint MUST ignore frames that it receives on closed streams
# after it has sent a RST_STREAM frame."
# The initial RST_STREAM was sent in the test setup. Additional frames
# should be ignored.
assert not events
assert c.data_to_send() == rst_frame.serialize()
assert c.data_to_send() == b""

events = c.receive_data(f.serialize() * 3)
assert not events
assert c.data_to_send() == rst_frame.serialize() * 3
assert c.data_to_send() == b""

# Iterate over the streams to make sure it's gone, then confirm the
# behaviour is unchanged.
c.open_outbound_streams

events = c.receive_data(f.serialize() * 3)
assert not events
assert c.data_to_send() == rst_frame.serialize() * 3
assert c.data_to_send() == b""

def test_resets_further_data_frames_after_send_reset(self,
frame_factory):
Expand Down

0 comments on commit 397c071

Please sign in to comment.