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

[tor-commits] [stem/master] RelayExtraInfoDescriptor creation



commit 7b5be00d5ddf5f668d5a366845693cfa215ed0b6
Author: Damian Johnson <atagar@xxxxxxxxxxxxxx>
Date:   Mon May 1 11:02:18 2017 -0700

    RelayExtraInfoDescriptor creation
---
 stem/descriptor/extrainfo_descriptor.py      | 15 ++++++
 test/mocking.py                              | 30 -----------
 test/unit/descriptor/extrainfo_descriptor.py | 81 ++++++++++++++--------------
 3 files changed, 55 insertions(+), 71 deletions(-)

diff --git a/stem/descriptor/extrainfo_descriptor.py b/stem/descriptor/extrainfo_descriptor.py
index 716b75c..7a2e7b1 100644
--- a/stem/descriptor/extrainfo_descriptor.py
+++ b/stem/descriptor/extrainfo_descriptor.py
@@ -77,8 +77,10 @@ import stem.util.enum
 import stem.util.str_tools
 
 from stem.descriptor import (
+  CRYPTO_BLOB,
   PGP_BLOCK_END,
   Descriptor,
+  _descriptor_content,
   _read_until_keywords,
   _get_descriptor_components,
   _value,
@@ -155,6 +157,15 @@ SINGLE_FIELDS = (
   'exit-streams-opened',
 )
 
+RELAY_EXTRAINFO_HEADER = (
+  ('extra-info', 'ninja B2289C3EAB83ECD6EB916A2F481A02E6B76A0A48'),
+  ('published', '2012-05-05 17:03:50'),
+)
+
+RELAY_EXTRAINFO_FOOTER = (
+  ('router-signature', '\n-----BEGIN SIGNATURE-----%s-----END SIGNATURE-----' % CRYPTO_BLOB),
+)
+
 
 _timestamp_re = re.compile('^(.*) \(([0-9]+) s\)( .*)?$')
 _locale_re = re.compile('^[a-zA-Z0-9\?]{2}$')
@@ -914,6 +925,10 @@ class RelayExtraInfoDescriptor(ExtraInfoDescriptor):
     'router-signature': _parse_router_signature_line,
   })
 
+  @classmethod
+  def content(cls, attr = None, exclude = ()):
+    return _descriptor_content(attr, exclude, RELAY_EXTRAINFO_HEADER, RELAY_EXTRAINFO_FOOTER)
+
   @lru_cache()
   def digest(self):
     # our digest is calculated from everything except our signature
diff --git a/test/mocking.py b/test/mocking.py
index caf7d44..dc08a61 100644
--- a/test/mocking.py
+++ b/test/mocking.py
@@ -17,7 +17,6 @@ Helper functions for creating mock objects.
       get_microdescriptor - Microdescriptor
 
     stem.descriptor.extrainfo_descriptor
-      get_relay_extrainfo_descriptor  - RelayExtraInfoDescriptor
       get_bridge_extrainfo_descriptor - BridgeExtraInfoDescriptor
 
     stem.descriptor.networkstatus
@@ -76,15 +75,6 @@ DOC_SIG = stem.descriptor.networkstatus.DocumentSignature(
   'BF112F1C6D5543CFD0A32215ACABD4197B5279AD',
   '-----BEGIN SIGNATURE-----%s-----END SIGNATURE-----' % CRYPTO_BLOB)
 
-RELAY_EXTRAINFO_HEADER = (
-  ('extra-info', 'ninja B2289C3EAB83ECD6EB916A2F481A02E6B76A0A48'),
-  ('published', '2012-05-05 17:03:50'),
-)
-
-RELAY_EXTRAINFO_FOOTER = (
-  ('router-signature', '\n-----BEGIN SIGNATURE-----%s-----END SIGNATURE-----' % CRYPTO_BLOB),
-)
-
 BRIDGE_EXTRAINFO_HEADER = (
   ('extra-info', 'ec2bridgereaac65a3 1EC248422B57D9C0BD751892FE787585407479A4'),
   ('published', '2012-05-05 17:03:50'),
@@ -341,26 +331,6 @@ def _get_descriptor_content(attr = None, exclude = (), header_template = (), foo
   return stem.util.str_tools._to_bytes('\n'.join(header_content + remainder + footer_content))
 
 
-def get_relay_extrainfo_descriptor(attr = None, exclude = (), content = False):
-  """
-  Provides the descriptor content for...
-  stem.descriptor.extrainfo_descriptor.RelayExtraInfoDescriptor
-
-  :param dict attr: keyword/value mappings to be included in the descriptor
-  :param list exclude: mandatory keywords to exclude from the descriptor
-  :param bool content: provides the str content of the descriptor rather than the class if True
-
-  :returns: RelayExtraInfoDescriptor for the requested descriptor content
-  """
-
-  desc_content = _get_descriptor_content(attr, exclude, RELAY_EXTRAINFO_HEADER, RELAY_EXTRAINFO_FOOTER)
-
-  if content:
-    return desc_content
-  else:
-    return stem.descriptor.extrainfo_descriptor.RelayExtraInfoDescriptor(desc_content, validate = True)
-
-
 def get_bridge_extrainfo_descriptor(attr = None, exclude = (), content = False):
   """
   Provides the descriptor content for...
diff --git a/test/unit/descriptor/extrainfo_descriptor.py b/test/unit/descriptor/extrainfo_descriptor.py
index cab3440..61f5ee7 100644
--- a/test/unit/descriptor/extrainfo_descriptor.py
+++ b/test/unit/descriptor/extrainfo_descriptor.py
@@ -10,7 +10,7 @@ import stem.descriptor
 
 from stem.descriptor.extrainfo_descriptor import RelayExtraInfoDescriptor, DirResponse, DirStat
 
-from test.mocking import get_relay_extrainfo_descriptor, get_bridge_extrainfo_descriptor, CRYPTO_BLOB
+from test.mocking import get_bridge_extrainfo_descriptor, CRYPTO_BLOB
 
 from test.unit.descriptor import get_resource
 
@@ -183,8 +183,7 @@ k0d2aofcVbHr4fPQOSST0LXDrhFl5Fqo5um296zpJGvRUeO6S44U/EfJAGShtqWw
     attributes.
     """
 
-    desc = get_relay_extrainfo_descriptor()
-
+    desc = RelayExtraInfoDescriptor.create()
     self.assertEqual('ninja', desc.nickname)
     self.assertEqual('B2289C3EAB83ECD6EB916A2F481A02E6B76A0A48', desc.fingerprint)
     self.assertTrue(CRYPTO_BLOB in desc.signature)
@@ -194,7 +193,7 @@ k0d2aofcVbHr4fPQOSST0LXDrhFl5Fqo5um296zpJGvRUeO6S44U/EfJAGShtqWw
     Includes unrecognized content in the descriptor.
     """
 
-    desc = get_relay_extrainfo_descriptor({'pepperjack': 'is oh so tasty!'})
+    desc = RelayExtraInfoDescriptor.create({'pepperjack': 'is oh so tasty!'})
     self.assertEqual(['pepperjack is oh so tasty!'], desc.get_unrecognized_lines())
 
   def test_proceeding_line(self):
@@ -202,7 +201,7 @@ k0d2aofcVbHr4fPQOSST0LXDrhFl5Fqo5um296zpJGvRUeO6S44U/EfJAGShtqWw
     Includes a line prior to the 'extra-info' entry.
     """
 
-    desc_text = b'exit-streams-opened port=80\n' + get_relay_extrainfo_descriptor(content = True)
+    desc_text = b'exit-streams-opened port=80\n' + RelayExtraInfoDescriptor.content()
     self._expect_invalid_attr(desc_text)
 
   def test_trailing_line(self):
@@ -210,7 +209,7 @@ k0d2aofcVbHr4fPQOSST0LXDrhFl5Fqo5um296zpJGvRUeO6S44U/EfJAGShtqWw
     Includes a line after the 'router-signature' entry.
     """
 
-    desc_text = get_relay_extrainfo_descriptor(content = True) + b'\nexit-streams-opened port=80'
+    desc_text = RelayExtraInfoDescriptor.content() + b'\nexit-streams-opened port=80'
     self._expect_invalid_attr(desc_text)
 
   def test_extrainfo_line_missing_fields(self):
@@ -228,7 +227,7 @@ k0d2aofcVbHr4fPQOSST0LXDrhFl5Fqo5um296zpJGvRUeO6S44U/EfJAGShtqWw
     )
 
     for entry in test_entries:
-      desc_text = get_relay_extrainfo_descriptor({'extra-info': entry}, content = True)
+      desc_text = RelayExtraInfoDescriptor.content({'extra-info': entry})
       desc = self._expect_invalid_attr(desc_text, 'nickname')
       self.assertEqual(None, desc.nickname)
       self.assertEqual(None, desc.fingerprint)
@@ -240,10 +239,10 @@ k0d2aofcVbHr4fPQOSST0LXDrhFl5Fqo5um296zpJGvRUeO6S44U/EfJAGShtqWw
     """
 
     geoip_db_digest = '916A3CA8B7DF61473D5AE5B21711F35F301CE9E8'
-    desc = get_relay_extrainfo_descriptor({'geoip-db-digest': geoip_db_digest})
+    desc = RelayExtraInfoDescriptor.create({'geoip-db-digest': geoip_db_digest})
     self.assertEqual(geoip_db_digest, desc.geoip_db_digest)
 
-    desc = get_relay_extrainfo_descriptor({'geoip6-db-digest': geoip_db_digest})
+    desc = RelayExtraInfoDescriptor.create({'geoip6-db-digest': geoip_db_digest})
     self.assertEqual(geoip_db_digest, desc.geoip6_db_digest)
 
     test_entries = (
@@ -255,10 +254,10 @@ k0d2aofcVbHr4fPQOSST0LXDrhFl5Fqo5um296zpJGvRUeO6S44U/EfJAGShtqWw
     )
 
     for entry in test_entries:
-      desc_text = get_relay_extrainfo_descriptor({'geoip-db-digest': entry}, content = True)
+      desc_text = RelayExtraInfoDescriptor.content({'geoip-db-digest': entry})
       self._expect_invalid_attr(desc_text, 'geoip_db_digest')
 
-      desc_text = get_relay_extrainfo_descriptor({'geoip6-db-digest': entry}, content = True)
+      desc_text = RelayExtraInfoDescriptor.content({'geoip6-db-digest': entry})
       self._expect_invalid_attr(desc_text, 'geoip6_db_digest')
 
   def test_cell_circuits_per_decile(self):
@@ -272,7 +271,7 @@ k0d2aofcVbHr4fPQOSST0LXDrhFl5Fqo5um296zpJGvRUeO6S44U/EfJAGShtqWw
     )
 
     for entry in ('0', '11', '25'):
-      desc = get_relay_extrainfo_descriptor({'cell-circuits-per-decile': entry})
+      desc = RelayExtraInfoDescriptor.create({'cell-circuits-per-decile': entry})
       self.assertEqual(int(entry), desc.cell_circuits_per_decile)
 
     test_entries = (
@@ -283,7 +282,7 @@ k0d2aofcVbHr4fPQOSST0LXDrhFl5Fqo5um296zpJGvRUeO6S44U/EfJAGShtqWw
     )
 
     for entry in test_entries:
-      desc_text = get_relay_extrainfo_descriptor({'cell-circuits-per-decile': entry}, content = True)
+      desc_text = RelayExtraInfoDescriptor.content({'cell-circuits-per-decile': entry})
       self._expect_invalid_attr(desc_text, 'cell_circuits_per_decile')
 
   def test_dir_response_lines(self):
@@ -297,7 +296,7 @@ k0d2aofcVbHr4fPQOSST0LXDrhFl5Fqo5um296zpJGvRUeO6S44U/EfJAGShtqWw
       unknown_attr = attr + '_unknown'
 
       test_value = 'ok=0,unavailable=0,not-found=984,not-modified=0,something-new=7'
-      desc = get_relay_extrainfo_descriptor({keyword: test_value})
+      desc = RelayExtraInfoDescriptor.create({keyword: test_value})
       self.assertEqual(0, getattr(desc, attr)[DirResponse.OK])
       self.assertEqual(0, getattr(desc, attr)[DirResponse.UNAVAILABLE])
       self.assertEqual(984, getattr(desc, attr)[DirResponse.NOT_FOUND])
@@ -311,7 +310,7 @@ k0d2aofcVbHr4fPQOSST0LXDrhFl5Fqo5um296zpJGvRUeO6S44U/EfJAGShtqWw
       )
 
       for entry in test_entries:
-        desc_text = get_relay_extrainfo_descriptor({keyword: entry}, content = True)
+        desc_text = RelayExtraInfoDescriptor.content({keyword: entry})
         desc = self._expect_invalid_attr(desc_text)
         self.assertEqual(None, getattr(desc, attr))
         self.assertEqual(None, getattr(desc, unknown_attr))
@@ -327,7 +326,7 @@ k0d2aofcVbHr4fPQOSST0LXDrhFl5Fqo5um296zpJGvRUeO6S44U/EfJAGShtqWw
       unknown_attr = attr + '_unknown'
 
       test_value = 'complete=2712,timeout=32,running=4,min=741,d1=14507,d2=22702,q1=28881,d3=38277,d4=73729,md=111455,d6=168231,d7=257218,q3=319833,d8=390507,d9=616301,something-new=11,max=29917857'
-      desc = get_relay_extrainfo_descriptor({keyword: test_value})
+      desc = RelayExtraInfoDescriptor.create({keyword: test_value})
       self.assertEqual(2712, getattr(desc, attr)[DirStat.COMPLETE])
       self.assertEqual(32, getattr(desc, attr)[DirStat.TIMEOUT])
       self.assertEqual(4, getattr(desc, attr)[DirStat.RUNNING])
@@ -353,7 +352,7 @@ k0d2aofcVbHr4fPQOSST0LXDrhFl5Fqo5um296zpJGvRUeO6S44U/EfJAGShtqWw
       )
 
       for entry in test_entries:
