[tor-commits] [stem/master] Deduplicate new capability messages

atagar at torproject.org atagar at torproject.org
Mon Dec 17 18:44:02 UTC 2018


commit 1764f4396bff96671b4709ffd2f8a88fa0d6ccf4
Author: Damian Johnson <atagar at torproject.org>
Date:   Fri Dec 14 11:27:44 2018 -0800

    Deduplicate new capability messages
    
    Clearly we're being way too verbose...
    
    Your version of Tor has capabilities stem currently isn't taking advantage of.
    If you're running the latest version of stem then please file a ticket on:
    
      https://trac.torproject.org/projects/tor/wiki/doc/stem/bugs
    
    New capabilities are:
    
      [Flag (microdescriptor)] StaleDesc
      [Flag] StaleDesc
      [Flag (microdescriptor)] StaleDesc
      [Flag (microdescriptor)] StaleDesc
      [Flag (microdescriptor)] StaleDesc
      [Flag (microdescriptor)] StaleDesc
      [Flag (microdescriptor)] StaleDesc
      [Flag (microdescriptor)] StaleDesc
      [Flag (microdescriptor)] StaleDesc
      [Flag (microdescriptor)] StaleDesc
      [Flag (microdescriptor)] StaleDesc
      [Flag (microdescriptor)] StaleDesc
      [Flag (microdescriptor)] StaleDesc
      [Flag (microdescriptor)] StaleDesc
      [Flag (microdescriptor)] StaleDesc
      [Flag (microdescriptor)] StaleDesc
      [Flag (microdescriptor)] StaleDesc
      [Flag (microdescriptor)] StaleDesc
      [Flag (microdescriptor)] StaleDesc
      [Flag (microdescriptor)] StaleDesc
      [Flag (microdescriptor)] StaleDesc
      [Signal] ACTIVE
      [Signal] DORMANT
---
 run_tests.py                           | 2 +-
 test/__init__.py                       | 6 +++---
 test/integ/descriptor/networkstatus.py | 4 ++--
 3 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/run_tests.py b/run_tests.py
index 3afc5c9a..7fb0a9f9 100755
--- a/run_tests.py
+++ b/run_tests.py
@@ -310,7 +310,7 @@ def main():
   if new_capabilities:
     println(NEW_CAPABILITIES_FOUND, ERROR)
 
-    for capability_type, msg in new_capabilities:
+    for capability_type, msg in sorted(new_capabilities, key = lambda x: x[1]):
       println('  [%s] %s' % (capability_type, msg), ERROR)
 
   sys.exit(1 if error_tracker.has_errors_occured() else 0)
diff --git a/test/__init__.py b/test/__init__.py
index db6282f4..6ca66041 100644
--- a/test/__init__.py
+++ b/test/__init__.py
@@ -61,7 +61,7 @@ STEM_BASE = os.path.sep.join(__file__.split(os.path.sep)[:-2])
 
 # Store new capabilities (events, descriptor entries, etc.)
 
-NEW_CAPABILITIES = []
+NEW_CAPABILITIES = set()
 NEW_CAPABILITIES_SUPPRESSION_TOKENS = set()
 
 # File extensions of contents that should be ignored.
@@ -84,7 +84,7 @@ def get_new_capabilities():
   Provides a list of capabilities tor supports but stem doesn't, as discovered
   while running our tests.
 
-  :returns: **list** of (type, message) tuples for the capabilities
+  :returns: **set** of (type, message) tuples for the capabilities
   """
 
   return NEW_CAPABILITIES
@@ -101,7 +101,7 @@ def register_new_capability(capability_type, msg, suppression_token = None):
   """
 
   if suppression_token not in NEW_CAPABILITIES_SUPPRESSION_TOKENS:
-    NEW_CAPABILITIES.append((capability_type, msg))
+    NEW_CAPABILITIES.add((capability_type, msg))
 
     if suppression_token:
       NEW_CAPABILITIES_SUPPRESSION_TOKENS.add(suppression_token)
diff --git a/test/integ/descriptor/networkstatus.py b/test/integ/descriptor/networkstatus.py
index 81eea545..b9684e6f 100644
--- a/test/integ/descriptor/networkstatus.py
+++ b/test/integ/descriptor/networkstatus.py
@@ -58,7 +58,7 @@ class TestNetworkStatus(unittest.TestCase):
 
         for flag in router.flags:
           if flag not in stem.Flag and flag not in reported_flags:
-            test.register_new_capability('Flag', flag)
+            test.register_new_capability('Flag (consensus)', flag)
             reported_flags.append(flag)
 
         for line in router.get_unrecognized_lines():
@@ -91,7 +91,7 @@ class TestNetworkStatus(unittest.TestCase):
 
         for flag in router.flags:
           if flag not in stem.Flag:
-            test.register_new_capability('Flag (microdescriptor)', flag)
+            test.register_new_capability('Flag (microdescriptor consensus)', flag)
             reported_flags.append(flag)
 
         for line in router.get_unrecognized_lines():





More information about the tor-commits mailing list