algorithms.c: Add a Keccak `set' method now there's upstream support.
[catacomb-python] / t / t-algorithms.py
index 261c53b..455e947 100644 (file)
@@ -76,8 +76,7 @@ class HashBufferTestMixin (U.TestCase):
 
     ## Check overflow detection.
     h0, _ = makefn(w)
-    me.assertRaises((OverflowError, ValueError),
-                    hashfn, h0, 1 << 8*w)
+    me.assertRaises(OverflowError, hashfn, h0, 1 << 8*w)
 
   def check_hashbuffer_bufn(me, w, bigendp, makefn, hashfn):
     """Check `hashbufN'."""
@@ -747,11 +746,11 @@ class TestKeccak (HashBufferTestMixin):
     st1.mix(m0).step()
     me.assertNotEqual(st0.extract(32), st1.extract(32))
 
-    ## Check state copying.
+    ## Check state copying and `mix' vs `set'.
     st1 = st0.copy()
     mask = st1.extract(len(m1))
     st0.mix(m1)
-    st1.mix(m1)
+    st1.set(m1 ^ mask)
     me.assertEqual(st0.extract(32), st1.extract(32))
 
     ## Check error conditions.
@@ -759,6 +758,9 @@ class TestKeccak (HashBufferTestMixin):
     me.assertRaises(ValueError, st0.extract, 201)
     st0.mix(T.span(200))
     me.assertRaises(ValueError, st0.mix, T.span(201))
+    st0.set(T.span(200))
+    me.assertRaises(ValueError, st0.set, T.span(201))
+    me.assertRaises(ValueError, st0.set, T.span(199))
 
   def check_shake(me, xcls, c, done_matches_xof = True):
     """