-        desc_text = get_relay_extrainfo_descriptor({keyword: entry}, content = True)
+        desc_text = RelayExtraInfoDescriptor.content({keyword: entry})
         desc = self._expect_invalid_attr(desc_text)
         self.assertEqual(None, getattr(desc, attr))
         self.assertEqual(None, getattr(desc, unknown_attr))
@@ -363,7 +362,7 @@ k0d2aofcVbHr4fPQOSST0LXDrhFl5Fqo5um296zpJGvRUeO6S44U/EfJAGShtqWw
     Parses the conn-bi-direct line with valid and invalid data.
     """
 
-    desc = get_relay_extrainfo_descriptor({'conn-bi-direct': '2012-05-03 12:07:50 (500 s) 277431,12089,0,2134'})
+    desc = RelayExtraInfoDescriptor.create({'conn-bi-direct': '2012-05-03 12:07:50 (500 s) 277431,12089,0,2134'})
     self.assertEqual(datetime.datetime(2012, 5, 3, 12, 7, 50), desc.conn_bi_direct_end)
     self.assertEqual(500, desc.conn_bi_direct_interval)
     self.assertEqual(277431, desc.conn_bi_direct_below)
@@ -384,7 +383,7 @@ k0d2aofcVbHr4fPQOSST0LXDrhFl5Fqo5um296zpJGvRUeO6S44U/EfJAGShtqWw
     )
 
     for entry in test_entries:
-      desc_text = get_relay_extrainfo_descriptor({'conn-bi-direct': entry}, content = True)
+      desc_text = RelayExtraInfoDescriptor.content({'conn-bi-direct': entry})
       desc = self._expect_invalid_attr(desc_text)
       self.assertEqual(None, desc.conn_bi_direct_end)
       self.assertEqual(None, desc.conn_bi_direct_interval)
@@ -410,7 +409,7 @@ k0d2aofcVbHr4fPQOSST0LXDrhFl5Fqo5um296zpJGvRUeO6S44U/EfJAGShtqWw
       )
 
       for test_value, expected_value in test_entries:
-        desc = get_relay_extrainfo_descriptor({keyword: test_value})
+        desc = RelayExtraInfoDescriptor.create({keyword: test_value})
         self.assertEqual(expected_value, getattr(desc, attr))
 
       test_entries = (
@@ -421,7 +420,7 @@ k0d2aofcVbHr4fPQOSST0LXDrhFl5Fqo5um296zpJGvRUeO6S44U/EfJAGShtqWw
       )
 
       for entry in test_entries:
-        desc_text = get_relay_extrainfo_descriptor({keyword: entry}, content = True)
+        desc_text = RelayExtraInfoDescriptor.content({keyword: entry})
         self._expect_invalid_attr(desc_text, attr)
 
   def test_number_list_lines(self):
@@ -441,7 +440,7 @@ k0d2aofcVbHr4fPQOSST0LXDrhFl5Fqo5um296zpJGvRUeO6S44U/EfJAGShtqWw
       )
 
       for test_value, expected_value in test_entries:
-        desc = get_relay_extrainfo_descriptor({keyword: test_value})
+        desc = RelayExtraInfoDescriptor.create({keyword: test_value})
         self.assertEqual(expected_value, getattr(desc, attr))
 
       test_entries = (
@@ -451,7 +450,7 @@ k0d2aofcVbHr4fPQOSST0LXDrhFl5Fqo5um296zpJGvRUeO6S44U/EfJAGShtqWw
       )
 
       for entry, expected in test_entries:
-        desc_text = get_relay_extrainfo_descriptor({keyword: entry}, content = True)
+        desc_text = RelayExtraInfoDescriptor.content({keyword: entry})
         self._expect_invalid_attr(desc_text, attr, expected)
 
   def test_timestamp_lines(self):
@@ -463,7 +462,7 @@ k0d2aofcVbHr4fPQOSST0LXDrhFl5Fqo5um296zpJGvRUeO6S44U/EfJAGShtqWw
     for keyword in ('published', 'geoip-start-time'):
       attr = keyword.replace('-', '_')
 
-      desc = get_relay_extrainfo_descriptor({keyword: '2012-05-03 12:07:50'})
+      desc = RelayExtraInfoDescriptor.create({keyword: '2012-05-03 12:07:50'})
       self.assertEqual(datetime.datetime(2012, 5, 3, 12, 7, 50), getattr(desc, attr))
 
       test_entries = (
@@ -474,7 +473,7 @@ k0d2aofcVbHr4fPQOSST0LXDrhFl5Fqo5um296zpJGvRUeO6S44U/EfJAGShtqWw
       )
 
       for entry in test_entries:
-        desc_text = get_relay_extrainfo_descriptor({keyword: entry}, content = True)
+        desc_text = RelayExtraInfoDescriptor.content({keyword: entry})
         self._expect_invalid_attr(desc_text, attr)
 
   def test_timestamp_and_interval_lines(self):
@@ -487,7 +486,7 @@ k0d2aofcVbHr4fPQOSST0LXDrhFl5Fqo5um296zpJGvRUeO6S44U/EfJAGShtqWw
       end_attr = keyword.replace('-', '_').replace('dirreq', 'dir')
       interval_attr = end_attr[:-4] + '_interval'
 
-      desc = get_relay_extrainfo_descriptor({keyword: '2012-05-03 12:07:50 (500 s)'})
+      desc = RelayExtraInfoDescriptor.create({keyword: '2012-05-03 12:07:50 (500 s)'})
       self.assertEqual(datetime.datetime(2012, 5, 3, 12, 7, 50), getattr(desc, end_attr))
       self.assertEqual(500, getattr(desc, interval_attr))
 
@@ -502,7 +501,7 @@ k0d2aofcVbHr4fPQOSST0LXDrhFl5Fqo5um296zpJGvRUeO6S44U/EfJAGShtqWw
     )
 
     for entry in test_entries:
-      desc_text = get_relay_extrainfo_descriptor({'entry-stats-end': entry}, content = True)
+      desc_text = RelayExtraInfoDescriptor.content({'entry-stats-end': entry})
       desc = self._expect_invalid_attr(desc_text)
       self.assertEqual(None, desc.entry_stats_end)
       self.assertEqual(None, desc.entry_stats_interval)
@@ -519,13 +518,13 @@ k0d2aofcVbHr4fPQOSST0LXDrhFl5Fqo5um296zpJGvRUeO6S44U/EfJAGShtqWw
       interval_attr = base_attr + '_interval'
       values_attr = base_attr + '_values'
 
-      desc = get_relay_extrainfo_descriptor({keyword: '2012-05-03 12:07:50 (500 s) 50,11,5'})
+      desc = RelayExtraInfoDescriptor.create({keyword: '2012-05-03 12:07:50 (500 s) 50,11,5'})
       self.assertEqual(datetime.datetime(2012, 5, 3, 12, 7, 50), getattr(desc, end_attr))
       self.assertEqual(500, getattr(desc, interval_attr))
       self.assertEqual([50, 11, 5], getattr(desc, values_attr))
 
     for test_value in ('', ' '):
-      desc = get_relay_extrainfo_descriptor({'write-history': '2012-05-03 12:07:50 (500 s)%s' % test_value})
+      desc = RelayExtraInfoDescriptor.create({'write-history': '2012-05-03 12:07:50 (500 s)%s' % test_value})
       self.assertEqual(datetime.datetime(2012, 5, 3, 12, 7, 50), desc.write_history_end)
       self.assertEqual(500, desc.write_history_interval)
       self.assertEqual([], desc.write_history_values)
@@ -540,7 +539,7 @@ k0d2aofcVbHr4fPQOSST0LXDrhFl5Fqo5um296zpJGvRUeO6S44U/EfJAGShtqWw
     )
 
     for entry in test_entries:
-      desc_text = get_relay_extrainfo_descriptor({'write-history': entry}, content = True)
+      desc_text = RelayExtraInfoDescriptor.content({'write-history': entry})
       desc = self._expect_invalid_attr(desc_text)
       self.assertEqual(None, desc.write_history_end)
       self.assertEqual(None, desc.write_history_interval)
@@ -562,7 +561,7 @@ k0d2aofcVbHr4fPQOSST0LXDrhFl5Fqo5um296zpJGvRUeO6S44U/EfJAGShtqWw
       )
 
       for test_value, expected_value in test_entries:
-        desc = get_relay_extrainfo_descriptor({keyword: test_value})
+        desc = RelayExtraInfoDescriptor.create({keyword: test_value})
         self.assertEqual(expected_value, getattr(desc, attr))
 
       test_entries = (
@@ -575,7 +574,7 @@ k0d2aofcVbHr4fPQOSST0LXDrhFl5Fqo5um296zpJGvRUeO6S44U/EfJAGShtqWw
       )
 
       for entry in test_entries:
-        desc_text = get_relay_extrainfo_descriptor({keyword: entry}, content = True)
+        desc_text = RelayExtraInfoDescriptor.content({keyword: entry})
         self._expect_invalid_attr(desc_text, attr)
 
   def test_hidden_service_stats_end(self):
@@ -583,7 +582,7 @@ k0d2aofcVbHr4fPQOSST0LXDrhFl5Fqo5um296zpJGvRUeO6S44U/EfJAGShtqWw
     Exercise the hidserv-stats-end, which should be a simple date.
     """
 
