Add tests for published lines containing milliseconds.

Milliseconds are simply ignored, because SimpleDateFormat only looks at
"yyyy-MM-dd HH:mm:ss" and ignores everything after that.

Related to #9286 where we discovered that some relays include milliseconds
in their descriptors.
This commit is contained in:
Karsten Loesing 2013-07-18 14:21:36 +02:00
parent 60a066a0b0
commit 008781b7e5
2 changed files with 14 additions and 0 deletions

View File

@ -804,6 +804,13 @@ public class ExtraInfoDescriptorImplTest {
assertEquals(1328951316000L, descriptor.getPublishedMillis());
}
@Test()
public void testPublishedMillis() throws DescriptorParseException {
ExtraInfoDescriptor descriptor = DescriptorBuilder.
createWithPublishedLine("opt published 2012-02-11 09:08:36.123");
assertEquals(1328951316000L, descriptor.getPublishedMillis());
}
@Test(expected = DescriptorParseException.class)
public void testWriteHistoryNegativeBytes()
throws DescriptorParseException {

View File

@ -537,6 +537,13 @@ public class ServerDescriptorImplTest {
DescriptorBuilder.createWithPublishedLine("published 2012-01-01");
}
@Test()
public void testPublishedMillis() throws DescriptorParseException {
ServerDescriptor descriptor = DescriptorBuilder.
createWithPublishedLine("opt published 2012-01-01 04:03:19.123");
assertEquals(1325390599000L, descriptor.getPublishedMillis());
}
@Test()
public void testFingerprintNoOpt() throws DescriptorParseException {
ServerDescriptor descriptor = DescriptorBuilder.