[tor-commits] [metrics-lib/master] Make "consensus-methods" line optional in votes.
karsten at torproject.org
karsten at torproject.org
Tue May 31 18:49:22 UTC 2016
commit 8b814ef8db2b83af1fb9cd1ed69f3d2d92a33331
Author: Karsten Loesing <karsten.loesing at gmx.net>
Date: Fri May 20 11:36:06 2016 +0200
Make "consensus-methods" line optional in votes.
---
CHANGELOG.md | 2 ++
.../torproject/descriptor/impl/RelayNetworkStatusVoteImpl.java | 8 +++++---
.../descriptor/impl/RelayNetworkStatusVoteImplTest.java | 7 +++++--
3 files changed, 12 insertions(+), 5 deletions(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index e5789c1..45ce45f 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -14,6 +14,8 @@
* Minor changes
- Include a Torperf results line with more than one unrecognized
key only once in the unrecognized lines.
+ - Make "consensus-methods" line optional in network statuses votes,
+ which would mean that only method 1 is supported.
- Stop reporting "-----END .*-----" lines in directory key
certificates as unrecognized.
diff --git a/src/org/torproject/descriptor/impl/RelayNetworkStatusVoteImpl.java b/src/org/torproject/descriptor/impl/RelayNetworkStatusVoteImpl.java
index 7d59282..886612f 100644
--- a/src/org/torproject/descriptor/impl/RelayNetworkStatusVoteImpl.java
+++ b/src/org/torproject/descriptor/impl/RelayNetworkStatusVoteImpl.java
@@ -42,14 +42,15 @@ public class RelayNetworkStatusVoteImpl extends NetworkStatusImpl
throws DescriptorParseException {
super(voteBytes, failUnrecognizedDescriptorLines, false, false);
Set<String> exactlyOnceKeywords = new HashSet<>(Arrays.asList((
- "vote-status,consensus-methods,published,valid-after,fresh-until,"
+ "vote-status,published,valid-after,fresh-until,"
+ "valid-until,voting-delay,known-flags,dir-source,"
+ "dir-key-certificate-version,fingerprint,dir-key-published,"
+ "dir-key-expires,dir-identity-key,dir-signing-key,"
+ "dir-key-certification,directory-signature").split(",")));
this.checkExactlyOnceKeywords(exactlyOnceKeywords);
Set<String> atMostOnceKeywords = new HashSet<>(Arrays.asList((
- "client-versions,server-versions,flag-thresholds,params,contact,"
+ "consensus-methods,client-versions,server-versions,"
+ + "flag-thresholds,params,contact,"
+ "legacy-key,dir-key-crosscert,dir-address,directory-footer").
split(",")));
this.checkAtMostOnceKeywords(atMostOnceKeywords);
@@ -499,7 +500,8 @@ public class RelayNetworkStatusVoteImpl extends NetworkStatusImpl
private Integer[] consensusMethods;
public List<Integer> getConsensusMethods() {
- return Arrays.asList(this.consensusMethods);
+ return this.consensusMethods == null ? null :
+ Arrays.asList(this.consensusMethods);
}
private long publishedMillis;
diff --git a/test/org/torproject/descriptor/impl/RelayNetworkStatusVoteImplTest.java b/test/org/torproject/descriptor/impl/RelayNetworkStatusVoteImplTest.java
index 17f59a8..6111b59 100644
--- a/test/org/torproject/descriptor/impl/RelayNetworkStatusVoteImplTest.java
+++ b/test/org/torproject/descriptor/impl/RelayNetworkStatusVoteImplTest.java
@@ -4,6 +4,7 @@ package org.torproject.descriptor.impl;
import org.torproject.descriptor.DescriptorParseException;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import java.util.ArrayList;
@@ -622,10 +623,12 @@ public class RelayNetworkStatusVoteImplTest {
"vote-status TheMagicVoteStatus");
}
- @Test(expected = DescriptorParseException.class)
+ @Test()
public void testConsensusMethodNoLine()
throws DescriptorParseException {
- VoteBuilder.createWithConsensusMethodsLine(null);
+ RelayNetworkStatusVote vote =
+ VoteBuilder.createWithConsensusMethodsLine(null);
+ assertNull(vote.getConsensusMethods());
}
@Test(expected = DescriptorParseException.class)
More information about the tor-commits
mailing list