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

[tor-commits] [stem/master] Test that tor's present dirauths match stem's hardcoded list



commit d32a5c09deb81d51e7f792fe2d150579a6769842
Author: Damian Johnson <atagar@xxxxxxxxxxxxxx>
Date:   Thu Feb 19 09:45:50 2015 -0800

    Test that tor's present dirauths match stem's hardcoded list
    
    Stem includes a hardcoded list of tor's directory authorities much as tor
    itself does, so it can do remote descriptor fetching. Adding a simple test that
    it matches the present tor consensus to help us stay in sync...
    
      https://trac.torproject.org/projects/tor/ticket/14832
---
 test/integ/descriptor/remote.py |   25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git a/test/integ/descriptor/remote.py b/test/integ/descriptor/remote.py
index 9183c0d..61370d2 100644
--- a/test/integ/descriptor/remote.py
+++ b/test/integ/descriptor/remote.py
@@ -4,6 +4,7 @@ Integration tests for stem.descriptor.remote.
 
 import unittest
 
+import stem.descriptor
 import stem.descriptor.extrainfo_descriptor
 import stem.descriptor.microdescriptor
 import stem.descriptor.networkstatus
@@ -14,6 +15,30 @@ import test.runner
 
 
 class TestDescriptorDownloader(unittest.TestCase):
+  def test_authorities_are_up_to_date(self):
+    """
+    Check that our hardcoded directory authority data matches the present
+    consensus.
+    """
+
+    if test.runner.require_online(self):
+      return
+    elif test.runner.only_run_once(self):
+      return
+
+    downloader = stem.descriptor.remote.DescriptorDownloader()
+    consensus = downloader.get_consensus(document_handler = stem.descriptor.DocumentHandler.BARE_DOCUMENT).run()[0]
+
+    for auth in consensus.directory_authorities:
+      stem_auth = stem.descriptor.remote.get_authorities().get(auth.nickname)
+
+      if not stem_auth:
+        self.fail("%s isn't a recognized directory authority in stem" % auth.nickname)
+
+      for attr in ('address', 'fingerprint', 'or_port', 'dir_port'):
+        if getattr(auth, attr) != getattr(stem_auth, attr):
+          self.fail("%s has %s %s, but we expected %s" % (auth.nickname, attr, getattr(auth, attr), getattr(stem_auth, attr)))
+
   def test_using_authorities(self):
     """
     Fetches a descriptor from each of the directory authorities. This is



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