예제 #1
0
    def test_receive_sack_discard(self):
        client_transport, _ = dummy_dtls_transport_pair()
        client = RTCSctpTransport(client_transport)
        client._last_received_tsn = 0

        # receive sack
        sack_point = client._last_sacked_tsn
        chunk = SackChunk()
        chunk.cumulative_tsn = tsn_minus_one(sack_point)
        run(client._receive_chunk(chunk))

        # sack point must not changed
        self.assertEqual(client._last_sacked_tsn, sack_point)
예제 #2
0
    def test_receive_shutdown(self):
        async def mock_send_chunk(chunk):
            pass

        client_transport, _ = dummy_dtls_transport_pair()
        client = RTCSctpTransport(client_transport)
        client._last_received_tsn = 0
        client._send_chunk = mock_send_chunk
        client.state = RTCSctpTransport.State.ESTABLISHED

        # receive shutdown
        chunk = ShutdownChunk()
        chunk.cumulative_tsn = tsn_minus_one(client._last_sacked_tsn)
        run(client._receive_chunk(chunk))
        self.assertEqual(client.state,
                         RTCSctpTransport.State.SHUTDOWN_ACK_SENT)

        # receive shutdown complete
        chunk = ShutdownCompleteChunk()
        run(client._receive_chunk(chunk))
        self.assertEqual(client.state, RTCSctpTransport.State.CLOSED)
예제 #3
0
 def test_tsn_minus_one(self):
     self.assertEqual(tsn_minus_one(0), 4294967295)
     self.assertEqual(tsn_minus_one(1), 0)
     self.assertEqual(tsn_minus_one(4294967294), 4294967293)
     self.assertEqual(tsn_minus_one(4294967295), 4294967294)