]> Cypherpunks.ru repositories - pyssss.git/blobdiff - test_ssss.py
Trivial tests
[pyssss.git] / test_ssss.py
diff --git a/test_ssss.py b/test_ssss.py
new file mode 100644 (file)
index 0000000..5deaabe
--- /dev/null
@@ -0,0 +1,18 @@
+# coding: utf-8
+
+from os import urandom
+from random import randint
+from unittest import TestCase
+
+import ssss
+
+
+class TestSSSS(TestCase):
+    def test_symmetric(self):
+        for _ in range(10):
+            n = randint(3, 100)
+            r = randint(1, n)
+            secret = urandom(32)
+            frags = ssss.split(secret, n, r)
+            recovered = ssss.combine(r, frags[:r])
+            self.assertEqual(secret, recovered)