]> Cypherpunks.ru repositories - pyssss.git/commitdiff
Trivial tests
authorSergey Matveev <stargrave@stargrave.org>
Sun, 10 Apr 2016 08:40:21 +0000 (11:40 +0300)
committerSergey Matveev <stargrave@stargrave.org>
Sun, 10 Apr 2016 08:40:21 +0000 (11:40 +0300)
test_ssss.py [new file with mode: 0644]

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)