[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [stem/master] Resume hidden service tests



commit 13e166b54eb3b7c1c8d4e4960d08df6571f93f00
Author: Damian Johnson <atagar@xxxxxxxxxxxxxx>
Date:   Sun Nov 17 14:46:38 2019 -0800

    Resume hidden service tests
    
    Resuming our HSv3 tests, with blinding mocked out so we don't negatively impact
    runtime (without these mocks the unit tests jump from 6s => 51s).
---
 test/unit/descriptor/hidden_service_v3.py | 41 ++++++++++++++-----------------
 1 file changed, 19 insertions(+), 22 deletions(-)

diff --git a/test/unit/descriptor/hidden_service_v3.py b/test/unit/descriptor/hidden_service_v3.py
index 34108188..6a838c8a 100644
--- a/test/unit/descriptor/hidden_service_v3.py
+++ b/test/unit/descriptor/hidden_service_v3.py
@@ -80,14 +80,21 @@ with open(get_resource('hidden_service_v3_intro_point')) as intro_point_file:
   INTRO_POINT_STR = intro_point_file.read()
 
 
-# TODO: Blinded key creation and signing are horribly slow. 1.5 seconds each,
-# making each call to HiddenServiceDescriptorV3.create() take over three
-# seconds.
-#
-# Obviously we need to address this, but for the moment skipping the slow tests
-# don't slow branch development.
+def disable_blinding(func):
+  """
+  Blinded key creation and signing are horribly slow. 1.5 seconds each,
+  making each call to HiddenServiceDescriptorV3.create() take over three
+  seconds.
 
-SKIP_SLOW_TESTS = True
+  As such disabling it in most tests.
+  """
+
+  def wrapped(*args, **kwargs):
+    with patch('stem.descriptor.hidden_service._blinded_pubkey', Mock(return_value = b'k' * 32)):
+      with patch('stem.descriptor.hidden_service._blinded_sign', Mock(return_value = b'a' * 64)):
+        return func(*args, **kwargs)
+
+  return wrapped
 
 
 class TestHiddenServiceDescriptorV3(unittest.TestCase):
@@ -171,15 +178,13 @@ class TestHiddenServiceDescriptorV3(unittest.TestCase):
     self.assertEqual(None, intro_point.legacy_key_raw)
     self.assertEqual(None, intro_point.legacy_key_cert)
 
+  @disable_blinding
   @test.require.ed25519_support
   def test_required_fields(self):
     """
     Check that we require the mandatory fields.
     """
 
-    if SKIP_SLOW_TESTS:
-      return
-
     line_to_attr = {
       'hs-descriptor': 'version',
       'descriptor-lifetime': 'lifetime',
@@ -193,15 +198,13 @@ class TestHiddenServiceDescriptorV3(unittest.TestCase):
       desc_text = HiddenServiceDescriptorV3.content(exclude = (line,))
       expect_invalid_attr_for_text(self, desc_text, line_to_attr[line], None)
 
+  @disable_blinding
   @test.require.ed25519_support
   def test_invalid_version(self):
     """
     Checks that our version field expects a numeric value.
     """
 
-    if SKIP_SLOW_TESTS:
-      return
-
     test_values = (
       '',
       '-10',
@@ -211,15 +214,13 @@ class TestHiddenServiceDescriptorV3(unittest.TestCase):
     for test_value in test_values:
       expect_invalid_attr(self, {'hs-descriptor': test_value}, 'version')
 
+  @disable_blinding
   @test.require.ed25519_support
   def test_invalid_lifetime(self):
     """
     Checks that our lifetime field expects a numeric value.
     """
 
-    if SKIP_SLOW_TESTS:
-      return
-
     test_values = (
       '',
       '-10',
@@ -229,15 +230,13 @@ class TestHiddenServiceDescriptorV3(unittest.TestCase):
     for test_value in test_values:
       expect_invalid_attr(self, {'descriptor-lifetime': test_value}, 'lifetime')
 
+  @disable_blinding
   @test.require.ed25519_support
   def test_invalid_revision_counter(self):
     """
     Checks that our revision counter field expects a numeric value.
     """
 
-    if SKIP_SLOW_TESTS:
-      return
-
     test_values = (
       '',
       '-10',
@@ -428,15 +427,13 @@ class TestHiddenServiceDescriptorV3(unittest.TestCase):
     self.assertEqual(1, len(inner_layer.introduction_points))
     self.assertEqual('1.1.1.1', inner_layer.introduction_points[0].link_specifiers[0].address)
 
+  @disable_blinding
   @test.require.ed25519_support
   def test_descriptor_creation(self):
     """
     HiddenServiceDescriptorV3 creation.
     """
 
-    if SKIP_SLOW_TESTS:
-      return
-
     # minimal descriptor
 
     self.assertTrue(HiddenServiceDescriptorV3.content().startswith('hs-descriptor 3\ndescriptor-lifetime 180\n'))



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits