commit 796ea199b44fbd0fe4d2b55faad1a1bdcd64bef0 Author: Damian Johnson atagar@torproject.org Date: Tue Mar 19 07:09:50 2013 -0700
Switching the server descriptor's family to a set
Suggestion from gsathya. Duplicate family entries are moot and order doesn't matter, so might as well make this a set. --- stem/descriptor/server_descriptor.py | 6 +++--- test/integ/descriptor/server_descriptor.py | 12 ++++++------ 2 files changed, 9 insertions(+), 9 deletions(-)
diff --git a/stem/descriptor/server_descriptor.py b/stem/descriptor/server_descriptor.py index 102a660..bb7baa9 100644 --- a/stem/descriptor/server_descriptor.py +++ b/stem/descriptor/server_descriptor.py @@ -159,7 +159,7 @@ class ServerDescriptor(stem.descriptor.Descriptor): :var str contact: contact information :var stem.exit_policy.ExitPolicy exit_policy: ***** stated exit policy :var stem.exit_policy.MicroExitPolicy exit_policy_v6: ***** exit policy for IPv6 - :var list family: ***** nicknames or fingerprints of declared family + :var set family: ***** nicknames or fingerprints of declared family
:var int average_bandwidth: ***** average rate it's willing to relay in bytes/s :var int burst_bandwidth: ***** burst rate it's willing to relay in bytes/s @@ -226,7 +226,7 @@ class ServerDescriptor(stem.descriptor.Descriptor): self.contact = None self.exit_policy = None self.exit_policy_v6 = stem.exit_policy.MicroExitPolicy("reject 1-65535") - self.family = [] + self.family = set()
self.average_bandwidth = None self.burst_bandwidth = None @@ -500,7 +500,7 @@ class ServerDescriptor(stem.descriptor.Descriptor): elif validate: raise ValueError("Protocols line did not match the expected pattern: %s" % line) elif keyword == "family": - self.family = value.split(" ") + self.family = set(value.split(" ")) elif keyword == "eventdns": self.eventdns = value == "1" elif keyword == "ipv6-policy": diff --git a/test/integ/descriptor/server_descriptor.py b/test/integ/descriptor/server_descriptor.py index ec7c464..e3745c0 100644 --- a/test/integ/descriptor/server_descriptor.py +++ b/test/integ/descriptor/server_descriptor.py @@ -30,7 +30,7 @@ class TestServerDescriptor(unittest.TestCase):
descriptor_file = open(get_resource("example_descriptor"), 'rb')
- expected_family = [ + expected_family = set([ "$0CE3CFB1E9CC47B63EA8869813BF6FAB7D4540C1", "$1FD187E8F69A9B74C9202DC16A25B9E7744AB9F6", "$74FB5EFA6A46DE4060431D515DC9A790E6AD9A7C", @@ -39,7 +39,7 @@ class TestServerDescriptor(unittest.TestCase): "$D2F37F46182C23AB747787FD657E680B34EAF892", "$E0BD57A11F00041A9789577C53A1B784473669E4", "$E5E3E9A472EAF7BE9682B86E92305DB4C71048EF", - ] + ])
expected_onion_key = """-----BEGIN RSA PUBLIC KEY----- MIGJAoGBAJv5IIWQ+WDWYUdyA/0L8qbIkEVH/cwryZWoIaPAzINfrw1WfNZGtBmg @@ -133,7 +133,7 @@ Qlx9HNCqCY877ztFRC624ja2ql6A2hBcuoYMbkHjcQ4= self.assertEquals(False, desc.extra_info_cache) self.assertEquals(None, desc.extra_info_digest) self.assertEquals(None, desc.hidden_service_dir) - self.assertEquals([], desc.family) + self.assertEquals(set(), desc.family) self.assertEquals(102400, desc.average_bandwidth) self.assertEquals(10485760, desc.burst_bandwidth) self.assertEquals(0, desc.observed_bandwidth) @@ -220,7 +220,7 @@ Qlx9HNCqCY877ztFRC624ja2ql6A2hBcuoYMbkHjcQ4= self.assertEquals(False, desc.extra_info_cache) self.assertEquals("51E9FD0DA7C235D8C0250BAFB6E1ABB5F1EF9F04", desc.extra_info_digest) self.assertEquals(["2"], desc.hidden_service_dir) - self.assertEquals([], desc.family) + self.assertEquals(set(), desc.family) self.assertEquals(81920, desc.average_bandwidth) self.assertEquals(102400, desc.burst_bandwidth) self.assertEquals(84275, desc.observed_bandwidth) @@ -282,11 +282,11 @@ Qlx9HNCqCY877ztFRC624ja2ql6A2hBcuoYMbkHjcQ4=
descriptor_file = open(get_resource("bridge_descriptor"), 'rb')
- expected_family = [ + expected_family = set([ "$CE396C72A3D0880F74C064FEA79D68C15BD380B9", "$AB8B00C00B1347BA80A88E548FAC9EDF701D7D0E", "$8C8A470D7C23151665A7B84E75E89FCC205A3304", - ] + ])
desc = next(stem.descriptor.parse_file(descriptor_file, "bridge-server-descriptor 1.0")) self.assertEquals("Unnamed", desc.nickname)