changeset 646:89187d5b7d6a

Test case for generate_triples.
author Martin Geisler <mg@daimi.au.dk>
date Sat, 05 Apr 2008 00:00:24 +0200
parents ed0992a4915d
children 5f643bb9c9fb
files viff/test/test_active_runtime.py
diffstat 1 files changed, 22 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/viff/test/test_active_runtime.py	Sat Apr 05 00:00:24 2008 +0200
+++ b/viff/test/test_active_runtime.py	Sat Apr 05 00:00:24 2008 +0200
@@ -84,3 +84,25 @@
             result.addCallback(verify)
             results.append(result)
         return gatherResults(results)
+
+    @protocol
+    def test_generate_triples(self, runtime):
+        """Test generation of multiplication triples."""
+        triples = runtime.generate_triples(self.Zp)
+
+        def verify(triple):
+            """Verify a multiplication triple."""
+            self.assertEquals(triple[0] * triple[1], triple[2])
+
+        results = []
+        for a, b, c in triples:
+            self.assert_type(a, Share)
+            self.assert_type(b, Share)
+            self.assert_type(c, Share)
+            open_a = runtime.open(a)
+            open_b = runtime.open(b)
+            open_c = runtime.open(c)
+            result = gatherResults([open_a, open_b, open_c])
+            result.addCallback(verify)
+            results.append(result)
+        return gatherResults(results)