commit 07a6eebb30cda2f592a8929d433cfc0a66598c02 Author: Damian Johnson atagar@torproject.org Date: Thu Jan 31 11:23:42 2019 -0800
Default 'version_flavor' attribute to 'ns'
Tor adjusted its spec to make the flavor optional, and explicitly state that if it is not present it should default to 'ns'...
https://gitweb.torproject.org/torspec.git/commit/?id=d97f8d980be01bda3f6122f... --- docs/change_log.rst | 1 + stem/client/cell.py | 2 +- stem/descriptor/networkstatus.py | 6 +++--- test/unit/descriptor/networkstatus/document_v3.py | 10 +++++----- 4 files changed, 10 insertions(+), 9 deletions(-)
diff --git a/docs/change_log.rst b/docs/change_log.rst index 0d0ce864..edf574c3 100644 --- a/docs/change_log.rst +++ b/docs/change_log.rst @@ -65,6 +65,7 @@ The following are only available within Stem's `git repository * Added :func:`~stem.descriptor.networkstatus.NetworkStatusDocumentV3.is_valid` and :func:`~stem.descriptor.networkstatus.NetworkStatusDocumentV3.is_fresh` methods (:trac:`28448`) * Replaced :func:`~stem.descriptor.router_status_entry.RouterStatusEntryMicroV3` hex encoded **digest** attribute with a base64 encoded **microdescriptor_digest** * Replaced the **digest** attribute of :class:`~stem.descriptor.microdescriptor.Microdescriptor` with a method by the same name (:trac:`28398`) + * Default the **version_flavor** attribute of :class:`~stem.descriptor.networkstatus.NetworkStatusDocumentV3` to 'ns' (:spec:`d97f8d9`) * DescriptorDownloader crashed if **use_mirrors** is set (:trac:`28393`) * Don't download from Serge, a bridge authority that frequently timeout
diff --git a/stem/client/cell.py b/stem/client/cell.py index 94862b38..b74094c8 100644 --- a/stem/client/cell.py +++ b/stem/client/cell.py @@ -639,7 +639,7 @@ class NetinfoCell(Cell): Information relays exchange about each other.
:var datetime timestamp: current time - :var stem.client.Address receiver_address: receiver's OR address + :var stem.client.datatype.Address receiver_address: receiver's OR address :var list sender_addresses: sender's OR addresses """
diff --git a/stem/descriptor/networkstatus.py b/stem/descriptor/networkstatus.py index 44255f95..f463530f 100644 --- a/stem/descriptor/networkstatus.py +++ b/stem/descriptor/networkstatus.py @@ -668,7 +668,7 @@ def _parse_header_network_status_version_line(descriptor, entries): if ' ' in value: version, flavor = value.split(' ', 1) else: - version, flavor = value, None + version, flavor = value, 'ns'
if not version.isdigit(): raise ValueError('Network status document has a non-numeric version: network-status-version %s' % value) @@ -944,7 +944,7 @@ class NetworkStatusDocumentV3(NetworkStatusDocument): mapping for relays contained in the document
:var int version: ***** document version - :var str version_flavor: ***** flavor associated with the document (such as 'microdesc') + :var str version_flavor: ***** flavor associated with the document (such as 'ns' or 'microdesc') :var bool is_consensus: ***** **True** if the document is a consensus :var bool is_vote: ***** **True** if the document is a vote :var bool is_microdescriptor: ***** **True** if this is a microdescriptor @@ -1034,7 +1034,7 @@ class NetworkStatusDocumentV3(NetworkStatusDocument):
ATTRIBUTES = { 'version': (None, _parse_header_network_status_version_line), - 'version_flavor': (None, _parse_header_network_status_version_line), + 'version_flavor': ('ns', _parse_header_network_status_version_line), 'is_consensus': (True, _parse_header_vote_status_line), 'is_vote': (False, _parse_header_vote_status_line), 'is_microdescriptor': (False, _parse_header_network_status_version_line), diff --git a/test/unit/descriptor/networkstatus/document_v3.py b/test/unit/descriptor/networkstatus/document_v3.py index daa88a09..ce7cfdb7 100644 --- a/test/unit/descriptor/networkstatus/document_v3.py +++ b/test/unit/descriptor/networkstatus/document_v3.py @@ -101,7 +101,7 @@ ci356fosgLiM1sVqCUkNdA== document = stem.descriptor.networkstatus.NetworkStatusDocumentV3(descriptor_file.read(), default_params = False)
self.assertEqual(3, document.version) - self.assertEqual(None, document.version_flavor) + self.assertEqual('ns', document.version_flavor) self.assertEqual(True, document.is_consensus) self.assertEqual(False, document.is_vote) self.assertEqual(False, document.is_microdescriptor) @@ -227,7 +227,7 @@ DnN5aFtYKiTc19qIC7Nmo+afPdDEf0MlJvEOP5EWl3w= document = stem.descriptor.networkstatus.NetworkStatusDocumentV3(descriptor_file.read(), default_params = False)
self.assertEqual(3, document.version) - self.assertEqual(None, document.version_flavor) + self.assertEqual('ns', document.version_flavor) self.assertEqual(False, document.is_consensus) self.assertEqual(True, document.is_vote) self.assertEqual(False, document.is_microdescriptor) @@ -303,7 +303,7 @@ DnN5aFtYKiTc19qIC7Nmo+afPdDEf0MlJvEOP5EWl3w=
self.assertEqual({}, document.routers) self.assertEqual(3, document.version) - self.assertEqual(None, document.version_flavor) + self.assertEqual('ns', document.version_flavor) self.assertEqual(True, document.is_consensus) self.assertEqual(False, document.is_vote) self.assertEqual(False, document.is_microdescriptor) @@ -524,7 +524,7 @@ DnN5aFtYKiTc19qIC7Nmo+afPdDEf0MlJvEOP5EWl3w=
document = NetworkStatusDocumentV3.create({'network-status-version': '3'}) self.assertEqual(3, document.version) - self.assertEqual(None, document.version_flavor) + self.assertEqual('ns', document.version_flavor) self.assertEqual(False, document.is_microdescriptor)
document = NetworkStatusDocumentV3.create({'network-status-version': '3 microdesc'}) @@ -537,7 +537,7 @@ DnN5aFtYKiTc19qIC7Nmo+afPdDEf0MlJvEOP5EWl3w=
document = NetworkStatusDocumentV3(content, False) self.assertEqual(4, document.version) - self.assertEqual(None, document.version_flavor) + self.assertEqual('ns', document.version_flavor) self.assertEqual(False, document.is_microdescriptor)
def test_vote_status(self):
tor-commits@lists.torproject.org