From 98a0759c91c17bd795357e65ebdd26ccf6a0991f Mon Sep 17 00:00:00 2001 From: Glen Chatfield Date: Sun, 27 Mar 2022 12:20:35 +1100 Subject: [PATCH] tests: Fix RST_STREAM asserts not conforming to RFC --- test/test_closed_streams.py | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/test/test_closed_streams.py b/test/test_closed_streams.py index ef88d8e46..283db2843 100644 --- a/test/test_closed_streams.py +++ b/test/test_closed_streams.py @@ -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): @@ -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( @@ -496,15 +502,16 @@ 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. @@ -512,7 +519,7 @@ def test_resets_further_frames_after_send_reset(self, 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):