commit b69544ba095710c4b8a6b38c4a965b668b1b8717 Author: Damian Johnson atagar@torproject.org Date: Tue Mar 14 13:46:09 2017 -0700
Simplify assertion that descriptor ends with router-sig-ed25519
The spec says 'next-to-last' but we allow it to be at the end too. Not quite sure why, maybe related to sanitized bridge descriptors? Anywho, might as well combine these two conditionals into one and fix the message. --- stem/descriptor/server_descriptor.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/stem/descriptor/server_descriptor.py b/stem/descriptor/server_descriptor.py index 76173a0..9c44256 100644 --- a/stem/descriptor/server_descriptor.py +++ b/stem/descriptor/server_descriptor.py @@ -669,10 +669,8 @@ class ServerDescriptor(Descriptor): if 'identity-ed25519' in entries.keys(): if 'router-sig-ed25519' not in entries.keys(): raise ValueError('Descriptor must have router-sig-ed25519 entry to accompany identity-ed25519') - - if 'router-sig-ed25519' != list(entries.keys())[-2]: - if 'router-sig-ed25519' != list(entries.keys())[-1]: - raise ValueError("Descriptor must end with a 'router-sig-ed25519' entry") + elif 'router-sig-ed25519' not in list(entries.keys())[-2:]: + raise ValueError("Descriptor must have 'router-sig-ed25519' as the next-to-last entry")
if not self.exit_policy: raise ValueError("Descriptor must have at least one 'accept' or 'reject' entry")
tor-commits@lists.torproject.org