viff

changeset 1279:513ad56cd8cc

Skip tests when commitment module is not found.
author Martin Geisler <mg@cs.au.dk>
date Fri, 16 Oct 2009 14:30:15 +0200
parents 4b686925f035
children ba17bb67e477
files viff/test/test_orlandi_runtime.py
diffstat 1 files changed, 12 insertions(+), 64 deletions(-) [+]
line diff
     1.1 --- a/viff/test/test_orlandi_runtime.py	Fri Oct 16 14:29:22 2009 +0200
     1.2 +++ b/viff/test/test_orlandi_runtime.py	Fri Oct 16 14:30:15 2009 +0200
     1.3 @@ -19,15 +19,19 @@
     1.4  
     1.5  from viff.test.util import RuntimeTestCase, protocol, BinaryOperatorTestCase
     1.6  from viff.runtime import Share, gather_shares
     1.7 -from viff.orlandi import OrlandiRuntime, OrlandiShare
     1.8 +try:
     1.9 +    from viff.orlandi import OrlandiRuntime, OrlandiShare
    1.10 +    import commitment
    1.11 +except ImportError:
    1.12 +    commitment = None
    1.13 +    OrlandiRuntime = None
    1.14 +    OrlandiShare = None
    1.15  
    1.16  from viff.field import FieldElement, GF
    1.17  from viff.passive import PassiveRuntime
    1.18  
    1.19  from viff.util import rand
    1.20  
    1.21 -# import commitment
    1.22 -
    1.23  
    1.24  def _get_triple(runtime, field):
    1.25      n = field(0)
    1.26 @@ -68,8 +72,6 @@
    1.27          share.addCallback(check)
    1.28          return share
    1.29  
    1.30 -    test_secret_share.skip = "Commitment module is not included in VIFF."
    1.31 -
    1.32      @protocol
    1.33      def test_open_secret_share(self, runtime):
    1.34          """Test sharing and open of a number."""
    1.35 @@ -87,8 +89,6 @@
    1.36          d.addCallback(check)
    1.37          return d
    1.38  
    1.39 -    test_open_secret_share.skip = "Commitment module is not included in VIFF."
    1.40 -
    1.41      @protocol
    1.42      def test_random_share(self, runtime):
    1.43          """Test creation of a random shared number."""
    1.44 @@ -103,8 +103,6 @@
    1.45          d.addCallback(check)
    1.46          return d
    1.47   
    1.48 -    test_random_share.skip = "Commitment module is not included in VIFF."
    1.49 -
    1.50      @protocol
    1.51      def test_sum(self, runtime):
    1.52          """Test addition of two numbers."""
    1.53 @@ -132,8 +130,6 @@
    1.54          d.addCallback(check)
    1.55          return d
    1.56  
    1.57 -    test_sum.skip = "Commitment module is not included in VIFF."
    1.58 -
    1.59      @protocol
    1.60      def test_sum_plus(self, runtime):
    1.61          """Test addition of two numbers."""
    1.62 @@ -161,8 +157,6 @@
    1.63          d.addCallback(check)
    1.64          return d
    1.65  
    1.66 -    test_sum_plus.skip = "Commitment module is not included in VIFF."
    1.67 -
    1.68      @protocol
    1.69      def test_sum_constant(self, runtime):
    1.70          """Test addition of two numbers."""
    1.71 @@ -185,8 +179,6 @@
    1.72          d.addCallback(check)
    1.73          return d
    1.74  
    1.75 -    test_sum_constant.skip = "Commitment module is not included in VIFF."
    1.76 -
    1.77      @protocol
    1.78      def test_sub(self, runtime):
    1.79          """Test subtration of two numbers."""
    1.80 @@ -214,8 +206,6 @@
    1.81          d.addCallback(check)
    1.82          return d
    1.83  
    1.84 -    test_sub.skip = "Commitment module is not included in VIFF."
    1.85 -
    1.86      @protocol
    1.87      def test_sub_minus(self, runtime):
    1.88          """Test subtration of two numbers."""
    1.89 @@ -243,8 +233,6 @@
    1.90          d.addCallback(check)
    1.91          return d
    1.92  
    1.93 -    test_sub_minus.skip = "Commitment module is not included in VIFF."
    1.94 -
    1.95      @protocol
    1.96      def test_sub_constant(self, runtime):
    1.97          """Test subtration of two numbers."""
    1.98 @@ -267,7 +255,6 @@
    1.99          d.addCallback(check)
   1.100          return d
   1.101  
   1.102 -    test_sub_constant.skip = "Commitment module is not included in VIFF."
   1.103  
   1.104  class OrlandiAdvancedCommandsTest(RuntimeTestCase):
   1.105      """Test for advanced commands."""
   1.106 @@ -293,8 +280,6 @@
   1.107          d.addCallback(check)
   1.108          return d
   1.109  
   1.110 -    test_shift.skip = "Commitment module is not included in VIFF."
   1.111 -
   1.112      @protocol
   1.113      def test_shift_two_inputters(self, runtime):
   1.114          """Test addition of the shift command."""
   1.115 @@ -311,8 +296,6 @@
   1.116          d2.addCallback(check)
   1.117          return DeferredList([d1, d2])
   1.118  
   1.119 -    test_shift_two_inputters.skip = "Commitment module is not included in VIFF."
   1.120 -
   1.121      @protocol
   1.122      def test_shift_two_consequtive_inputters(self, runtime):
   1.123          """Test addition of the shift command."""
   1.124 @@ -329,8 +312,6 @@
   1.125          r.addCallback(r1)
   1.126          return r
   1.127  
   1.128 -    test_shift_two_consequtive_inputters.skip = "Commitment module is not included in VIFF."
   1.129 -
   1.130      @protocol
   1.131      def test_shift_two_consequtive_inputters2(self, runtime):
   1.132          """Test addition of the shift command."""
   1.133 @@ -350,8 +331,6 @@
   1.134          r.addCallback(r1)
   1.135          return r
   1.136  
   1.137 -    test_shift_two_consequtive_inputters2.skip = "Commitment module is not included in VIFF."
   1.138 -
   1.139      @protocol
   1.140      def test_input(self, runtime):
   1.141          """Test of many uses of the input command."""
   1.142 @@ -374,8 +353,6 @@
   1.143          shares_ready = gather_shares(a_shares + b_shares)
   1.144          return shares_ready
   1.145  
   1.146 -    test_input.skip = "Commitment module is not included in VIFF."
   1.147 -
   1.148      @protocol
   1.149      def test_basic_multiply(self, runtime):
   1.150          """Test multiplication of two numbers."""
   1.151 @@ -397,8 +374,6 @@
   1.152          d.addCallback(check)
   1.153          return d
   1.154  
   1.155 -    test_basic_multiply.skip = "Commitment module is not included in VIFF."
   1.156 -
   1.157      @protocol
   1.158      def test_mul_mul(self, runtime):
   1.159          """Test multiplication of two numbers."""
   1.160 @@ -419,8 +394,6 @@
   1.161          d.addCallback(check)
   1.162          return d
   1.163  
   1.164 -    test_mul_mul.skip = "Commitment module is not included in VIFF."
   1.165 -
   1.166      @protocol
   1.167      def test_basic_multiply_constant_right(self, runtime):
   1.168          """Test multiplication of two numbers."""
   1.169 @@ -441,8 +414,6 @@
   1.170          d.addCallback(check)
   1.171          return d
   1.172  
   1.173 -    test_basic_multiply_constant_right.skip = "Commitment module is not included in VIFF."
   1.174 -
   1.175      @protocol
   1.176      def test_basic_multiply_constant_left(self, runtime):
   1.177          """Test multiplication of two numbers."""
   1.178 @@ -463,8 +434,6 @@
   1.179          d.addCallback(check)
   1.180          return d
   1.181  
   1.182 -    test_basic_multiply_constant_left.skip = "Commitment module is not included in VIFF."
   1.183 -
   1.184      @protocol
   1.185      def test_constant_multiplication_constant_left(self, runtime):
   1.186          """Test multiplication of two numbers."""
   1.187 @@ -484,8 +453,6 @@
   1.188          d.addCallback(check)
   1.189          return d
   1.190  
   1.191 -    test_constant_multiplication_constant_left.skip = "Commitment module is not included in VIFF."
   1.192 -
   1.193      @protocol
   1.194      def test_constant_multiplication_constant_right(self, runtime):
   1.195          """Test multiplication of two numbers."""
   1.196 @@ -505,8 +472,6 @@
   1.197          d.addCallback(check)
   1.198          return d
   1.199  
   1.200 -    test_constant_multiplication_constant_right.skip = "Commitment module is not included in VIFF."
   1.201 -
   1.202      @protocol
   1.203      def test_constant_multiplication_constant_None(self, runtime):
   1.204          """Test multiplication of two numbers."""
   1.205 @@ -519,8 +484,6 @@
   1.206          x2 = runtime.shift([1], self.Zp, x1)
   1.207          y2 = runtime.shift([1], self.Zp, y1)
   1.208  
   1.209 -    test_constant_multiplication_constant_None.skip = "Commitment module is not included in VIFF."
   1.210 -
   1.211      @protocol
   1.212      def test_sum_poly(self, runtime):
   1.213          """Test implementation of sum_poly."""
   1.214 @@ -539,8 +502,6 @@
   1.215          self.assertEquals(Cx, 29)
   1.216          return x
   1.217  
   1.218 -    test_sum_poly.skip = "Commitment module is not included in VIFF."
   1.219 - 
   1.220      @protocol
   1.221      def test_sum_poly(self, runtime):
   1.222          """Test implementation of sum_poly."""
   1.223 @@ -563,8 +524,6 @@
   1.224          self.assertEquals(Cx, Cf1**3 * Cf2**9 * Cf3**27)
   1.225          return x
   1.226  
   1.227 -    test_sum_poly.skip = "Commitment module is not included in VIFF."
   1.228 -
   1.229      @protocol
   1.230      def test_delta(self, runtime):
   1.231          """Test implementation of compute_delta."""
   1.232 @@ -582,8 +541,6 @@
   1.233   
   1.234          return delta
   1.235  
   1.236 -    test_delta.skip = "Commitment module is not included in VIFF."
   1.237 -
   1.238      @protocol
   1.239      def test_leak_mul(self, runtime):
   1.240          """Test leaktolerant multiplication of two numbers."""
   1.241 @@ -616,11 +573,9 @@
   1.242          self.assertEquals(z2, None)
   1.243          return z2
   1.244  
   1.245 -    test_leak_mul.skip = "Commitment module is not included in VIFF."
   1.246 -
   1.247  class TripleGenTest(RuntimeTestCase):
   1.248      """Test for generation of triples."""
   1.249 -    
   1.250 +
   1.251      # Number of players.
   1.252      num_players = 3
   1.253   
   1.254 @@ -648,8 +603,6 @@
   1.255          d.addCallbacks(open, runtime.error_handler)
   1.256          return d
   1.257  
   1.258 -    test_tripleGen.skip = "Commitment module is not included in VIFF."
   1.259 -
   1.260      @protocol
   1.261      def test_tripleGen2(self, runtime):
   1.262          """Test the triple_gen command."""
   1.263 @@ -676,8 +629,6 @@
   1.264          d.addCallbacks(open, runtime.error_handler)
   1.265          return d
   1.266  
   1.267 -    test_tripleGen2.skip = "Commitment module is not included in VIFF."
   1.268 -    
   1.269      @protocol
   1.270      def test_tripleTest(self, runtime):
   1.271          """Test the triple_test command."""
   1.272 @@ -698,8 +649,6 @@
   1.273          d.addCallbacks(open, runtime.error_handler)
   1.274          return d
   1.275  
   1.276 -    test_tripleTest.skip = "Commitment module is not included in VIFF."
   1.277 -
   1.278      @protocol
   1.279      def test_random_triple(self, runtime):
   1.280          """Test the triple_combiner command."""
   1.281 @@ -730,8 +679,6 @@
   1.282          d.addCallbacks(open, runtime.error_handler)
   1.283          return d
   1.284  
   1.285 -    test_random_triple.skip = "Commitment module is not included in VIFF."
   1.286 -
   1.287      @protocol
   1.288      def test_random_triple3_parallel(self, runtime):
   1.289          """Test the triple_combiner command."""
   1.290 @@ -765,8 +712,6 @@
   1.291          d.addCallbacks(open, runtime.error_handler)
   1.292          return d
   1.293  
   1.294 -    test_random_triple3_parallel.skip = "Commitment module is not included in VIFF."
   1.295 -
   1.296      @protocol
   1.297      def test_random_triple_parallel(self, runtime):
   1.298          """Test the triple_combiner command."""
   1.299 @@ -822,4 +767,7 @@
   1.300          runtime.schedule_callback(shares_ready, cont)
   1.301          return shares_ready
   1.302  
   1.303 -    test_random_triple_parallel.skip = "Commitment module is not included in VIFF."
   1.304 +if not commitment:
   1.305 +    OrlandiAdvancedCommandsTest.skip = "Skipped due to missing commitment module."
   1.306 +    OrlandiBasicCommandsTest.skip = "Skipped due to missing commitment module."
   1.307 +    TripleGenTest.skip = "Skipped due to missing commitment module."