viff

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 diff
     1.1 --- a/viff/test/test_active_runtime.py	Sat Apr 05 00:00:24 2008 +0200
     1.2 +++ b/viff/test/test_active_runtime.py	Sat Apr 05 00:00:24 2008 +0200
     1.3 @@ -84,3 +84,25 @@
     1.4              result.addCallback(verify)
     1.5              results.append(result)
     1.6          return gatherResults(results)
     1.7 +
     1.8 +    @protocol
     1.9 +    def test_generate_triples(self, runtime):
    1.10 +        """Test generation of multiplication triples."""
    1.11 +        triples = runtime.generate_triples(self.Zp)
    1.12 +
    1.13 +        def verify(triple):
    1.14 +            """Verify a multiplication triple."""
    1.15 +            self.assertEquals(triple[0] * triple[1], triple[2])
    1.16 +
    1.17 +        results = []
    1.18 +        for a, b, c in triples:
    1.19 +            self.assert_type(a, Share)
    1.20 +            self.assert_type(b, Share)
    1.21 +            self.assert_type(c, Share)
    1.22 +            open_a = runtime.open(a)
    1.23 +            open_b = runtime.open(b)
    1.24 +            open_c = runtime.open(c)
    1.25 +            result = gatherResults([open_a, open_b, open_c])
    1.26 +            result.addCallback(verify)
    1.27 +            results.append(result)
    1.28 +        return gatherResults(results)