-    desc = get_relay_extrainfo_descriptor({'hidserv-stats-end': '2012-05-03 12:07:50'})
+    desc = RelayExtraInfoDescriptor.create({'hidserv-stats-end': '2012-05-03 12:07:50'})
     self.assertEqual(datetime.datetime(2012, 5, 3, 12, 7, 50), desc.hs_stats_end)
 
     test_entries = (
@@ -597,7 +596,7 @@ k0d2aofcVbHr4fPQOSST0LXDrhFl5Fqo5um296zpJGvRUeO6S44U/EfJAGShtqWw
     )
 
     for entry in test_entries:
-      desc_text = get_relay_extrainfo_descriptor({'hidserv-stats-end': entry}, content = True)
+      desc_text = RelayExtraInfoDescriptor.content({'hidserv-stats-end': entry})
       self._expect_invalid_attr(desc_text, 'hs_stats_end')
 
   def test_hidden_service_stats(self):
@@ -623,24 +622,24 @@ k0d2aofcVbHr4fPQOSST0LXDrhFl5Fqo5um296zpJGvRUeO6S44U/EfJAGShtqWw
     for keyword, stat_attr, extra_attr in attributes:
       # just the numeric stat (no extra attributes)
 
-      desc = get_relay_extrainfo_descriptor({keyword: '345'})
+      desc = RelayExtraInfoDescriptor.create({keyword: '345'})
       self.assertEqual(345, getattr(desc, stat_attr))
       self.assertEqual({}, getattr(desc, extra_attr))
 
       # values can be negative (#15276)
 
