Exemplo n.º 1
0
 def test_codec_index_identity(self):
     """Test that encoding and decoding an index works."""
     for i in range(200):
         index = i * 100000
         encoded = crypto.encode_index(index)
         self.assertEqual(6, len(encoded))
         self.assertEqual(crypto.INDEX_ENCODE_LENGTH, len(encoded))
         decoded = crypto.decode_index(encoded)
         self.assertEqual(index, decoded)
Exemplo n.º 2
0
 def test_decode_index_bad(self):
     """Test that encode index detects bad input."""
     with self.assertRaises(CryptoError):
         crypto.decode_index("asdf")
     with self.assertRaises(CryptoError):
         crypto.decode_index("1234567")
     with self.assertRaises(CryptoError):
         crypto.decode_index(crypto.encode_index(crypto.INDEX_MAX+1))