Skip to content

Commit 6706876

Browse files
committed
Test that a batch sends an address once however it is spelled
The input is a set, so only two spellings of one address reach the batch's own dedup: a mutant keeping both survived every test, with the cache on and off, until a batch of 8.8.8.8 beside its mapped forms asserted one entry on the wire.
1 parent 23bf4c0 commit 6706876

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

‎src/test/java/io/internetdata/ConformanceTest.java‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,22 @@ void anIpv4MappedAddressIsTheIpv4AddressItCarries() {
126126
}
127127
}
128128

129+
// Two spellings of one address are one address: sent once, and answered under each spelling.
130+
@Test
131+
void aMappedAddressBesideItsPlainFormIsSentOnce() {
132+
for (boolean cached : new boolean[] {true, false}) {
133+
StubHttpClient http = StubHttpClient.echoing(Duration.ZERO);
134+
try (InternetData client = clientOn(http).cacheEnabled(cached).build()) {
135+
LinkedHashMap<String, BatchResult> got = client.lookupBatch(
136+
List.of("8.8.8.8", "::ffff:8.8.8.8", "::FFFF:808:808"));
137+
138+
assertEquals(List.of("8.8.8.8", "::ffff:8.8.8.8", "::FFFF:808:808"), new ArrayList<>(got.keySet()));
139+
got.values().forEach(answer -> assertEquals("8.8.8.8", answer.orElseThrow().ip()));
140+
assertEquals(List.of("8.8.8.8"), http.batchIps, "cache " + cached + ": the batch body");
141+
}
142+
}
143+
}
144+
129145
/**
130146
* A bogon is answered locally in the corpus's answer, the address filled in: every flag present
131147
* and false, every detail object present and empty, and every shared object with every key.

0 commit comments

Comments
 (0)