-      desc = get_relay_extrainfo_descriptor({keyword: '-345'})
+      desc = RelayExtraInfoDescriptor.create({keyword: '-345'})
       self.assertEqual(-345, getattr(desc, stat_attr))
       self.assertEqual({}, getattr(desc, extra_attr))
 
       # with extra attributes
 
-      desc = get_relay_extrainfo_descriptor({keyword: '345 spiffy=true snowmen=neat'})
+      desc = RelayExtraInfoDescriptor.create({keyword: '345 spiffy=true snowmen=neat'})
       self.assertEqual(345, getattr(desc, stat_attr))
       self.assertEqual({'spiffy': 'true', 'snowmen': 'neat'}, getattr(desc, extra_attr))
 
       for entry in test_entries:
-        desc_text = get_relay_extrainfo_descriptor({keyword: entry}, content = True)
+        desc_text = RelayExtraInfoDescriptor.content({keyword: entry})
         self._expect_invalid_attr(desc_text, stat_attr)
         self._expect_invalid_attr(desc_text, extra_attr, {})
 
@@ -659,7 +658,7 @@ k0d2aofcVbHr4fPQOSST0LXDrhFl5Fqo5um296zpJGvRUeO6S44U/EfJAGShtqWw
       )
 
       for test_value, expected_value in test_entries:
