Commit 8b814ef8 authored by Karsten Loesing's avatar Karsten Loesing
Browse files

Make "consensus-methods" line optional in votes.

parent 2cd92728
......@@ -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.
......
......@@ -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;
......
......@@ -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)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment