def test_sendPacketEncrypted(self):
        """
        Test that packets sent while encryption is enabled are sent
        correctly.  The whole packet should be encrypted.
        """
        proto = MockTransportBase()
        proto.makeConnection(self.transport)
        self.finishKeyExchange(proto)
        proto.currentEncryptions = testCipher = MockCipher()
        message = ord('A')
        payload = b'BC'
        self.transport.clear()
        proto.sendPacket(message, payload)
        self.assertTrue(testCipher.usedEncrypt)
        value = self.transport.value()
        self.assertEqual(
            value,
            # Four byte length prefix
            b'\x00\x00\x00\x08'
            # One byte padding length
            b'\x04'
            # The actual application data
            b'ABC'
            # "Random" padding - see the secureRandom monkeypatch in setUp
            b'\x99\x99\x99\x99'
            # The MAC
            b'\x02')

        Test that packets sent while encryption is enabled are sent
        correctly.  The whole packet should be encrypted.
        
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_transport.py