-        desc = get_relay_extrainfo_descriptor({keyword: test_value})
+        desc = RelayExtraInfoDescriptor.create({keyword: test_value})
         self.assertEqual(expected_value, getattr(desc, attr))
 
       test_entries = (
@@ -670,7 +669,7 @@ k0d2aofcVbHr4fPQOSST0LXDrhFl5Fqo5um296zpJGvRUeO6S44U/EfJAGShtqWw
       )
 
       for entry in test_entries:
-        desc_text = get_relay_extrainfo_descriptor({keyword: entry}, content = True)
+        desc_text = RelayExtraInfoDescriptor.content({keyword: entry})
         self._expect_invalid_attr(desc_text, attr)
 
   def test_minimal_bridge_descriptor(self):
@@ -725,7 +724,7 @@ k0d2aofcVbHr4fPQOSST0LXDrhFl5Fqo5um296zpJGvRUeO6S44U/EfJAGShtqWw
     self.assertEqual({'obfs3': (None, None, None)}, desc.transport)
     self.assertEqual([], desc.get_unrecognized_lines())
 
-    desc = get_relay_extrainfo_descriptor({'transport': 'obfs2 83.212.96.201:33570'})
+    desc = RelayExtraInfoDescriptor.create({'transport': 'obfs2 83.212.96.201:33570'})
     self.assertEqual({'obfs2': ('83.212.96.201', 33570, [])}, desc.transport)
     self.assertEqual([], desc.get_unrecognized_lines())
 



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