'When on_data receives an invalid encryption, crypto_in() should throw a CryptoException.'

def test_on_data_invalid_encoding(self):

    tunnel_crypto = object.__new__(TunnelCrypto)
    self.tunnel_community.settings = TunnelSettings()
    circuit = Circuit(42L)
    hop = Hop(tunnel_crypto.generate_key(u'curve25519'))
    hop.session_keys = tunnel_crypto.generate_session_keys('1234')
    circuit.add_hop(hop)
    self.tunnel_community.circuits[42] = circuit
    packet = TunnelConversion.encode_data(42, ('127.0.0.1', 1337), ('127.0.0.1', 1337), '')
    (_, encrypted) = TunnelConversion.split_encrypted_packet(packet, u'data')
    self.assertRaises(CryptoException, self.tunnel_community.crypto_in, 42, encrypted, is_data=True)
